private void context_AddFolder_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.GetFileName(folderBrowserDialog.SelectedPath) + "\\" + Path.GetDirectoryName(str).Replace(folderBrowserDialog.SelectedPath, "")).Trim('\\')).Trim('\\');
                string  rdaDestFile = RDAFile.FileNameToRDAFileName(str, folderpath);
                RDAFile rdafile     = Folder.GetAllFiles().Find(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();
        }
        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();
        }
        public static RDAFileTreeViewItem ToTreeViewItem(this RDAFile file)
        {
            string str   = Path.GetExtension(file.FileName).ToLower();
            string file1 = "pack://application:,,,/Images/Icons/page_white.png";

            if (str == ".xml")
            {
                file1 = "pack://application:,,,/Images/Icons/page_white_code.png";
            }
            else if (str == ".txt" || str == ".ini" || str == ".cfg")
            {
                file1 = "pack://application:,,,/Images/Icons/page_white_text.png";
            }
            else if (str == ".jpg" || str == ".bmp" || (str == ".png" || str == ".dds"))
            {
                file1 = "pack://application:,,,/Images/Icons/page_white_picture.png";
            }
            else if (str == ".mp3" || str == ".wav" || str == ".wma")
            {
                file1 = "pack://application:,,,/Images/Icons/sound.png";
            }
            RDAFileTreeViewItem fileTreeViewItem = new RDAFileTreeViewItem();

            fileTreeViewItem.Header        = ControlExtension.BuildImageTextblock(file1, Path.GetFileName(file.FileName));
            fileTreeViewItem.SemanticValue = "<File>";
            fileTreeViewItem.File          = file;
            return(fileTreeViewItem);
        }
Пример #4
0
        private void context_AddFolderAsRoot_Click(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

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

            foreach (string str in Directory.GetFiles(folderBrowserDialog.SelectedPath, "*", System.IO.SearchOption.AllDirectories))
            {
                string  folderpath  = (CurrentReader.rdaFolder.FullPath + "\\" + Path.GetDirectoryName(str).Replace(folderBrowserDialog.SelectedPath, "")).Trim('\\');
                string  rdaDestFile = RDAFile.FileNameToRDAFileName(str, folderpath);
                RDAFile rdafile     = CurrentReader.rdaFolder.GetAllFiles().Find(f => f.FileName == rdaDestFile);
                if (rdafile == null)
                {
                    RDAFile rdaFile = RDAFile.Create(CurrentReader.rdaFolder.Version, str, folderpath);
                    if (rdaFile != null)
                    {
                        files.Add(rdaFile);
                    }
                }
                else
                {
                    Misc.RDAFileExtension.SetFile(rdafile, str, true);
                }
            }
            CurrentReader.rdaFolder.AddFiles(files);
            RebuildTreeView();
        }
 public static void SetFile(this RDAFile rdafile, string file, bool deleteOldFileInTemp)
 {
     rdafile.SetFile(file);
     if (!deleteOldFileInTemp)
     {
         return;
     }
     if (!File.Exists(DirectoryExtension.GetTempWorkingDirectory() + "\\" + rdafile.FileName))
     {
         return;
     }
     try
     {
         File.Delete(DirectoryExtension.GetTempWorkingDirectory() + "\\" + rdafile.FileName);
     }
     catch (Exception)
     {
     }
 }