src/FingersDance.Control.Menu/UserControlMenu.xaml.cs
changeset 76 5af0f0a8706d
parent 75 99d003723474
child 81 6b991b7e8046
equal deleted inserted replaced
73:bda95242e600 76:5af0f0a8706d
    10 using Microsoft.Surface;
    10 using Microsoft.Surface;
    11 using Microsoft.Surface.Presentation;
    11 using Microsoft.Surface.Presentation;
    12 using System.Xml.Serialization;
    12 using System.Xml.Serialization;
    13 using System.Reflection;
    13 using System.Reflection;
    14 
    14 
       
    15 using FingersDance.ActionFactory;
       
    16 using FingersDance.Actions;
       
    17 using FingersDance.Control.SyncSource;
       
    18 using FingersDance.Control.TimeLine;
       
    19 
    15 namespace FingersDance.Control.Menu
    20 namespace FingersDance.Control.Menu
    16 {
    21 {
    17 	public partial class UserControlMenu
    22 	public partial class UserControlMenu
    18 	{
    23 	{
    19 		public UserControlMenu()
    24 		public UserControlMenu()
    20 		{
    25 		{
    21 			this.InitializeComponent();
    26 			this.InitializeComponent();
       
    27 
       
    28             // Insert code required on object creation below this point.
    22             initChildSize();
    29             initChildSize();
    23 
       
    24 			// Insert code required on object creation below this point.
       
    25 		}
    30 		}
    26 
    31 
    27         //Premet de deplacer les sous menus vers la droite pour avoir un effect tree view
    32         //Premet de deplacer les sous menus vers la droite pour avoir un effect tree view
    28          private void initChildSize()
    33          private void initChildSize()
    29         {
    34         {
    73                      Temp.Visibility = Visibility.Collapsed;
    78                      Temp.Visibility = Visibility.Collapsed;
    74                      MItem.Children.Add(Temp);
    79                      MItem.Children.Add(Temp);
    75                  }
    80                  }
    76                  else
    81                  else
    77                  {
    82                  {
       
    83                      ItemButton.ContactDown += ActionButton_ContactDown;
       
    84                      ItemButton.Click += ActionButton_ContactDown;
    78                      ItemButton.Action = item.Action;
    85                      ItemButton.Action = item.Action;
    79                      MItem.Children.Add(ItemButton);
    86                      MItem.Children.Add(ItemButton);
    80                  }
    87                  }
    81                  return MItem;
    88                  return MItem;
    82              }
    89              }
    84              {
    91              {
    85                  throw ex;
    92                  throw ex;
    86              }
    93              }
    87          }
    94          }
    88 
    95 
       
    96          void ActionButton_ContactDown(object sender, RoutedEventArgs e)
       
    97          {
       
    98              // Generate action
       
    99              // We get the instance of the user panel
       
   100              UserControl userPanel = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent;
       
   101              // Its content...
       
   102              Grid o = (Grid)userPanel.Content;
       
   103              // and the UserControlSyncSource within the grid...
       
   104              UserControlSyncSource syncSrc = (UserControlSyncSource)((Grid)o.Children[0]).Children[0];
       
   105              // and finally the timeline
       
   106              UserControlTimeLine tl = syncSrc.userControlTimeLine;
       
   107 
       
   108              String actionId = ((CustomSurfaceButton)sender).Action;
       
   109              ActionGenerator ag = new ActionGenerator();
       
   110              ActionBase ab = ag.GetAction(actionId, tl);
       
   111              if(ab!=null)
       
   112                  ab.Execute();
       
   113          }
       
   114 
    89          private void ButtonMenu_ContactDown(object sender, RoutedEventArgs e)
   115          private void ButtonMenu_ContactDown(object sender, RoutedEventArgs e)
    90          {
   116          {
    91              foreach (UIElement Child in ((Panel)((CustomSurfaceButton)sender).Parent).Children)
   117              foreach (UIElement Child in ((Panel)((CustomSurfaceButton)sender).Parent).Children)
       
   118              {
    92                  try
   119                  try
    93                  {
   120                  {
    94                      if (((StackPanel)Child).Name.Equals(((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Content.ToString().Replace(' ', '_') + "Panel"))
   121                      if (((StackPanel)Child).Name.Equals(((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Content.ToString().Replace(' ', '_') + "Panel"))
    95                      {
   122                      {
    96                          if (((StackPanel)Child).Visibility == Visibility.Collapsed)
   123                          if (((StackPanel)Child).Visibility == Visibility.Collapsed)
   103                          }
   130                          }
   104                          return;
   131                          return;
   105                      }
   132                      }
   106                  }
   133                  }
   107                  catch (Exception ex) { }
   134                  catch (Exception ex) { }
       
   135              }
   108          }
   136          }
   109 
   137 
   110         #region Events
   138         #region Events
   111 
   139 
   112      /*    
   140      /*