Exemplo n.º 1
0
 private bool newWatch(string path)
 {
     Thread objThread = new Thread(new ParameterizedThreadStart(watchPathProcess));
     //Make the thread as background thread.
     objThread.IsBackground = true;
     //Set the Priority of the thread.
     objThread.Priority = ThreadPriority.AboveNormal;
     //Start the thread.
     objThread.Start(path);
     listItem[] nlis = new listItem[100];
     this.listIndex = 0;
     foreach (listItem li in this.lis)
     {
         if (li != null)
         {
             if (li.path == path)
             {
                 li.ifWathed = true;
                 li.watchThread = objThread;
             }
             nlis[this.listIndex++] = li;
         }
         else
         {
             break;
         }
     }
     this.lis = nlis;
     return true;
 }
Exemplo n.º 2
0
 private bool modifyListItem(String path, bool ifWatched)
 {
     this.listIndex = 0;
     listItem[] nlis = new listItem[100];
     foreach (listItem li in this.lis)
     {
         if (li != null)
         {
             if (li.path == path)
             {
                 li.ifWathed = ifWatched;
             }
             nlis[this.listIndex++] = li;
         }
         else
         {
             break;
         }
     }
     this.lis = nlis;
     return true;
 }
Exemplo n.º 3
0
        private bool addListItem(string path, bool ifWathed,bool relWriteXml=false)
        {
            // whether the path is in the lis at all;
            if (this.listIndex > 0)
            {
                foreach (listItem li in this.lis)
                {
                    if (li != null)
                    {
                        if (li.path == path)
                        {
                            MessageBox.Show("This path is added already!");
                            return false;
                        }
                    }
                    else
                    {
                        break;
                    }

                }
            }
            //todo 如果路径被删除了的话,需要重新整理xml
            if (Directory.Exists(path))
            {
                listItem l = new listItem();
                l.path = path;
                l.ifWathed = ifWathed;
                this.lis[this.listIndex++] = l;
                this.dirGrid.Rows.Add(new Object[] { path, ifWathed, "Delete" });
                if (relWriteXml)
                {
                    this.write2Xml();
                }
                return true;
            }
            return false;
        }
Exemplo n.º 4
0
        private bool delListItem(string path)
        {
            this.listIndex=0;
            listItem[] nlis=new listItem[100];
            foreach (listItem li in this.lis)
            {
                if (li != null)
                {
                    if (li.path == path)
                    {
                        li.readForDel = true;
                    }
                    nlis[this.listIndex++] = li;
                }
                else
                {
                    break;
                }
            }
            this.lis = nlis;

            return true;
        }
Exemplo n.º 5
0
        public void watchPathProcess(object path)
        {
            try
            {
                string command = rubyPath + " " + compassPath + " watch \"" + path + "\"";
                // create the ProcessStartInfo using "cmd" as the program to be run,
                // and "/c " as the parameters.
                // Incidentally, /c tells cmd that we want it to execute the command that follows,
                // and then exit.
                ProcessStartInfo procStartInfo =
                    new ProcessStartInfo(rubyPath);
                procStartInfo.Arguments = compassPath + " watch \"" + path + "\"";

                // The following commands are needed to redirect the standard output.
                // This means that it will be redirected to the Process.StandardOutput StreamReader.
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.UseShellExecute = false;
                // Do not create the black window.
                procStartInfo.CreateNoWindow = true;
                // Now we create a process, assign its ProcessStartInfo and start it
                Process proc = new Process();
                proc.StartInfo = procStartInfo;

                listItem[] nlis = new listItem[100];
                this.listIndex = 0;
                foreach (listItem li in this.lis)
                {
                    if (li != null)
                    {
                        if (li.path == path)
                        {
                            li.watchProcess = proc;
                        }
                        nlis[this.listIndex++] = li;
                    }
                    else
                    {
                        break;
                    }
                }
                this.lis = nlis;
                proc.Start();

                // Get the output into a string
                //string result = proc.StandardOutput.ReadToEnd();
                // Display the command output.
                //Console.WriteLine(result);
                //this.add2CLI(result);
            }
            catch (Exception objException)
            {

                // Log the exception
            }
        }