Skip to content

Commit

Permalink
Files added
Browse files Browse the repository at this point in the history
Forgot to stage the files, teehee.
  • Loading branch information
RedDot-3ND7355 committed Nov 29, 2023
1 parent 5603991 commit c947613
Show file tree
Hide file tree
Showing 26 changed files with 5,234 additions and 0 deletions.
25 changes: 25 additions & 0 deletions MemoryCleaner.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MemoryCleaner", "MemoryCleaner\MemoryCleaner.csproj", "{F107BA72-C121-4E22-B8F7-9822E75D30E5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F107BA72-C121-4E22-B8F7-9822E75D30E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F107BA72-C121-4E22-B8F7-9822E75D30E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F107BA72-C121-4E22-B8F7-9822E75D30E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F107BA72-C121-4E22-B8F7-9822E75D30E5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {57F09158-6BCE-4072-895F-4B3BFA6B2AD4}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions MemoryCleaner/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
368 changes: 368 additions & 0 deletions MemoryCleaner/Form1.Designer.cs

Large diffs are not rendered by default.

164 changes: 164 additions & 0 deletions MemoryCleaner/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
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
{
public partial class Form1 : MaterialSkin.Controls.MaterialForm
{
// Globals
public readonly MaterialSkinManager materialSkinManager;
public _MemoryCleaner MemoryCleaner = new _MemoryCleaner();
public static Form1 CurrentForm;
private bool AppStarted = false;

// Ini Form
public Form1()
{
InitializeComponent();
// Set Static Form
CurrentForm = this;
// Set material colors
materialSkinManager = MaterialSkinManager.Instance;
materialSkinManager.EnforceBackcolorOnAllComponents = true;
materialSkinManager.AddFormToManage(this);
materialSkinManager.Theme = MaterialSkinManager.Themes.DARK;
// Ini Settings
SettingsHandler.IniSettings();
// Read Settings
SettingsHandler.ReadSettings();
// App Started Boolean
AppStarted = true;
}

// Manual Clean Button
private void button1_Click(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
// Start a thread that calls a parameterized instance method.
Thread thread1 = new Thread(new ThreadStart(StartClean));
thread1.Start();
}

// Set Interval
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();
}
}

// Cleaner Interval
private void CleanerTimer_Tick(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
// Start a thread that calls a parameterized instance method.
Thread thread1 = new Thread(new ThreadStart(StartClean));
thread1.Start();
}

private void StartClean() =>
MemoryCleaner.CleanMem(materialCheckbox2.Checked);

// Start with Windows
private void materialCheckbox1_CheckedChanged(object sender, EventArgs e)
{
if (AppStarted)
{
// Save Setting
SettingsHandler.SaveSettings();
// Proceed
if (materialCheckbox1.Checked)
{
/* This bit was taken by stackoverflow */
WshShell wshShell = new WshShell();
IWshShortcut shortcut;
string startUpFolderPath =
Environment.GetFolderPath(Environment.SpecialFolder.Startup);

// Create the shortcut
shortcut =
(IWshShortcut)wshShell.CreateShortcut(
startUpFolderPath + "\\" +
Application.ProductName + ".lnk");

shortcut.TargetPath = Application.ExecutablePath;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Description = "Memory Cleaner Startup";
//shortcut.IconLocation = Application.StartupPath + @"\App.ico";
shortcut.Save();
/* End of said bit */
}
else
{
// Delete startup shortcut
System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + Application.ProductName + ".lnk");
}
}
}

// Reset Log Text
public void ResetLauncherLog()
{
materialMultiLineTextBox21.Text = "Start of log";
}

// Add Logs to Form
public void AddLauncherLog(string log)
{
// Proceed
materialMultiLineTextBox21.Text += Environment.NewLine + log;

}

// Show Processes in logs
private void materialCheckbox2_CheckedChanged(object sender, EventArgs e)
{
if (AppStarted)
// Save Setting
SettingsHandler.SaveSettings();
}

// Minimize to tray
private void materialButton1_Click(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
this.Hide();
}

// Recover window from tray
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
this.Show();
notifyIcon1.Visible = false;
}

// 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!");
}
}
}
Loading

0 comments on commit c947613

Please sign in to comment.