Exemplo n.º 1
0
        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";
        }
Exemplo n.º 2
0
        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.");
            }
        }
Exemplo n.º 3
0
        internal static bool IsDebugMode()
        {
#if DEBUG
            return(true);
#endif

            return((LibraryRegistry.GetStringValue(LibraryRegistry.PermanentRegistryPath, "IsDebug") ??
                    string.Empty).ToLowerInvariant() == "true");
        }
Exemplo n.º 4
0
        private void SaveReferenceToNewTrayIcon()
        {
            // Save our new tray icon info in case we get killed and restart, so that we'll be able
            // to clean up the tray.  (E.g. after an update, the new version will be able to clean
            // up the icon from before the update.)
            try {
                int trayIconID = (int)trayIcon.GetType().GetField("id", BindingFlags.NonPublic |
                                                                  BindingFlags.Instance).GetValue(trayIcon);

                var window = (NativeWindow)trayIcon.GetType().GetField("window", BindingFlags.NonPublic |
                                                                       BindingFlags.Instance).GetValue(trayIcon);

                if (window != null && window.Handle != IntPtr.Zero)
                {
                    LibraryRegistry.SetInt32Value(RegSettingNames.LastTrayID, trayIconID);
                    LibraryRegistry.SetInt32Value(RegSettingNames.LastTrayHwnd, window.Handle.ToInt32());
                }
            } catch (Exception e) {
                Log.Logger.ErrorException("Exception updating last tray icon data", e);
            }
        }
Exemplo n.º 5
0
        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.");
            }
        }
Exemplo n.º 6
0
        private void CleanUpOldTrayIconIfAppropriate()
        {
            // If we closed improperly last time, make sure the old tray icon isn't still around.
            try {
                var oldTrayIconID   = LibraryRegistry.GetInt32Value(RegSettingNames.LastTrayID);
                var oldTrayIconHwnd = LibraryRegistry.GetInt32Value(RegSettingNames.LastTrayHwnd);
                if (oldTrayIconID.HasValue && oldTrayIconHwnd.HasValue)
                {
                    try {
                        var oldTrayIconData = new NOTIFYICONDATA();
                        oldTrayIconData.hwnd = new IntPtr(oldTrayIconHwnd.Value);
                        oldTrayIconData.uID  = oldTrayIconID.Value;

                        Shell_NotifyIcon(NIM_DELETE, ref oldTrayIconData);
                    } finally {
                        LibraryRegistry.DeleteValue(RegSettingNames.LastTrayID);
                        LibraryRegistry.DeleteValue(RegSettingNames.LastTrayHwnd);
                    }
                }
            } catch (Exception e) {
                Log.Logger.WarnException("Exception removing last tray icon", e);
            }
        }
Exemplo n.º 7
0
 private void DeleteReferenceToProperlyClosedTrayIcon()
 {
     // we're shutting down properly, so no need to save the last tray icon info
     LibraryRegistry.DeleteValue(RegSettingNames.LastTrayID);
     LibraryRegistry.DeleteValue(RegSettingNames.LastTrayHwnd);
 }