Ejemplo n.º 1
0
 public void CheckedAll()
 {
     RegeditCheckBox.Invoke(new MethodInvoker(() =>
     {
         RegeditCheckBox.Checked = true;
     }));
     CheatConfigFilesCheckBox.Invoke(new MethodInvoker(() =>
     {
         CheatConfigFilesCheckBox.Checked = true;
     }));
     WindowsFilesCheckBox.Invoke(new MethodInvoker(() =>
     {
         WindowsFilesCheckBox.Checked = true;
     }));
     ScreenShotsFilesCheckBox.Invoke(new MethodInvoker(() =>
     {
         ScreenShotsFilesCheckBox.Checked = true;
     }));
     CrashFilesCheckBox.Invoke(new MethodInvoker(() =>
     {
         CrashFilesCheckBox.Checked = true;
     }));
     MediaFilesCheckBox.Invoke(new MethodInvoker(() =>
     {
         MediaFilesCheckBox.Checked = true;
     }));
     LogsFilesCheckBox.Invoke(new MethodInvoker(() =>
     {
         LogsFilesCheckBox.Checked = true;
     }));
     CacheFilesCheckBox.Invoke(new MethodInvoker(() =>
     {
         CacheFilesCheckBox.Checked = true;
     }));
     BackUpFilesCheckBox.Invoke(new MethodInvoker(() =>
     {
         BackUpFilesCheckBox.Checked = true;
     }));
 }
Ejemplo n.º 2
0
        public async Task Optimize()
        {
            ClearButton.Invoke(new MethodInvoker(() =>
            {
                ClearButton.Enabled = false;
            }));
            CleanerFileSettings    cleanermethod = new CleanerFileSettings();
            CleanerRegeditSettings regeditmethod = new CleanerRegeditSettings();
            long deleted = 0;

            if (RegeditCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerRegeditSettings.RegeditFiles clear in regeditmethod.lastactivity)
                    {
                        clear.Delete();
                    }

                    RegeditCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        RegeditCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=Registry");
                            RegistryClears.Invoke(new MethodInvoker(() =>
                            {
                                RegistryClears.Text    = newclears + " clears";
                                RegistryClears.Visible = true;
                            }));
                        }
                    }
                    catch { }
                });
                tasks.Add(updatecounter);
            }
            if (CheatConfigFilesCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerFileSettings.ClearFiles clear in cleanermethod.cheatconfigfiles)
                    {
                        deleted += clear.Delete();
                    }

                    CheatConfigFilesCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        CheatConfigFilesCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=CheatSettings");
                            CheatSettingsClears.Invoke(new MethodInvoker(() =>
                            {
                                CheatSettingsClears.Text    = newclears + " clears";
                                CheatSettingsClears.Visible = true;
                            }));
                        }
                    }
                    catch { }
                });
                tasks.Add(updatecounter);
            }
            if (WindowsFilesCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerFileSettings.ClearFiles clear in cleanermethod.windowsfiles)
                    {
                        deleted += clear.Delete();
                    }

                    WindowsFilesCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        WindowsFilesCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task temp2 = Task.Factory.StartNew(() =>
                {
                    SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlags.SHERB_NOSOUND | RecycleFlags.SHERB_NOCONFIRMATION | RecycleFlags.SHERB_NOPROGRESSUI);
                });
                tasks.Add(temp2);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=Windows");
                            WindowsGarbageClears.Invoke(new MethodInvoker(() =>
                            {
                                WindowsGarbageClears.Text    = newclears + " clears";
                                WindowsGarbageClears.Visible = true;
                            }));
                        }
                    }
                    catch { }
                });
                tasks.Add(updatecounter);
            }
            if (ScreenShotsFilesCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerFileSettings.ClearFiles clear in cleanermethod.screenshotfiles)
                    {
                        deleted += clear.Delete();
                    }

                    ScreenShotsFilesCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        ScreenShotsFilesCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=Screenshots");
                            ScreenshotsClears.Invoke(new MethodInvoker(() =>
                            {
                                ScreenshotsClears.Text    = newclears + " clears";
                                ScreenshotsClears.Visible = true;
                            }));
                        }
                    }
                    catch { }
                });
                tasks.Add(updatecounter);
            }
            if (CrashFilesCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerFileSettings.ClearFiles clear in cleanermethod.crashfiles)
                    {
                        deleted += clear.Delete();
                    }

                    CrashFilesCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        CrashFilesCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=Crashes");
                            CrashesClears.Invoke(new MethodInvoker(() =>
                            {
                                CrashesClears.Text    = newclears + " clears";
                                CrashesClears.Visible = true;
                            }));
                        }
                    }
                    catch { }
                });
                tasks.Add(updatecounter);
            }
            if (BackUpFilesCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerFileSettings.ClearFiles clear in cleanermethod.backupfiles)
                    {
                        deleted += clear.Delete();
                    }

                    BackUpFilesCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        BackUpFilesCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=Backups");
                            BackupsClears.Invoke(new MethodInvoker(() =>
                            {
                                BackupsClears.Text    = newclears + " clears";
                                BackupsClears.Visible = true;
                            }));
                        }
                    }
                    catch { }
                });
                tasks.Add(updatecounter);
            }
            if (MediaFilesCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerFileSettings.ClearFiles clear in cleanermethod.videofiles)
                    {
                        deleted += clear.Delete();
                    }

                    MediaFilesCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        MediaFilesCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=Media");
                            MediaClears.Invoke(new MethodInvoker(() =>
                            {
                                MediaClears.Text    = newclears + " clears";
                                MediaClears.Visible = true;
                            }));
                        }
                    }
                    catch { }
                });
                tasks.Add(updatecounter);
            }
            if (LogsFilesCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerFileSettings.ClearFiles clear in cleanermethod.logsfiles)
                    {
                        deleted += clear.Delete();
                    }

                    LogsFilesCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        LogsFilesCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=Logs");
                            LogsClears.Invoke(new MethodInvoker(() =>
                            {
                                LogsClears.Text    = newclears + " clears";
                                LogsClears.Visible = true;
                            }));
                        }
                    } catch { }
                });
                tasks.Add(updatecounter);
            }
            if (CacheFilesCheckBox.Checked)
            {
                Task temp = Task.Factory.StartNew(() =>
                {
                    foreach (CleanerFileSettings.ClearFiles clear in cleanermethod.cachefiles)
                    {
                        deleted += clear.Delete();
                    }

                    ScreenShotsFilesCheckBox.Invoke(new MethodInvoker(() =>
                    {
                        CacheFilesCheckBox.Checked = false;
                    }));
                });
                tasks.Add(temp);
                Task updatecounter = Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string newclears = wc.DownloadString("http://nekiplay.000webhostapp.com/Win10Optimizer/Clear.php?type=Cache");
                            CacheClears.Invoke(new MethodInvoker(() =>
                            {
                                CacheClears.Text    = newclears + " clears";
                                CacheClears.Visible = true;
                            }));
                        }
                    }
                    catch { }
                });
                tasks.Add(updatecounter);
            }
            foreach (Task task in tasks)
            {
                await task;
            }
            if (deleted != 0)
            {
                NotificationManager.Manager notify = new NotificationManager.Manager();
                notify.MaxTextWidth = 150;
                notify.EnableOffset = false;
                notify.Alert("Cleared: " + BytesToString(deleted), NotificationManager.NotificationType.Info);
                notify.StopTimer(1000);
            }
            ClearButton.Invoke(new MethodInvoker(() =>
            {
                ClearButton.Enabled = true;
            }));
        }