示例#1
0
 /// <summary>
 /// Turn the Registry Watcher on or off.
 /// </summary>
 /// <param name="Sender">The Sender.</param>
 /// <param name="e">Event Arguments.</param>
 private void MenuItemWatcher_Click(object Sender, EventArgs e)
 {
     if (DarkEnabler.IsWatcherRunning())
     {
         DarkEnabler.StopRegistryWatcher();
         menuItemWatcher.Text        = "Run Watcher";
         menuItemWatcher.ToolTipText = "Run the Registry Watcher";
         menuItemWatcher.Image       = Resources.play.ToBitmap();
     }
     else
     {
         DarkEnabler.RunRegistryWatcher();
         menuItemWatcher.Text        = "Stop Watcher";
         menuItemWatcher.ToolTipText = "Stop the Registry Watcher";
         menuItemWatcher.Image       = Resources.stop.ToBitmap();
     }
 }
示例#2
0
        public About()
        {
            // Initialize this form first.
            InitializeComponent();
            BackColor = Color.FromArgb(darkColor);
            ForeColor = Color.White;
            shown     = true;

            // Initialize DarkTitleBarHack Class.
            DarkEnabler.Write("Initializing DarkTitleBarHack()...");
            set = new Settings();
            DarkEnabler.darkTitleBar         = set.DarkTitleBar;
            DarkEnabler.darkTitleBarInactive = set.DarkTitleBarInactive;
            DarkEnabler.userColor            = set.UserColor;
            DarkEnabler.userColorInactive    = set.UserColorInactive;
            DarkEnabler._userColor           = set.UserColor_;
            DarkEnabler.interval             = set.Interval;
            DarkEnabler.hackApplied          = set.HackApplied;
            DarkEnabler.settings             = new Settings();
            DarkEnabler.WriteLine("OK");

            // Initialize components.
            menuItemExit      = new ToolStripMenuItem();
            menuItemDarkTheme = new ToolStripMenuItem();
            menuItemUserTheme = new ToolStripMenuItem();
            menuItemWatcher   = new ToolStripMenuItem();
            menuItemOptions   = new ToolStripMenuItem();
            menuItemAbout     = new ToolStripMenuItem();
            menuItemLog       = new ToolStripMenuItem();

            // Set MessagBox variables.
            MessagBox.DialogBack = MessagBox.ButtonBack = Color.FromArgb(darkColorInactive);
            MessagBox.DialogFore = MessagBox.ButtonBorder = MessagBox.FormFore = Color.White;
            MessagBox.FormBack   = Color.FromArgb(darkColor);

            // First check for Admin rights aka is this process elevated?
            bool dwm_ok = false;

            if (CheckForAdminRights())
            {
                // Check DWM registry entry and disable important buttons if false.
                dwm_ok = DarkEnabler.DWM.Exists();

                // If the Windows /DWM/ RegistryEntry Exists or is Accessable.
                if (dwm_ok)
                {
                    // Shall we Hack on Start?
                    if (set.HackOnStart)
                    {
                        // Check if the 'AccentColorInactive' value exists within the Registry. If not, add it to it.
                        RegCheck state = DarkEnabler.AccentColorInactive.Exists();
                        if (state == RegCheck.False || !DarkEnabler.AccentColorInactive.FromRegistry().Equals(DarkEnabler.GetAccentColorInactive(), ccIgnoreCase))
                        {
                            if (!DarkEnabler.AccentColorInactive.Hack())
                            {
                                dwm_ok = false;
                            }
                            else
                            {
                                DarkEnabler.SetHackApplied();
                            }
                        } // Check if reg Color do match stored one. Change it if not.
                        if (dwm_ok && !DarkEnabler.AccentColor.FromRegistry().Equals(DarkEnabler.GetAccentColor(), ccIgnoreCase))
                        {
                            if (!DarkEnabler.AccentColor.Hack())
                            {
                                dwm_ok = false;
                            }
                            else
                            {
                                DarkEnabler.SetHackApplied();
                            }
                        } // Toogle Color prevalence
                        state = DarkEnabler.ColorPrevalence.Exists();
                        if (dwm_ok && state == RegCheck.True && !DarkEnabler.ColorPrevalence.FromRegistry().Equals(1))
                        {
                            if (!DarkEnabler.ColorPrevalence.Toogle())
                            {
                                dwm_ok = false;
                            }
                            else
                            {
                                DarkEnabler.SetHackApplied();
                            }
                        }
                    }

                    // Shall we run the Registry Watcher on start of the app?
                    if (set.RunWatcherOnStart && dwm_ok)
                    {
                        DarkEnabler.RunRegistryWatcher();

                        // Check if watcher is running and format context menu entry name.
                        if (DarkEnabler.IsWatcherRunning())
                        {
                            menuItemWatcher.Text        = "Stop Watcher";
                            menuItemWatcher.ToolTipText = "Stop the Registry Watcher";
                            menuItemWatcher.Image       = Resources.stop.ToBitmap();
                        }
                    }
                }
            }
            else
            {
                Options.Error("You must run this app with Administrator rights.\nAll registry functions have been disabled.");
            }

            // Initialize menuItems
            menuItemExit.MergeIndex       = 0;
            menuItemExit.Text             = "Exit";
            menuItemExit.Image            = Resources.close.ToBitmap();
            menuItemExit.Click           += new EventHandler(MenuItemExit_Click);
            menuItemOptions.MergeIndex    = 1;
            menuItemOptions.Enabled       = dwm_ok;
            menuItemOptions.Text          = "Options";
            menuItemOptions.ToolTipText   = "Lets you easely pick up custom colors for the Title Bar Hack";
            menuItemOptions.Image         = Resources.signpost.ToBitmap();
            menuItemOptions.Click        += new EventHandler(MenuItemOptions_Click);
            menuItemWatcher.MergeIndex    = 2;
            menuItemWatcher.Enabled       = dwm_ok;
            menuItemWatcher.Text          = "Run Watcher";
            menuItemWatcher.ToolTipText   = "Run the Registry Watcher";
            menuItemWatcher.Image         = Resources.play.ToBitmap();
            menuItemWatcher.Click        += new EventHandler(MenuItemWatcher_Click);
            menuItemDarkTheme.MergeIndex  = 3;
            menuItemDarkTheme.Enabled     = dwm_ok;
            menuItemDarkTheme.Text        = "Apply Dark Theme";
            menuItemDarkTheme.ToolTipText = "Applys the Dark Title Bar and Inactive Dark Title Bar Colors";
            menuItemDarkTheme.Image       = Resources.apply.ToBitmap();
            menuItemDarkTheme.Click      += new EventHandler(MenuItemApplyDarkTheme_Click);
            menuItemUserTheme.MergeIndex  = 4;
            menuItemUserTheme.Enabled     = dwm_ok;
            menuItemUserTheme.Text        = "Apply User Theme";
            menuItemUserTheme.ToolTipText = "Applys the Title Bar and Inactive Title Bar User Colors";
            menuItemUserTheme.Image       = Resources.apply.ToBitmap();
            menuItemUserTheme.Click      += new EventHandler(MenuItemApplyUserTheme_Click);
            menuItemAbout.MergeIndex      = 5;
            menuItemAbout.Text            = "About";
            menuItemAbout.Image           = Resources.about.ToBitmap();
            menuItemAbout.Click          += new EventHandler(MenuItemAbout_Click);
            menuItemLog.MergeIndex        = 6;
            menuItemLog.Text   = "Notify";
            menuItemLog.Image  = Resources.bug.ToBitmap();
            menuItemLog.Click += new EventHandler(MenuItemNotify_Click);

            // Initialize contextMenu
            contextMenu.BackColor = Color.FromArgb(darkColor);
            contextMenu.ForeColor = Color.White;
            contextMenu.Renderer  = new DarkRenderer();
            contextMenu.Items.AddRange(new ToolStripMenuItem[] { menuItemExit, menuItemOptions, menuItemWatcher, menuItemDarkTheme, menuItemUserTheme, menuItemAbout, menuItemLog });
        }