示例#1
0
        //private void SetDefaultSettings()
        //{
        //    _mainForm.textBoxUnresponsiveInterval.Text = "30";
        //    _mainForm.textBoxHeartbeatInterval.Text    = "15";
        //    _mainForm.textBoxHeartbeatInterval.Text    = "15";
        //    _mainForm.textBoxMaxProcesses.Text         = "1";
        //    _mainForm.textBoxMinProcesses.Text         = "1";
        //    _mainForm.textBoxProcessName.Text          = "";
        //    _mainForm.textBoxApplicationPath.Text      = "";
        //    _mainForm.checkBoxUseHeartbeat.Checked     = false;
        //    _mainForm.checkBoxGrantKillRequest.Checked = true;
        //    _mainForm.textBoxStartupMonitorDelay.Text  = "30";
        //    applicationHandlerConfig.Active
        //}

        private void SetForm(ApplicationHandlerConfig applicationHandlerConfig)
        {
            _mainForm.textBoxProcessName.Text     = applicationHandlerConfig.ApplicationName;
            _mainForm.textBoxApplicationPath.Text = applicationHandlerConfig.ApplicationPath;

            _mainForm.listBoxMonitoredApplications.SelectedItem = applicationHandlerConfig.ApplicationName;
        }
示例#2
0
        private void SetSelectedItem(int i)
        {
            // Check old state
            //if (i != _selectedItemNo)
            //{
            //    // check if settings have changed, if so, ask for Accept
            //    //_selectedItem = _configuration.ApplicationHandlers[_selectedItemNo];
            //    if (!SettingsSame(_selectedItem))
            //    {
            //        var result = MessageBox.Show("This Application has not been applied. Do you want to apply and store it? If not, these updates will be lost",
            //            "Update Monitored Application",
            //            MessageBoxButtons.YesNo,
            //            MessageBoxIcon.Question);
            //        if (result == DialogResult.Yes)
            //        {
            //            AcceptChanges();
            //        }
            //    }
            //}


            if (i < _configuration.ApplicationHandlers.Count)
            {
                _selectedItem   = _configuration.ApplicationHandlers[i];
                _selectedItemNo = i;

                SetForm(_selectedItem);
            }
        }
示例#3
0
        public Configuration()
        {
            ApplicationHandlersConfig = new List <ApplicationHandler>();
            ShowTrayIcon = true;

            var app = new ApplicationHandlerConfig()
            {
                ApplicationPath = @"D:\DevelPers\WatchDog\MonitoredApplication\bin\Release\MonitoredApplication.exe",
                ApplicationPath = "MonitoredApplication",
                Active          = true
            };
            //var applicationHandler = new ApplicationHandler("MonitoredApplication", @"D:\DevelPers\WatchDog\MonitoredApplication\bin\Release\MonitoredApplication.exe", 10, 10, 1, 1,false, true) {Active = true};
        }
示例#4
0
 private bool SettingsSame(ApplicationHandlerConfig applicationHandlerConfig)
 {
     return(_editApplicationsForm.textBoxUnresponsiveInterval.Text == applicationHandlerConfig.NonResponsiveInterval.ToString() &&
            _editApplicationsForm.textBoxHeartbeatInterval.Text == applicationHandlerConfig.HeartbeatInterval.ToString() &&
            _editApplicationsForm.textBoxMaxProcesses.Text == applicationHandlerConfig.MaxProcesses.ToString() &&
            _editApplicationsForm.textBoxMinProcesses.Text == applicationHandlerConfig.MinProcesses.ToString() &&
            _editApplicationsForm.textBoxProcessName.Text == applicationHandlerConfig.ApplicationName &&
            _editApplicationsForm.textBoxApplicationPath.Text == applicationHandlerConfig.ApplicationPath &&
            _editApplicationsForm.checkBoxUseHeartbeat.Checked == applicationHandlerConfig.UseHeartbeat &&
            _editApplicationsForm.checkBoxGrantKillRequest.Checked == applicationHandlerConfig.GrantKillRequest &&
            _editApplicationsForm.textBoxStartupMonitorDelay.Text == applicationHandlerConfig.StartupMonitorDelay.ToString() &&
            _editApplicationsForm.buttonDeactivate.Enabled == applicationHandlerConfig.Active);
 }
示例#5
0
        public EditFormVm(EditForm editApplicationsForm, ApplicationHandlerConfig applicationHandlerConfig, Configuration configuration)
        {
            _editApplicationsForm = editApplicationsForm;

            _applicationHandlerConfig = applicationHandlerConfig;
            _configuration            = configuration;
            //_serializer                                                  = serializer;
            SetForm();

            _editApplicationsForm.buttonActivate.Click   += ButtonActivateClick;
            _editApplicationsForm.buttonDeactivate.Click += ButtonDeactivateClick;

            _editApplicationsForm.buttonAcceptChanges.Click += ButtonAcceptClick;
        }
示例#6
0
        private void ButtonAddProcessClick(object sender, EventArgs e)
        {
            var applicationHandlerConfig = new ApplicationHandlerConfig();

            _configuration.ApplicationHandlers.Add(applicationHandlerConfig);

            var editForm   = new EditForm();
            var editFormVm = new EditFormVm(editForm, applicationHandlerConfig, _configuration);

            editForm.ShowDialog(_mainForm);

            _serializer.Serialize(_configuration);


            _mainForm.listBoxMonitoredApplications.Items.Add(applicationHandlerConfig.ApplicationName);
            SelectMenuItemInList(_mainForm.listBoxMonitoredApplications.Items.Count - 1);


            SetForm(applicationHandlerConfig);
        }
示例#7
0
        public MainFormVm(MainForm mainForm, ApplicationWatcher applicationWatcher, Configuration configuration, Utilities.ConfigurationSerializer <Configuration> serializer)
        {
            _mainForm           = mainForm;
            _applicationWatcher = applicationWatcher;
            _configuration      = configuration;
            _serializer         = serializer;
            _selectedItem       = null;
            // todo load item
            _mainForm.listBoxMonitoredApplications.SelectedIndexChanged += this.ListBoxMonitoredApplicationsSelectedIndexChanged;

            _mainForm.buttonAddProcess.Click     += ButtonAddProcessClick;
            _mainForm.buttonDeleteProcess.Click  += ButtonDeleteProcessOnClick;
            _mainForm.buttonEditProcess.Click    += ButtonEditProcessClick;
            _mainForm.buttonRebootSettings.Click += ButtonRebootSettingsClick;

            foreach (var applicationHandlerConfig in configuration.ApplicationHandlers)
            {
                _mainForm.listBoxMonitoredApplications.Items.Add(applicationHandlerConfig.ApplicationName);
            }
            SelectMenuItemInList(0);
        }
示例#8
0
 private bool SettingsSame(ApplicationHandlerConfig applicationHandlerConfig)
 {
     return(_mainForm.textBoxProcessName.Text == applicationHandlerConfig.ApplicationName &&
            _mainForm.textBoxApplicationPath.Text == applicationHandlerConfig.ApplicationPath);
 }