private void ShowFileDialog(PackagePathEventArgs e) { OnRequestShowFileDialog(this, e); if (e.Cancel == false && RootLocations.Contains(e.Path)) e.Cancel = true; }
private bool CanDelete(object param) { if (RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) == SelectedIndex) { return false; } return RootLocations.Count > 1; }
private int ConvertPathToIndex(object path) { if (path is int pint) { return(pint); } return(RootLocations.IndexOf(path as string)); }
private int GetIndexOfProgramDataPackagePath() { var programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); var programDataPackagePath = RootLocations.Where(x => x.StartsWith(programDataPath)).FirstOrDefault(); var programDataPackagePathIndex = RootLocations.IndexOf(programDataPackagePath); return(programDataPackagePathIndex); }
private void RemovePathAt(int index) { var pathToRemove = RootLocations[index]; SetPackagesScheduledState(pathToRemove, packagePathDisabled: true); RootLocations.RemoveAt(index); RaiseCanExecuteChanged(); }
private bool CanUpdate(int param) { var programDataPackagePathIndex = GetIndexOfProgramDataPackagePath(); //editing builtin packages or programData package paths is not allowed. return(RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) != param && programDataPackagePathIndex != param); }
private bool CanUpdate(int param) { var programDataPackagePathIndex = GetIndexOfProgramDataPackagePath(); var appDataPackagePathIndex = GetIndexOfDefaultAppDataPackagePath(); //editing builtin packages or programData package paths is not allowed. return(RootLocations.IndexOf(Resources.PackagePathViewModel_BuiltInPackages) != param && programDataPackagePathIndex != param && appDataPackagePathIndex != param); }
private void RemovePathAt(int index) { RootLocations.RemoveAt(index); if (index <= SelectedIndex && SelectedIndex > 0) SelectedIndex--; RaiseCanExecuteChanged(); }
private bool CanDelete(int param) { var programDataPackagePathIndex = GetIndexOfProgramDataPackagePath(); if (RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) == param || programDataPackagePathIndex == param) { return(false); } return(RootLocations.Count > 1); }
private int GetIndexOfDefaultAppDataPackagePath() { var index = -1; if (PreferenceSettings is PreferenceSettings prefs) { var appDataPath = prefs.OnRequestUserDataFolder(); index = RootLocations.IndexOf(appDataPath); } return(index); }
private bool CanDelete(int param) { var programDataPackagePathIndex = GetIndexOfProgramDataPackagePath(); var appDataPackagePathIndex = GetIndexOfDefaultAppDataPackagePath(); if (RootLocations.IndexOf(Resources.PackagePathViewModel_BuiltInPackages) == param || programDataPackagePathIndex == param || appDataPackagePathIndex == param) { return(false); } return(RootLocations.Count > 1); }
private void InsertPath() { var args = new PackagePathEventArgs(); ShowFileDialog(args); if (args.Cancel) return; RootLocations.Insert(RootLocations.Count, args.Path); RaiseCanExecuteChanged(); }
private void InsertPath() { var args = new PackagePathEventArgs(); ShowFileDialog(args); if (args.Cancel) { return; } RootLocations.Insert(RootLocations.Count, args.Path); SetPackagesScheduledState(args.Path, packagePathDisabled: false); RaiseCanExecuteChanged(); }
internal bool IsPathCurrentlyDisabled(string path) { if (setting is IDisablePackageLoadingPreferences disablePrefs) { //disabled if stdlib disabled and path is stdlib if ((disablePrefs.DisableStandardLibrary && path == Resources.PackagePathViewModel_Standard_Library) //or if custompaths disabled and path is custom path || (disablePrefs.DisableCustomPackageLocations && setting.CustomPackageFolders.Contains(path)) //or if custompaths disabled and path is known path that is not std.lib - needed because new paths that are not commited //will not be added to customPackagePaths yet. || (disablePrefs.DisableCustomPackageLocations && RootLocations.Contains(path) && path != Resources.PackagePathViewModel_Standard_Library)) { return(true); } } return(false); }
internal bool IsPathCurrentlyDisabled(string path) { if (!(PreferenceSettings is IDisablePackageLoadingPreferences disablePrefs)) { return(false); } //disabled if builtinpackages disabled and path is builtinpackages if ((disablePrefs.DisableBuiltinPackages && path == Resources.PackagePathViewModel_BuiltInPackages) //or if custompaths disabled and path is custom path || (disablePrefs.DisableCustomPackageLocations && PreferenceSettings.CustomPackageFolders.Contains(path)) //or if custompaths disabled and path is known path that is not builtinpackages - needed because new paths that are not committed //will not be added to customPackagePaths yet. || (disablePrefs.DisableCustomPackageLocations && RootLocations.Contains(path) && path != Resources.PackagePathViewModel_BuiltInPackages)) { return(true); } return(false); }
private void RemovePathAt(int index) { RootLocations.RemoveAt(index); RaiseCanExecuteChanged(); }
private bool CanUpdate(object param) { return RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) != SelectedIndex; }