示例#1
0
 private void BrowseButton_Click(object sender, EventArgs e)
 {
     RootFolderDialog.SelectedPath = PathTextBox.Text;
     if (RootFolderDialog.ShowDialog(this) != DialogResult.OK)
     {
         return;
     }
     else
     {
         PathTextBox.Text = RootFolderDialog.SelectedPath;
     }
 }
        /// <summary>
        /// Edits the selected root folder
        /// </summary>
        private void EditSelectedRootFolder()
        {
            try
            {
                if (IsOrganising)
                {
                    GeneralMethods.MessageBoxApplicationError("Please wait for the library to finish organising before editing any root folders");
                    return;
                }

                RootFolder selectedRootFolder = dgRootFolders.SelectedItem as RootFolder;

                if (selectedRootFolder == null)
                {
                    GeneralMethods.MessageBoxApplicationError("Please select a root folder to edit");
                    return;
                }

                RootFolderDialog rootFolderDialog = new RootFolderDialog(GetTags(), selectedRootFolder.Clone() as RootFolder);
                rootFolderDialog.Owner        = Application.Current.MainWindow;
                rootFolderDialog.PathChanged += rootFolderDialog_PathChanged;

                if (GeneralMethods.GetNullableBoolValue(rootFolderDialog.ShowDialog()))
                {
                    List <RootFolder> rootFolders = new List <RootFolder>(RootFolders);
                    rootFolders.Remove(selectedRootFolder);
                    rootFolders.Add(rootFolderDialog.SelectedRootFolder);

                    List <SortDescription> sortDescriptions = new List <SortDescription>(SortDescriptions);

                    RootFolders = rootFolders.ToArray();

                    SortDescriptions.Clear();

                    foreach (SortDescription sortDescription in sortDescriptions)
                    {
                        SortDescriptions.Add(sortDescription);
                    }

                    dgRootFolders.SelectedItem = rootFolderDialog.SelectedRootFolder;
                }
            }
            catch (System.Exception e)
            {
                GeneralMethods.MessageBoxException(e, "Could not edit root folder: ");
            }
        }