protected override void Dispose(bool disposing) { if (!DesignMode && _Persistence != ePersistence.None && conf != null) { IConfigurationItem list = conf.GetConfigurationItem(Name); if (list == null) { DefineConfiguration(); list = conf.GetConfigurationItem(Name); } if (list != null) { list.Clear(); foreach (string elem in Items) { list.AddConfigurationItem(new IConfigurationItemImpl("item" + Convert.ToString(list.ConfigurationItems.Count + 1), elem, _ConfigurationSource)); } } if ((this as IConfigurationControl).ConfigurationName() != "") { ConfigurationRepository.IConfiguration.SetConfigurationValue((this as IConfigurationControl).ConfigurationName(), SelectedIndex); } conf.Save(); } base.Dispose(disposing); }
public void SaveConfiguration() { DefineConfiguration(); log.Debug(_ConfigurationName); IConfigurationItem dbNode = conf.GetConfigurationItem(_ConfigurationName); dbNode.Clear(); _stash.PersistConnections(dbNode, configurationSource); conf.SetConfigurationValue(_PersistanceLastValue, cbxDatabase.Text); }
void IConfigurationItem.Clear() { while (_ConfigurationItems.Count > 0) { IConfigurationItem item = _ConfigurationItems[0]; _ConfigurationItems.RemoveAt(0); item.Clear(); item = null; } //while (_ConfigurationItems.Count > 0) //_Source = eConfigurationSource.Undefined; } //void IConfigurationItem.Clear()
} //bool IConfigurationItem.RemoveConfigurationItem( bool IConfigurationItem.RemoveConfigurationItem(string path) { IConfigurationItem item = ConfigurationItemFromPath(path); if (item != null) { item.Clear(); item.Parent.ConfigurationItems.Remove(item); return(true); } //if (item != null) return(false); } //bool IConfigurationItem.RemoveConfigurationItem(
private void picTrash_Click(object sender, EventArgs e) { ConnectionTrash frm = new ConnectionTrash(stash); if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { IConfiguration conf = ConfigurationRepository.IConfiguration; IConfigurationItem dbConfigs = conf.GetConfigurationItem("databases"); dbConfigs.Clear(); stash.PersistConnections(dbConfigs); conf.Save(); } }
bool IConfigurationItem.RemoveConfigurationItem(IConfigurationItem item) { if (item != null && _ConfigurationItems.Contains(item)) { item.Clear(); _ConfigurationItems.Remove(item); if (_ConfigurationItems.Count == 0) { _Source = eConfigurationSource.Undefined; } return(true); } //if (_ConfigurationItems.Contains(item)) return(false); } //bool IConfigurationItem.RemoveConfigurationItem(
private void btnOk_Click(object sender, EventArgs e) { IConfigurationItem size = conf.GetConfigurationItem(UI_Constants.ConfigurationFormSize); (size as IConfigurationItemObject <Size>).SetValue(this.Size); IConfigurationItem location = conf.GetConfigurationItem(UI_Constants.ConfigurationFormLocation); (location as IConfigurationItemObject <Point>).SetValue(this.Location); conf.SetConfigurationValue(UI_Constants.SakwaModelPath, tbxModelFolder.Text); conf.SetConfigurationValue(UI_Constants.SakwaTemplatePath, tbxTemplateFolder.Text); conf.SetConfigurationValue(UI_Constants.SakwaModelOnStart, chxOpenOnStart.Checked.ToString()); conf.SetConfigurationValue(UI_Constants.FullHelpPath, tbxHelpFile.Text); modelGUIConfig.Save(); IConfigurationItem stockMethods = conf.GetConfigurationItem(UI_Constants.StockMethods); if (stockMethods != null) { eConfigurationSource src = stockMethods.Source; stockMethods.Clear(); stockMethods.Source = src; foreach (string mthd in lbMethods.Items) { string name = string.Format("item-{0}", stockMethods.ConfigurationItems.Count + 1); stockMethods.AddConfigurationItem(new IConfigurationItemImpl(name, mthd, UI_Constants.ConfigurationSource)); } } string json = (tpgInferenceConfig.Controls[0] as ucPropertyEditor).PropertiesAsJson; conf.SetConfigurationValue(UI_Constants.GlobalConnectionProperties, json); conf.Save(); }
private void TemplateForm_FormClosing(object sender, FormClosingEventArgs e) { bool CanExit = true; DialogResult UserSelected = DialogResult.None; SakwaUserControl oldEditor = editor.Controls.Count > 0 ? editor.Controls[0] as SakwaUserControl : null; if (oldEditor != null) { oldEditor.OnDeactivate(); } foreach (IDecisionTree tree in ctrl.Trees) { if (tree.IsDirty) { UserSelected = IApplicationInterface.GetFloatingForm( eFloatReason.NotSet, new ucUnsavedExit(true)).ShowDialog(); switch (UserSelected) { case DialogResult.OK: CanExit = true; break; case DialogResult.Yes: btnSave_Click(this, new EventArgs()); CanExit = true; break; default: CanExit = false; break; } break; } } if (CanExit) { conf.SetConfigurationValue(UI_Constants.TemplateFormState, this.WindowState.ToString()); IConfigurationItem size = conf.GetConfigurationItem(UI_Constants.TemplateFormSize); (size as IConfigurationItemObject <Size>).SetValue(this.Size); IConfigurationItem location = conf.GetConfigurationItem(UI_Constants.TemplateFormLocation); (location as IConfigurationItemObject <Point>).SetValue(this.Location); IConfigurationItem recentProjects = conf.GetConfigurationItem(UI_Constants.TemplateRecentProjects); if (recentProjects != null) { recentProjects.Clear(); foreach (IDecisionTree tree in ctrl.Trees) { if (File.Exists(tree.FullPath)) { string itemName = string.Format("item-{0}", recentProjects.ConfigurationItems.Count + 1); recentProjects.AddConfigurationItem(new IConfigurationItemImpl(itemName, tree.FullPath, UI_Constants.ConfigurationSource)); } } string path = ctrl.SelectedPath; conf.SetConfigurationValue(UI_Constants.TemplateRecentNode, path); } try { conf.Save(); } catch (Exception ex) { log.Debug(ex.ToString()); } _IApplication.ShowHideTemplateEditor(false, true); } else { e.Cancel = true; } }