private void context_AddFolderAsRoot_Click(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            List <RDAFile> files = new List <RDAFile>();

            foreach (string str in Directory.GetFiles(folderBrowserDialog.SelectedPath, "*", SearchOption.AllDirectories))
            {
                string  folderpath  = (Folder.FullPath + "\\" + Path.GetDirectoryName(str).Replace(folderBrowserDialog.SelectedPath, "")).Trim('\\');
                string  rdaDestFile = RDAFile.FileNameToRDAFileName(str, folderpath);
                RDAFile rdafile     = Folder.GetAllFiles().Find((Predicate <RDAFile>)(f => f.FileName == rdaDestFile));
                if (rdafile == null)
                {
                    RDAFile rdaFile = RDAFile.Create(Folder.Version, str, folderpath);
                    if (rdaFile != null)
                    {
                        files.Add(rdaFile);
                    }
                }
                else
                {
                    RDAFileExtension.SetFile(rdafile, str, true);
                }
            }
            Folder.AddFiles(files);
            UpdateSubItems();
        }
 public void UpdateSubItems()
 {
     Items.Clear();
     foreach (RDAFolder rdaFolder in Enumerable.OrderBy(Folder.Folders, f => f.Name))
     {
         RDAFolderTreeViewItem folderTreeViewItem = new RDAFolderTreeViewItem();
         folderTreeViewItem.Folder = rdaFolder;
         folderTreeViewItem.Header = ControlExtension.BuildImageTextblock("pack://application:,,,/Images/Icons/folder.png", rdaFolder.Name);
         Items.Add(folderTreeViewItem);
         if ((TreeViewExtension.GetTreeView(this) as MultiSelectTreeView).SelectedItems.Contains(this))
         {
             (TreeViewExtension.GetTreeView(this) as MultiSelectTreeView).SelectItem(folderTreeViewItem);
             (TreeViewExtension.GetTreeView(this) as MultiSelectTreeView).UpdateSelectedItems();
         }
     }
     foreach (RDAFile file in Enumerable.OrderBy(Folder.Files, f => f.FileName))
     {
         RDAFileTreeViewItem fileTreeViewItem = RDAFileExtension.ToTreeViewItem(file);
         fileTreeViewItem.SelectOnRightClick = true;
         Items.Add(fileTreeViewItem);
         if ((TreeViewExtension.GetTreeView(this) as MultiSelectTreeView).SelectedItems.Contains(this))
         {
             (TreeViewExtension.GetTreeView(this) as MultiSelectTreeView).SelectItem(fileTreeViewItem);
             (TreeViewExtension.GetTreeView(this) as MultiSelectTreeView).UpdateSelectedItems();
         }
     }
     AlreadyExpanded = true;
     IsExpanded      = true;
 }
        private void context_AddFiles_Click(object sender, RoutedEventArgs e)
        {
            AnnoModificationManager4.Misc.OpenFileDialog openFileDialog = new AnnoModificationManager4.Misc.OpenFileDialog();
            openFileDialog.Filter      = "All files|*.*";
            openFileDialog.Multiselect = true;
            bool?nullable = openFileDialog.ShowDialog();

            if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) == 0)
            {
                return;
            }
            foreach (string file in openFileDialog.FileNames)
            {
                string  generatedRDAFileName = RDAFile.FileNameToRDAFileName(file, Folder.FullPath);
                RDAFile rdafile = Folder.Files.Find(f => f.FileName == generatedRDAFileName);
                if (rdafile == null)
                {
                    RDAFile rdaFile = RDAFile.Create(Folder.Version, file, Folder.FullPath);
                    if (rdaFile != null)
                    {
                        Folder.Files.Add(rdaFile);
                    }
                }
                else
                {
                    RDAFileExtension.SetFile(rdafile, file, true);
                }
            }
            UpdateSubItems();
        }