private void btn_add_Click(object sender, EventArgs e)
 {
     OpenFileDialog file = new OpenFileDialog();
     file.Filter = "Programs (*.exe)|*.exe|All Files (*.*)|*.*";
     file.Multiselect = false;
     file.RestoreDirectory = true;
     if (file.ShowDialog() == DialogResult.OK)
     {
         PrgNamePath prg;
         int index = (file.FileName.LastIndexOf("\\"));
         if (index < 0) return;
         string name = file.FileName.Substring(index + 1);
         prg = new PrgNamePath(name, file.FileName, true);
         FindProgram findProgram = new FindProgram(prg);
         if (programs.Find(findProgram.FindItem) == null)
         {
             programs.Add(prg);
             lV_list.Items.Add(prg);
         }
         OnEnableApply(true);
     }
 }
        private bool ListContainItem(List<PrgNamePath> list, PrgNamePath item)
        {
            foreach (PrgNamePath prog in list)
                if (prog.Active && 
                    prog.PrgName == item.PrgName && 
                    prog.Path == item.Path)
                    return true;
            return false;

        }
 public bool FindItem(PrgNamePath pattern)
 {
     return finding.Path == pattern.Path;
 }
 public FindProgram(PrgNamePath _finding)
 {
     finding = _finding;
 }
 public static void LoadLists(out List<PrgNamePath> whiteList, out List<PrgNamePath> blackList, out List<PrgNamePath> finalList)
 {
     XmlDocument document = new XmlDocument();
     XmlTextReader reader = null;
     PrgNamePath prog = new PrgNamePath();
     whiteList = new List<PrgNamePath>();
     blackList = new List<PrgNamePath>();
     finalList = new List<PrgNamePath>();
     string reading = null;
     try
     {
         reader = new XmlTextReader(Config.Default.FilesLocation + PROGRAMS);
         while (reader.Read())
         {
             if (reader.Name == "WhiteList")
                 reading = "WhiteList";
             else if (reader.Name == "BlackList")
                 reading = "BlackList";
             else if (reader.Name == "FinalList")
                 reading = "FinalList";
             else if (reader.Name == "program")
                 prog.PrgName = reader["name"];
             else if (reader.Name == "path")
                 prog.Path = reader.ReadString();
             else if (reader.Name == "active")
             {
                 bool result = false;
                 bool.TryParse(reader.ReadString(), out result);
                 prog.Active = result;
                 if (reading == "WhiteList")
                     whiteList.Add(new PrgNamePath(prog.PrgName, prog.Path, prog.Active));
                 else if (reading == "BlackList")
                     blackList.Add(new PrgNamePath(prog.PrgName, prog.Path, prog.Active));
                 else if (reading == "FinalList")
                 {
                     string state = prog.Active ? OptionItems.UC_autoBehaviour.STATE_ENABLED : OptionItems.UC_autoBehaviour.STATE_DISABLED;
                     finalList.Add(new PrgNamePath(state, prog.PrgName, prog.Path));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
     finally
     {
         if (reader != null) reader.Close();
     }
 }
Example #6
0
 public bool FindItem(PrgNamePath pattern)
 {
     return(finding.Path == pattern.Path);
 }
Example #7
0
 public FindProgram(PrgNamePath _finding)
 {
     finding = _finding;
 }