예제 #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>
 /// 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();
         }
     }
 }
예제 #3
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();
                }
            }
        }