private void ButtonSelectFolder_Click(object sender, RoutedEventArgs e) { string folder = FolderPath; if (string.IsNullOrEmpty(folder)) { folder = mmApp.Model.ActiveDocument?.Filename; if (string.IsNullOrEmpty(folder)) { folder = System.IO.Path.GetDirectoryName(folder); } else { folder = KnownFolders.GetPath(KnownFolder.Libraries); } } var dlg = new CommonOpenFileDialog(); dlg.Title = "Select folder to open in the Folder Browser"; dlg.IsFolderPicker = true; dlg.InitialDirectory = folder; dlg.RestoreDirectory = true; dlg.ShowHiddenItems = true; dlg.ShowPlacesList = true; dlg.EnsurePathExists = true; var result = dlg.ShowDialog(); if (result != CommonFileDialogResult.Ok) { return; } FolderPath = dlg.FileName; TreeFolderBrowser.Focus(); }
private void Button_CloseSearch_Click(object sender, RoutedEventArgs e) { SearchPanel.Visibility = Visibility.Collapsed; TreeFolderBrowser.Focus(); }
private void MenuDeleteFile_Click(object sender, RoutedEventArgs e) { var selected = TreeFolderBrowser.SelectedItem as PathItem; if (selected == null) { return; } if (MessageBox.Show( "Delete:\r\n" + selected.FullPath + "\r\n\r\n" + "Are you sure?", "Delete File", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } try { //Directory.Delete(selected.FullPath, true); //File.Delete(selected.FullPath); // Recyle Bin Code can handle both files and directories if (!mmFileUtils.MoveToRecycleBin(selected.FullPath)) { return; } var parent = selected.Parent; var index = -1; var file = parent?.Files?.FirstOrDefault(fl => fl.FullPath == selected.FullPath); if (file != null) { var tab = Window.GetTabFromFilename(file.FullPath); if (tab != null) { Window.CloseTab(tab, dontPromptForSave: true); } if (parent != null) { index = parent.Files.IndexOf(selected); parent.Files.Remove(file); if (index > 0) { SetTreeViewSelectionByItem(parent.Files[index]); } } } // Delay required to overcome editor focus after MsgBox Dispatcher.Delay(700, s => TreeFolderBrowser.Focus()); } catch (Exception ex) { Window.ShowStatus("Delete operation failed: " + ex.Message, 6000); Window.SetStatusIcon(FontAwesome.WPF.FontAwesomeIcon.Warning, Colors.Red); } }