Ejemplo n.º 1
0
        private void ReloadCache()
        {
            List <string> tmp1 = new List <string>(0);
            List <string> tmp2 = new List <string>(0);

            appCache = new List <ResultItem>(0);
            string p1 = Filesystem.GetFolderPath(Environment.SpecialFolder.StartMenu);
            string p2 = Filesystem.GetFolderPath(Environment.SpecialFolder.CommonStartMenu);

            GetApps(p1, tmp1);
            try
            {
                appCache.Sort();
            }
            catch { }
            GetApps(p2, tmp2);
            List <string> fnd = new List <string>(0);

            foreach (string t in tmp1)
            {
                string fnd2 = t.Substring(p1.Length + 1);
                string dtxt;
                if (!fnd2.EndsWith("\\"))
                {
                    fnd2 = fnd2.Remove(fnd2.Length - 4);
                    dtxt = fnd2.Substring(fnd2.LastIndexOf("\\") + 1);
                }
                else
                {
                    dtxt = fnd2.Substring(fnd2.Remove(fnd2.Length - 1).LastIndexOf("\\") + 1);
                }
                appCache.Add(new ResultItem(dtxt, t, fnd2));
                fnd.Add(fnd2);
            }
            foreach (string t in tmp2)
            {
                string fnd2 = t.Substring(p2.Length + 1);
                string dtxt;
                if (!fnd2.EndsWith("\\"))
                {
                    fnd2 = fnd2.Remove(fnd2.Length - 4);
                    dtxt = fnd2.Substring(fnd2.LastIndexOf("\\") + 1);
                }
                else
                {
                    dtxt = fnd2.Substring(fnd2.Remove(fnd2.Length - 1).LastIndexOf("\\") + 1);
                }
                if (fnd.Contains(fnd2))
                {
                    continue;
                }
                int ind = 0;
                foreach (string t1 in tmp1)
                {
                    string fnd3 = t1.Substring(p2.Length + 1);
                    if (!fnd3.EndsWith("\\"))
                    {
                        fnd3 = fnd3.Remove(fnd3.Length - 4);
                    }
                    if (fnd2.CompareTo(fnd3) < 0)
                    {
                        ind++;
                    }
                    else
                    {
                        break;
                    }
                }
                tmp1.Insert(ind, t);
                appCache.Insert(ind, new ResultItem(dtxt, t, fnd2));
            }
        }