# HG changeset patch # User PAMPHILE Jonathan # Date 1249404734 -7200 # Node ID 225dba4c261ac40ae35aeb452524210f2febea7b # Parent 600c47d2d86398fd90b339575f530b9d640c2c4d Test des menus diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu.sln.cache --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu.sln.cache Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,115 @@ + + + <_SolutionProjectConfiguration>Debug|Any CPU + <_SolutionProjectToolsVersion>3.5 + <_SolutionProjectCacheVersion>3.5 + + + <_SolutionProjectProjects Include="TestMenu\TestMenu.csproj" /> + + + + Debug + AnyCPU + + + + + Release + AnyCPU + + + + + + Debug + + + Any CPU + + + $(Configuration) + + + C:\Users\Jonathan\Desktop\Développement\IRI\test\TestMenu\ + .sln + TestMenu.sln + TestMenu + C:\Users\Jonathan\Desktop\Développement\IRI\test\TestMenu\TestMenu.sln + + + v2.0 + v3.5 + + + + + Debug|AnyCPU + + + + + + + Release|AnyCPU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu.sln.orig --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu.sln.orig Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestMenu", "TestMenu\TestMenu.csproj", "{2211F916-A6FF-40D4-BFC5-09AAB1088D3A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2211F916-A6FF-40D4-BFC5-09AAB1088D3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2211F916-A6FF-40D4-BFC5-09AAB1088D3A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2211F916-A6FF-40D4-BFC5-09AAB1088D3A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2211F916-A6FF-40D4-BFC5-09AAB1088D3A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/ActionBase.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/ActionBase.cs Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TestMenu +{ + public interface ActionBase + { + void Execute(); + } +} diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/ActionFactory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/ActionFactory.cs Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TestMenu +{ + class ActionFactory + { + public ActionBase GenerateAction(Type T, Object Arg) + { + try + { + return (ActionBase)Activator.CreateInstance(T); + } + catch (Exception ex) + { + return null; + } + } + } +} diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/ActionShowMessage.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/ActionShowMessage.cs Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.Windows.Threading; +using Microsoft.Surface; +using Microsoft.Surface.Presentation; +using Microsoft.Surface.Presentation.Controls; + +namespace TestMenu +{ + class ActionShowMessage : ActionBase + { + string _Text = ""; + + public ActionShowMessage(string text) + { + _Text = text; + } + + public void Execute() + { + MessageBox.Show(_Text); + } + } +} diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/Item.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/Item.cs Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TestMenu +{ + [Serializable] + public class Item + { + public List Items = new List(); + public string name = ""; + } +} diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/Menu.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/Menu.cs Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TestMenu +{ + [Serializable] + public class Menu + { + public List Items = new List(); + } +} diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/Resources/WindowBackground.jpg Binary file test/TestMenu/TestMenu/Resources/WindowBackground.jpg has changed diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/Resources/icon.png Binary file test/TestMenu/TestMenu/Resources/icon.png has changed diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/Resources/iconPreview.png Binary file test/TestMenu/TestMenu/Resources/iconPreview.png has changed diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/SurfaceWindow1.xaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/SurfaceWindow1.xaml Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,14 @@ + + + + + + + + + diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/SurfaceWindow1.xaml.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/SurfaceWindow1.xaml.cs Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.Windows.Threading; +using Microsoft.Surface; +using Microsoft.Surface.Presentation; +using Microsoft.Surface.Presentation.Controls; +using System.IO; +using System.Xml.Serialization; + +namespace TestMenu +{ + /// + /// Interaction logic for SurfaceWindow1.xaml + /// + public partial class SurfaceWindow1 : SurfaceWindow + { + /// + /// Default constructor. + /// + public SurfaceWindow1() + { + InitializeComponent(); + + StreamReader reader = null; + reader = new StreamReader("test.xml"); + XmlSerializer serializer = new XmlSerializer(typeof(Menu)); + Menu temp = (Menu)serializer.Deserialize(reader); + foreach (Item elt in temp.Items) + MyMenu.Items.Add(CreateMenuItem(elt)); + reader.Close(); + + // Add handlers for Application activation events + AddActivationHandlers(); + } + + public SurfaceMenuItem CreateMenuItem(Item item) + { + SurfaceMenuItem MItem = new SurfaceMenuItem(); + MItem.Header = item.name; + MItem.Visibility = Visibility.Visible; + foreach (Item elt in item.Items) MItem.Items.Add(CreateMenuItem(elt)); + return MItem; + } + + /// + /// Occurs when the window is about to close. + /// + /// + protected override void OnClosed(EventArgs e) + { + base.OnClosed(e); + + // Remove handlers for Application activation events + RemoveActivationHandlers(); + } + + /// + /// Adds handlers for Application activation events. + /// + private void AddActivationHandlers() + { + // Subscribe to surface application activation events + ApplicationLauncher.ApplicationActivated += OnApplicationActivated; + ApplicationLauncher.ApplicationPreviewed += OnApplicationPreviewed; + ApplicationLauncher.ApplicationDeactivated += OnApplicationDeactivated; + } + + /// + /// Removes handlers for Application activation events. + /// + private void RemoveActivationHandlers() + { + // Unsubscribe from surface application activation events + ApplicationLauncher.ApplicationActivated -= OnApplicationActivated; + ApplicationLauncher.ApplicationPreviewed -= OnApplicationPreviewed; + ApplicationLauncher.ApplicationDeactivated -= OnApplicationDeactivated; + } + + /// + /// This is called when application has been activated. + /// + /// + /// + private void OnApplicationActivated(object sender, EventArgs e) + { + //TODO: enable audio, animations here + } + + /// + /// This is called when application is in preview mode. + /// + /// + /// + private void OnApplicationPreviewed(object sender, EventArgs e) + { + //TODO: Disable audio here if it is enabled + + //TODO: optionally enable animations here + } + + /// + /// This is called when application has been deactivated. + /// + /// + /// + private void OnApplicationDeactivated(object sender, EventArgs e) + { + //TODO: disable audio, animations here + } + } +} \ No newline at end of file diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/TestMenu.idc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/TestMenu.idc Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,1 @@ + diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/TestMenu.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/TestMenu/TestMenu/TestMenu.xml Tue Aug 04 18:52:14 2009 +0200 @@ -0,0 +1,64 @@ + + + + + + TestMenu + TestMenu + TestMenu.exe + + Resources\icon.png + + Resources\iconPreview.png + + + + + + + + + + + + + \ No newline at end of file diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/Window1.xaml --- a/test/TestMenu/TestMenu/Window1.xaml Tue Aug 04 18:45:52 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - diff -r 600c47d2d863 -r 225dba4c261a test/TestMenu/TestMenu/Window1.xaml.cs --- a/test/TestMenu/TestMenu/Window1.xaml.cs Tue Aug 04 18:45:52 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace TestMenu -{ - /// - /// Logique d'interaction pour Window1.xaml - /// - public partial class Window1 : Window - { - public Window1() - { - InitializeComponent(); - } - } -}