Skip to content

Commit

Permalink
v1.7
Browse files Browse the repository at this point in the history
Added Start minimized to tray on windows startup
  • Loading branch information
RedDot-3ND7355 committed May 26, 2024
1 parent 4e83149 commit 9e6454e
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 14 deletions.
49 changes: 44 additions & 5 deletions MemoryCleaner/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 30 additions & 4 deletions MemoryCleaner/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MemoryCleaner
Expand All @@ -17,6 +18,7 @@ public partial class Form1 : MaterialSkin.Controls.MaterialForm
public static Form1 CurrentForm;
private bool AppStarted = false;
private bool bypass = false;
private string appver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.Replace(".0.0", "");

// Ini Form
public Form1()
Expand All @@ -35,10 +37,28 @@ public Form1()
SettingsHandler.ReadSettings();
// App Started Boolean
AppStarted = true;
// Set Version
materialLabel5.Text = "v" + appver;
// Restart as admin if clean cache is checked
CheckCachedCleanPerm();
// Set Timer if any at start
CheckForExistingTimer();
// Set Minimized if config present
CheckForStartAsMinimized();
}

// Check Start as Minimized added for folks that wants to save 1 second of their time XD
private void CheckForStartAsMinimized()
{
if (materialCheckbox4.Checked)
{
notifyIcon1.Visible = true;
Task.Delay(50).ContinueWith(delegate
{
CheckForIllegalCrossThreadCalls = false;
this.Hide();
});
}
}

// Check Perms
Expand Down Expand Up @@ -175,10 +195,8 @@ 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.6{Environment.NewLine}Run as admin for best results!");
}
private void materialButton3_Click(object sender, EventArgs e) =>
MaterialSkin.Controls.MaterialMessageBox.Show($"Made by Endless (Kogaruh){Environment.NewLine}Version: {appver}{Environment.NewLine}Run as admin for best results!");

// Toggle Standby Cache Memory Clear (with admin check)
private void materialCheckbox3_CheckedChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -219,5 +237,13 @@ private void RestartAsAdmin(string exe)
materialCheckbox3.Checked = false;
} catch { materialCheckbox3.Checked = false; }
}

// Save start as minimized
private void materialCheckbox4_CheckedChanged(object sender, EventArgs e)
{
if (AppStarted)
// Save Setting
SettingsHandler.SaveSettings();
}
}
}
4 changes: 2 additions & 2 deletions MemoryCleaner/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MemoryCleaner")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
11 changes: 8 additions & 3 deletions MemoryCleaner/SettingsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MemoryCleaner
public static class SettingsHandler
{
static string default_path = Path.GetDirectoryName(Application.ExecutablePath) + "\\Settings.conf";
static string default_text = $"Interval = OFF{Environment.NewLine}Startup = false{Environment.NewLine}Advanced = false{Environment.NewLine}Cached = true";
static string default_text = $"Interval = OFF{Environment.NewLine}Startup = False{Environment.NewLine}Advanced = False{Environment.NewLine}Cached = True{Environment.NewLine}SMinimized = False";

// Initialize Settings
public static void IniSettings()
Expand All @@ -26,7 +26,7 @@ public static void IniSettings()
public static void SaveSettings()
{
// Save Current Settings
File.WriteAllText(default_path, $"Interval = {Form1.CurrentForm.materialComboBox1.SelectedItem.ToString()}{Environment.NewLine}Startup = {Form1.CurrentForm.materialCheckbox1.Checked.ToString()}{Environment.NewLine}Advanced = {Form1.CurrentForm.materialCheckbox2.Checked.ToString()}{Environment.NewLine}Cached = {Form1.CurrentForm.materialCheckbox3.Checked.ToString()}");
File.WriteAllText(default_path, $"Interval = {Form1.CurrentForm.materialComboBox1.SelectedItem.ToString()}{Environment.NewLine}Startup = {Form1.CurrentForm.materialCheckbox1.Checked.ToString()}{Environment.NewLine}Advanced = {Form1.CurrentForm.materialCheckbox2.Checked.ToString()}{Environment.NewLine}Cached = {Form1.CurrentForm.materialCheckbox3.Checked.ToString()}{Environment.NewLine}SMinimized = {Form1.CurrentForm.materialCheckbox4.Checked.ToString()}");
}

// Read Settings
Expand All @@ -52,11 +52,16 @@ public static void ReadSettings()
_setting = setting.Replace("Advanced = ", "");
Form1.CurrentForm.materialCheckbox2.Checked = bool.Parse(_setting);
}
if (settings.Contains("Cached = ")) // boolean
if (setting.Contains("Cached = ")) // boolean
{
_setting = setting.Replace("Cached = ", "");
Form1.CurrentForm.materialCheckbox3.Checked = bool.Parse(_setting);
}
if (setting.Contains("SMinimized = ")) // boolean
{
_setting = setting.Replace("SMinimized = ", "");
Form1.CurrentForm.materialCheckbox4.Checked = bool.Parse(_setting);
}
}
}
}
Expand Down

0 comments on commit 9e6454e

Please sign in to comment.