Ejemplo n.º 1
0
        private void ShowFileDialog(PackagePathEventArgs e)
        {
            OnRequestShowFileDialog(this, e);

            if (e.Cancel == false && RootLocations.Contains(e.Path))
                e.Cancel = true;
        }
Ejemplo n.º 2
0
 private bool CanDelete(object param)
 {
     if (RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) == SelectedIndex)
     {
         return false;
     }
     return RootLocations.Count > 1;
 }
Ejemplo n.º 3
0
 private int ConvertPathToIndex(object path)
 {
     if (path is int pint)
     {
         return(pint);
     }
     return(RootLocations.IndexOf(path as string));
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        private void RemovePathAt(int index)
        {
            var pathToRemove = RootLocations[index];

            SetPackagesScheduledState(pathToRemove, packagePathDisabled: true);
            RootLocations.RemoveAt(index);
            RaiseCanExecuteChanged();
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        private void RemovePathAt(int index)
        {
            RootLocations.RemoveAt(index);

            if (index <= SelectedIndex && SelectedIndex > 0)
                SelectedIndex--;

            RaiseCanExecuteChanged();
        }
Ejemplo n.º 9
0
        private bool CanDelete(int param)
        {
            var programDataPackagePathIndex = GetIndexOfProgramDataPackagePath();

            if (RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) == param ||
                programDataPackagePathIndex == param)
            {
                return(false);
            }

            return(RootLocations.Count > 1);
        }
Ejemplo n.º 10
0
        private int GetIndexOfDefaultAppDataPackagePath()
        {
            var index = -1;

            if (PreferenceSettings is PreferenceSettings prefs)
            {
                var appDataPath = prefs.OnRequestUserDataFolder();
                index = RootLocations.IndexOf(appDataPath);
            }

            return(index);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        private void InsertPath()
        {
            var args = new PackagePathEventArgs();

            ShowFileDialog(args);

            if (args.Cancel)
                return;

            RootLocations.Insert(RootLocations.Count, args.Path);

            RaiseCanExecuteChanged();
        }
Ejemplo n.º 13
0
        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();
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
 private void RemovePathAt(int index)
 {
     RootLocations.RemoveAt(index);
     RaiseCanExecuteChanged();
 }
Ejemplo n.º 17
0
 private bool CanUpdate(object param)
 {
     return RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) != SelectedIndex;
 }