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(); } }
/// <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); } }
/// <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; }
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(); } }
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(); } }
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(); } }
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(); } }
public void AddByPath(string[] fileNames, AppCategoryType categoryType) { InsertByPath(fileNames, -1, categoryType); }
public void AddByPath(string fileName, AppCategoryType categoryType) { InsertByPath(new string[] { fileName }, -1, categoryType); }