private void HandleImportExecuted(object obj) { // For now fall back to standard windows dialoges; might be replaced with custom dialogs later on OpenFileDialog ofd = new OpenFileDialog { Title = LocalString("OFD_Title"), InitialDirectory = _edidFolder, Multiselect = false }; string filter = LocalString("OFD_Filter"); try { filter = filter.Trim(); ofd.Filter = filter; } catch (Exception ex) { } if (ofd.ShowDialog() == true) { if (!EDID.IsEDIDFile(ofd.FileName)) { MessageBox.Show(LocalString("OFD_NoEDID"), LocalString("Error"), MessageBoxButton.OK); return; } string destPath = Path.Combine(_edidFolder, Path.GetFileName(ofd.FileName)); if (File.Exists(destPath)) { var replace = MessageBox.Show(LocalString("OFD_Exists"), LocalString("Error"), MessageBoxButton.YesNoCancel); if (replace == MessageBoxResult.Cancel) { return; } if (replace == MessageBoxResult.No) { destPath = destPath.GetNextFilename(); } } File.Copy(ofd.FileName, destPath, true); if (!_edidFiles.Contains(Path.GetFileName(destPath))) { _edidFiles.Add(Path.GetFileName(destPath)); } } }
private void HandleLoadedExecuted(object obj) { if (Loading) { return; } Loading = true; Task.Factory.StartNew(() => { if (!Directory.Exists(_edidFolder)) { Directory.CreateDirectory(_edidFolder); } var files = new DirectoryInfo(_edidFolder).GetFiles().Where(fi => EDID.IsEDIDFile(fi.FullName)).Select(fi => fi.Name); App.Current.Dispatcher.BeginInvoke(new Action(() => { EDIDFiles = new ObservableCollection <string>(files); }), null); App.Current.Dispatcher.BeginInvoke(new Action(() => { Loading = false; }), null); }); }