52 public StackPanel CreateMenuItem(Item item) |
52 public StackPanel CreateMenuItem(Item item) |
53 { |
53 { |
54 try |
54 try |
55 { |
55 { |
56 StackPanel MItem = new StackPanel(); |
56 StackPanel MItem = new StackPanel(); |
57 Microsoft.Surface.Presentation.Controls.SurfaceButton ItemButton = new Microsoft.Surface.Presentation.Controls.SurfaceButton(); |
57 CustomSurfaceButton ItemButton = new CustomSurfaceButton(); |
58 ItemButton.Content = item.Name; |
58 ItemButton.Content = item.Name; |
|
59 ItemButton.Style = (Style)FindResource(item.Ressource); |
59 if (item.Items.Count > 0) |
60 if (item.Items.Count > 0) |
60 { |
61 { |
61 ItemButton.ContactDown += ButtonMenu_ContactDown; |
62 ItemButton.ContactDown += ButtonMenu_ContactDown; |
62 ItemButton.Click += ButtonMenu_ContactDown; |
63 ItemButton.Click += ButtonMenu_ContactDown; |
63 MItem.Children.Add(ItemButton); |
64 MItem.Children.Add(ItemButton); |
64 StackPanel Temp = new StackPanel(); |
65 StackPanel Temp = new StackPanel(); |
65 Temp.Margin = new Thickness(15,0,0,0); |
|
66 foreach (Item elt in item.Items) |
66 foreach (Item elt in item.Items) |
67 try |
67 try |
68 { |
68 { |
69 Temp.Children.Add(CreateMenuItem(elt)); |
69 Temp.Children.Add(CreateMenuItem(elt)); |
70 } |
70 } |
71 catch (Exception) { } |
71 catch (Exception) { } |
72 Temp.Name = ItemButton.Content + "Panel"; |
72 Temp.Name = ItemButton.Content.ToString().Replace(' ', '_') + "Panel"; |
73 Temp.Visibility = Visibility.Collapsed; |
73 Temp.Visibility = Visibility.Collapsed; |
74 MItem.Children.Add(Temp); |
74 MItem.Children.Add(Temp); |
75 } |
75 } |
76 else |
76 else |
77 { |
77 { |
78 ItemButton.ContactDown += GenerateAction; |
78 ItemButton.Action = item.Action; |
79 ItemButton.Click += GenerateAction; |
|
80 MItem.Children.Add(ItemButton); |
79 MItem.Children.Add(ItemButton); |
81 } |
80 } |
82 return MItem; |
81 return MItem; |
83 } |
82 } |
84 catch (Exception ex) |
83 catch (Exception ex) |
85 { |
84 { |
86 throw ex; |
85 throw ex; |
87 } |
86 } |
88 } |
87 } |
89 |
88 |
90 private void GenerateAction(Object sender, RoutedEventArgs Event) |
|
91 { |
|
92 try |
|
93 { |
|
94 ActionFactory.ActionGenerator AG = (new ActionFactory.ActionFactory()).GetGenerator(); |
|
95 FingersDance.Actions.ActionBase action = AG.GetAction("Action" + ((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Content, null); |
|
96 if (action != null) |
|
97 { |
|
98 //action.Execute(); |
|
99 //this.debug.addToList(action.GetType().ToString()); |
|
100 } |
|
101 } |
|
102 catch (Exception e) { } |
|
103 } |
|
104 |
|
105 private void ButtonMenu_ContactDown(object sender, RoutedEventArgs e) |
89 private void ButtonMenu_ContactDown(object sender, RoutedEventArgs e) |
106 { |
90 { |
107 foreach (UIElement Child in ((Panel)((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Parent).Children) |
91 foreach (UIElement Child in ((Panel)((CustomSurfaceButton)sender).Parent).Children) |
108 try |
92 try |
109 { |
93 { |
110 if (((StackPanel)Child).Name.Equals(((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Content + "Panel")) |
94 if (((StackPanel)Child).Name.Equals(((Microsoft.Surface.Presentation.Controls.SurfaceButton)sender).Content.ToString().Replace(' ', '_') + "Panel")) |
111 { |
95 { |
112 if (((StackPanel)Child).Visibility == Visibility.Collapsed) |
96 if (((StackPanel)Child).Visibility == Visibility.Collapsed) |
113 { |
97 { |
114 ((StackPanel)Child).Visibility = Visibility.Visible; |
98 ((StackPanel)Child).Visibility = Visibility.Visible; |
115 } |
99 } |