public void ShowOpenFileDialogTest() { FileDialogService service = new FileDialogService(); AssertHelper.ExpectedException <ArgumentNullException>(() => service.ShowOpenFileDialog(null, null, null)); AssertHelper.ExpectedException <ArgumentException>(() => service.ShowOpenFileDialog(new FileType[] {}, null, null)); }
public void LoadRom() { string fileName = FileDialogService.ShowOpenFileDialog("GameBoy ROMs (*.gb;*.gbc;*.cgb)|*.gb;*.gbc;*.cgb|All Files (*.*)|*.*"); if (fileName != null) { LoadRom(fileName); } }
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; } }
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; } } } }
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; //}); } }
private void ExecuteShowOpen(object _) { FileName = FileDialogService.ShowOpenFileDialog(Title, Extension, Filter); }
public void ShowOpenFileDialogTest_FileTypesEmpty() { FileDialogService service = new FileDialogService(); service.ShowOpenFileDialog(null, new FileType[] { }, null, null); }