Пример #1
0
 /// <summary>
 /// On Button click do.
 /// </summary>
 /// <param name="sender">The Event Sender.</param>
 /// <param name="e">The Event Arguments.</param>
 private void PBDarkTheme_Click(object sender, EventArgs e)
 {
     if (Question("DarkTheme", "This will apply the DarkTheme to your Registry"))
     {
         DarkEnabler.SetUserFlag(false);
         if (DarkEnabler.AccentColor.Hack())
         {
             DarkEnabler.SetHackApplied();
         }
         if (DarkEnabler.AccentColorInactive.Hack())
         {
             DarkEnabler.SetHackApplied();
         }
     }
 }
Пример #2
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();
     }
 }
Пример #3
0
 /// <summary>
 /// Apply the User Theme.
 /// </summary>
 /// <param name="Sender">The Sender.</param>
 /// <param name="e">Event Arguments.</param>
 private void MenuItemApplyUserTheme_Click(object Sender, EventArgs e)
 {
     DarkEnabler.SetUserFlag(true);
     if (DarkEnabler.AccentColor.Hack())
     {
         DarkEnabler.SetHackApplied();
     }
     if (DarkEnabler.AccentColorInactive.Hack())
     {
         DarkEnabler.SetHackApplied();
     }
     if (!DarkEnabler.ColorPrevalence.FromRegistry().Equals(1))
     {
         if (DarkEnabler.ColorPrevalence.Toogle())
         {
             DarkEnabler.SetHackApplied();
         }
     }
 }
Пример #4
0
 /// <summary>
 /// On FormClosing do.
 /// </summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void Options_FormClosing(object sender, FormClosingEventArgs e)
 {
     DarkEnabler.SetInterval((uint)numUpDown.Value);
 }
Пример #5
0
        /// <summary>
        /// On Button click do.
        /// </summary>
        /// <param name="sender">The Event Sender.</param>
        /// <param name="e">The Event Arguments.</param>
        private void ButtonApply_Click(object sender, EventArgs e)
        {
            if (Question("ApplyTheme", "This will apply the Colors to your Registry"))
            {
                if (textBoxActive.Text == string.Empty)
                {
                    Error("Active Text Field is empty.");
                    return;
                }
                else if (textBoxInactive.Text == string.Empty)
                {
                    Error("Inactive Text Field is empty.");
                    return;
                }
                else if (textBoxActive.TextLength > 13)
                {
                    Error("Value of Active Text Field is to long.");
                    return;
                }
                else if (textBoxInactive.TextLength > 13)     // Why 13?
                {
                    Error("Value of Inactive Text Field is to long.");
                    return;
                }
                else if (!textBoxActive.Text.IsHex() || !textBoxInactive.Text.IsHex())
                {
                    if (!regEx.IsMatch(textBoxActive.Text.Replace(",", "")) || !regEx.IsMatch(textBoxInactive.Text.Replace(",", "")))
                    {
                        Error("\nNot a Hex Number nor a RGB Color Integer\nPlease use: FFAAB7D9\nor\n255, 45, 123\nas formating.");
                        return;
                    }
                    else
                    {
                        string[] split = textBoxActive.Text.Split(',');
                        if (split.Length != 3)
                        {
                            Error("RGB Color of Active TextField is to short.\nValues have to be 3.");
                            return;
                        }
                        else
                        {
                            uint result2, result3;
                            if (!uint.TryParse(split[0], out uint result))
                            {
                                Error("First RGB Color value of Active TextField is not a 'non negative' number.");
                                return;
                            }
                            else if (!uint.TryParse(split[1], out result2))
                            {
                                Error("Second RGB Color value of Active TextField is not a 'non negative' number.");
                                return;
                            }
                            else if (!uint.TryParse(split[2], out result3))
                            {
                                Error("Third RGB Color value of Active TextField is not a 'non negative' number.");
                                return;
                            }
                            else if (result > 255)
                            {
                                Error("First RGB Color value of Active TextField is greater then 255.\nImpossibrew !!");
                                return;
                            }
                            else if (result2 > 255)
                            {
                                Error("Second RGB Color value of Active TextField is greater then 255.\nImpossibrew !!");
                                return;
                            }
                            else if (result3 > 255)
                            {
                                Error("Third RGB Color value of Active TextField is greater then 255.\nImpossibrew !!");
                                return;
                            }
                            byte[] toHex = new byte[3];
                            toHex[0]           = Convert.ToByte(result);
                            toHex[1]           = Convert.ToByte(result2);
                            toHex[2]           = Convert.ToByte(result3);
                            textBoxActive.Text = "ff" + BitConverter.ToString(toHex).Replace("-", "");
                        }

                        split = textBoxInactive.Text.Split(',');
                        if (split.Length != 3)
                        {
                            Error("RGB Color of Inactive TextField is to short.\nValues have to be 3.");
                            return;
                        }
                        else
                        {
                            uint result2, result3;
                            if (!uint.TryParse(split[0], out uint result))
                            {
                                Error("First RGB Color value of Inactive TextField is not a 'non negative' number.");
                                return;
                            }
                            else if (!uint.TryParse(split[1], out result2))
                            {
                                Error("Second RGB Color value of Inactive TextField is not a 'non negative' number.");
                                return;
                            }
                            else if (!uint.TryParse(split[2], out result3))
                            {
                                Error("Third RGB Color value of Inactive TextField is not a 'non negative' number.");
                                return;
                            }
                            else if (result > 255)
                            {
                                Error("First RGB Color value of Inactive TextField is greater then 255.\nImpossibrew !!");
                                return;
                            }
                            else if (result2 > 255)
                            {
                                Error("Second RGB Color value of Inactive TextField is greater then 255.\nImpossibrew !!");
                                return;
                            }
                            else if (result3 > 255)
                            {
                                Error("Third RGB Color value of Inactive TextField is greater then 255.\nImpossibrew !!");
                                return;
                            }
                            byte[] toHex = new byte[3];
                            toHex[0]             = Convert.ToByte(result);
                            toHex[1]             = Convert.ToByte(result2);
                            toHex[2]             = Convert.ToByte(result3);
                            textBoxInactive.Text = "ff" + BitConverter.ToString(toHex).Replace("-", "");
                        }
                    }
                }
                else if (textBoxActive.TextLength > 8 || !textBoxActive.Text.IsHexAlign())
                {
                    Error("The Active Color is either to long or not Hex Aligned!");
                    return;
                }
                else if (textBoxInactive.TextLength > 8 || !textBoxInactive.Text.IsHexAlign())
                {
                    Error("The Inactive Color is either to long or not Hex Aligned!");
                    return;
                }
                else
                {
                    // Hex align the user input to 4 bytes.
                    string addActive   = string.Empty;
                    string addInactive = string.Empty;
                    for (int i = 0; i < (4 - textBoxActive.TextLength / 2); i++)
                    {
                        addActive += "ff";
                    }
                    textBoxActive.Text = addActive + textBoxActive.Text;

                    for (int i = 0; i < (4 - textBoxInactive.TextLength / 2); i++)
                    {
                        addInactive += "ff";
                    }
                    textBoxInactive.Text = addInactive + textBoxInactive.Text;
                }

                // Went everything like it should?
                if (textBoxActive.Text.Length > 8)
                {
                    Error("Something went very bad!\nThe Active Color is to long.\nStop.");
                    return;
                }
                else if (textBoxInactive.Text.Length > 8)
                {
                    Error("Something went very bad!\nThe Inactive Color is to long.\nStop.");
                    return;
                }

                // Add Testing ?

                DarkEnabler.SetColor(textBoxActive.Text);
                DarkEnabler.SetColorInactive(textBoxInactive.Text);
                DarkEnabler.SetUserFlag(true);
                if (DarkEnabler.AccentColor.Hack())
                {
                    DarkEnabler.SetHackApplied();
                }
                if (DarkEnabler.AccentColorInactive.Hack())
                {
                    DarkEnabler.SetHackApplied();
                }
            }
        }
Пример #6
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 });
        }