public void SetPath(string newPath) { DirectoryInfo prevDir = CurrentDirectory; try { if (Path.IsPathRooted(newPath)) { CurrentDirectory = new DirectoryInfo(newPath); UpdateContent(); ManagerLogger.Log("Set_Path", $"{prevDir.FullName} -> {newPath}"); } else { throw new Exception("Incorrect path"); } } catch (Exception e) { ManagerDialogWindows.ErrorMessage(e.Message); ManagerLogger.Log("Set_Path_Failure", $"{e.Message}; Path - {newPath}"); CurrentDirectory = prevDir; } ContentState = State.Default; MainMenu.NullPos(); }
public void History() { MainMenu.Content = ManagerLogger.History().Inverse(); if (MainMenu.Content.Count == 0) { ManagerDialogWindows.ErrorMessage("History is empty"); UpdateContent(); } else { ContentState = State.History; } MainMenu.NullPos(); }
public void MoveOut() { DirectoryInfo prevDir = CurrentDirectory; try { if (ContentState == State.Default) { CurrentDirectory = CurrentDirectory.Parent; } ContentState = State.Default; UpdateContent(); MainMenu.NullPos(); ManagerLogger.Log("Move_Out", prevDir.FullName); } catch { ManagerDialogWindows.ErrorMessage("There is no way out"); CurrentDirectory = prevDir; } }
public void MoveIn(Menu menu) { try { if (menu.GetCurrentElement().ToDirectoryInfo().Exists) { DirectoryInfo prevDir = CurrentDirectory; try { CurrentDirectory = menu.GetCurrentElement().ToDirectoryInfo(); ContentState = State.Default; UpdateContent(); MainMenu.NullPos(); ManagerLogger.Log("Move_In", CurrentDirectory.FullName); } catch (Exception e) { CurrentDirectory = prevDir; throw e; } } else { if (FileOpeningPriorities().ContainsKey(menu.GetCurrentElement().Extension)) { System.Diagnostics.Process.Start(FileOpeningPriorities()[menu.GetCurrentElement().Extension], menu.GetCurrentElement().FullName); } else { System.Diagnostics.Process.Start(menu.GetCurrentElement().FullName); } ManagerLogger.Log("Move_In", menu.GetCurrentElement().FullName); } } catch (Exception e) { ManagerDialogWindows.ErrorMessage(e.Message); ManagerLogger.Log("Move_In_Failure", $"{e.Message}; Path - {MainMenu.GetCurrentElement()}"); } }
public void Search(string param) { if (param != String.Empty) { if (ContentState == State.Searched || ContentState == State.History) { MoveOut(); } MainMenu.Content = CurrentDirectory.Search(param); Sort(new DirFilesComparer()); SearchRes = new List <FileSystemInfo>(MainMenu.Content); ManagerLogger.Log("Search", CurrentDirectory.FullName); if (MainMenu.Content.Count == 0) { ManagerDialogWindows.ErrorMessage("No results :("); UpdateContent(); } else { ContentState = State.Searched; } MainMenu.NullPos(); } }
public void LastSearchRes() { ContentState = State.Searched; MainMenu.Content = SearchRes; MainMenu.NullPos(); }