1 of 2
1
Surface-like App Launcher
Posted: 21 January 2011 12:51 PM   [ Ignore ]
Rank
Joined  2009-07-31
Total Posts:  15
New Member

Hi all,

I want to know how to make a surface-like apps launcher by C#?
Currently, I am using Process class to do a external call which is not good enough?
any hint about how to make it?

Thanks a lot?

Profile
 
 
Posted: 21 January 2011 11:56 PM   [ Ignore ]   [ # 1 ]
Avatar
RankRankRankRank
Joined  2006-11-09
Total Posts:  1499
Administrator

Well this really comes down to how you design the underlying framework as in you could simply use Process to call external apps or load apps internally which is a bit more work. The Surface launcher loads XNA apps internally I believe, but as you could imagine there is some a lot of work to assure best performance.

 Signature 

~

Profile
 
 
Posted: 06 February 2011 04:59 AM   [ Ignore ]   [ # 2 ]
Avatar
RankRank
Joined  2010-11-08
Total Posts:  135
Member

hey there,
I have a self-made C# Launcher-App too. I took a SurfaceLibraryBar control.. on startup it takes all .lnk-files in its root directory an associates them with .png-images of the same filename. Then it builds a SurfaceButton inside the LibraryBar for every .lnk-.png-pair. Its not very elegant and the LibraryBar is neither loop-scrollable nor very pretty…
If you are interested we may combine our C# skills and ideas to make a better one! :D
Below is a screenshot of my current version. It’s called ‘Simple Launcher’.

Image Attachments
simplelauncher.png
 Signature 

Twitter Blog

Profile
 
 
Posted: 06 February 2011 12:48 PM   [ Ignore ]   [ # 3 ]
Rank
Joined  2010-03-19
Total Posts:  52
New Member

That looks really cool. I’m working on a 360 menu launcher (a circle, so everyone around the table can use it smile). Would you like to share your code? I’m wondering how you launch the .exe, and can you go back to the menu IN the app you just opened? (Like the Surface corner buttons).

I hope you can answer my questions smile.

Grtz
Niels

Profile
 
 
Posted: 06 February 2011 01:51 PM   [ Ignore ]   [ # 4 ]
Avatar
RankRank
Joined  2010-11-08
Total Posts:  135
Member

360°.. personally I prefer the surface-like design with a infinite horizontal scrollbar and the manual selection of the user-perspective, but this is only a design thing..
here is the xaml code for the LibraryBar:

<s:LibraryBar Grid.Row="1" Height="Auto" Rows="1" HorizontalAlignment="Center" Margin="12,12,12,12" Name="libraryBar1" VerticalAlignment="Center" Width="Auto">
        <
s:LibraryBar.ItemTemplate>
            <
DataTemplate>
                <
s:SurfaceButton Name="iconButton" Click="iconButton_Click">
                    <
Image Name="TemplateImage" Source="{Binding}"/>
                </
s:SurfaceButton>
            </
DataTemplate>
        </
s:LibraryBar.ItemTemplate>
</
s:LibraryBar>

I don’t remember exactly, but I think this part was pretty much copy&paste from a msdn-tutorial.
Next is the c# code to get the files in the root-directory and add Buttons to the LibraryBar

protected override void OnInitialized(EventArgs e)
        
{
            base
.OnInitialized(e);
            
string imagesPath System.IO.Directory.GetCurrentDirectory();//gets the root directory
            
try
            
{
                libraryBar1
.ItemsSource System.IO.Directory.GetFiles(imagesPath"*.png");//b/c of the ItemTemplate this creates a Button w/ an image as content for each *.png file
            
}
            
catch (System.IO.DirectoryNotFoundException)
            
{
                
// Handle exception as needed.
            
}
        }

then there’s the EventHandler for a button:

private void iconButton_Click(object senderRoutedEventArgs e)
        
{
            ClickedButton 
= (Button)e.Source as Button;//get the clicked button
            
LibraryBarItem item = (LibraryBarItem)libraryBar1.ContainerFromElement(ClickedButton);
            
ContentPresenter content FindContentPresenter(item);
            if (
content != null)
            
{
                ClickedButtonsImage 
= (Image)content.ContentTemplate.FindName("TemplateImage"content);//get the image
                
string ImgPath Convert.ToString(ClickedButtonsImage.Source);//take image path into cache
                
int ImgPathLen ImgPath.Length;//measure lenght of path
                
string LnkPath ImgPath.Substring(0ImgPathLen 4) + @".lnk";//cut the png extension off; if the image was named correclty this is now the path of the *.lnk
                
System.Diagnostics.Process.Start(LnkPath); //<<<<<<<<=== here the target of the shortcut file is executed
            
}
        }

and then there is the FindContentPresenter()-function (copy&paste) from the very same msdn-tut…

private ContentPresenter FindContentPresenter(DependencyObject obj)
        
{
            
for (int i 0VisualTreeHelper.GetChildrenCount(obj); i++)
            
{
                DependencyObject child 
VisualTreeHelper.GetChild(obji);
                if (
child != null && child is System.Windows.Controls.ContentPresenter)
                
{
                    
return (ContentPresenter)child;
                
}
                
else
                
{
                    ContentPresenter childOfChild 
FindContentPresenter(child);
                    if (
childOfChild != null)
                    
{
                        
return childOfChild;
                    
}
                }
            }
            
return null;
        
}

Basically it’s very simple. There is a shortcut (*.lnk-file w/ hidden file extension) e.g. ‘SampleApplication’. It can be easily executed with System.Diagnostics.Process.Start();
The png-file has the same filename with another extension. In the OnInitialized-function it was set as the buttons content and when the button is clicked the path of the image is extracted. The last 4 chars (.png) are cut of and ‘.lnk’ is attached. Now it is the path that points to the shortcut.

If the started application is a fullscreen application the taskbar won’t show up and when it’s closed the launcher is topmost+fulscreen again. For non-fullscreen applications the taskbar will be visible, but unless you interact with the taskbar the application will close to topmost+fullscreen launcher too. (You may edit the taskbars properties to ‘autohide’, it may work..). So there’s no switching between applications, it’s always closing.. exept when you minimize n applications wich does not allow multiple instances…

Any idea how to extract the shortcuts icon in c# to use it as the image? And if you have a solution for the more surface-like thing of switching/rotating let me know =)

 Signature 

Twitter Blog

Profile
 
 
Posted: 06 February 2011 02:00 PM   [ Ignore ]   [ # 5 ]
Rank
Joined  2010-03-19
Total Posts:  52
New Member

Thanks for your information, looks very interesting. Do you think you can share your project-file, or maybe a sample file with just 1 button. I’m doing a study in Graphic Arts, so I’m not really into coding (Hey, it’s hard grin) but I must say WPF in combination with Expression Blend really opened up a world for me.. really cool!.

Grtz,
Niels

Profile
 
 
Posted: 06 February 2011 02:18 PM   [ Ignore ]   [ # 6 ]
Avatar
RankRank
Joined  2010-11-08
Total Posts:  135
Member

Yes, here I have a zip with the project inside.. hope you can run it. If there are any problems make sure you have the ms toolkit for windows touch beta installed.. the only shortcut is the one to mspaint.exe (see in the debug directory..)
good luck^^

File Attachments
Simple Launcher Project File.zip  (File Size: 712KB - Downloads: 701)
 Signature 

Twitter Blog

Profile
 
 
Posted: 25 February 2011 03:31 AM   [ Ignore ]   [ # 7 ]
Avatar
RankRank
Joined  2010-11-08
Total Posts:  135
Member

The ones of you who have downloaded (& hopefully tested) SimpleLauncher, can you give me some feedback or recommendations?
I’ll soon redo the app with a ScrollViewer or so instead of the LibraryBar. Also I thought of using only the images as icons and maybe display each applications name below the icons. Any ideas how to extract the icons of the shortcut?
Btw.: I haven’t tested it, but it should work for shortcuts to websites or files too^.
~theCake

 Signature 

Twitter Blog

Profile
 
 
Posted: 25 February 2011 07:26 PM   [ Ignore ]   [ # 8 ]
RankRank
Joined  2008-09-21
Total Posts:  120
Member

If you look for an infinite-loop list, this post could help: http://drwpf.com/blog/2009/08/05/itemscontrol-n-is-for-natural-user-interface/

Profile
 
 
Posted: 26 February 2011 07:25 AM   [ Ignore ]   [ # 9 ]
Avatar
RankRankRankRank
Joined  2008-01-04
Total Posts:  676
Moderator

@theCake, Looks good and works well!
Will test on my table tomorrow and see how that goes.

Thanks for sharing wink

 Signature 

Get Sparked at sparkon.net
ORION Multi-Touch Display (blog)
My YouTube

Profile
 
 
Posted: 26 February 2011 05:01 PM   [ Ignore ]   [ # 10 ]
Avatar
RankRank
Joined  2010-11-08
Total Posts:  135
Member

..well it works, but there are still some issues. First when there are many icons in the LibraryBar the offset is 0 on startup (looks very bad..). Secondly it seems to me that the LibraryBar requires more performance than needed and thirdly I’d ike to see a loopable-scroller.
Somewhere in MSDN there’s sample code for a loopable scroll control with images inside, but it is vertical.. If there’s someone who can modify the code from the MSDN sample it would really help us all..
Today I tried to re-code the Launcher with a SurfaceScrollViewer or StackPanel. The SurfaceScrollViewer looks very nice, but I didn’t manage to differ TouchDown/MouseDown on the Image from a scroll-attempt, so the user had to use the scroll bar, but that’s very un-NUI, you know.. Using a button inside the SSV. results in working Click-events, but the scrolling only hops to the next button…
All in all it was about three hours wasted time..
Any ideas?
goodnight ~theCake

 Signature 

Twitter Blog

Profile
 
 
Posted: 31 March 2011 08:23 AM   [ Ignore ]   [ # 11 ]
Rank
Joined  2011-03-10
Total Posts:  10
New Member
theCake - 06 February 2011 04:59 AM

hey there,
I have a self-made C# Launcher-App too. I took a SurfaceLibraryBar control.. on startup it takes all .lnk-files in its root directory an associates them with .png-images of the same filename. Then it builds a SurfaceButton inside the LibraryBar for every .lnk-.png-pair. Its not very elegant and the LibraryBar is neither loop-scrollable nor very pretty…
If you are interested we may combine our C# skills and ideas to make a better one! :D
Below is a screenshot of my current version. It’s called ‘Simple Launcher’.

Hi everyone ! First of all thanks a lot the Cake ! I was looking for some ideas when I found your thread and that made me really happy !
I took your source code and tried to adapt it a bit by adding a change background button and then i wanted to be able to move the library bar, resize it and be able to play a bit more with it !

Thanks to the microsoft samples I was able to understand a bit more the way to use the libraryContainer item and to put it into a scatter view to allow us to make something more interactive !

That’s why I’m happy to add a new version of your idea with my own launcher !

The main differences are :

- Change background button (which allow you to switch between pictures in the directory “Background”
- 4 different categories of programs, (Screen Apps,Navigation Apps,Images App,Games App)
all of them in library container which allow you to resize it, move it through the screen and switch between a stack visualisation mode and a bar launching mode

Feel free to comment and if u have any ideas maybe we’ll be able to create something really interesting !

See u

Yann

Image Attachments
1.jpg2.jpg
Profile
 
 
Posted: 31 March 2011 09:19 AM   [ Ignore ]   [ # 12 ]
Avatar
RankRank
Joined  2010-11-08
Total Posts:  135
Member

hi, blacksad
I’m happy that I could inspire you smile
and I really like your approach to use the container-controls: it allows to bring structure into the apps, removes the need to be on the ‘bottom’ screen-edge and (of course) is very nui-like wink
so here are my questions:

1. the icons inside the LibraryBar, are they centered when the application launches, or is the first icon left-aligned to the center of the control?

2. does the launcher remember where you put wich application? (if not this could be a future feature and I already have an idea how to do it =) - this would enable users with greater amounts of applications to bring more structure in.

3. (I’ve already addressed it earlier) it’d be better if the launcher does not require the icon-pngs, so it’d be great if anyone could code a method that returns the icon of the shortcut’s target^^

4. Do you use a OpenFileDialog to change the background, or are there some defaults - how did you do it?

So if you like you can share the code and I do the ‘save-state’-thing^^ (btw.: any experiences w/ the Visual Studio/Codeplex combination?)

cheers
~theCake

 Signature 

Twitter Blog

Profile
 
 
Posted: 31 March 2011 10:52 AM   [ Ignore ]   [ # 13 ]
Rank
Joined  2011-03-10
Total Posts:  10
New Member

Hey good to know that u liked it :p

Well to answer ur questions:

1- the icons inside the library bar are not centered after the launch ! I tried quickly to find a way to arrange that but it seems difficult to achieve ! the first icon is left aligned to the center of the control as in your version !

2- in fact it’s a really basic version with only four directory hardcoded in code behind (u have to name them as i coded it and put them in the same directory as the app itself. then it works a bit like yours with the png files and a shortcut to the real app. But as u can see in the screenshots, the four"balls" don’t have showed name so it means that u have in fact 4 possible type of app and u can put as many items as u want in the directory !
A good point would be to be able to add dynamically a new librarycontainer and the apps inside too !

3- U’re right with that idea but in fact in my case it’s good to have both files because when u’re in the stack mode I use only the image file in png which allow the stack normal behavior to work correctly (when u click on one image, the image goes behind the stack and u see the next one which alllow u to have a preview of the app list without deploying the bar), and when u switch into the bar mode I change them into buttons to be able to click on it and launch the apps

4- I don’t use OpenFileDialog to change the Background cause I thought it wasn’t NUI friendly, so instead I just added another directory called background where u have to put your images inside and when u click the button, u just switch between the different jpeg files found in the directory !

I’m not sure about u’re last question, what do you mean by using “any experiences w/ the Visual Studio/Codeplex combination?” ??? I already used some controls from codeplex but SSIS solutions and not really in XAML application! Did u find some interesting new controls on codeplex website ?

Cheers,

Yann

PS:I still have to make some corrections on the code but I’ll definately post it really soon !

Profile
 
 
Posted: 31 March 2011 01:49 PM   [ Ignore ]   [ # 14 ]
Avatar
RankRank
Joined  2010-11-08
Total Posts:  135
Member

Okay, so this centering-issue seems to be quite complicated. Tomorrow I’ll take a look at some of the samples, I’m sure there isa way to do this^
Folders are a smart solution^ they even simplify the drag and drop manipulations of the icons. And with these directories I have a solution for dynamic add/remove too smile
Well if you manage to extract the icon’s image you have an instance of it to use it in the container control, but maybe saving it as a png is better for performance. So what about auto-extract for new shortcuts and png-use for existing ones?
Switching backgrounds is good, but selecting new jpgs with a (maybe a selfmade nui-friendly) OpenFileDialog is better don’t you think? Something like enabling the user to manage (add/remove) the files in \background and select one of them..
With my last question I meant the possibilities of synchronized sharing or storing the code in the cloud^
For example I sync my Visual Studio projects-directory with Windows Live Mesh between my PC and my notebook (and its really useful!)
But I’m no expert on these collectively coded open source things, so maybe you have a solution to enhance the simultaneous coding wink
If you can give me the new code until tomorrow (Friday) evening I can add some of the features =)

 Signature 

Twitter Blog

Profile
 
 
Posted: 01 April 2011 05:03 AM   [ Ignore ]   [ # 15 ]
Rank
Joined  2011-03-10
Total Posts:  10
New Member
theCake - 31 March 2011 01:49 PM

Okay, so this centering-issue seems to be quite complicated. Tomorrow I’ll take a look at some of the samples, I’m sure there isa way to do this^
Folders are a smart solution^ they even simplify the drag and drop manipulations of the icons. And with these directories I have a solution for dynamic add/remove too smile
Well if you manage to extract the icon’s image you have an instance of it to use it in the container control, but maybe saving it as a png is better for performance. So what about auto-extract for new shortcuts and png-use for existing ones?
Switching backgrounds is good, but selecting new jpgs with a (maybe a selfmade nui-friendly) OpenFileDialog is better don’t you think? Something like enabling the user to manage (add/remove) the files in \background and select one of them..
With my last question I meant the possibilities of synchronized sharing or storing the code in the cloud^
For example I sync my Visual Studio projects-directory with Windows Live Mesh between my PC and my notebook (and its really useful!)
But I’m no expert on these collectively coded open source things, so maybe you have a solution to enhance the simultaneous coding wink
If you can give me the new code until tomorrow (Friday) evening I can add some of the features =)

Hey you ! Here is the rar file of my source code ! I’m a bit busy today so I cannot give you a lot of details but u’ll have to change the path to the resource dictionnary in app.xaml to link with the libraryControlResourceDictionnary situated in the directory Shared and u’ll also have to add the directories needed to put the images and link file !

Sharing the code in the cloud is a good idea but I never did that so we can speak about that later but it would be definitely good !

Have fun and keep me in touch ! I had an idea last night about new features I’ll post that after doing it it’ll be a surprise !

Cheers,
Yann

File Attachments
ControlsBox.rar  (File Size: 115KB - Downloads: 532)
Profile
 
 
   
1 of 2
1