private void RefreshDisplayTextForDynamicMenuItems() { if (InvokeRequired) { BeginInvoke(new SimpleDelegate(RefreshDisplayTextForDynamicMenuItems)); return; } if (LibraryRegistry.GetBooleanValue(RegSettingNames.AutomaticUpdatesEnabled).GetValueOrDefault(true)) { toggleAutomaticUpdatesToolStripMenuItem.Text = "Disable automatic updates"; } else { toggleAutomaticUpdatesToolStripMenuItem.Text = "Enable automatic updates"; } if (LibraryRegistry.GetBooleanValue(RegSettingNames.StartupWithWindowsEnabled).GetValueOrDefault(true)) { toggleStartupWithWindowsToolStripMenuItem.Text = "Disable startup with Windows"; } else { toggleStartupWithWindowsToolStripMenuItem.Text = "Enable startup with Windows"; } trayIcon.Text = "DesktopBootstrap"; }
private void toggleAutomaticUpdatesToolStripMenuItem_Click(object sender, EventArgs e) { // we have three things to do: // // first, update the flag in our currentuser settings // second, update the display text for the menu item // third, update the flag in localmachine, by signaling to the service LibraryRegistry.SetValue(RegSettingNames.AutomaticUpdatesEnabled, !LibraryRegistry.GetBooleanValue( RegSettingNames.AutomaticUpdatesEnabled).GetValueOrDefault(true)); RefreshDisplayTextForDynamicMenuItems(); if (LibraryRegistry.GetBooleanValue(RegSettingNames.AutomaticUpdatesEnabled).GetValueOrDefault(true)) { ServiceIpc.SignalEnableAutoUpdates(); Log.Logger.Debug("User reenabled automatic updates."); } else { // updates were enabled, but have now been disabled ServiceIpc.SignalEnableAutoUpdates(); Log.Logger.Debug("User disabled automatic updates."); } }
private void toggleStartWithWindowsToolStripMenuItem_Click(object sender, EventArgs e) { LibraryRegistry.SetValue(RegSettingNames.StartupWithWindowsEnabled, !LibraryRegistry.GetBooleanValue( RegSettingNames.StartupWithWindowsEnabled).GetValueOrDefault(true)); RefreshDisplayTextForDynamicMenuItems(); if (LibraryRegistry.GetBooleanValue(RegSettingNames.StartupWithWindowsEnabled).GetValueOrDefault(true)) { // add the Windows 'Run' registry value back in ServiceIpc.SignalEnableWindowsStartup(); Log.Logger.Debug("User reenabled startup with Windows."); } else { // delete the Windows 'Run' registry value ServiceIpc.SignalDisableWindowsStartup(); Log.Logger.Debug("User disabled startup with Windows."); } }