Création du CustomSurfaceButton
authorPAMPHILE Jonathan <pamphile@efrei.fr>
Tue, 15 Sep 2009 21:19:51 +0200
changeset 62 cbe5b01679a3
parent 61 9e2f007b19b3
child 63 99813224e948
Création du CustomSurfaceButton
src/FingersDance.Control.Menu/CustomSurfaceButton.cs
src/FingersDance.Control.Menu/FingersDance.Control.Menu.csproj
src/FingersDance.Control.Menu/UserControlMenu.xaml
src/FingersDance.Control.Menu/UserControlMenu.xaml.cs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FingersDance.Control.Menu/CustomSurfaceButton.cs	Tue Sep 15 21:19:51 2009 +0200
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Surface;
+using Microsoft.Surface.Presentation;
+using Microsoft.Surface.Presentation.Controls;
+
+namespace FingersDance.Control.Menu
+{
+    public class CustomSurfaceButton:SurfaceButton
+    {
+        string _Action = "";
+        string _Ressource = "";
+
+        public string Action
+        {
+            get { return _Action; }
+            set { _Action = value; }
+        }
+
+        public string Ressource
+        {
+            get { return _Ressource; }
+            set { _Ressource = value; }
+        }
+
+        public CustomSurfaceButton()
+        {
+            this.ContactDown += GenerateAction;
+            this.Click += GenerateAction;
+        }
+
+        private void GenerateAction(Object sender, EventArgs Event)
+        {
+            try
+            {
+                ActionFactory.ActionGenerator AG = (new ActionFactory.ActionFactory()).GetGenerator();
+                FingersDance.Actions.ActionBase action = AG.GetAction("Action" + ((CustomSurfaceButton)sender).Content, null);
+                if (action != null)
+                {
+                    //action.Execute();
+                    //this.debug.addToList(action.GetType().ToString());
+                }
+            }
+            catch (Exception e) { }
+        }
+    }
+}
--- a/src/FingersDance.Control.Menu/FingersDance.Control.Menu.csproj	Tue Sep 15 18:20:09 2009 +0200
+++ b/src/FingersDance.Control.Menu/FingersDance.Control.Menu.csproj	Tue Sep 15 21:19:51 2009 +0200
@@ -88,6 +88,7 @@
     </Compile>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="CustomSurfaceButton.cs" />
     <Compile Include="Item.cs" />
     <Compile Include="Menu.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
--- a/src/FingersDance.Control.Menu/UserControlMenu.xaml	Tue Sep 15 18:20:09 2009 +0200
+++ b/src/FingersDance.Control.Menu/UserControlMenu.xaml	Tue Sep 15 21:19:51 2009 +0200
@@ -17,10 +17,5 @@
                 <GradientStop Color="#FF414141" Offset="0.772"/>
             </LinearGradientBrush>
         </StackPanel.Background>
-
-
-
-
-
     </StackPanel>
 </UserControl>
\ No newline at end of file
--- a/src/FingersDance.Control.Menu/UserControlMenu.xaml.cs	Tue Sep 15 18:20:09 2009 +0200
+++ b/src/FingersDance.Control.Menu/UserControlMenu.xaml.cs	Tue Sep 15 21:19:51 2009 +0200
@@ -54,7 +54,7 @@
              try
              {
                  StackPanel MItem = new StackPanel();
-                 Microsoft.Surface.Presentation.Controls.SurfaceButton ItemButton = new Microsoft.Surface.Presentation.Controls.SurfaceButton();
+                 CustomSurfaceButton ItemButton = new CustomSurfaceButton();
                  ItemButton.Content = item.Name;
                  if (item.Items.Count > 0)
                  {
@@ -75,8 +75,9 @@
                  }
                  else
                  {
-                     ItemButton.ContactDown += GenerateAction;
-                     ItemButton.Click += GenerateAction;
+                     ItemButton.Action = item.Action;
+                     //ItemButton.ContactDown += GenerateAction;
+                     //ItemButton.Click += GenerateAction;
                      MItem.Children.Add(ItemButton);
                  }
                  return MItem;
@@ -86,7 +87,10 @@
                  throw ex;
              }
          }
-
+        
+        /*
+         *  Déplacé dans le CustomSurfaceButton
+         
          private void GenerateAction(Object sender, RoutedEventArgs Event)
          {
              try
@@ -101,10 +105,13 @@
              }
              catch (Exception e) { }
          }
+         
+         * 
+         */
 
          private void ButtonMenu_ContactDown(object sender, RoutedEventArgs e)
          {
-             foreach (UIElement Child in ((Panel)((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Parent).Children)
+             foreach (UIElement Child in ((Panel)((CustomSurfaceButton)sender).Parent).Children)
                  try
                  {
                      if (((StackPanel)Child).Name.Equals(((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Content + "Panel"))