private void goPage2() { bdrMain.Visibility = Visibility.Collapsed; bdrPage2.Visibility = Visibility.Visible; // Grab the Programs CategoryList catList = appGrabber.CategoryList; // Get the Uncategorized category Category uncat = catList.GetSpecialCategory(AppCategoryType.Uncategorized); // Get the Quick Launch category Category quicklaunch = catList.GetSpecialCategory(AppCategoryType.QuickLaunch); // Add apps to category if they haven't been added to one yet. foreach (ApplicationInfo app in programsMenuAppsCollection) { if (app.Category == null) { string cat; if (app.IsStoreApp) { cat = autoCategorizeByName(app.Name); } else { cat = autoCategorizeByName(Path.GetFileNameWithoutExtension(app.Path)); } if (cat != "") { // Get the category - create it if it doesn't exist. Category categoryToAdd = catList.GetCategory(cat); if (categoryToAdd == null) { categoryToAdd = new Category(cat, true); catList.Add(categoryToAdd); } categoryToAdd.Add(app); } else { // not a known app, add to Uncategorized if (uncat != null) { uncat.Add(app); } } } } categoryView.ItemsSource = catList; categoryView.Visibility = Visibility.Visible; }
private void CategoryButtonClicked(object sender, RoutedEventArgs e) { Button button = sender as Button; Category actionableCategory = button.CommandParameter as Category; CategoryList catList = actionableCategory.ParentCategoryList; switch (button.Content as String) { case "5": catList.MoveCategory(actionableCategory, -1); break; case "6": catList.MoveCategory(actionableCategory, 1); break; case "r": //Don't allow removal of special category if (actionableCategory.Type > 0) { return; } Category uncategorized = catList.GetSpecialCategory(AppCategoryType.Uncategorized); for (int i = actionableCategory.Count - 1; i >= 0; i--) { ApplicationInfo app = actionableCategory[i]; actionableCategory.RemoveAt(i); uncategorized.Add(app); } catList.Remove(actionableCategory); break; } }
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(); } }
public void Rename(ApplicationInfo app, string newName) { app.Name = newName; Save(); CollectionViewSource.GetDefaultView(CategoryList.GetSpecialCategory(AppCategoryType.All)).Refresh(); CollectionViewSource.GetDefaultView(app.Category).Refresh(); }
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 AddToQuickLaunch(ApplicationInfo app) { Category quickLaunch = CategoryList.GetSpecialCategory(3); if (!quickLaunch.Contains(app)) { ApplicationInfo appClone = app.Clone(); appClone.Icon = null; appClone.IconPath = null; quickLaunch.Add(appClone); 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(); } }