diff -r 5eb765a7a793 -r 0cdb8089a29f ui/wpf/UIcore/Menu.cs --- a/ui/wpf/UIcore/Menu.cs Sun Jan 25 15:01:04 2015 +0100 +++ b/ui/wpf/UIcore/Menu.cs Tue Jan 27 09:59:32 2015 +0100 @@ -34,12 +34,12 @@ current.Add(menu); } - public void EndMenu() + public void EndSubMenu() { current.Remove(current.Last()); } - public void AddMenuItem(String label, Action action) + public void AddMenuItem(String label, Action action) { if(current.Count != 0) { @@ -48,14 +48,14 @@ } } - public System.Windows.Controls.Menu CreateMenu() + public System.Windows.Controls.Menu CreateMenu(IntPtr uiobj) { System.Windows.Controls.Menu menu = new System.Windows.Controls.Menu(); foreach (Menu m in Menus) { System.Windows.Controls.MenuItem i = new System.Windows.Controls.MenuItem(); i.Header = m.Label; - m.AddItems(i); + m.AddItems(i, uiobj); menu.Items.Add(i); } return menu; @@ -64,7 +64,7 @@ public interface IMenuItem { - void AddTo(System.Windows.Controls.MenuItem menu); + void AddTo(System.Windows.Controls.MenuItem menu, IntPtr uiobj); } public class Menu : IMenuItem @@ -77,19 +77,19 @@ Label = label; } - public void AddItems(System.Windows.Controls.MenuItem i) + public void AddItems(System.Windows.Controls.MenuItem i, IntPtr uiobj) { foreach (IMenuItem item in Items) { - item.AddTo(i); + item.AddTo(i, uiobj); } } - void IMenuItem.AddTo(System.Windows.Controls.MenuItem menu) + void IMenuItem.AddTo(System.Windows.Controls.MenuItem menu, IntPtr uiobj) { System.Windows.Controls.MenuItem i = new System.Windows.Controls.MenuItem(); i.Header = Label; - AddItems(i); + AddItems(i, uiobj); menu.Items.Add(i); } } @@ -97,17 +97,19 @@ public class MenuItem : IMenuItem { String Label; - Action Action; + Action Action; - public MenuItem(String label, Action action) + public MenuItem(String label, Action action) { Label = label; Action = action; } - void IMenuItem.AddTo(System.Windows.Controls.MenuItem menu) + void IMenuItem.AddTo(System.Windows.Controls.MenuItem menu, IntPtr uiobj) { System.Windows.Controls.MenuItem i = new System.Windows.Controls.MenuItem(); + EventCallback cb = new EventCallback(uiobj, Action); + i.Click += cb.Callback; i.Header = Label; menu.Items.Add(i); }