Пример #1
0
        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();
        }
Пример #2
0
        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();
                }
            }
        }
Пример #3
0
        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();
        }
Пример #4
0
        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();
        }
Пример #5
0
        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();
        }
Пример #6
0
        private void BrokenShortcutsBox_CheckedChanged(object sender, EventArgs e)
        {
            if (brokenShortcutsBox.Checked)
            {
                Default.DeleteBrokenShortcuts = true;
            }
            else
            {
                Default.DeleteBrokenShortcuts = false;
            }

            Default.Save();
        }
Пример #7
0
        private void LoggingBox_CheckedChanged(object sender, EventArgs e)
        {
            if (LoggingBox.Checked)
            {
                Default.LoggingEnabled = true;
            }
            else
            {
                Default.LoggingEnabled = false;
            }

            Default.Save();
        }
Пример #8
0
        private void InvalidVariablesBox_CheckedChanged(object sender, EventArgs e)
        {
            if (InvalidVariablesBox.Checked)
            {
                Default.InvalidVariablesBox = true;
            }
            else
            {
                Default.InvalidVariablesBox = false;
            }

            Default.Save();
        }
Пример #9
0
        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();
                }
            }
        }
Пример #10
0
        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();
        }
Пример #11
0
        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);
                }
            }
        }
Пример #12
0
        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);
                }
            }
        }
Пример #13
0
        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);
                }
            }
        }
Пример #14
0
        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);
                }
            }
        }
Пример #15
0
        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);
                }
            }
        }
Пример #16
0
        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);
                }
            }
        }
Пример #17
0
        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);
                }
            }
        }
Пример #18
0
        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);
        }