Browse Source

ProgressBar theming

deadmoon 4 years ago
parent
commit
93503f18e0

+ 2 - 2
Optimizer/ColoredControls/ColoredCheckBox.cs

@@ -10,12 +10,12 @@ namespace Optimizer
         {
             base.OnCheckedChanged(e);
 
-            this.Tag = "themeable";
-
             // custom theming
             if (this.Checked)
             {
+                this.Tag = "themeable";
                 this.Font = new Font(this.Font, FontStyle.Underline);
+
                 switch (Options.CurrentOptions.Color)
                 {
                     case Theme.Caramel:

+ 28 - 0
Optimizer/ColoredControls/ColoredProgress.cs

@@ -0,0 +1,28 @@
+using System.Windows.Forms;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace Optimizer
+{
+    internal class ColoredProgress : ProgressBar
+    {
+        public ColoredProgress()
+        {
+            this.SetStyle(ControlStyles.UserPaint, true);
+        }
+
+        protected override void OnPaint(PaintEventArgs e)
+        {
+            LinearGradientBrush brush = null;
+            Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
+
+            if (ProgressBarRenderer.IsSupported)
+                ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
+
+            rec.Width = (int)(rec.Width * ((double)base.Value / Maximum)) - 4;
+            rec.Height -= 4;
+            brush = new LinearGradientBrush(rec, Options.ForegroundAccentColor, Options.ForegroundColor, LinearGradientMode.Vertical);
+            e.Graphics.FillRectangle(brush, 2, 2, rec.Width, rec.Height);
+        }
+    }
+}

+ 5 - 50
Optimizer/MainForm.Designer.cs

@@ -116,7 +116,7 @@ namespace Optimizer
             this.btnGetFeed = new System.Windows.Forms.Button();
             this.panelCommonApps = new System.Windows.Forms.Panel();
             this.cAutoInstall = new Optimizer.ColoredCheckBox();
-            this.progressDownloader = new System.Windows.Forms.ProgressBar();
+            this.progressDownloader = new Optimizer.ColoredProgress();
             this.c64 = new Optimizer.ColoredRadioButton();
             this.c32 = new Optimizer.ColoredRadioButton();
             this.btnDownloadApps = new System.Windows.Forms.Button();
@@ -295,9 +295,6 @@ namespace Optimizer
             this.pictureBox29 = new System.Windows.Forms.PictureBox();
             this.pictureBox26 = new System.Windows.Forms.PictureBox();
             this.cleanerTab = new System.Windows.Forms.TabPage();
-            this.cleaningpanel = new System.Windows.Forms.Panel();
-            this.progress2 = new System.Windows.Forms.ProgressBar();
-            this.label4 = new System.Windows.Forms.Label();
             this.label6 = new System.Windows.Forms.Label();
             this.panel1 = new System.Windows.Forms.Panel();
             this.lblPretext = new System.Windows.Forms.Label();
@@ -576,7 +573,6 @@ namespace Optimizer
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox29)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox26)).BeginInit();
             this.cleanerTab.SuspendLayout();
-            this.cleaningpanel.SuspendLayout();
             this.panel1.SuspendLayout();
             this.pingerTab.SuspendLayout();
             this.panel7.SuspendLayout();
@@ -1914,7 +1910,7 @@ namespace Optimizer
             // 
             // progressDownloader
             // 
-            this.progressDownloader.Location = new System.Drawing.Point(7, 100);
+            this.progressDownloader.Location = new System.Drawing.Point(7, 108);
             this.progressDownloader.MarqueeAnimationSpeed = 15;
             this.progressDownloader.Name = "progressDownloader";
             this.progressDownloader.Size = new System.Drawing.Size(302, 10);
@@ -2009,7 +2005,7 @@ namespace Optimizer
             this.txtDownloadStatus.AutoSize = true;
             this.txtDownloadStatus.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.txtDownloadStatus.ForeColor = System.Drawing.Color.LightGray;
-            this.txtDownloadStatus.Location = new System.Drawing.Point(3, 76);
+            this.txtDownloadStatus.Location = new System.Drawing.Point(3, 83);
             this.txtDownloadStatus.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.txtDownloadStatus.Name = "txtDownloadStatus";
             this.txtDownloadStatus.Size = new System.Drawing.Size(38, 21);
@@ -4004,7 +4000,6 @@ namespace Optimizer
             // cleanerTab
             // 
             this.cleanerTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
-            this.cleanerTab.Controls.Add(this.cleaningpanel);
             this.cleanerTab.Controls.Add(this.label6);
             this.cleanerTab.Controls.Add(this.panel1);
             this.cleanerTab.Location = new System.Drawing.Point(4, 24);
@@ -4015,41 +4010,6 @@ namespace Optimizer
             this.cleanerTab.TabIndex = 5;
             this.cleanerTab.Text = "Cleaner";
             // 
-            // cleaningpanel
-            // 
-            this.cleaningpanel.Controls.Add(this.progress2);
-            this.cleaningpanel.Controls.Add(this.label4);
-            this.cleaningpanel.Location = new System.Drawing.Point(11, 288);
-            this.cleaningpanel.Margin = new System.Windows.Forms.Padding(2);
-            this.cleaningpanel.Name = "cleaningpanel";
-            this.cleaningpanel.Size = new System.Drawing.Size(511, 70);
-            this.cleaningpanel.TabIndex = 47;
-            // 
-            // progress2
-            // 
-            this.progress2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
-            this.progress2.Location = new System.Drawing.Point(29, 38);
-            this.progress2.Margin = new System.Windows.Forms.Padding(2);
-            this.progress2.MarqueeAnimationSpeed = 1;
-            this.progress2.Name = "progress2";
-            this.progress2.Size = new System.Drawing.Size(454, 11);
-            this.progress2.TabIndex = 44;
-            this.progress2.Visible = false;
-            // 
-            // label4
-            // 
-            this.label4.AutoSize = true;
-            this.label4.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.label4.ForeColor = System.Drawing.Color.DodgerBlue;
-            this.label4.Location = new System.Drawing.Point(25, 13);
-            this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
-            this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(85, 21);
-            this.label4.TabIndex = 45;
-            this.label4.Tag = "themeable";
-            this.label4.Text = "Cleaning...";
-            this.label4.Visible = false;
-            // 
             // label6
             // 
             this.label6.AutoSize = true;
@@ -4099,7 +4059,7 @@ namespace Optimizer
             this.lblFootprint.Font = new System.Drawing.Font("Segoe UI Semibold", 13F, ((System.Drawing.FontStyle)(((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic) 
                 | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.lblFootprint.ForeColor = System.Drawing.Color.DodgerBlue;
-            this.lblFootprint.Location = new System.Drawing.Point(235, 195);
+            this.lblFootprint.Location = new System.Drawing.Point(232, 195);
             this.lblFootprint.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.lblFootprint.Name = "lblFootprint";
             this.lblFootprint.Size = new System.Drawing.Size(119, 31);
@@ -6712,8 +6672,6 @@ namespace Optimizer
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox26)).EndInit();
             this.cleanerTab.ResumeLayout(false);
             this.cleanerTab.PerformLayout();
-            this.cleaningpanel.ResumeLayout(false);
-            this.cleaningpanel.PerformLayout();
             this.panel1.ResumeLayout(false);
             this.panel1.PerformLayout();
             this.pingerTab.ResumeLayout(false);
@@ -6789,8 +6747,6 @@ namespace Optimizer
         private ColoredCheckBox checkBin;
         private ColoredCheckBox checkMiniDumps;
         private System.Windows.Forms.Panel panel1;
-        private System.Windows.Forms.Label label4;
-        private System.Windows.Forms.ProgressBar progress2;
         private System.Windows.Forms.TabPage startupTab;
         private System.Windows.Forms.Label label5;
         private System.Windows.Forms.Button button32;
@@ -6836,7 +6792,6 @@ namespace Optimizer
         private System.Windows.Forms.Button button47;
         private System.Windows.Forms.TextBox txtIP;
         private ColoredCheckBox checkErrorReports;
-        private System.Windows.Forms.Panel cleaningpanel;
         private System.Windows.Forms.TabPage integratorTab;
         private System.Windows.Forms.TabControl synapse;
         private System.Windows.Forms.TabPage integratorInfoTab;
@@ -7067,7 +7022,7 @@ namespace Optimizer
         private System.Windows.Forms.Panel panelApps1;
         private System.Windows.Forms.Panel panelApps5;
         private ColoredCheckBox chkOnlyRemovable;
-        private System.Windows.Forms.ProgressBar progressDownloader;
+        private ColoredProgress progressDownloader;
         private System.Windows.Forms.PictureBox pictureBox75;
         private ColoredCheckBox cUT2;
         private System.Windows.Forms.Button btnGetFeed;

+ 11 - 28
Optimizer/MainForm.cs

@@ -356,6 +356,8 @@ namespace Optimizer
             // theming
             Options.ApplyTheme(this);
             launcherMenu.Renderer = new ToolStripRendererMaterial();
+            progressDownloader.BackColor = Options.ForegroundColor;
+            progressDownloader.ForeColor = Options.ForegroundAccentColor;
 
             // quick access
             _trayMenu = Options.CurrentOptions.EnableTray;
@@ -519,36 +521,11 @@ namespace Optimizer
             }
             finally
             {
-                CleaningAnimation(false);
+                Cleaning(false);
                 GetFootprint();
             }
         }
 
-        private void CleaningAnimation(bool start)
-        {
-            if (start)
-            {
-                Utilities.SetControlPropertyThreadSafe(cleaningpanel, "Visible", true);
-                Utilities.SetControlPropertyThreadSafe(progress2, "Visible", true);
-                Utilities.SetControlPropertyThreadSafe(progress2, "Style", ProgressBarStyle.Marquee);
-                Utilities.SetControlPropertyThreadSafe(progress2, "MarqueeAnimationSpeed", 1);
-                Utilities.SetControlPropertyThreadSafe(label4, "Visible", true);
-                Utilities.SetControlPropertyThreadSafe(button20, "Enabled", false);
-                Utilities.SetControlPropertyThreadSafe(panel1, "Enabled", false);
-            }
-            else
-            {
-                Utilities.SetControlPropertyThreadSafe(cleaningpanel, "Visible", false);
-                Utilities.SetControlPropertyThreadSafe(progress2, "Visible", false);
-                Utilities.SetControlPropertyThreadSafe(progress2, "Value", 0);
-                Utilities.SetControlPropertyThreadSafe(progress2, "Style", ProgressBarStyle.Blocks);
-                Utilities.SetControlPropertyThreadSafe(progress2, "MarqueeAnimationSpeed", 1);
-                Utilities.SetControlPropertyThreadSafe(label4, "Visible", false);
-                Utilities.SetControlPropertyThreadSafe(button20, "Enabled", true);
-                Utilities.SetControlPropertyThreadSafe(panel1, "Enabled", true);
-            }
-        }
-
         private bool FixRegistry()
         {
             bool changeDetected = false;
@@ -657,7 +634,7 @@ namespace Optimizer
 
         private void Main_Load(object sender, EventArgs e)
         {
-
+          
         }
 
         private void GetDesktopItems()
@@ -849,11 +826,17 @@ namespace Optimizer
 
         private void button20_Click(object sender, EventArgs e)
         {
-            CleaningAnimation(true);
+            Cleaning(true);
             Task t = new Task(() => CleanPC());
             t.Start();
         }
 
+        private void Cleaning(bool enabled)
+        {
+            button20.Enabled = !enabled;
+            button20.Text = (enabled) ? "..." : "Clean";
+        }
+
         private void button32_Click(object sender, EventArgs e)
         {
             if (listStartupItems.SelectedItems.Count == 1)

+ 9 - 54
Optimizer/MainForm.resx

@@ -139,24 +139,6 @@
         VUrZey8AAAAASUVORK5CYII=
 </value>
   </data>
-  <data name="label19.Text" xml:space="preserve">
-    <value>Items can have custom icons and position.
-They can also be hidden, accessible only
-by pressing the SHIFT key.
-
-It can also create custom commands
-for Run Dialog, making it easy to launch
-any application only by typing your desired keyword.</value>
-  </data>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
   <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>615, 45</value>
   </metadata>
@@ -171,42 +153,6 @@ Completely safe to apply.
 - Always shows file extensions
 - Shows hidden files</value>
   </data>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
-  <metadata name="infoBaloon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>615, 45</value>
-  </metadata>
   <data name="pictureBox58.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAYAAAB/HSuDAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
@@ -44256,6 +44202,15 @@ Completely safe to apply.
         VLbzIqMj2EmIooKmomaBkFgxaUf+7+fRv0dvibQj2EkIIWUk2EkIIWUk2EkIIWUk2EkIIWUk2EkIIWUk
         2EkIIWUk2EkIIWUk2EkIIWUk2EkIIWUk2EkIIeVjyzv+P/YEdIroBYDTAAAAAElFTkSuQmCC
 </value>
+  </data>
+  <data name="label19.Text" xml:space="preserve">
+    <value>Items can have custom icons and position.
+They can also be hidden, accessible only
+by pressing the SHIFT key.
+
+It can also create custom commands
+for Run Dialog, making it easy to launch
+any application only by typing your desired keyword.</value>
   </data>
   <data name="pictureBox84.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>

+ 3 - 0
Optimizer/Optimizer.csproj

@@ -89,6 +89,9 @@
     <Compile Include="AboutForm.Designer.cs">
       <DependentUpon>AboutForm.cs</DependentUpon>
     </Compile>
+    <Compile Include="ColoredControls\ColoredProgress.cs">
+      <SubType>Component</SubType>
+    </Compile>
     <Compile Include="ColoredControls\ToolStripRendererMaterial.cs" />
     <Compile Include="ErrorLogger.cs" />
     <Compile Include="FeedApp.cs" />

+ 7 - 0
Optimizer/Options.cs

@@ -142,6 +142,13 @@ namespace Optimizer
                     tmp.ForeColor = c1;
                 }
             }
+            foreach (RadioButton tmp in Utilities.GetSelfAndChildrenRecursive(f).OfType<RadioButton>().ToList())
+            {
+                if ((string)tmp.Tag == _themeFlag)
+                {
+                    tmp.ForeColor = c1;
+                }
+            }
         }
 
         internal static void SaveSettings()