private void btnApply_Click(object sender, EventArgs e) { nut.cfg.afterSeconds = int.Parse(txtSecondsOnBattery.Text); nut.cfg.secondsRemaining = int.Parse(txtSecondRemaining.Text); nut.cfg.percentRemaining = int.Parse(txtPercentRemaining.Text); nut.cfg.hostname = txtHostname.Text; nut.cfg.port = int.Parse(txtPort.Text); nut.cfg.upsDevice = txtUPSDevice.Text; nut.cfg.pollPeriod = int.Parse(txtPollPeriod.Text); if (txtPassword.TextLength > 0) { nut.cfg.password = txtPassword.Text; } nut.cfg.minimiseToTray = chkMinimiseToTray.Checked; nut.cfg.startWithWindows = chkStartWithWindows.Checked; nut.cfg.logLevel = (NutLog.ELogLevel)cboLogLevel.SelectedValue; if (nut.cfg.startWithWindows && nut.cfg.runAs == NutConfig.ERunAs.Application) { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", Application.ProductName, System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); } else { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", Application.ProductName, ""); } nut.cfg.write(); nut.Stop(); nut.nut.update -= Nut_update; nut = new NutControl(application: true); nut.nut.update += Nut_update; nut.Start(); }
private void MainForm_Load(object sender, EventArgs e) { nut.Start(); }