private static void ListRemoved(List <SavedPath> listSavedPath, IEnumerable <string> listRemoved, List <DisplayPath> listMerged) { if (listRemoved.Any()) { foreach (var s in listRemoved) { foreach (var x in listSavedPath) { if (x.PathDirectory.Equals(s, StringComparison.OrdinalIgnoreCase)) { DisplayPath merge = new DisplayPath { SeqNumber = x.SeqNumber, PathType = x.PathType, PathDirectory = x.PathDirectory, PathStatus = "Removed" }; listMerged.Add(merge); DisplayPath.NumDifferences++; if (UserSettings.Setting.KeepLogFile) { WriteMsg2Log("Removed", x.PathType, x.PathDirectory); } break; } } } } }
private void DataGridRow_MouseEnter(object sender, MouseEventArgs e) { if (UserSettings.Setting.ShowRightStatus) { try { DataGridRow row = e.Source as DataGridRow; DisplayPath dp = (DisplayPath)dgPath.Items.GetItemAt(row.GetIndex()); DirectoryInfo di = new DirectoryInfo(dp.PathDirectory); FileInfo[] fi = di.GetFiles(); DirectoryInfo[] d = di.GetDirectories(); string fn = fi.Length == 1 ? "File" : "Files"; string dn = d.Length == 1 ? "Subdirectory" : "Subdirectories"; stbStatusR.Content = $"Contains {fi.Length:N0} {fn} and {d.Length:N0} {dn}"; } catch (UnauthorizedAccessException ex) { logTemp.Error(ex, "Error enumerating files and subdirectories"); stbStatusR.Content = "Not Authorized"; } catch (Exception ex) { logTemp.Error(ex, "Error enumerating files and subdirectories"); stbStatusR.Content = "Error"; } } }
private static void ListUnchanged(List <DisplayPath> listCurrentPath, IEnumerable <string> listUnchanged, List <DisplayPath> listMerged) { if (listUnchanged.Any()) { foreach (var x in listCurrentPath) { foreach (var s in listUnchanged) { if (x.PathDirectory.Equals(s, StringComparison.OrdinalIgnoreCase)) { DisplayPath merge = new DisplayPath { SeqNumber = x.SeqNumber, PathType = x.PathType, PathDirectory = x.PathDirectory, PathStatus = "Unchanged" }; foreach (var path in listCurrentPath) { if (path.PathDirectory.Equals(s, StringComparison.OrdinalIgnoreCase) && path.SeqNumber != x.SeqNumber) { merge.PathStatus = "Duplicate"; logTemp.Warn($"Duplicate found: {merge.SeqNumber} {merge.PathType} {merge.PathDirectory}"); logPerm.Warn($"Duplicate found: {merge.SeqNumber} {merge.PathType} {merge.PathDirectory}"); DisplayPath.NumDifferences++; } } listMerged.Add(merge); break; } } } } }
private void CmxCopyCB_Click(object sender, RoutedEventArgs e) { DisplayPath row = (DisplayPath)dgPath.SelectedItem; string selPath = Path.GetFullPath(row.PathDirectory); Clipboard.Clear(); Clipboard.SetText(selPath); }
private void CmxProps_Click(object sender, RoutedEventArgs e) { if (dgPath.SelectedItem != null) { DisplayPath row = (DisplayPath)dgPath.SelectedItem; string selPath = Path.GetFullPath(row.PathDirectory); _ = ShowFileProperties(selPath); } }
private void DataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (dgPath.SelectedItem != null) { DisplayPath row = (DisplayPath)dgPath.SelectedItem; string selPath = Path.GetFullPath(row.PathDirectory); using Process exp = new Process(); exp.StartInfo.FileName = "Explorer.exe"; exp.StartInfo.Arguments = selPath; _ = exp.Start(); } }
private void CxmTerminal_Click(object sender, RoutedEventArgs e) { if (dgPath.SelectedItem != null) { DisplayPath row = (DisplayPath)dgPath.SelectedItem; string selPath = Path.GetFullPath(row.PathDirectory).TrimEnd('\\'); using Process wt = new Process(); wt.StartInfo.FileName = "wt.exe"; wt.StartInfo.Arguments = $"-d \"{selPath}\" "; wt.StartInfo.UseShellExecute = false; try { _ = wt.Start(); } catch (Win32Exception ex) { logTemp.Warn(ex, "Unable to launch Windows Terminal. Falling back to CMD.exe"); using Process cmd = new Process(); cmd.StartInfo.FileName = "cmd.exe"; cmd.StartInfo.Arguments = "/k Title PathTools"; cmd.StartInfo.WorkingDirectory = selPath; cmd.StartInfo.UseShellExecute = true; try { _ = cmd.Start(); } catch (Exception ex2) { logTemp.Warn(ex2, "Unable to launch CMD.exe"); _ = TKMessageBox.Show("Unable to launch a terminal. See log file.", "PathTools Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { _ = TKMessageBox.Show("Unable to launch a terminal. See log file.", "PathTools Error", MessageBoxButton.OK, MessageBoxImage.Error); logTemp.Warn(ex, "Unable to launch Windows Terminal."); } } }
private static List <DisplayPath> ListCurrent(List <SavedPath> curPath) { // Put current path into a list List <DisplayPath> listCurrentPath = new List <DisplayPath>(); foreach (var item in curPath) { if (item != null) { DisplayPath x = new DisplayPath { SeqNumber = item.SeqNumber, PathType = item.PathType, PathDirectory = item.PathDirectory }; listCurrentPath.Add(x); } } return(listCurrentPath); }