예제 #1
0
        private void UpdateButton(int changeState = -1)
        {
            Color tc   = (Properties.Settings.Default.ThemeColor == "Inherit") ? ThemeInfo.GetThemeColor() : Engine.ColorFromHex(Properties.Settings.Default.ThemeColor);
            Color _col = Engine.ColorFromHex(Properties.Settings.Default.ThemeColor);

            if (changeState != -1)
            {
                this.CurrentState = changeState;
            }

            int _r = 0;
            int _g = 0;
            int _b = 0;

            switch (changeState)
            {
            default:
            case 0:
                this.BackColor = tc;
                break;

            case 1:
                _r = (_col.R + 50 >= 225) ? -50 : 50;
                _g = (_col.G + 50 >= 225) ? -50 : 50;
                _b = (_col.B + 50 >= 225) ? -50 : 50;

                this.BackColor = Color.FromArgb(255, tc.R + _r, tc.G + _g, tc.B + _b);
                break;

            case 2:
                _r = (_col.R + 50 >= 225) ? -100 : 100;
                _g = (_col.G + 50 >= 225) ? -100 : 100;
                _b = (_col.B + 50 >= 225) ? -100 : 100;

                this.BackColor = Color.FromArgb(255, tc.R + _r, tc.G + _g, tc.B + _b);
                break;
            }

            this.btnIcon.Image = this.icon;

            if (this.InvokeRequired)
            {
                this.Invoke(new MethodInvoker(this.Update));
            }
            else
            {
                this.Update();
            }
        }
예제 #2
0
        private void DesktopWidget_Load(object sender, EventArgs e)
        {
            RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (Properties.Settings.Default.AllowStartup)
            {
                if (rk.GetValue(Application.ProductName) == null)
                {
                    rk.SetValue(Application.ProductName, Application.ExecutablePath);
                }
            }
            else
            {
                rk.DeleteValue(Application.ProductName, false);
            }

            if (Properties.Settings.Default.ThemeColor == "Inherit")
            {
                this.WidgetBody.BackColor     = ThemeInfo.GetThemeColor();
                this.ProgressStatus.BackColor = ThemeInfo.GetThemeColor();

                Properties.Settings.Default.ThemeColor = Engine.ColorToHex(ThemeInfo.GetThemeColor());
                Properties.Settings.Default.Save();
                Properties.Settings.Default.Reload();
            }
            else
            {
                this.WidgetBody.BackColor     = Engine.ColorFromHex(Properties.Settings.Default.ThemeColor);
                this.ProgressStatus.BackColor = Engine.ColorFromHex(Properties.Settings.Default.ThemeColor);
            }

            this.Opacity  = (Properties.Settings.Default.UseTransparency) ? 0.75 : 1;
            this.Location = this.GetPosition();

            this.UpdateContextMenuOptions();
            this.InitializeEventHandlers();

            if (Properties.Settings.Default.ShowSideButtons)
            {
                CustomButton exit_btn    = new CustomButton("ExitButton", "Hide", new Point(5, 6), Properties.Resources.hide_icon, this.ToggleWidget);
                CustomButton refresh_btn = new CustomButton("RefreshButton", "Refresh", new Point(5, 49), Properties.Resources.refresh_icon, this.DoRefresh);

                if (Properties.Settings.Default.AllowDisposal)
                {
                    CustomButton disposal_btn = new CustomButton("DisposalButton", "Kill non-responsive tasks", new Point(5, 92), Properties.Resources.disposal_icon, this.DoTaskDisposal);
                    this.Controls.Add(disposal_btn);
                }

                this.Controls.Add(exit_btn);
                this.Controls.Add(refresh_btn);
            }

            // shortcut is handled in the program's Main method
            if (!Properties.Settings.Default.AllowDisposal)
            {
                if (this.Controls.ContainsKey("DisposalButton"))
                {
                    this.Controls.RemoveByKey("DisposalButton");
                }
            }

            if (Properties.Settings.Default.ShowIntStatus)
            {
                this.UpdateConnectivity();
            }
            else
            {
                NetworkChange.NetworkAvailabilityChanged -= this.ConnectivityChangeEvent;
            }
        }
예제 #3
0
        private void InitializeEventHandlers()
        {
            ColorDialog OpenColorDialog(bool useCurrent = false)
            {
                ColorDialog cd = new ColorDialog();

                cd.SolidColorOnly = true;
                cd.AnyColor       = true;

                if (useCurrent)
                {
                    cd.Color = this.selectedThemeColor;
                }

                return(cd);
            }

            List <Control> children = new List <Control>();

            string[] whitelist = { "GroupBox" };

            void GetRecursiveChildren(Control cnt)
            {
                foreach (Control cont in cnt.Controls)
                {
                    if (whitelist.Contains(cont.GetType().Name))
                    {
                        children.Add(cont);
                    }

                    if (cont.HasChildren)
                    {
                        GetRecursiveChildren(cont);
                    }
                }
            }

            GetRecursiveChildren(this);

            foreach (Control child in children)
            {
                if (child.GetType().Name == "GroupBox")
                {
                    child.Paint += new PaintEventHandler(this.PaintGroupBox);
                }
            }

            this.SetInheritBtn.Click += new EventHandler(delegate
            {
                this.selectedThemeColor = Color.Transparent;
                this.UpdateThemeSettings();
            });

            this.SetThemeColorBtn.Click += new EventHandler(delegate { this.UpdateThemeSettings(); });

            this.CustomizeColorBtn.Click += new EventHandler(delegate
            {
                ColorDialog cd = OpenColorDialog(true);
                cd.ShowDialog();

                this.JustInheritedTheme = true;
                this.selectedThemeColor = cd.Color;
                this.UpdateColorPreview();
            });

            this.ShowInheritBtn.Click += new EventHandler(delegate
            {
                this.JustInheritedTheme = true;
                this.selectedThemeColor = ThemeInfo.GetThemeColor();
                this.UpdateColorPreview();
            });

            this.ColorPreviewPanel.BackColorChanged += new EventHandler(delegate
            {
                if (Properties.Settings.Default.ThemeColor != Engine.ColorToHex(this.selectedThemeColor))
                {
                    this.StatusMessage.Text = "Color not set.";
                }
            });

            this.EyeDropBtn.Click  += new EventHandler(delegate { this.EyeDropper(); });
            this.TryParseBtn.Click += new EventHandler(delegate { this.AttemptColorParse(); });

            this.RedSelector.ValueChanged   += new EventHandler(delegate { this.ChangeTheme(); });
            this.GreenSelector.ValueChanged += new EventHandler(delegate { this.ChangeTheme(); });
            this.BlueSelector.ValueChanged  += new EventHandler(delegate { this.ChangeTheme(); });
            this.Offset.ValueChanged        += new EventHandler(delegate { this.ChangeTheme(); });

            this.BackBtn.Click       += new EventHandler(delegate { this.UpdateValueSettings();  this.Dispose(); });
            this.DeleteLogsBtn.Click += new EventHandler(delegate { Engine.DeleteLogs(); });

            this.StartupUpdateBtn.Click += new EventHandler(delegate { this.UpdateStartupInfo(); });
            this.StartupRemoveBtn.Click += new EventHandler(delegate { this.UpdateStartupInfo(true); });
            this.QuitAppBtn.Click       += new EventHandler(delegate { Application.Exit(); });
        }