Esempio n. 1
0
        public override void Launch(Record rec)
        {
            String execPath = rec.Path + "\\" + rec.Name;
            try
            {
                Process exec = new Process();
                exec.StartInfo.FileName = execPath;
                exec.StartInfo.Arguments = "";
                exec.StartInfo.UseShellExecute = true;

                exec.Start();
            }
            catch (Exception e) { }
        }
Esempio n. 2
0
 public abstract void Launch(Record rec);
Esempio n. 3
0
        /// <summary>
        /// When it's time to find the best matches for the users query, this function gets called.
        /// 
        /// It clears the current list of matches, then it finds all records in the catalog that match
        /// the loose general expression form of the user's query, then it sorts the matching records by 
        /// calling sortMatches, and finally it places the #1 suggestion in the suggestion box found in the GUI
        /// </summary>
        /// <param name="text">The user's query</param>
        private void updateFields(string text)
        {
            //			MessageBox.Show(text)
            // Find the records that match
            currentMatches.Clear();
            string regex = "^.*";
            foreach (char c in text)
            {
                regex += c + ".*";
            }
            string lowtext = text.ToLower();
            // Compile the regular expression.
            Regex r = new Regex(regex, RegexOptions.IgnoreCase);

            Match m;
            foreach (Record rec in catalog)
            {
                m = r.Match(rec.Name);
                if (m.Success) {
                    rec.match = m;
                    currentMatches.Add(rec);
                }
            }
            // Sort the matches

            sortMatches(lowtext);

            if (currentMatches.Count > 0)
            {
                String best = ((Record)currentMatches[0]).ToString();
                    Suggestion.Text = best;
            //				Suggestion.Text = ((Record) currentMatches[0]).Name.TrimEnd(".lnk".ToCharArray());
                selectedRecord = (Record)currentMatches[0];
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Given a directory and a filetype it recursively (infinite depth) scans the
        /// directory and subdirectories for the file type, creates records of them, and
        /// adds them to the catalog
        /// </summary>
        /// <param name="dir">The root of the directory tree to search</param>
        /// <param name="type">The filetype to search for</param>
        /// <param name="launcher">The class which knows how to execute the type</param>
        private void scanMenu(string dir, string type, Launcher launcher)
        {
            DirectoryInfo di;
            try
            {
                di = new DirectoryInfo(dir);
                DirectoryInfo[] dirs = di.GetDirectories();
                foreach(DirectoryInfo curDir in dirs)
                {
                    scanMenu(curDir.FullName, type, launcher);
                }
                FileInfo[] rgFiles = di.GetFiles("*" + type);

                foreach(FileInfo fi in rgFiles)
                {
                    Record rec = new Record();
                    rec.Name = fi.Name;
                    rec.LowName = fi.Name.ToLower();
                    rec.Path = fi.DirectoryName;

                    rec.type = type;
                    rec.launcher = launcher;

                    // Is it a duplicate?
                    bool isdup = false;

                    // This is expensive, it's n^2 just to add records
                    // to the catalog.  We need to find a slick way around this.
                    foreach(Record r in catalog)
                    {
                        if (r.Name == rec.Name)
                            isdup = true;
                    }
                    if (!isdup)
                        catalog.Add(rec);
                }
            }
            catch(Exception e) {return;}
        }
Esempio n. 5
0
        /// <summary>
        /// Given a directory and a filetype it recursively (infinite depth) scans the
        /// directory and subdirectories for the file type, creates records of them, and
        /// adds them to the catalog
        /// </summary>
        /// <param name="dir">The root of the directory tree to search</param>
        /// <param name="type">The filetype to search for</param>
        /// <param name="launcher">The class which knows how to execute the type</param>
        private void scanMenu(string dir, string type, Launcher launcher)
        {
            DirectoryInfo di;
            try
            {
                di = new DirectoryInfo(dir);
                DirectoryInfo[] dirs = di.GetDirectories();
                foreach (DirectoryInfo curDir in dirs)
                {
                    scanMenu(curDir.FullName, type, launcher);
                }
                FileInfo[] rgFiles = di.GetFiles("*" + type);

                foreach (FileInfo fi in rgFiles)
                {
                    Record rec = new Record();
                    rec.Name = fi.Name;
                    rec.LowName = fi.Name.ToLower();
                    rec.Path = fi.DirectoryName;

                    rec.type = type;
                    rec.launcher = launcher;

                    int ind = rec.Name.IndexOf(type);
                    if (ind != -1)
                        rec.croppedName = rec.Name.Substring(0, ind);
                    else
                        rec.croppedName = rec.Name;

                    if (!catalog.ContainsKey(rec.Name))
                        catalog.Add(rec.Name, (object)rec);
                }
            }
            catch (Exception e) { return; }
        }