private void ExclusionListAdd_Click(object sender, EventArgs e) { bool ItemExists = false; var selected = ExclusionListTextBox.Text; if (selected != string.Empty) { foreach (string item in ExclusionListBox.Items) { if (item == selected) { ItemExists = true; break; } } if (!ItemExists) { ExclusionListBox.Items.Add(selected); Default.ExclusionList.Add(selected); } ExclusionListTextBox.Text = string.Empty; } Default.Save(); }
private void FileBrowser(ComboBox comboBox, StringCollection collection) { using (OpenFileDialog browserDialog = new OpenFileDialog()) { DialogResult result = browserDialog.ShowDialog(); if (result == DialogResult.OK) { string selected = browserDialog.FileName; bool ItemExists = false; if (selected != string.Empty) { foreach (string item in comboBox.Items) { if (item == selected) { ItemExists = true; break; } } if (!ItemExists) { comboBox.Items.Add(selected); collection.Add(selected); } } Default.Save(); } } }
private void TasksDisableButton_Click(object sender, EventArgs e) { bool ItemExists = false; var selected = TasksTextBox.Text; if (selected != string.Empty) { foreach (string item in TasksDisableBox.Items) { if (item == selected) { ItemExists = true; break; } } if (!ItemExists) { TasksDisableBox.Items.Add(selected); Default.TasksToDisable.Add(selected); } TasksTextBox.Text = string.Empty; } Default.Save(); }
private void AddTexValuesTextBox(TextBox textBox, ComboBox comboBox, StringCollection collection) { string selected = textBox.Text; bool ItemExists = false; if (selected != string.Empty) { foreach (string item in comboBox.Items) { if (item == selected) { ItemExists = true; break; } } if (!ItemExists) { comboBox.Items.Add(selected); collection.Add(selected); } textBox.Text = string.Empty; } Default.Save(); }
private void AddTexValuesComboBox(ComboBox comboBox, StringCollection collection, bool isService = false) { string selected = comboBox.Text; bool ItemExists = false; if (selected != string.Empty) { foreach (string item in comboBox.Items) { if (item == selected) { ItemExists = true; break; } } if (!ItemExists) { if (!isService) { comboBox.Items.Add(selected); collection.Add(selected); } else { try { ServiceController sc = new ServiceController(selected); var displayName = sc.DisplayName; foreach (string item in comboBox.Items) { if (item == selected + ';' + displayName) { ItemExists = true; break; } } if (!ItemExists) { comboBox.Items.Add(selected + ';' + displayName); collection.Add(selected + ';' + displayName); } } catch (Exception ex) { EasyLogger.Error(selected + " : " + ex + Environment.NewLine); BeginInvoke(new MethodInvoker(() => Console(selected + " : " + ex.Message))); } } } comboBox.Text = string.Empty; } Default.Save(); }
private void BrokenShortcutsBox_CheckedChanged(object sender, EventArgs e) { if (brokenShortcutsBox.Checked) { Default.DeleteBrokenShortcuts = true; } else { Default.DeleteBrokenShortcuts = false; } Default.Save(); }
private void LoggingBox_CheckedChanged(object sender, EventArgs e) { if (LoggingBox.Checked) { Default.LoggingEnabled = true; } else { Default.LoggingEnabled = false; } Default.Save(); }
private void InvalidVariablesBox_CheckedChanged(object sender, EventArgs e) { if (InvalidVariablesBox.Checked) { Default.InvalidVariablesBox = true; } else { Default.InvalidVariablesBox = false; } Default.Save(); }
private void DirectoryBrowser(ComboBox comboBox, StringCollection collection, bool AskDays = false) { using (FolderBrowserDialog browserDialog = new FolderBrowserDialog()) { DialogResult result = browserDialog.ShowDialog(); if (result == DialogResult.OK) { string selected = browserDialog.SelectedPath; string value = string.Empty; // AskDays if (AskDays) { if (InputBox("Days to keep", "How many days until delete:", ref value) == DialogResult.OK) { selected = value + ", " + selected; } } bool ItemExists = false; if (selected != string.Empty) { foreach (string item in comboBox.Items) { if (item == selected) { ItemExists = true; break; } } if (!ItemExists) { comboBox.Items.Add(selected); collection.Add(selected); } } Default.Save(); } } }
private void ServicesManualButton_Click(object sender, EventArgs e) { bool ItemExists = false; var selected = ServicesTextBox.Text; if (selected != string.Empty) { try { ServiceController sc = new ServiceController(selected); var displayName = sc.DisplayName; foreach (string item in ServicesManualBox.Items) { if (item == selected + ';' + displayName) { ItemExists = true; break; } } if (!ItemExists) { ServicesManualBox.Items.Add(selected + ';' + displayName); Default.ServicesToManual.Add(selected + ';' + displayName); } } catch (Exception ex) { EasyLogger.Error(selected + " : " + ex + Environment.NewLine); BeginInvoke(new MethodInvoker(() => Console(selected + " : " + ex.Message))); } ServicesTextBox.Text = string.Empty; } Default.Save(); }
private void ExclusionListRemove_Click(object sender, EventArgs e) { if (ExclusionListBox.SelectedItem != null) { foreach (var item in Default.ExclusionList) { if (item == ExclusionListBox.SelectedItem.ToString()) { Default.ExclusionList.Remove(item); break; } } Default.Save(); Default.Reload(); ExclusionListBox.Items.Clear(); ExclusionListBox.Text = string.Empty; foreach (var item in Default.ExclusionList) { ExclusionListBox.Items.Add(item); } } }
private void ServicesManualRemove_Click(object sender, EventArgs e) { if (ServicesManualBox.SelectedItem != null) { foreach (var item in Default.ServicesToManual) { if (item == ServicesManualBox.SelectedItem.ToString()) { Default.ServicesToManual.Remove(item); break; } } Default.Save(); Default.Reload(); ServicesManualBox.Items.Clear(); ServicesManualBox.Text = string.Empty; foreach (var item in Default.ServicesToManual) { ServicesManualBox.Items.Add(item); } } }
private void PathHideRemove_Click(object sender, EventArgs e) { if (PathHideListBox.SelectedItem != null) { foreach (var item in Default.DirectoriesToHide) { if (item == PathHideListBox.SelectedItem.ToString()) { Default.DirectoriesToHide.Remove(item); break; } } Default.Save(); Default.Reload(); PathHideListBox.Items.Clear(); PathHideListBox.Text = string.Empty; foreach (var item in Default.DirectoriesToHide) { PathHideListBox.Items.Add(item); } } }
private void PathFilesDelOldRemove_Click(object sender, EventArgs e) { if (PathFilesDelOldBox.SelectedItem != null) { foreach (var item in Default.PathFilesToDeleteOlder) { if (item == PathFilesDelOldBox.SelectedItem.ToString()) { Default.PathFilesToDeleteOlder.Remove(item); break; } } Default.Save(); Default.Reload(); PathFilesDelOldBox.Items.Clear(); PathFilesDelOldBox.Text = string.Empty; foreach (var item in Default.PathFilesToDeleteOlder) { PathFilesDelOldBox.Items.Add(item); } } }
private void FilesHideRemove_Click(object sender, EventArgs e) { if (FilesHideBox.SelectedItem != null) { foreach (var item in Default.FilesToHide) { if (item == FilesHideBox.SelectedItem.ToString()) { Default.FilesToHide.Remove(item); break; } } Default.Save(); Default.Reload(); FilesHideBox.Items.Clear(); FilesHideBox.Text = string.Empty; foreach (var item in Default.FilesToHide) { FilesHideBox.Items.Add(item); } } }
private void DirDelRemove_Click(object sender, EventArgs e) { if (DirToDelBox.SelectedItem != null) { foreach (var item in Default.DirectoriesToDelete) { if (item == DirToDelBox.SelectedItem.ToString()) { Default.DirectoriesToDelete.Remove(item); break; } } Default.Save(); Default.Reload(); DirToDelBox.Items.Clear(); DirToDelBox.Text = string.Empty; foreach (var item in Default.DirectoriesToDelete) { DirToDelBox.Items.Add(item); } } }
private void TasksDisableRemove_Click(object sender, EventArgs e) { if (TasksDisableBox.SelectedItem != null) { foreach (var item in Default.TasksToDisable) { if (item == TasksDisableBox.SelectedItem.ToString()) { Default.TasksToDisable.Remove(item); break; } } Default.Save(); Default.Reload(); TasksDisableBox.Items.Clear(); TasksDisableBox.Text = string.Empty; foreach (var item in Default.TasksToDisable) { TasksDisableBox.Items.Add(item); } } }
static void Main(string[] args) { if (Default.LoggingEnabled) { EasyLogger.BackupLogs(EasyLogger.LogFile, 30); EasyLogger.AddListener(EasyLogger.LogFile); } if (Default.UpgradeRequired) { Default.Upgrade(); Default.UpgradeRequired = false; Default.Save(); Default.Reload(); } if (Default.FirstRun) { Default.FirstRun = false; Default.Save(); Default.Reload(); SettingsForm settings = new SettingsForm(); settings.ShowDialog(); Environment.Exit(0); } if (args.Length > 0) { try { string A0 = args[0].ToLower(); if (args[0] == "/optimize" || args[0] == "-optimize") { StartLightCleanup(); } else { StartLightCleanup(); } } catch (Exception ex) { EasyLogger.Info(ex.Message); } } else { // Run Settings and Close SettingsForm settings = new SettingsForm(); settings.ShowDialog(); } EasyLogger.Info("********************* END OF OPTIMIZATIONS *********************"); EasyLogger.RemoveListener(); #if DEBUG using (StreamReader sr = File.OpenText(EasyLogger.LogFile)) { string lines = sr.ReadToEnd(); if (lines.ToLower().Contains("[error]")) { MessageBox.Show("The log file contains errors!", "Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Warning); Process.Start(EasyLogger.LogDirectory); } } #endif Environment.Exit(0); }