コード例 #1
0
        private void _AddApplicationMenu()
        {
            if (_AppSupportsCommands())
            {
                AppCommand rootCommand = new AppCommand(ID_ROOT, "Scheduler");

                LatchedAppCommand enabledCommand = new LatchedAppCommand("SchedulerEnabled", "Enabled");
                enabledCommand.IsChecked = _data.IsEnabled;
                enabledCommand.Checked  += (sender, e) => {
                    // Not setting the data member in _SetEnableState because we want to be
                    // able to call _SetEnableState without affecting the data (to stop
                    // the scheduler upon shutdown).
                    _data.IsEnabled = e.CheckedState;
                    _SetEnableState(_data.IsEnabled);
                };

                AppCommand separator1 = new AppCommand("s1", "-");

                AppCommand showCommand = new AppCommand("SchedulerShow", "Show");
                showCommand.Click += (sender, e) => {
                    using (SchedulerForm schedulerForm = new SchedulerForm(_data)) {
                        if (schedulerForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            enabledCommand.IsChecked = _data.IsEnabled;
                        }
                    }
                };

                rootCommand.Add(enabledCommand);
                rootCommand.Add(separator1);
                rootCommand.Add(showCommand);

                _application.AppCommands.Add(rootCommand);
            }
        }
コード例 #2
0
        private void _AddApplicationMenu()
        {
            if(_AppSupportsCommands()) {
                AppCommand rootCommand = new AppCommand(ID_ROOT, "Scheduler");

                LatchedAppCommand enabledCommand = new LatchedAppCommand("SchedulerEnabled", "Enabled");
                enabledCommand.IsChecked = _data.IsEnabled;
                enabledCommand.Checked += (sender, e) => {
                    // Not setting the data member in _SetEnableState because we want to be
                    // able to call _SetEnableState without affecting the data (to stop
                    // the scheduler upon shutdown).
                    _data.IsEnabled = e.CheckedState;
                    _SetEnableState(_data.IsEnabled);
                };

                AppCommand separator1 = new AppCommand("s1", "-");

                AppCommand showCommand = new AppCommand("SchedulerShow", "Show");
                showCommand.Click += (sender, e) => {
                    using(SchedulerForm schedulerForm = new SchedulerForm(_data)) {
                        if(schedulerForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                            enabledCommand.IsChecked = _data.IsEnabled;
                        }
                    }
                };

                rootCommand.Add(enabledCommand);
                rootCommand.Add(separator1);
                rootCommand.Add(showCommand);

                _application.AppCommands.Add(rootCommand);
            }
        }