示例#1
0
        public static void Show(TREInfoFile tif)
        {
            using (var saveDialog = new SaveFileDialog
            {
                Title = "Save As",
                Filter = string.Format("{0} Files|*.{1}|All Files|*.*", tif.FileType.Name, tif.FileType.Extension),
                InitialDirectory = Wxv.Swg.Explorer.Properties.Settings.Default.SaveAsDirectoryName,
                FileName = Path.GetFileName(tif.Path)
            })
            {
                if (saveDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    File.WriteAllBytes(saveDialog.FileName, tif.Data);

                    Wxv.Swg.Explorer.Properties.Settings.Default.RepositoryDirectoryName = Path.GetDirectoryName(saveDialog.FileName);
                    Wxv.Swg.Explorer.Properties.Settings.Default.Save();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                    MessageBox.Show("Error saving: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#2
0
        public static bool Show(IRepository repository, TREInfoFile treInfoFile)
        {
            ViewForm viewForm;

            if (viewForms.TryGetValue(treInfoFile.Path, out viewForm))
            {
                viewForm.Activate();
                return(true);
            }

            var data = repository.Load <byte[]>(
                treInfoFile.TreFileName,
                treInfoFile.Path,
                stream => stream.ReadBytes());

            if (data == null)
            {
                return(false);
            }

            viewForm = new ViewForm
            {
                Repository  = repository,
                TREInfoFile = treInfoFile,
                Data        = data
            };
            viewForms.Add(treInfoFile.Path, viewForm);
            viewForm.Show();
            return(true);
        }
示例#3
0
        public static void Show(TREInfoFile tif)
        {
            using (var saveDialog = new SaveFileDialog
            {
                Title = "Save As",
                Filter = string.Format("{0} Files|*.{1}|All Files|*.*", tif.FileType.Name, tif.FileType.Extension),
                InitialDirectory = Wxv.Swg.Explorer.Properties.Settings.Default.SaveAsDirectoryName,
                FileName = Path.GetFileName(tif.Path)
            })
            {
                if (saveDialog.ShowDialog() != DialogResult.OK)
                    return;

                try
                {
                    File.WriteAllBytes(saveDialog.FileName, tif.Data);

                    Wxv.Swg.Explorer.Properties.Settings.Default.RepositoryDirectoryName = Path.GetDirectoryName(saveDialog.FileName);
                    Wxv.Swg.Explorer.Properties.Settings.Default.Save();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                    MessageBox.Show("Error saving: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#4
0
        public static void Show(TREInfoFile tif)
        {
            if (tif.Exporters.Count() == 0)
            {
                return;
            }

            string fileFilter = string.Join("|",
                                            tif.Exporters
                                            .Select(fte => string.Format("{0} Files|*.{1}", fte.Name, fte.Extension))
                                            .ToArray());

            using (var saveDialog = new SaveFileDialog
            {
                Title = "Export To",
                Filter = fileFilter,
                InitialDirectory = Wxv.Swg.Explorer.Properties.Settings.Default.SaveAsDirectoryName,
                FileName = Path.GetFileNameWithoutExtension(tif.Path)
            })
            {
                if (saveDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var fte = tif.Exporters.FirstOrDefault(fte0 => string.Equals("." + fte0.Extension, Path.GetExtension(saveDialog.FileName)));
                if (fte == null)
                {
                    return;
                }

                try
                {
                    fte.Converter(tif.Repository, tif.Data, saveDialog.FileName);

                    Wxv.Swg.Explorer.Properties.Settings.Default.SaveAsDirectoryName = Path.GetDirectoryName(saveDialog.FileName);
                    Wxv.Swg.Explorer.Properties.Settings.Default.Save();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                    MessageBox.Show("Error exporting: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#5
0
        public static void Show(TREInfoFile tif)
        {
            if (tif.Exporters.Count() == 0) 
                return;

            string fileFilter = string.Join("|",
                tif.Exporters
                    .Select(fte => string.Format("{0} Files|*.{1}", fte.Name, fte.Extension))
                    .ToArray());

            using (var saveDialog = new SaveFileDialog
            {
                Title = "Export To",
                Filter = fileFilter,
                InitialDirectory = Wxv.Swg.Explorer.Properties.Settings.Default.SaveAsDirectoryName,
                FileName = Path.GetFileNameWithoutExtension(tif.Path)
            })
            {
                if (saveDialog.ShowDialog() != DialogResult.OK)
                    return;

                var fte = tif.Exporters.FirstOrDefault(fte0 => string.Equals("." + fte0.Extension, Path.GetExtension(saveDialog.FileName)));
                if (fte == null)
                    return;

                try
                {
                    fte.Converter(tif.Repository, tif.Data, saveDialog.FileName);

                    Wxv.Swg.Explorer.Properties.Settings.Default.SaveAsDirectoryName = Path.GetDirectoryName(saveDialog.FileName);
                    Wxv.Swg.Explorer.Properties.Settings.Default.Save();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                    MessageBox.Show("Error exporting: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#6
0
        private void LoadRepository(string directoryName, out IRepository repository, out DirectoryTree <TREInfoFile> directoryTree)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                repository    = null;
                directoryTree = null;

                if (string.IsNullOrEmpty(directoryName))
                {
                    return;
                }

                var localRepository = Wxv.Swg.Common.Repository.Load(directoryName);

                IEnumerable <TREInfoFile> treInfoFiles;
                if (localRepository != null)
                {
                    treInfoFiles = localRepository.Files
                                   .SelectMany(tf => tf.TREFile.InfoFiles, (tf, tfif) => new TREInfoFile(localRepository, tf.FileName, tfif))
                                   .OrderBy(tif => tif.Path)
                                   .ToList();
                }
                else
                {
                    treInfoFiles = new TREInfoFile[] { }
                };

                repository    = localRepository;
                directoryTree = DirectoryTree <TREInfoFile> .Get("", treInfoFiles, tif => tif.Path, "/");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
示例#7
0
        private void LoadRepository(string directoryName, out IRepository repository, out DirectoryTree<TREInfoFile> directoryTree)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                repository = null;
                directoryTree = null;

                if (string.IsNullOrEmpty(directoryName))
                    return;

                var localRepository = Wxv.Swg.Common.Repository.Load(directoryName);

                IEnumerable<TREInfoFile> treInfoFiles;
                if (localRepository != null)
                    treInfoFiles = localRepository.Files
                        .SelectMany(tf => tf.TREFile.InfoFiles, (tf, tfif) => new TREInfoFile(localRepository, tf.FileName, tfif))
                        .OrderBy(tif => tif.Path)
                        .ToList();
                else
                    treInfoFiles = new TREInfoFile[] { };

                repository = localRepository;
                directoryTree = DirectoryTree<TREInfoFile>.Get("", treInfoFiles, tif => tif.Path, "/");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }