Starting an app from another app - c#

I have two problems:
I need to start an app from another app.
I need to make two certain image links do just one action each (right now, both of them do both action).
Details for no. 1: i've directly called Process.Start("D:\\proba/ControlsBasics-WPF.appref-ms");
What do I do when I move the app or instal it on a different computer and the respective user does not have that pathway? I want to make a connection between two apps.
Details for no.2: right now, I have two image links (pic2) that open both a main window and an article . I need to make one of them open the main window and the other one open the article. I've done a printscreen so that you can see the codelines for the image links.
This is a very important problem for me and I hope I was clear enough.
Thank you.
http://i.stack.imgur.com/x3fVi.jpg
I've also added the code so that you can see it better:
<List x:TypeArguments="mskbm:ExperienceOptionModel" xmlns="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:mskbm="clr-namespace:Microsoft.Samples.Kinect.InteractionGallery.Models;assembly=InteractionGallery-WPF" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<mskbm:ExperienceOptionModel
Name="VIDEO"
ImageUri="pack://application:,,,/Content/HomeScreen/01.png"
OverlayImageUri="pack://application:,,,/Content/HomeScreen/play-overlay.png"
NavigableContextName="Video"
NavigableContextParameter="Content/Videos/K4W.wmv" />
<mskbm:ExperienceOptionModel
Name="VIDEO"
ImageUri="pack://application:,,,/Content/HomeScreen/02.png"
OverlayImageUri="pack://application:,,,/Content/HomeScreen/play-overlay.png"
NavigableContextName="Video"
NavigableContextParameter="Content/Videos/K4W_NISSAN.wmv" />
<mskbm:ExperienceOptionModel
Name="MAPPA PUNTI VENDITA"
ImageUri="pack://application:,,,/Content/img/03.png"
NavigableContextName="PannableContent"
NavigableContextParameter="pack://application:,,,/Content/PannableContentScreen/WorldMap.xaml" />
<mskbm:ExperienceOptionModel
Name="TUTORIAL KINECT"
ImageUri="pack://application:,,,/Content/img/05.png"
NavigableContextName="Article"
NavigableContextParameter="pack://application:,,,/Content/ArticleScreen/Article2.xaml" />
<mskbm:ExperienceOptionModel
Name="CATALOGO INTERATTIVO"
ImageUri="pack://application:,,,/Content/img/01.png"
NavigableContextName="Article"
NavigableContextParameter="pack://application:,,,/Content/ArticleScreen/Article2.xaml" />
<mskbm:ExperienceOptionModel
Name="INFO E CONTANTI"
ImageUri="pack://application:,,,/Content/img/06.png"
NavigableContextName="Article"
NavigableContextParameter="pack://application:,,,/Content/ArticleScreen/Article2.xaml" />
</List>

Related

how play video in media element from shared folder in networking

i want play video in media element from shearing file in networking . how can do it ?
for example my local IP is 192.168.1.51 and shared folder name is 'SharedFileVideo' . i can access this file from windows explorer with \192.168.1.51\SharedFileVideo\video.mp4 but when i use \192.168.1.51\SharedFileVideo or file://192.168.1.51/SharedFileVideo/video.mp4 in Uri for source of element media doesn't play my video .
how can bind video from file shared in networking for medial element in uwp .
many thanks
To play a video file in shared folder on network, we can get the StorageFile first and then use the SetSource method to set the source to the file. To access files in the shared folder, we need declare some capabilities in the app manifest.
Universal Naming Convention (UNC) is the naming system commonly used in Microsoft Windows for accessing shared network folders. For more info, please see File access permissions.
So we can set Package.appxmanifest like following:
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="UWPApp.App">
<uap:VisualElements DisplayName="UWPApp" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="UWPApp" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.fileTypeAssociation">
<uap:FileTypeAssociation Name="myvideotest">
<uap:DisplayName>MyVideoTest</uap:DisplayName>
<uap:SupportedFileTypes>
<uap:FileType>.mp4</uap:FileType>
</uap:SupportedFileTypes>
</uap:FileTypeAssociation>
</uap:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />
<Capability Name="internetClientServer" />
<uap:Capability Name="enterpriseAuthentication" />
</Capabilities>
And then in code-behind, retrieve the shared folder first.
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(#"\\192.168.1.51\SharedFileVideo");
After this, we can retrieve the video file and set it as MediaElement's source like:
StorageFile file = await folder.GetFileAsync("video.mp4");
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
MediaElement.SetSource(stream, file.ContentType);
Have you tried setting your source to:
\\192.168.1.51\SharedFileVideo\video.mp4
back slashes (\) not forward slashes (/) and make sure to start with a double back slash
i do this with my raspberry pi and it gets them fine
\\RASPBERRYPI\Films\OS1\Films\video.mp4
dont forget to do this in xaml youll need this:
<MediaElement Source="\\192.168.1.51\SharedFileVideo\video.mp4"/>
or for binding:
<MediaElement Source="{Binding Path=URI}"/>
and in code:
URI = #"\\192.168.1.51\SharedFileVideo\video.mp4";
as i said this works fine for me, i dont need synchronous programming and my machines and routers seem good enough not to cause lag or buffering issues
one other thing to remember if binding the source to a string then sometimes the media element needs telling to play. if so dont forget to tell it your manually loading video with the loaded behaviour tag.
so xaml:
<MediaElement Name="VideoPlayer" Source="{Binding Path=URI}" LoadedBehaviour="Manual"/>
and in code add:
URI = #"\\192.168.1.51\SharedFileVideo\video.mp4";
VideoPlayer.Play();

How can one set minimalist interface of Excel with C#?

Using C#, I'm writing a program that has to use Excel only in order to edit some tabular data provided by my program. My program just creates an Excel application (the Microsoft.Office.Interop.Excel.Application object), creates within it a workbook, creates a worksheet, puts the data in Excel, and, after this, allows to a user to edit these data. The edited data can be easily read by my program. That's, in principal, all what I need from Excel.
This, therefore, means that a user of my program should not be able to format data in Excel, save an Excel file to the hard drive, open Excel files, and so on and so on. A user even does not need the Excel ribbon. Working with formulas is also does not required. Hotkeys (like "Ctrl + B" making the font bold, "Ctrl + S" saving the file, and so on) should be also not workable.
My question is: Is there a way to simply set such a minimalist interface for Excel? Or I should disable any aspect mentioned above by hand, step by step (disable the ribbon, switch off the hotkeys ans so on)?
When working within a VSTO project, you can disable most/all of the UI by using a custom ribbon XML file (there is a visual designer too but I doubt it would be sufficient for this).
To remove things, add a section for what you're removing, and set visible="false" or enabled="false" (users could still potentially add it back to the ribbon, but disabling it makes it grayed out).
e.g.:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<commands>
<command idMso="Cut" enabled="false" />
</commands>
<ribbon>
<tabs>
<tab idMso="TabHome" visible="false" />
</tabs>
</ribbon>
<contextualTabs>
<tabSet idMso="TabSetDrawingTools" visible="false" />
</contextualTabs>
<backstage>
<tab idMso="TabInfo" visible="false">
</backstage>
<contextMenus>
<contextMenu idMso="ContextMenuText">
<!-- you can't hide a context menu entirely, you have to hide each item -->
<button idMso="FontDialog" visible="false" />
</contextMenu>
</contextMenus>
</customUI>
This may also be possible if you're working with Office in the way that you seem to be, I don't really know.

Images in WPF application disappear after navigating away

I'm experiencing an interesting phenomenon in my WPF application.
I have two separate views affected - one that allows editing of statistics and one that allows editing of templates. On both of these views I have a navigation bar that on allows the user to navigate forward and backward through search results and I use buttons with an image for the Back/Next UI. If I go navigate through statistics, and then through templates, the images show up fine; however, if I go back to statistics, the images no longer appear, but the buttons and navigation works. If I go back to templates, the images are still there. If I do templates first, then statistics and back to templates, the same order of behavior persists - statistics keeps the images. So it seems to do with the order, and not the views.
I have the images added to my project and have Build Action set to Resource. I have them referenced in my ResourceDictionary like so:
<Image x:Key="ico_Right" Source="/GOKOMS.Home;component/Images/nav_single_right.png" />
Within my View itself, I reference as
<Button Content="{StaticResource ico_Right}" Width="35" Height="35"
Visibility="{Binding Vis_Next, UpdateSourceTrigger=PropertyChanged}"
ToolTip="Next Record"
Command="{Binding NavCommand}"
CommandParameter="Next"
/>
I know it's not the binding as the button itself appears; I've even removed that just to be certain. It feels like this is the pertinent code, but I can add more if needed. Has anyone experienced something like this before?
This is because your Image control resource can only be attached to one place in the visual tree and you are trying to attach it to 2 different button elements (on different views)
You could try restructuring your views so that there is only one instance of the navigation menu, or you could create multiple image resources, or you could use a BitmapImage resource instead:
Resource:
<BitmapImage x:Key="ico_Right" UriSource="/GOKOMS.Home;component/Images/nav_single_right.png" />
Button:
<Button Width="35" Height="35"
Visibility="{Binding Vis_Next, UpdateSourceTrigger=PropertyChanged}"
ToolTip="Next Record"
Command="{Binding NavCommand}"
CommandParameter="Next">
<Image Source="{StaticResource ico_Right}" />
</Button>

2 Buttons but just one work in wpf window

I want to insert 2 Buttons in my C# Project. But just one of them works. I Tried different things, and i noticed in the second button script BorderBrush="{x:Null}" /> is a /> i think this is the problem. But at the time i remove it / convert it to a > it gives me an error out.
But heres the code, maybe you can help:
*Edit: Code is to long so heres a Link: http://pastebin.com/MysA7Dh1
**Edit: First a big Thanks for the Help :)! And i dont want you to do the work for me but i dont find an solution. The first button just looks like the second on the xaml code for me.
But now i can click the button but this time i dont see the image. I see it on the first button but not on the second.
Updated code: http://pastebin.com/PZhtssSy
nvm i set the Margin wrong. :/
Are you trying to include that image inside the button code? Or is the image supposed to be separate?
If you're trying to include the image inside the button, your code should look like this (code overly simplified for clarity):
<Button>
<Image/>
</Button>
If they are supposed to be separate:
<Button />
<Image />

Image Control asynchronous

I have an image control that I want it to load the image asynchronously over the network. I see some sample code in the network saying something like:
<Image HorizontalAlignment="Left" Height="118" Margin="2,8,0,0" VerticalAlignment="Top" Width="167" x:Name="ImageThumbnail" Source="{Binding SummaryImageLink, IsAsync=True}" />
However, in Windows Phone 7, I cannot find anything like that. Does anybody know a way to do that without I have to code a lot myself
Unfortunately you are going to have to write, or include, more code yourself to do this properly. I have a similar solution with the goal to cache images after the first download. The image cache class is accessed via a IValueConverter, so once you have included the appropriate code, you only have to add a decorator on the Image object:
<Image Source="{Binding ElementName=ImageSource, Path=Text, Converter={StaticResource imageCacheConverter}}" Width="200" />
Full details here and source code here: http://www.ben.geek.nz/2010/07/one-time-cached-images-in-windows-phone-7/
David Anson's work with LowProfileImageLoader may be of interest to you.
Keep a low profile [LowProfileImageLoader helps the Windows Phone 7 UI thread stay responsive by loading images in the background] - Delay's Blog
Alternatively you can asynchronously download the picture (for ex. with a BackgroundWorker) and assign it as source for your image control only when the download has completed.

Categories