예제 #1
0
        private void HandleAction(ToolAction action)
        {
            try
            {
                if (!IsToolActionEnabled(action))
                {
                    return;
                }

                FileTaskForm activeFileTask = null;

                updateUiTimer.Stop();

                List <string> selItems = opmShellList.SelectedPaths;
                switch (action)
                {
                case ToolAction.ToolActionNewFolder:
                    opmShellList.CreateNewFolder();
                    return;

                case ToolAction.ToolActionBack:
                    opmShellList.ExploreBack();
                    return;

                case ToolAction.ToolActionFwd:
                    opmShellList.ExploreForward();
                    return;

                case ToolAction.ToolActionUp:
                    NavigateUp();
                    return;

                case ToolAction.ToolActionSearch:
                    SearchWizard.Tasks.Task taskSearch = new SearchWizard.Tasks.Task();
                    taskSearch.SearchPath = opmShellList.Path;
                    if (SearchWizardMain.Execute(taskSearch) == DialogResult.OK)
                    {
                        switch (taskSearch.Action)
                        {
                        case ToolAction.ToolActionProTONEEnqueue:
                        {
                            if (taskSearch.MatchingItems.Count > 0)
                            {
                                RemoteControlHelper.SendPlayerCommand(
                                    OPMedia.Runtime.ProTONE.RemoteControl.CommandType.EnqueueFiles,
                                    taskSearch.MatchingItems.ToArray());
                            }
                        }
                        break;

                        case ToolAction.ToolActionProTONEPlay:
                        {
                            if (taskSearch.MatchingItems.Count > 0)
                            {
                                RemoteControlHelper.SendPlayerCommand(
                                    OPMedia.Runtime.ProTONE.RemoteControl.CommandType.PlayFiles,
                                    taskSearch.MatchingItems.ToArray());
                            }
                        }
                        break;

                        case ToolAction.ToolActionJumpToItem:
                            if (taskSearch.MatchingItems.Count > 0)
                            {
                                opmShellList.JumpToItem(taskSearch.MatchingItems[0], false);
                            }
                            break;

                        case ToolAction.ToolActionTaggingWizard:
                        {
                            TaggedFileProp.TaggingWizard.Task taskTagging = new TaggedFileProp.TaggingWizard.Task();
                            foreach (string item in taskSearch.MatchingItems)
                            {
                                if (Directory.Exists(item))
                                {
                                    taskTagging.Files.AddRange(PathUtils.EnumFiles(item, "*.mp?", SearchOption.AllDirectories));
                                }
                                else if (File.Exists(item))
                                {
                                    taskTagging.Files.Add(item);
                                }
                            }

                            TaggingWizardMain.Execute(FindForm(), taskTagging);
                            ReloadProperties();
                        }
                        break;

                        case ToolAction.ToolActionCopy:
                            _pasteFileTask = new FEFileTaskForm(FileTaskType.Copy, taskSearch.MatchingItems, opmShellList.Path);
                            break;

                        case ToolAction.ToolActionCut:
                            _pasteFileTask = new FEFileTaskForm(FileTaskType.Move, taskSearch.MatchingItems, opmShellList.Path);
                            break;

                        case ToolAction.ToolActionDelete:
                            _deleteFileTask = new FEFileTaskForm(FileTaskType.Delete, taskSearch.MatchingItems, opmShellList.Path);
                            activeFileTask  = _deleteFileTask;
                            break;

                        case ToolAction.ToolActionLaunch:
                            if (taskSearch.MatchingItems.Count > 0)
                            {
                                opmShellList.OpenItem(taskSearch.MatchingItems[0]);
                            }
                            break;
                        }
                    }
                    return;

                case ToolAction.ToolActionReload:
                    GlobalReload();
                    return;

                case ToolAction.ToolActionTaggingWizard:
                {
                    TaggedFileProp.TaggingWizard.Task taskTagging = new TaggedFileProp.TaggingWizard.Task();
                    foreach (string item in opmShellList.SelectedPaths)
                    {
                        if (Directory.Exists(item))
                        {
                            taskTagging.Files.AddRange(PathUtils.EnumFiles(item, "*.mp?", SearchOption.AllDirectories));
                        }
                        else if (File.Exists(item))
                        {
                            taskTagging.Files.Add(item);
                        }
                    }

                    TaggingWizardMain.Execute(FindForm(), taskTagging);

                    if (taskTagging.TaskType != TaskType.MultiRename)
                    {
                        ReloadProperties();
                    }
                    else
                    {
                        RaiseNavigationAction(NavActionType.ActionSelectMultipleItems, opmShellList.SelectedPaths);
                    }
                }
                    return;

                case ToolAction.ToolActionCdRipper:
                {
                    OPMedia.Addons.Builtin.Navigation.FileExplorer.CdRipperWizard.Tasks.Task task =
                        new Navigation.FileExplorer.CdRipperWizard.Tasks.Task();

                    task.OutputFolder = opmShellList.Path;

                    CdRipperWizardMain.Execute(task);
                    ReloadNavigation();
                }
                break;

                case ToolAction.ToolActionCopy:
                    _pasteFileTask = new FEFileTaskForm(FileTaskType.Copy, opmShellList.SelectedPaths, opmShellList.Path);
                    return;

                case ToolAction.ToolActionCut:
                    _pasteFileTask = new FEFileTaskForm(FileTaskType.Move, opmShellList.SelectedPaths, opmShellList.Path);
                    return;

                case ToolAction.ToolActionPaste:
                    if (_pasteFileTask != null)
                    {
                        _pasteFileTask.DestFolder = opmShellList.Path;
                        activeFileTask            = _pasteFileTask;
                    }
                    break;

                case ToolAction.ToolActionDelete:
                    if (!opmShellList.IsInEditMode)
                    {
                        _deleteFileTask = new FEFileTaskForm(FileTaskType.Delete, opmShellList.SelectedPaths, opmShellList.Path);
                        activeFileTask  = _deleteFileTask;
                    }
                    break;

                case ToolAction.ToolActionRename:
                    Rename();
                    return;

                case ToolAction.ToolActionFavoritesAdd:
                {
                    List <string> favorites = new List <string>(ProTONEConfig.GetFavoriteFolders("FavoriteFolders"));
                    if (favorites.Contains(opmShellList.Path))
                    {
                        return;
                    }

                    favorites.Add(opmShellList.Path);
                    ProTONEConfig.SetFavoriteFolders(favorites, "FavoriteFolders");
                }
                    return;

                case ToolAction.ToolActionFavoritesManage:
                    new FavoriteFoldersManager("FavoriteFolders").ShowDialog();
                    return;

                case ToolAction.ToolActionProTONEEnqueue:
                {
                    List <String> items = opmShellList.SelectedPaths;
                    if (items.Count > 0)
                    {
                        RemoteControlHelper.SendPlayerCommand(
                            OPMedia.Runtime.ProTONE.RemoteControl.CommandType.EnqueueFiles,
                            items.ToArray());
                    }
                }
                break;

                case ToolAction.ToolActionProTONEPlay:
                {
                    List <String> items = opmShellList.SelectedPaths;
                    if (items.Count > 0)
                    {
                        RemoteControlHelper.SendPlayerCommand(
                            OPMedia.Runtime.ProTONE.RemoteControl.CommandType.PlayFiles,
                            items.ToArray());
                    }
                }
                break;
                }

                if (activeFileTask != null)
                {
                    RaiseNavigationAction(NavActionType.ActionCancelAutoPreview, null, null);

                    try
                    {
                        opmShellList.EnableAutoRefresh(false);
                        DialogResult dlg = activeFileTask.ShowDialog();
                    }
                    finally
                    {
                        if (activeFileTask.RequiresRefresh)
                        {
                            opmShellList.RefreshList(true);
                        }

                        opmShellList.EnableAutoRefresh(true);

                        if (activeFileTask.FileTaskType == FileTaskType.Delete)
                        {
                            _deleteFileTask = null;
                        }
                        else
                        {
                            _pasteFileTask = null;
                        }

                        activeFileTask = null;
                    }
                }
            }
            finally
            {
                updateUiTimer.Start();
            }
        }
 public void Save()
 {
     ProTONEConfig.SetFavoriteFolders(this.FavoriteFolders,
                                      this.FavoriteFoldersHiveName);
 }
 private void btnOK_Click(object sender, EventArgs e)
 {
     ProTONEConfig.SetFavoriteFolders(favoriteFoldersControl.FavoriteFolders,
                                      favoriteFoldersControl.FavoriteFoldersHiveName);
 }