private void OnButtonOverwrite(object sender, EventArgs e) { // warning message if (DialogResult.No == MessageBox.Show( Properties.Resources.ID_DATABASEOVERWRITE , Application.ProductName, MessageBoxButtons.YesNo)) { return; } try { // get listbox selected index int iSel = listBoxLibraries.SelectedIndex; if (-1 == iSel) { return; } // download if (libFetcher.DownloadLibraryAndOverwrite(iSel)) { DatabaseModified?.Invoke(this, e); } } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void OnButtonMerge(object sender, EventArgs e) { try { // get listbox selected index int iSel = listBoxLibraries.SelectedIndex; if (-1 == iSel) { return; } // download if (libFetcher.DownloadLibraryAndMerge(iSel)) { DatabaseModified?.Invoke(this, e); } } catch (Exception ex) { _log.Error(ex.ToString()); } }
/// <summary> /// Loads the specified database into the control. /// </summary> /// <param name="database">Database to load.</param> public void LoadDatabase(Database database) { NotifyCollectionChangedEventHandler collection_changed = (coll_sender, coll_e) => { database._Modified = true; DatabaseModified?.Invoke(this, new DatabaseEventArgs() { Database = database }); }; PropertyChangedEventHandler property_changed = (prop_sender, prop_e) => { database._Modified = true; DatabaseModified?.Invoke(this, new DatabaseEventArgs() { Database = database }); }; database.PropertyChanged += property_changed; // Tables Utilities.BindChangedCollection(database.Table, collection_changed, (prop_sender, prop_e) => { property_changed(prop_sender, prop_e); if (prop_e.PropertyName == "UseCustomSql") { Refresh(); } }); Utilities.BindChangedCollection(database.Association, collection_changed, property_changed); foreach (var table in database.Table) { Utilities.BindChangedCollection(table.Column, collection_changed, property_changed); Utilities.BindChangedCollection(table.Index, collection_changed, property_changed); } // Configurations Utilities.BindChangedCollection(database.Configuration, collection_changed, (prop_sender, prop_e) => { // Ignore the visibility property because this is internal to the GUI and has nothing to do with the schema. if (prop_e.PropertyName != "Visibility") { property_changed(prop_sender, prop_e); } }); // Functions Utilities.BindChangedCollection(database.Function, collection_changed, property_changed); // Views Utilities.BindChangedCollection(database.View, collection_changed, property_changed); foreach (var view in database.View) { Utilities.BindChangedCollection(view.Column, collection_changed, property_changed); } // Enumerations Utilities.BindChangedCollection(database.Enumeration, collection_changed, property_changed); foreach (var enum_item in database.Enumeration) { Utilities.BindChangedCollection(enum_item.EnumValue, collection_changed, property_changed); } loaded_databases.Add(database); database.Initialize(); Refresh(); if (LoadedDatabase != null) { LoadedDatabase(this, new DatabaseEventArgs() { Database = database }); } }