private void UserControl_Drop(object sender, DragEventArgs e) { try { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { string fileExtension = System.IO.Path.GetExtension(file); if (fileExtension.Contains("sqlite")) { viewModel.DBFile = file; viewModel.RvtSheetData = SheetDataReader.ReadSheetDatabase(file, viewModel.RvtSheetData); viewModel.RvtSheetData.SelectedDisciplineIndex = 0; viewModel.DatabaseOpened = true; viewModel.StatusText = file; bool opened = SheetDataWriter.OpenDatabase(file); break; } } } } catch (Exception ex) { MessageBox.Show("Failed to drop files.\n" + ex.Message, "File Drop", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void CreateDBExecuted(object param) { try { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Create a New Sheet Data File"; saveDialog.DefaultExt = ".sqlite"; saveDialog.Filter = "SQLITE File (.sqlite)|*.sqlite"; if ((bool)saveDialog.ShowDialog()) { this.DBFile = saveDialog.FileName; bool created = SheetDataWriter.CreateDatabase(dbFile); if (created) { this.RvtSheetData = SheetDataReader.ReadSheetDatabase(dbFile, rvtSheetData); this.RvtSheetData.SelectedDisciplineIndex = 0; this.DatabaseOpened = true; this.StatusText = dbFile; } } } catch (Exception ex) { MessageBox.Show("Failed to create the database file.\n" + ex.Message, "Create Database File", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void ReloadDBExecuted(object param) { try { this.RvtSheetData = SheetDataReader.ReadSheetDatabase(dbFile, rvtSheetData); this.RvtSheetData.SelectedDisciplineIndex = 0; } catch (Exception ex) { MessageBox.Show("Failed to reload the database file.\n" + ex.Message, "Reload Database File", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void OpenDBExecuted(object param) { try { OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Title = "Open a Sheet Database File"; openDialog.DefaultExt = ".sqlite"; openDialog.Filter = "SQLITE File (.sqlite)|*.sqlite"; if ((bool)openDialog.ShowDialog()) { this.DBFile = openDialog.FileName; this.RvtSheetData = SheetDataReader.ReadSheetDatabase(dbFile, rvtSheetData); this.RvtSheetData.SelectedDisciplineIndex = 0; this.DatabaseOpened = true; this.StatusText = dbFile; bool opened = SheetDataWriter.OpenDatabase(dbFile); } } catch (Exception ex) { MessageBox.Show("Failed to open the database file.\n" + ex.Message, "Open Database File", MessageBoxButton.OK, MessageBoxImage.Warning); } }