コード例 #1
0
ファイル: AppGrabber.cs プロジェクト: espritfollet/cairoshell
        public void AddStoreApp(string appUserModelId, AppCategoryType categoryType)
        {
            bool success = false;

            // not great but gets the job done I suppose
            foreach (string[] app in UWPInterop.StoreAppHelper.GetStoreApps())
            {
                if (app[0] == appUserModelId)
                {
                    // bringo
                    ApplicationInfo ai = new ApplicationInfo();
                    ai.Name      = app[1];
                    ai.Path      = "appx:" + appUserModelId;
                    ai.Target    = appUserModelId;
                    ai.IconPath  = app[2];
                    ai.IconColor = app[3];

                    // add it
                    if (!ReferenceEquals(ai, null))
                    {
                        CategoryList.GetSpecialCategory(categoryType).Add(ai);
                        success = true;
                    }

                    break;
                }
            }

            if (success)
            {
                Save();
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns the category with the specified name.
        /// </summary>
        public Category GetSpecialCategory(AppCategoryType type)
        {
            foreach (Category c in this)
            {
                if (c.Type == type)
                {
                    return(c);
                }
            }

            // category wasn't found
            Category cat;

            switch (type)
            {
            case AppCategoryType.All:
                cat = new Category("All", true, AppCategoryType.All);
                Add(cat);
                return(cat);

            case AppCategoryType.Uncategorized:
                cat = new Category("Uncategorized", true, AppCategoryType.Uncategorized);
                Add(cat);
                return(cat);

            case AppCategoryType.QuickLaunch:
                cat = new Category("Quick Launch", true, AppCategoryType.QuickLaunch);
                Add(cat);
                return(cat);

            default:
                return(null);
            }
        }
コード例 #3
0
 /// <summary>
 /// Object that represents a named list of ApplicationInfos.
 /// </summary>
 /// <param name="name">The name of the category - retrievable from the Name property.</param>
 /// <param name="showInMenu">Should the category appear in the Programs menu</param>
 /// <param name="type">Type of category</param>
 public Category(String name, bool showInMenu, AppCategoryType type)
 {
     this.Name       = name;
     this.ShowInMenu = showInMenu;
     this.appsList   = new List <ApplicationInfo>();
     AppViewSorter.Sort(this, "Name");
     this.Type = type;
 }
コード例 #4
0
        public void InsertByPath(string[] fileNames, int index, AppCategoryType categoryType)
        {
            int count = 0;

            foreach (string fileName in fileNames)
            {
                if (!ShellHelper.Exists(fileName))
                {
                    continue;
                }

                ApplicationInfo customApp = PathToApp(fileName, false, true);
                if (ReferenceEquals(customApp, null))
                {
                    continue;
                }

                Category category;

                if (categoryType == AppCategoryType.Uncategorized || categoryType == AppCategoryType.Standard)
                {
                    // if type is standard, drop in uncategorized
                    category = CategoryList.GetSpecialCategory(AppCategoryType.Uncategorized);
                    if (CategoryList.FlatList.Contains(customApp))
                    {
                        // disallow duplicates within all programs menu categories
                        ShellLogger.Debug($"AppGrabberService: Excluded duplicate item: {customApp.Name}: {customApp.Target}");
                        continue;
                    }
                }
                else
                {
                    category = CategoryList.GetSpecialCategory(categoryType);
                    if (category.Contains(customApp))
                    {
                        // disallow duplicates within the category
                        ShellLogger.Debug($"AppGrabberService: Excluded duplicate item: {customApp.Name}: {customApp.Target}");
                        continue;
                    }
                }

                if (index >= 0)
                {
                    category.Insert(index, customApp);
                }
                else
                {
                    category.Add(customApp);
                }
                count++;
            }

            if (count > 0)
            {
                Save();
            }
        }
コード例 #5
0
ファイル: AppGrabber.cs プロジェクト: a1re1/cairoshell
        public void InsertByPath(string[] fileNames, int index, AppCategoryType categoryType)
        {
            int count = 0;

            foreach (string fileName in fileNames)
            {
                if (Shell.Exists(fileName))
                {
                    ApplicationInfo customApp = PathToApp(fileName, false);
                    if (!ReferenceEquals(customApp, null))
                    {
                        Category category;

                        if (categoryType == AppCategoryType.Uncategorized || categoryType == AppCategoryType.Standard)
                        {
                            // if type is standard, drop in uncategorized
                            category = CategoryList.GetSpecialCategory(AppCategoryType.Uncategorized);
                            if (CategoryList.FlatList.Contains(customApp))
                            {
                                // disallow duplicates within all programs menu categories
                                CairoLogger.Instance.Debug("Excluded duplicate item: " + customApp.Name + ": " + customApp.Target);
                                continue;
                            }
                        }
                        else
                        {
                            category = CategoryList.GetSpecialCategory(categoryType);
                            if (category.Contains(customApp))
                            {
                                // disallow duplicates within the category
                                CairoLogger.Instance.Debug("Excluded duplicate item: " + customApp.Name + ": " + customApp.Target);
                                continue;
                            }
                        }

                        if (index >= 0)
                        {
                            category.Insert(index, customApp);
                        }
                        else
                        {
                            category.Add(customApp);
                        }
                        count++;
                    }
                }
            }

            if (count > 0)
            {
                Save();
            }
        }
コード例 #6
0
        public void AddStoreApp(string appUserModelId, AppCategoryType categoryType)
        {
            var storeApp = ManagedShell.UWPInterop.StoreAppHelper.AppList.GetAppByAumid(appUserModelId);

            if (storeApp == null)
            {
                return;
            }

            ApplicationInfo ai = ApplicationInfo.FromStoreApp(storeApp);

            // add it
            if (!ReferenceEquals(ai, null))
            {
                CategoryList.GetSpecialCategory(categoryType).Add(ai);
                Save();
            }
        }
コード例 #7
0
ファイル: AppGrabber.cs プロジェクト: fpscan/cairoshell
        public void AddByPath(string[] fileNames, AppCategoryType categoryType)
        {
            int count = 0;

            foreach (String fileName in fileNames)
            {
                if (Shell.Exists(fileName))
                {
                    ApplicationInfo customApp = PathToApp(fileName, false);
                    if (!object.ReferenceEquals(customApp, null))
                    {
                        CategoryList.GetSpecialCategory(categoryType).Add(customApp);
                        count++;
                    }
                }
            }

            if (count > 0)
            {
                Save();
            }
        }
コード例 #8
0
 public void AddByPath(string[] fileNames, AppCategoryType categoryType)
 {
     InsertByPath(fileNames, -1, categoryType);
 }
コード例 #9
0
 public void AddByPath(string fileName, AppCategoryType categoryType)
 {
     InsertByPath(new string[] { fileName }, -1, categoryType);
 }