Пример #1
0
/*
 *      private void TextBlock_ExploreFile(object sender, MouseButtonEventArgs e)
 *      {
 *          if (sender is TextBlock textBlock)
 *          {
 *              var path = textBlock.DataContext as string;
 *              if (string.IsNullOrWhiteSpace(path))
 *                  Debugger.Break();
 *              else
 *                  FileSystemExplorerControl.StartExplorer(path, File.Exists(path));
 *          }
 *      }
 */

        #endregion Commands: Explore File

        #region Commands: Favorites
        private void AddFavoriteImpl(FavoritePathType?pathType)
        {
            if (!pathType.HasValue)
            {
                return;
            }
            var          type = pathType.Value;
            ExplorerItem item;

            switch (type)
            {
            case FavoritePathType.Folders:
                item = SelectedDirectory;
                break;

            case FavoritePathType.Icons:
                item = SelectedIcon;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
            var iconPath = item.IconPath;

            if (iconPath == null)
            {
                Debugger.Break();
            }
            var favorite = new FavoritePath(item.Title, item.FullPath, type, iconPath);

            Settings.Directories.AddFavorite(favorite);
        }
Пример #2
0
        private void EditFavoriteImpl(FavoritePath favorite)
        {
            var type      = favorite.Type;
            var typeTitle = type.ToString().TrimEnd('s');
            var prompt    = new MyPrompt($"Enter new name for {typeTitle} Favorite '{favorite.Path}':", $"Edit Favorite {typeTitle}", favorite.Name);

            if (!prompt)
            {
                return;
            }
            favorite.Name = prompt;
        }
Пример #3
0
        private void OpenFavoriteImpl(FavoritePath favorite)
        {
            var path = favorite.Path;
            var type = favorite.Type;
            RelayCommand <string> command;

            switch (type)
            {
            case FavoritePathType.Folders:
                command = OpenDirectoryInBrowser;
                break;

            case FavoritePathType.Icons:
                command = OpenIconInBrowser;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
            command.Execute(path);
        }
Пример #4
0
            public void AddFavorite(FavoritePath favorite)
            {
                var favorites = GetFavorites(favorite.Type);

                favorites.Add(favorite);
            }
Пример #5
0
            public void DeleteFavorite(FavoritePath favorite)
            {
                var favorites = GetFavorites(favorite.Type);

                favorites.Remove(favorite);
            }
Пример #6
0
 private void DeleteFavoriteImpl(FavoritePath favorite)
 {
     Settings.Directories.DeleteFavorite(favorite);
 }