From 0f9dc1613b6812252de4293bd5c905a40c741625 Mon Sep 17 00:00:00 2001 From: xEndless Date: Fri, 1 Dec 2023 05:45:24 -0500 Subject: [PATCH] v1.1 Fix for interval not being set properly on boot, sorry folks ;) teehee --- MemoryCleaner/Form1.cs | 48 +++++++++++++----------- MemoryCleaner/MemoryCleaner.csproj | 3 ++ MemoryCleaner/Properties/AssemblyInfo.cs | 2 +- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/MemoryCleaner/Form1.cs b/MemoryCleaner/Form1.cs index 138fabd..9f3aac5 100644 --- a/MemoryCleaner/Form1.cs +++ b/MemoryCleaner/Form1.cs @@ -1,16 +1,8 @@ using IWshRuntimeLibrary; using MaterialSkin; using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; -using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace MemoryCleaner { @@ -21,6 +13,7 @@ public partial class Form1 : MaterialSkin.Controls.MaterialForm public _MemoryCleaner MemoryCleaner = new _MemoryCleaner(); public static Form1 CurrentForm; private bool AppStarted = false; + private bool bypass = false; // Ini Form public Form1() @@ -39,6 +32,15 @@ public Form1() SettingsHandler.ReadSettings(); // App Started Boolean AppStarted = true; + // Set Timer if any at start + CheckForExistingTimer(); + } + + // Completely forgot about it, teehee. Function is pretty self explanatory. + private void CheckForExistingTimer() + { + bypass = true; + materialComboBox1_SelectedIndexChanged(this, null); } // Manual Clean Button @@ -55,18 +57,21 @@ private void materialComboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (AppStarted) { - // Save Setting - SettingsHandler.SaveSettings(); - - // Proceed - if (materialComboBox1.SelectedItem.ToString() != "OFF") - { - int milliseconds = Int32.Parse(materialComboBox1.SelectedItem.ToString()) * 60000; - CleanerTimer.Interval = milliseconds; - CleanerTimer.Start(); - } - else - CleanerTimer.Stop(); + if (!bypass) + // Save Setting + SettingsHandler.SaveSettings(); + else + // Reset save settings bypass + bypass = false; + // Proceed + if (materialComboBox1.SelectedItem.ToString() != "OFF") + { + int milliseconds = Int32.Parse(materialComboBox1.SelectedItem.ToString()) * 60000; + CleanerTimer.Interval = milliseconds; + CleanerTimer.Start(); + } + else + CleanerTimer.Stop(); } } @@ -79,6 +84,7 @@ private void CleanerTimer_Tick(object sender, EventArgs e) thread1.Start(); } + // Start MemClean Routine private void StartClean() => MemoryCleaner.CleanMem(materialCheckbox2.Checked); @@ -158,7 +164,7 @@ private void notifyIcon1_MouseClick(object sender, MouseEventArgs e) // About private void materialButton3_Click(object sender, EventArgs e) { - MaterialSkin.Controls.MaterialMessageBox.Show($"Made by Endless (Kogaruh){Environment.NewLine}Version: 1.0{Environment.NewLine}Run as admin for best results!"); + MaterialSkin.Controls.MaterialMessageBox.Show($"Made by Endless (Kogaruh){Environment.NewLine}Version: 1.1{Environment.NewLine}Run as admin for best results!"); } } } diff --git a/MemoryCleaner/MemoryCleaner.csproj b/MemoryCleaner/MemoryCleaner.csproj index 1d4899e..2119f6c 100644 --- a/MemoryCleaner/MemoryCleaner.csproj +++ b/MemoryCleaner/MemoryCleaner.csproj @@ -38,6 +38,9 @@ MemoryCleaner.Program + + false + ..\packages\MaterialSkin.2.2.3.1\lib\net48\MaterialSkin.dll diff --git a/MemoryCleaner/Properties/AssemblyInfo.cs b/MemoryCleaner/Properties/AssemblyInfo.cs index 91e8156..e54d224 100644 --- a/MemoryCleaner/Properties/AssemblyInfo.cs +++ b/MemoryCleaner/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")]