コード例 #1
0
        public void ShowOpenFileDialogTest()
        {
            FileDialogService service = new FileDialogService();

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

            if (fileName != null)
            {
                LoadRom(fileName);
            }
        }
コード例 #3
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;
            }
        }
コード例 #4
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;
             }
         }
     }
 }
コード例 #5
0
ファイル: MainWindowViewModel.cs プロジェクト: panlukz/GGProj
        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;
                //});
            }
        }
コード例 #6
0
 private void ExecuteShowOpen(object _)
 {
     FileName = FileDialogService.ShowOpenFileDialog(Title, Extension, Filter);
 }
コード例 #7
0
        public void ShowOpenFileDialogTest_FileTypesEmpty()
        {
            FileDialogService service = new FileDialogService();

            service.ShowOpenFileDialog(null, new FileType[] { }, null, null);
        }