/// <summary> /// Открывает файл при нажатии на кнопку на тулбаре /// </summary> /// <param name="sender">Button</param> /// <param name="e">RoutedEventArgs</param> private void FileOpenToolBarClick(object sender, RoutedEventArgs e) { var clickedButton = (Button)sender; var fileToLaunch = clickedButton.Tag.ToString(); try { if (File.Exists(fileToLaunch)) { Process.Start(fileToLaunch); } } catch (Win32Exception exp) { MessageBox.ShowDialog( String.Format( "Невозможно запустить процесс {0}\n\nHRESULT [{1:x}]\n\n{2}", fileToLaunch, exp.ErrorCode, exp.Message ), "Ultimate Commander - Подсистема защиты", MessageBoxButton.OK ); } }
/// <summary> /// Move file from selected DataGrid to unselected (dont make copies ) /// </summary> /// <param name="sender">object</param> /// <param name="e">RoutedEventArgs</param> private void MoveButtonClick(object sender, RoutedEventArgs e) { var moveTo = ((FocusedExplorer == expLeft) ? expRight.CurrentPath : expLeft.CurrentPath); if (MessageBox.ShowDialog( MakeMessageStr("Копировать"), "Ultimate Commander - Подсистема копирования данных", MessageBoxButton.YesNo ) != true) { return; } foreach (ILogicItem item in FocusedExplorer.SelectedItems) { if (item.IsFolder) { _fileSystem.MoveDirectory(item.Info.FullName, Path.Combine(moveTo, item.Info.Name)); } else { _fileSystem.MoveFile(item.Info.FullName, Path.Combine(moveTo, item.Info.Name)); } } }
private void CopyOnExecute(object sender, ExecutedRoutedEventArgs args) { var copyToDat = ((FocusedExplorer == expLeft) ? expRight.CurrentPath : expLeft.CurrentPath); if (MessageBox.ShowDialog( MakeMessageStr("Копировать"), "Ultimate Commander - Подсистема копирования данных", MessageBoxButton.YesNo ) != true) { return; } ILogicItem currentItem = null; try { foreach (ILogicItem t in FocusedExplorer.SelectedItems) { currentItem = t; if (currentItem.IsFolder) { _fileSystem.CopyDirectory(currentItem.Info.FullName, Path.Combine(copyToDat, currentItem.Info.Name)); } else { _fileSystem.CopyFile(currentItem.Info.FullName, Path.Combine(copyToDat, currentItem.Info.Name)); } } } catch (System.SystemException ex) { if (currentItem != null) { MessageBox.ShowDialog( string.Format("Невозможно копировать файл {0}, " + "возможно, файл используется или защищен:\n{1}", currentItem.Info.FullName, ex.Message), "Ultimate Commander - Подсистема доступа", MessageBoxButton.OK); } } }
private void DeleteOnExecute(object sender, ExecutedRoutedEventArgs args) { if (MessageBox.ShowDialog( MakeMessageStr("Удалить"), "Ultimate Commander - Подсистема данных", MessageBoxButton.YesNo ) != true) { return; } ILogicItem currentItem = null; try { foreach (ILogicItem t in FocusedExplorer.SelectedItems) { currentItem = t; if (currentItem.IsFolder) { _fileSystem.DeleteDirectory(currentItem.Info.FullName); } else { _fileSystem.DeleteFile(currentItem.Info.FullName); } } } catch (System.SystemException ex) { if (currentItem != null) { MessageBox.ShowDialog( string.Format("Невозможно удалить файл {0}, " + "возможно, файл используется или защищен:\n{1}", currentItem.Info.FullName, ex.Message), "Ultimate Commander - Подсистема доступа", MessageBoxButton.OK); } } }