Esempio n. 1
0
        void CreateMenu()
        {
            var openItem = new ButtonMenuItem {
                Text = "Open...", Shortcut = Application.Instance.CommonModifier | Keys.O
            };

            openItem.BindDataContext(c => c.Command, (UnitTestViewModel m) => m.OpenCommand);
            openItem.CommandParameter = this;

            var clear = new ButtonMenuItem {
                Text = "Close tests"
            };

            clear.BindDataContext(c => c.Command, (UnitTestViewModel m) => m.ClearCommand);

            var showOutput = new CheckMenuItem {
                Text = "Show output"
            };

            showOutput.BindDataContext(c => c.Checked, (UnitTestViewModel m) => m.ShowOutput);

            var showOnlyFailed = new CheckMenuItem {
                Text = "Show only failed tests"
            };

            showOnlyFailed.BindDataContext(c => c.Checked, (UnitTestViewModel m) => m.ShowOnlyFailed);

            Menu = new MenuBar
            {
                Items =
                {
                    new ButtonMenuItem {
                        Text = "&File", Items ={ openItem,          clear          }
                    },
                    new ButtonMenuItem {
                        Text = "&View", Items ={ showOutput,        showOnlyFailed }
                    }
                }
            };
        }
Esempio n. 2
0
        static ContextMenu CreateContextMenu(JourneyViewModel journeyViewModel)
        {
            var menu = new ContextMenu();

            var deleteItem = new ButtonMenuItem {
                Text = "Delete"
            };

            deleteItem.Click      += (s, e) => { journeyViewModel.DeleteSpending(); };
            deleteItem.DataContext = journeyViewModel;
            deleteItem.BindDataContext(c => c.Enabled, (JourneyViewModel m) => m.HasSelectedSpending);

            var addItem = new ButtonMenuItem {
                Text = "Add"
            };

            addItem.Click += (s, e) => { journeyViewModel.AddSpending(); };

            menu.Items.Add(deleteItem);
            menu.Items.Add(addItem);

            return(menu);
        }