예제 #1
0
        public void ShowSaveFileDialogTest()
        {
            var service = new FileDialogService();

            AssertHelper.ExpectedException <ArgumentNullException>(() => service.ShowSaveFileDialog(null !, null, null));
            AssertHelper.ExpectedException <ArgumentException>(() => service.ShowSaveFileDialog(new FileType[] { }, null, null));
        }
예제 #2
0
        private void ExecuteSaveAsCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(() =>
            {
                string fileName = FileDialogService.GetSaveTextureFileName(texture.Name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    texture.Save(fileName);
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(texture.Name, ex));
                }
            });
        }
예제 #3
0
        private void ExecuteReplaceAlphaMapCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string name     = texture.Name + "_alpha";
                string fileName = FileDialogService.GetOpenTextureFileName(name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    this.OptModel.File.Textures[texture.Name].SetAlphaMap(fileName);

                    dispatcher(() => this.OptModel.File = this.OptModel.File);
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(name, ex));
                }
            });
        }
예제 #4
0
        protected override bool ConfirmClose(IDocument document)
        {
            GameDocument gameDcument = document as GameDocument;

            if (gameDcument == null)
            {
                return(base.ConfirmClose(document));
            }

            bool closeConfirmed = true;

            if (gameDcument.AnyDirty)
            {
                string message = "One or more level and/or external resource is dirty"
                                 + Environment.NewLine + "Save Changes?";

                FileDialogResult result = FileDialogService.ConfirmFileClose(message);
                if (result == FileDialogResult.Yes)
                {
                    closeConfirmed = Save(document);
                }
                else if (result == FileDialogResult.Cancel)
                {
                    closeConfirmed = false;
                }
            }
            return(closeConfirmed);
        }
예제 #5
0
        public MainViewModel()
        {
            _logger.Info($"Starting AudibleBookmarks {TitleProvider.GetTitleWithVersion()}");
            ISubscribable fileSvc = new FileDialogService();

            fileSvc.StartListening();
            ISubscribable alertSvc = new AlertService();

            alertSvc.StartListening();

            _dbService = new DatabaseService();

            Books     = new ObservableCollection <Book>();
            Bookmarks = new ObservableCollection <Bookmark>();

            FilterableBooks            = CollectionViewSource.GetDefaultView(Books);
            FilterableBooks.Filter     = FilterBooks;
            FilterableBookmarks        = CollectionViewSource.GetDefaultView(Bookmarks);
            FilterableBookmarks.Filter = FilterBookmarks;

            if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                FileOpened(PathHelper.TryToGuessPathToLibrary());
            }
        }
예제 #6
0
        private void ExecuteSaveAsCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetSaveTextureFileName(texture.Name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    texture.Save(fileName);

                    dispatcher(() => this.OptModel.UndoStackPush("save " + System.IO.Path.GetFileName(fileName)));
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(texture.Name, ex));
                }
            });
        }
예제 #7
0
        private void ExecuteOpenCommand()
        {
            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenOptFileName();

                if (fileName == null)
                {
                    return;
                }

                BusyIndicatorService.Notify(string.Concat("Opening ", System.IO.Path.GetFileName(fileName), "..."));

                try
                {
                    dispatcher(() => this.OptModel.File = null);

                    var opt = OptFile.FromFile(fileName);

                    dispatcher(() => this.OptModel.File = opt);
                    dispatcher(() => this.OptModel.UndoStackPush("open " + System.IO.Path.GetFileNameWithoutExtension(fileName)));

                    if (!this.OptModel.IsPlayable)
                    {
                        Messenger.Instance.Notify(new MainViewSelectorMessage("PlayabilityMessages"));
                        Messenger.Instance.Notify(new MessageBoxMessage(fileName + "\n\n" + "This opt will not be fully playable.", "Check Opt Playability", MessageBoxButton.OK, MessageBoxImage.Warning));
                    }
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(fileName, ex));
                }
            });
        }
예제 #8
0
        private void ExecuteReplaceMapCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenTextureFileName(texture.Name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    var newTexture  = Texture.FromFile(fileName);
                    newTexture.Name = texture.Name;

                    this.OptModel.File.Textures[newTexture.Name] = newTexture;

                    dispatcher(() => this.OptModel.File = this.OptModel.File);
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(texture.Name, ex));
                }
            });
        }
예제 #9
0
        private void ExecuteExportAn8Command()
        {
            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetSaveAn8FileName(System.IO.Path.ChangeExtension(this.OptModel.File.FileName, "an8"));

                if (fileName == null)
                {
                    return;
                }

                BusyIndicatorService.Notify(string.Concat("Exporting ", System.IO.Path.GetFileName(fileName), "..."));

                var opt    = this.OptModel.File;
                bool scale = this.IsImportExportScaleEnabled;

                try
                {
                    OptAn8Converter.Converter.OptToAn8(opt, fileName, scale);
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(fileName, ex));
                }
            });
        }
예제 #10
0
        public void ShowSaveFileDialogTest()
        {
            FileDialogService service = new FileDialogService();

            AssertHelper.ExpectedException<ArgumentNullException>(() => service.ShowSaveFileDialog(null, null, null));
            AssertHelper.ExpectedException<ArgumentException>(() =>
                service.ShowSaveFileDialog(new FileType[] { }, null, null));
        }
예제 #11
0
        public void LoadRom()
        {
            string fileName = FileDialogService.ShowOpenFileDialog("GameBoy ROMs (*.gb;*.gbc;*.cgb)|*.gb;*.gbc;*.cgb|All Files (*.*)|*.*");

            if (fileName != null)
            {
                LoadRom(fileName);
            }
        }
예제 #12
0
        private void ExecuteImportOptCommand()
        {
            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenOptFileName();

                if (fileName == null)
                {
                    return;
                }

                BusyIndicatorService.Notify(string.Concat("Importing ", System.IO.Path.GetFileName(fileName), "..."));

                var opt = this.OptModel.File;

                try
                {
                    dispatcher(() => this.OptModel.File = null);

                    var import        = OptFile.FromFile(fileName);
                    string importName = System.IO.Path.GetFileNameWithoutExtension(fileName) + "_";

                    foreach (var faceGroup in import.Meshes.SelectMany(t => t.Lods).SelectMany(t => t.FaceGroups))
                    {
                        var textures = faceGroup.Textures.ToList();
                        faceGroup.Textures.Clear();

                        foreach (var texture in textures)
                        {
                            faceGroup.Textures.Add(texture.StartsWith(importName, StringComparison.Ordinal) ? texture : (importName + texture));
                        }
                    }

                    foreach (var texture in import.Textures.Values)
                    {
                        texture.Name = texture.Name.StartsWith(importName, StringComparison.Ordinal) ? texture.Name : (importName + texture.Name);
                    }

                    foreach (var texture in import.Textures.Values)
                    {
                        opt.Textures[texture.Name] = texture;
                    }

                    foreach (var mesh in import.Meshes)
                    {
                        opt.Meshes.Add(mesh);
                    }
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(fileName, ex));
                }

                dispatcher(() => this.OptModel.File = opt);
                dispatcher(() => this.OptModel.UndoStackPush("import " + System.IO.Path.GetFileName(fileName)));
            });
        }
예제 #13
0
        public SkillPch2Maker()
        {
            InitializeComponent();

            _options = new SkillPchOptions();

            _fileDialogService = new FileDialogService();
            // _skillPchService = new SkillPchService(_options);
            // _skillCacheService = new SkillCacheService();
        }
예제 #14
0
        public void OpenSoundFile()
        {
            string initialDir = SoundFile.IsNotNullOrEmpty() ? Path.GetDirectoryName(SoundFile) : string.Empty;
            var    soundFile  = FileDialogService.FileNameFromOpenFileDialog(ProgramTexts.FileDialog_SoundFileFilter, initialDir);

            if (soundFile.IsNotNullOrEmpty())
            {
                SoundFile = soundFile;
            }
        }
예제 #15
0
        public MainWindowViewModel()
        {
            ISubscribable fileSvc = new FileDialogService();

            fileSvc.StartListening();
            ISubscribable alertSvc = new AlertService();

            alertSvc.StartListening();

            _dbService = new DatabaseService();

            Books               = new ReactiveList <BookWrapper>();
            Bookmarks           = new ReactiveList <Bookmark>();
            FilterableBooks     = Books.CreateDerivedCollection(b => b, FilterBooks);
            FilterableBookmarks = Bookmarks.CreateDerivedCollection(b => b, FilterBookmarks);

            var observableSelectedBook = this.WhenAnyValue(x => x.SelectedBook);

            observableSelectedBook.Subscribe(b =>
            {
                if (b == null)
                {
                    return;
                }
                LoadChapters(b);
                LoadBookmarks(b);
            });

            _totalBookmarkCount = this.WhenAny(
                x => x.SelectedBook,
                x => x.Sender.Bookmarks.Count()
                )
                                  .ToProperty(this, x => x.TotalBookmarkCount);

            _emptyBookmarkCount = this.WhenAny(
                x => x.SelectedBook,
                x => x.Sender.Bookmarks.Count(bm => bm.IsEmptyBookmark)
                )
                                  .ToProperty(this, x => x.EmptyBookmarkCount);

            _onlyTitleBookmarkCount = this.WhenAny(
                x => x.SelectedBook,
                x => x.Sender.Bookmarks.Count(bm => string.IsNullOrWhiteSpace(bm.Note) && !string.IsNullOrWhiteSpace(bm.Title))
                )
                                      .ToProperty(this, x => x.OnlyTitleBookmarkCount);

            _onlyNoteBookmarkCount = this.WhenAny(
                x => x.SelectedBook,
                x => x.Sender.Bookmarks.Count(bm => string.IsNullOrWhiteSpace(bm.Title) && !string.IsNullOrWhiteSpace(bm.Note))
                )
                                     .ToProperty(this, x => x.OnlyNoteBookmarkCount);


            FileOpened(PathHelper.TryToGuessPathToLibrary());
        }
예제 #16
0
        private void SelectLogFile()
        {
            var result = FileDialogService.ShowOpenFileDialog(new[] { new FileType("Log4j Xml Schema File", ".xml") },
                                                              new FileType("Log4j Xml Schema File", ".xml"), CurrentFileName);

            if (result.IsValid)
            {
                CurrentFileName  = result.FileName;
                IsCurrentFileNew = true;
            }
        }
예제 #17
0
        private void SaveAsFile(object ignore = null)
        {
            string filePath = FileDialogService.ShowSaveAsFileDialog();

            if (!string.IsNullOrEmpty(filePath))
            {
                dataService.SaveCollectionToFile(ProductList, filePath);
                this.FilePath = filePath;
                this.IsSaved  = true;
            }
        }
예제 #18
0
        private void ExecuteAddTextureNameCommand()
        {
            if (this.CurrentFaceGroups.SelectedItem == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenTextureFileName();

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    var texture = Texture.FromFile(fileName);

                    int bpp = texture.BitsPerPixel;

                    texture.GenerateMipmaps();

                    if (bpp == 8)
                    {
                        texture.Convert32To8();
                    }

                    var mesh             = this.CurrentMeshes.SelectedItem;
                    var lod              = this.CurrentLods.SelectedItem;
                    var selectedTextures = this.CurrentFaceGroups.SelectedItem.Textures.ToList();
                    var faceGroups       = this.CurrentFaceGroups.SelectedItems.ToList();

                    this.OptModel.File.Textures[texture.Name] = texture;

                    foreach (var faceGroup in faceGroups.Where(t => selectedTextures.SequenceEqual(t.Textures)))
                    {
                        faceGroup.Textures.Add(texture.Name);
                    }

                    dispatcher(() => this.UpdateModel());
                    dispatcher(() => this.CurrentMeshes.SetSelection(mesh));
                    dispatcher(() => this.CurrentLods.SetSelection(lod));
                    dispatcher(() => this.CurrentFaceGroups.SetSelection(faceGroups));
                    dispatcher(() => this.OptModel.UndoStackPush("add texture name " + texture.Name));
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(fileName, ex));
                }
            });
        }
예제 #19
0
        private void ExportXmlCommandExecute()
        {
            FileDialogService dialog   = _fileDialog as FileDialogService;
            XmlService        xml      = _xmlService as XmlService;
            Products          products = null;

            if (ProductCollection.Count != 0)
            {
                products = new Products(ProductCollection.ToList());
            }

            _fileIOService.Export(dialog, xml, products);
        }
예제 #20
0
        public virtual void OpenFile(string defaultExtension, string initialDirectory, Dictionary <string, string> filters,
                                     string dialogTitle = "Open File", bool addExtension = true, bool checkFileExists = true, bool checkPathExists = true)
        {
            string fileName = FileDialogService.OpenFileDialog(
                defaultExtension, initialDirectory, filters,
                dialogTitle,
                addExtension, checkFileExists, checkPathExists);

            if (fileName != null)
            {
                FileService.OpenFile(fileName);
            }
        }
예제 #21
0
        private void ExecuteConvertAllTexturesTo8BppCommand()
        {
            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenOptFileName();

                if (fileName == null)
                {
                    return;
                }

                string directory = System.IO.Path.GetDirectoryName(fileName);

                BusyIndicatorService.Notify("Converting all textures to 8 bpp...");

                var message = Messenger.Instance.Notify(new MessageBoxMessage(string.Concat("The textures of all OPTs in \"", directory, "\" will be converted to 8 bpp.\nDo you want to continue?"), "Converting textures", MessageBoxButton.YesNo, MessageBoxImage.Warning));

                if (message.Result != MessageBoxResult.Yes)
                {
                    return;
                }

                foreach (string file in System.IO.Directory.GetFiles(directory, "*.opt"))
                {
                    BusyIndicatorService.Notify(string.Concat("Converting ", System.IO.Path.GetFileName(file), " to 8 bpp..."));

                    OptFile opt = null;

                    try
                    {
                        opt = OptFile.FromFile(file);
                    }
                    catch (System.IO.InvalidDataException)
                    {
                        continue;
                    }

                    if (opt.TexturesBitsPerPixel == 8)
                    {
                        continue;
                    }

                    opt.ConvertTextures32To8();
                    opt.Save(opt.FileName);
                }

                BusyIndicatorService.Notify("Converting all textures to 8 bpp completed.");

                Messenger.Instance.Notify(new MessageBoxMessage("Converting all textures to 8 bpp completed.", "Converting textures"));
            });
        }
예제 #22
0
        public void ExportToXlsx(HrsStatistic stats)
        {
            var result = new FileDialogService().ShowSaveFileDialog(null,
                                                                    FileType.Xlsx.ToEnumerable(),
                                                                    FileType.Xlsx,
                                                                    string.Format("{0} {1:yyyy.MM.dd HH.mm}", defName, DateTime.Now));

            if (result.IsValid)
            {
                var          newFile = FileHelper.CreateNewFile(result.FileName);
                ExcelPackage package = MakeExcelPackage(stats);
                SaveTo(package, newFile);
            }
        }
예제 #23
0
        public virtual void SaveFileAs(OpenedFile file, string defaultExtension, string initialDirectory, Dictionary <string, string> filters,
                                       string dialogTitle = "Save File", bool addExtension = true, bool checkFileExists = false, bool checkPathExists = true)
        {
            string fileName = FileDialogService.SaveFileDialog(
                file.FileName,
                defaultExtension, initialDirectory, filters,
                dialogTitle,
                addExtension, checkFileExists, checkPathExists);

            if (fileName != null)
            {
                file.FileName = FileName.Create(fileName);
                file.SaveToDisk();
            }
        }
예제 #24
0
 private void Browse()
 {
     if (FileDialogService != null)
     {
         var filename = FilePath;
         if (UseOpenDialog)
         {
             if (FileDialogService.ShowOpenFileDialog(ref filename, Filter, DefaultExtension))
             {
                 FilePath = filename;
             }
         }
         else
         {
             if (FileDialogService.ShowSaveFileDialog(ref filename, Filter, DefaultExtension))
             {
                 FilePath = filename;
             }
         }
     }
     else
     {
         // use Microsoft.Win32 dialogs
         if (UseOpenDialog)
         {
             var d = new OpenFileDialog();
             d.FileName   = FilePath;
             d.Filter     = Filter;
             d.DefaultExt = DefaultExtension;
             if (true == d.ShowDialog())
             {
                 FilePath = d.FileName;
             }
         }
         else
         {
             var d = new SaveFileDialog();
             d.FileName   = FilePath;
             d.Filter     = Filter;
             d.DefaultExt = DefaultExtension;
             if (true == d.ShowDialog())
             {
                 FilePath = d.FileName;
             }
         }
     }
 }
예제 #25
0
        private void OpenFile(object ignore)
        {
            string filePath = FileDialogService.ShowOpenFileDialog();
            ProductsCollection <Product> tmpProductsList = null;

            if (!string.IsNullOrEmpty(filePath))
            {
                //TODO Zmien to na TaskFactory
                BackgroundWorker bw = new BackgroundWorker();
                bw.WorkerReportsProgress      = true;
                bw.WorkerSupportsCancellation = true;

                bw.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    this.IsBusy = true;
                    BackgroundWorker worker = sender as BackgroundWorker;

                    //Thread.Sleep(5000);  //TODO Do testów
                    tmpProductsList = dataService.OpenCollectionFromFile(filePath) as ProductsCollection <Product>;
                };

                bw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    this.IsBusy      = false;
                    this.ProductList = tmpProductsList;
                    this.FilePath    = filePath;
                    this.IsSaved     = true;
                };

                if (bw.IsBusy == false)
                {
                    bw.RunWorkerAsync();
                }

                //TODO DO TESTOW, Dokonczyc:
                //Task.Factory.StartNew(() =>
                //{
                //    this.IsBusy = true;
                //    Thread.Sleep(2000); //TODO DO TESTOW
                //    this.ProductList = dataService.OpenCollectionFromFile(filePath) as ProductsCollection<Product>;
                //    this.FilePath = filePath;
                //    this.IsSaved = true;
                //    this.IsBusy = false;
                //});
            }
        }
예제 #26
0
        private void ExecuteReplaceAlphaMapCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string name = texture.Name + "_alpha";
                string fileName = FileDialogService.GetOpenTextureFileName(name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    int bpp = texture.BitsPerPixel;
                    int mipmapsCount = texture.MipmapsCount;

                    texture.RemoveMipmaps();
                    texture.SetAlphaMap(fileName);

                    if (mipmapsCount > 1)
                    {
                        texture.GenerateMipmaps();

                        if (bpp == 8)
                        {
                            texture.Convert32To8();
                        }
                    }

                    dispatcher(() => this.OptModel.File = this.OptModel.File);
                    dispatcher(() => this.OptModel.UndoStackPush("replace " + texture.Name));
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(name, ex));
                }
            });
        }
예제 #27
0
        private void ExecuteFolderBrowserCmd(string p)
        {
            string path = FileDialogService.GetService().OpenFolderBrowserDialog();

            switch (p)
            {
            case "S":
            {
                Model.Simple = path;
                break;
            }

            case "O":
            {
                Model.Location = path;
                break;
            }
            }
        }
예제 #28
0
        private void SaveRounds()
        {
            if (Rounds.IsNullOrEmpty())
            {
                return;
            }

            var fileName = FileDialogService.FileNameFromSaveFileDialog(ProgramTexts.FileDialog_XmlFileFilter);

            if (fileName.IsNullOrEmpty())
            {
                return;
            }

            using (var sw = new StreamWriter(fileName))
            {
                var roundsToSerialize = Rounds.Select(x => new RoundSerializable(x)).ToList();
                _roundsSerializer.Serialize(sw, roundsToSerialize);
            }
        }
예제 #29
0
        private void ExecuteReplaceMapCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenTextureFileName(texture.Name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    var newTexture = Texture.FromFile(fileName);
                    newTexture.Name = texture.Name;

                    int bpp = newTexture.BitsPerPixel;

                    newTexture.GenerateMipmaps();

                    if (bpp == 8)
                    {
                        newTexture.Convert32To8();
                    }

                    this.OptModel.File.Textures[newTexture.Name] = newTexture;

                    dispatcher(() => this.OptModel.File = this.OptModel.File);
                    dispatcher(() => this.OptModel.UndoStackPush("replace " + texture.Name));
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(texture.Name, ex));
                }
            });
        }
예제 #30
0
        private void NpcCacheScript_Click(object sender, EventArgs e)
        {
            FileDialogService fileDialogService = new FileDialogService
            {
                InitialDirectory = Environment.CurrentDirectory,
                Filter           = "Lineage II NpcData config|npcdata.txt|All files (*.*)|*.*"
            };

            if (!fileDialogService.OpenFileDialog())
            {
                return;
            }

            string NpcDataFile = fileDialogService.FileName;
            string NpcDataDir  = fileDialogService.FileDirectory;

            if (File.Exists(NpcDataDir + "\\" + NpcContants.NpcCacheFileName))
            {
                if (MessageBox.Show($"File {NpcContants.NpcCacheFileName} exist. Overwrite?", "Overwrite?", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
            }

            IProgress <int> progress = new Progress <int>(a => { ProgressBar.Value = a; });

            NpcCacheScript.Enabled = false;

            Task.Run(() =>
            {
                _npcCacheService.Generate(NpcDataDir, NpcDataFile, progress);
            }).ContinueWith(task =>
            {
                this.Invoker(() =>
                {
                    NpcCacheScript.Enabled = true;
                    ProgressBar.Value      = 0;
                });
                MessageBox.Show("Success.", "Complete");
            });
        }
예제 #31
0
        private void ExecuteImportAn8Command()
        {
            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenAn8FileName();

                if (fileName == null)
                {
                    return;
                }

                BusyIndicatorService.Notify(string.Concat("Importing ", System.IO.Path.GetFileName(fileName), "..."));

                var opt    = this.OptModel.File;
                bool scale = this.IsImportExportScaleEnabled;

                try
                {
                    dispatcher(() => this.OptModel.File = null);

                    var import = OptAn8Converter.Converter.An8ToOpt(fileName, scale);

                    foreach (var texture in import.Textures.Values)
                    {
                        opt.Textures[texture.Name] = texture;
                    }

                    foreach (var mesh in import.Meshes)
                    {
                        opt.Meshes.Add(mesh);
                    }
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(fileName, ex));
                }

                dispatcher(() => this.OptModel.File = opt);
                dispatcher(() => this.OptModel.UndoStackPush("import " + System.IO.Path.GetFileName(fileName)));
            });
        }
예제 #32
0
 public void ShowOpenFileDialogTest_FileTypesEmpty()
 {
     FileDialogService service = new FileDialogService();
     service.ShowOpenFileDialog(null, new FileType[] { }, null, null);
 }
예제 #33
0
        public void LoadFromFile()
        {
            List<BankOperation> overallLoadedOperations = new List<BankOperation>();
            using (OpenFileResult openFileResult = new FileDialogService()
                .OpenFile(ChosenParser.SupportedFileExtensions, true))
            {
                if(openFileResult.OpenedFiles.Count()==0)
                {
                    return;
                }

                foreach (var openedFile in openFileResult.OpenedFiles)
                {
                    var loadedOperations = _importer.ImportOperations(
                        openedFile.FileName,
                        ChosenParser.Parse(openedFile.Stream));
                    overallLoadedOperations.AddRange(loadedOperations);
                }
            }

            if (ApplyRules)
            {
                var classifier = new OperationsClassifier(
                    _context.GetRepository<IRepository<ClassificationDefinition>>(),
                    _context.GetRepository<IRepository<BankAccount>>());
                var classificationResult = classifier.ClasifyOpearations(overallLoadedOperations);

                _resolveConflicts.ResolveConflicts(classificationResult);

                var assigned = classifier.ApplyClassificationResult(classificationResult);
                var unassigned = classificationResult.Count() - assigned;

                string conent = string.Format(
                    Resources.Translations.OperationsClassificationResultTextTemplate,
                    assigned, Environment.NewLine, unassigned);

                _messageBoxService.ShowMessageBox("Info", conent);
            }

            _context.SaveChanges();

            ResetListData();
        }
예제 #34
0
 public void ShowSaveFileDialogTest_FileTypesNull()
 {
     FileDialogService service = new FileDialogService();
     service.ShowSaveFileDialog(null, null, null, null);
 }