Esempio n. 1
0
        public Form4()
        {
            InitializeComponent();
            this.Text = "Remove Exception";
            var dataSource = Exclude.getInstance().getNames();

            remove_exception_combo.DataSource = dataSource;
        }
Esempio n. 2
0
        private void save_exception_Click(object sender, EventArgs e)
        {
            String Name = remove_exception_combo.SelectedValue.ToString().Trim();

            if (Name == null || Name.Length < 1)
            {
                return;
            }

            Exclude.getInstance().removeName(Name);
            this.Close();
        }
Esempio n. 3
0
        //i dont want to tightly couple the IO class and other classes in this app by referencing IO directly in the creation of these objects
        //hence this object seperate the objects it generates from the object that generates them.


        public void getExclude()
        {
            Exclude saved = (Exclude)IO.getInstance().retrieveObject(Settings.getInstance().getExcludedFilesLocation());

            if (saved == null)
            {
                Exclude.getInstance();
            }
            else
            {
                Exclude.setInstance(saved);
                Console.WriteLine("Length found " + Exclude.getInstance().getNames().Count);
            }
        }
Esempio n. 4
0
        //we have a complete list of PIDS in the last 5 seconds
        public void batch_complete(List <uint> pids)
        {
            getCurrentApplication();
            foreach (uint pid in pids)
            {
                //get pid of current application

                //if current application is not this application, kill it
                if (pid != 0 && pid != CurrentPid && !Exclude.getInstance().isExcluded(pid))
                {
                    killProcess(pid, extract_name(getAppByPid(pid)));
                    // notifyKilled(pid, extract_name(getAppByPid(pid)));
                }
            }
        }
Esempio n. 5
0
 //kill unallowed process
 public void killProcess(uint Pid, String Name)
 {
     if (!Exclude.getInstance().isExcluded(Pid) && !Exclude.getInstance().isExcluded(Name))
     {
         Process p2 = new Process();
         p2.StartInfo.FileName               = "taskkill.exe";
         p2.StartInfo.Arguments              = "/pid " + Pid + " /f /t";
         p2.StartInfo.UseShellExecute        = false;
         p2.StartInfo.RedirectStandardOutput = true;
         p2.StartInfo.CreateNoWindow         = true;
         p2.Start();
         notifyKilled(Pid, Name);
     }
     else
     {
         notifySkipped(Pid, Name);
     }
 }
Esempio n. 6
0
        public void load()
        {
            //instances of this class are not saved here because they are singletons.
            FactoryBuilder build = new FactoryBuilder();

            build.getExclude();
            build.getSettings();


            //add startup shortcut
            String exePath      = Assembly.GetEntryAssembly().Location;
            String title        = "This Nonsense Must Stop";
            String description  = "Launch this Nonsense Must Stop";
            String linkLocation = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            new ShortCutMaker().add_desktop_shortcut(linkLocation, exePath, title, description);

            //prevent this app from getting closed by itself
            Exclude.getInstance().addPid(Convert.ToUInt32(Process.GetCurrentProcess().Id));
            this.Text = "This Nonsense Must Stop!";


            this.FormClosing += (object sender, FormClosingEventArgs es) =>
            {
                clean_up();
            };

            if (Settings.getInstance().AppRunning)
            {
                control_switch.Image = Properties.Resources.on_switch;
            }
            else
            {
                control_switch.Image = Properties.Resources.off;
            }
        }
Esempio n. 7
0
 private void clean_up()
 {
     IO.getInstance().saveObject(Settings.getInstance(), Settings.getInstance().getSettingsLocation());
     IO.getInstance().saveObject(Exclude.getInstance(), Settings.getInstance().getExcludedFilesLocation());
 }