public void ShowPanel() { string currentDirectory = A.Psf.SyncPaths(); try { string drive = UI.SelectMenu.SelectDrive(null, true); if (drive == null) { return; } AnyPanel ap; if (drive == "Folder &tree") { ap = new FolderTree(); } else if (drive == "&Any objects") { ap = new ObjectPanel(); } else { ap = new ItemPanel(drive); } ap.Open(); } finally { A.SetCurrentDirectoryFinally(currentDirectory); } }
public void ShowPanel() { string currentDirectory = A.Psf.SyncPaths(); try { string drive = UI.SelectMenu.SelectPowerPanel(); if (drive == null) { return; } AnyPanel ap; if (drive == UI.SelectMenu.TextFolderTree) { ap = new FolderTree(); } else if (drive == UI.SelectMenu.TextAnyObjects) { ap = new ObjectPanel(); } else { ap = new ItemPanel(drive); } ap.Open(); } finally { A.SetCurrentDirectoryFinally(currentDirectory); } }
/// <summary> /// Sync provider location and current directory with Far state. /// </summary> /// <remarks> /// Returned system path (if not null) must be restored by a called. /// </remarks> internal string SyncPaths() { // don't on running if (IsRunning) { return(null); } // don't on no panels mode IPanel panel = Far.Api.Panel; if (panel == null) { return(null); } // at first get both paths: for the current system directory and provider location string directory = Far.Api.CurrentDirectory; string location = null; if (panel.IsPlugin) { Panel plugin = panel as Panel; if (plugin != null) { var itemPanel = plugin as ItemPanel; if (itemPanel != null) { location = itemPanel.Explorer.Location; } else { FolderTree folderTree = plugin as FolderTree; if (folderTree != null) { location = panel.CurrentDirectory; if (location == "*") //_130117_234326 { location = directory; } } } } } // to set yet unknown location to the directory if (location == null) { location = directory; } // set the current provider location; let's do it first, in case of failure // we can skip directory setting/restoring in cases when they are the same. bool okLocation = true; try { //! Parameter is wildcard. Test: enter into a container "[]" and invoke a command. Engine.SessionState.Path.SetLocation(Kit.EscapeWildcard(location)); // drop failure info _failedInvokingLocationNew = null; _failedInvokingLocationOld = null; } catch { okLocation = false; // get the current string currentLocation = Engine.SessionState.Path.CurrentLocation.Path; // ask a user if he has not told to ignore this pair if (location != _failedInvokingLocationNew || currentLocation != _failedInvokingLocationOld) { string message = string.Format(null, @" Cannot set the current location to {0} Continue with this current location? {1} ", location, currentLocation); switch (Far.Api.Message(message, Res.Me, MessageOptions.GuiOnMacro | MessageOptions.AbortRetryIgnore | MessageOptions.Warning | MessageOptions.LeftAligned)) { case 1: break; case 2: _failedInvokingLocationNew = location; _failedInvokingLocationOld = currentLocation; break; default: if (Far.Api.MacroState != MacroState.None) { Far.Api.UI.Break(); } throw; } } } // do not try failed if (!okLocation && location == directory) { return(null); } // get the current directory to be restored by a caller string currentDirectory = Directory.GetCurrentDirectory(); // set the current directory to the active path to avoid confusions [_090929_061740] try { // try to set Directory.SetCurrentDirectory(directory); // drop failure info _failedInvokingDirectoryNew = null; _failedInvokingDirectoryOld = null; } catch { // ask a user if he has not told to ignore this pair if (directory != _failedInvokingDirectoryNew || currentDirectory != _failedInvokingDirectoryOld) { string message = string.Format(null, @" Cannot set the current directory to {0} Continue with this current directory? {1} ", directory, currentDirectory); switch (Far.Api.Message(message, Res.Me, MessageOptions.GuiOnMacro | MessageOptions.AbortRetryIgnore | MessageOptions.Warning | MessageOptions.LeftAligned)) { case 1: currentDirectory = null; break; case 2: currentDirectory = null; _failedInvokingDirectoryNew = directory; _failedInvokingDirectoryOld = currentDirectory; break; default: if (Far.Api.MacroState != MacroState.None) { Far.Api.UI.Break(); } throw; } } } // to be restored by a caller return(currentDirectory); }
public void ShowPanel() { string currentDirectory = A.Psf.SyncPaths(); try { string drive = UI.SelectMenu.SelectDrive(null, true); if (drive == null) return; AnyPanel ap; if (drive == "Folder &tree") ap = new FolderTree(); else if (drive == "&Any objects") ap = new ObjectPanel(); else ap = new ItemPanel(drive); ap.Open(); } finally { A.SetCurrentDirectoryFinally(currentDirectory); } }