private void CreateDatabaseView_Show( DatabaseMode theMode) { // Instantiate an instance CreateDatabaseView theView = new CreateDatabaseView(theMode); theView.textboxSourceDirectory.Leave += new EventHandler(CreateDatabaseView_textboxSourceDirectory_Leave); theView.buttonSourceDirectory.Click += new EventHandler(CreateDatabaseView_buttonSourceDirectory_Click); theView.textboxTargetFile.Leave += new EventHandler(CreateDatabaseView_textboxTargetFile_Leave); theView.buttonTargetFile.Click += new EventHandler(CreateDatabaseView_buttonTargetFile_Click); theView.buttonOK.Click += new EventHandler(CreateDatabaseView_buttonOK_Click); switch (theMode) { case DatabaseMode.CreateMusicDatabase: case DatabaseMode.RefreshMusicDatabase: theView.SaveFileDialog.Filter = "Karaokidex Music Databases (*.kmdb)|*.kmdb"; theView.SaveFileDialog.DefaultExt = "kmdb"; if (!String.IsNullOrEmpty(RegistryAgent.LastMusicDatabase)) { theView.textboxSourceDirectory.Text = DatabaseLayer.GetSourceDirectory( new FileInfo(RegistryAgent.LastMusicDatabase)); theView.textboxTargetFile.Text = RegistryAgent.LastMusicDatabase; } break; default: theView.SaveFileDialog.Filter = "Karaokidex Karokie Databases (*.kkdb)|*.kkdb"; theView.SaveFileDialog.DefaultExt = "kkdb"; if (!String.IsNullOrEmpty(RegistryAgent.LastKaraokeDatabase)) { theView.textboxSourceDirectory.Text = DatabaseLayer.GetSourceDirectory( new FileInfo(RegistryAgent.LastKaraokeDatabase)); theView.textboxTargetFile.Text = RegistryAgent.LastKaraokeDatabase; } break; } Controller.IsViewValid(theView); // Show the form theView.ShowDialog(this._MainView); }
public void CreateDatabaseAgentView_ShowForMusic( CreateDatabaseView theCallingView, DirectoryInfo theSourceDirectoryInfo, FileInfo theTargetFileInfo) { CreateDatabaseAgentView theView = new CreateDatabaseAgentView( theSourceDirectoryInfo, theTargetFileInfo); theView.FormClosing += new FormClosingEventHandler(CreateDatabaseAgentView_FormClosing); CreateMusicDatabaseAgent theAgent = new CreateMusicDatabaseAgent( theView, theTargetFileInfo, theSourceDirectoryInfo); theAgent.Inserting += new EventHandler(CreateDatabaseAgent_Inserting); theAgent.Updating += new EventHandler(CreateDatabaseAgent_Updating); theAgent.Completed += new EventHandler(CreateDatabaseAgent_Completed); RegistryAgent.LastMusicDatabase = theTargetFileInfo.FullName; this._CurrentMusicDatabaseFileInfo = new FileInfo(theTargetFileInfo.FullName); this._Thread = new Thread( new ThreadStart(theAgent.Start)); this._Thread.Start(); theView.ShowDialog( theCallingView); theCallingView.Close(); this.OpenDatabase(); }
private static void IsViewValid( CreateDatabaseView theView) { theView.buttonOK.Enabled = false; if (String.IsNullOrEmpty(theView.textboxSourceDirectory.Text) || String.IsNullOrEmpty(theView.textboxTargetFile.Text)) { return; } if (!File.Exists(theView.textboxTargetFile.Text)) { MessageBox.Show( theView, "The database file specified does not exist", theView.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1); Application.DoEvents(); return; } if (!Directory.Exists(theView.textboxSourceDirectory.Text)) { MessageBox.Show( theView, "The source directory specified does not exist", theView.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1); Application.DoEvents(); return; } theView.buttonOK.Enabled = true; }