Exemplo n.º 1
0
        public override void FinishedLaunching (NSObject notification)
        {
            plotWindowController = new PlotWindowController ();

            var menu = new NSMenu ();

            var appMenu = new NSMenu ();
            appMenu.AddItem (new NSMenuItem ("Next example", "n", (s, e) => this.NextExample (1)));
            appMenu.AddItem (new NSMenuItem ("Previous example", "p", (s, e) => this.NextExample (-1)));
            appMenu.AddItem (NSMenuItem.SeparatorItem);
            appMenu.AddItem (new NSMenuItem ("Quit", "q", (s, e) => NSApplication.SharedApplication.Terminate (menu)));
            menu.AddItem (new NSMenuItem { Submenu = appMenu });

            var fileMenu = new NSMenu ("File");
            fileMenu.AddItem (new NSMenuItem ("Export", "e"));
            menu.AddItem (new NSMenuItem { Submenu = fileMenu });

            var editMenu = new NSMenu ("Edit");
            editMenu.AddItem (new NSMenuItem ("Copy", "c"));
            menu.AddItem (new NSMenuItem { Submenu = editMenu });

            var examplesMenu = new NSMenu ("Examples");
            exampleList = Examples.GetList ();

            var categories = exampleList.Select (e => e.Category).Distinct ().OrderBy (c => c).ToArray ();
            var categoryMenus = new Dictionary<string,NSMenu> ();
            foreach (var category in categories) {
                var categoryMenu = new NSMenu (category);
                examplesMenu.AddItem (new NSMenuItem (category) { Submenu = categoryMenu });
                categoryMenus.Add (category, categoryMenu);
            }

            foreach (var example in exampleList) {
                var item = new NSMenuItem (example.Title, (s, e) => this.SetExample (example));
                var categoryMenu = categoryMenus [example.Category];
                categoryMenu.AddItem (item);
            }
            menu.AddItem (new NSMenuItem { Submenu = examplesMenu });
            this.SetExample (exampleList.First ());

            plotWindowController.Window.MakeKeyAndOrderFront (this);
            NSApplication.SharedApplication.MainMenu = menu;
        }
Exemplo n.º 2
0
        public override void FinishedLaunching(NSObject notification)
        {
            plotWindowController = new PlotWindowController();

            var menu = new NSMenu();

            var appMenu = new NSMenu();

            appMenu.AddItem(new NSMenuItem("Next example", "n", (s, e) => this.NextExample(1)));
            appMenu.AddItem(new NSMenuItem("Previous example", "p", (s, e) => this.NextExample(-1)));
            appMenu.AddItem(NSMenuItem.SeparatorItem);
            appMenu.AddItem(new NSMenuItem("Quit", "q", (s, e) => NSApplication.SharedApplication.Terminate(menu)));
            menu.AddItem(new NSMenuItem {
                Submenu = appMenu
            });

            var fileMenu = new NSMenu("File");

            fileMenu.AddItem(new NSMenuItem("Export", "e"));
            menu.AddItem(new NSMenuItem {
                Submenu = fileMenu
            });

            var editMenu = new NSMenu("Edit");

            editMenu.AddItem(new NSMenuItem("Copy", "c"));
            menu.AddItem(new NSMenuItem {
                Submenu = editMenu
            });

            var examplesMenu = new NSMenu("Examples");

            exampleList = Examples.GetList();

            var categories    = exampleList.Select(e => e.Category).Distinct().OrderBy(c => c).ToArray();
            var categoryMenus = new Dictionary <string, NSMenu> ();

            foreach (var category in categories)
            {
                var categoryMenu = new NSMenu(category);
                examplesMenu.AddItem(new NSMenuItem(category)
                {
                    Submenu = categoryMenu
                });
                categoryMenus.Add(category, categoryMenu);
            }

            foreach (var example in exampleList)
            {
                var item         = new NSMenuItem(example.Title, (s, e) => this.SetExample(example));
                var categoryMenu = categoryMenus [example.Category];
                categoryMenu.AddItem(item);
            }
            menu.AddItem(new NSMenuItem {
                Submenu = examplesMenu
            });
            this.SetExample(exampleList.First());

            plotWindowController.Window.MakeKeyAndOrderFront(this);
            NSApplication.SharedApplication.MainMenu = menu;
        }