private void btnNewSerial_Click(object sender, EventArgs e) { IAction currAct = (IAction)pgInterface.SelectedObject; IAction newAct = currAct.CreateNewChildObject(); AddObject <IAction> fm_AddObj = new AddObject <IAction> { Text = "Add new station", Object = newAct }; bool ok; do { ok = true; if (fm_AddObj.ShowDialog(this) != DialogResult.OK) { return; } try { newAct.AddObjectToTable(); } catch (Exception ex) { MessageBox.Show ("I cannot add new object to the configuration because: " + ex.Message, "Error while creating new object", MessageBoxButtons.OK, MessageBoxIcon.Error); ok = false; } }while (!ok); cmbStations.Items.Add((StationRowWrapper)newAct); cmbStations.SelectedItem = (StationRowWrapper)newAct; }
private void cn_ButtonAdd_Click(object sender, EventArgs e) { try { if (m_ParBlock.RowState == System.Data.DataRowState.Detached) { MessageBox.Show(Resources.tx_TagsCollection_pleasecreatedatablockfirst); return; } m_DB.EnforceConstraints = false; ComunicationNet.TagsRow cNTG = m_DB.Tags.NewTagsRow(m_ParBlock.DatBlockID, m_ParBlock.Name); TagsRowWrapper cRW = new TagsRowWrapper(cNTG, dataBlockRowWrapper, true); using (AddObject <TagsRowWrapper> cDial = new AddObject <TagsRowWrapper>(cRW)) { cDial.ShowDialog(this); if (cDial.DialogResult != DialogResult.OK) { cNTG.Delete(); cRW.AddUnfinishedCleanup(); return; } } cRW.AddObjectToTable(); FillLlist(cn_listBox.Items.Count - 1); } catch (Exception) { } finally { m_DB.EnforceConstraints = true; } }
/// <summary> /// Gets the configuration editor - user interface to edit the plug-in configuration file. /// </summary> public void EditConfiguration() { using (AddObject <object> _dialog = new AddObject <object>(Configuration)) { if (_dialog.ShowDialog() == DialogResult.OK) { RaiseOnChangeEvent(false); } } }
/// <summary> /// Edits this instance. /// </summary> public void Edit() { InstanceConfiguration copy; copy = (InstanceConfiguration)Clone(); using (AddObject <InstanceConfiguration> form = new AddObject <InstanceConfiguration>(copy)) if (form.ShowDialog() == DialogResult.OK) { DataSources = form.Object.DataSources; } }
private void m_OpenPortButton_Click(object sender, EventArgs e) { using (OKCancelForm okcan = new OKCancelForm("Data Provider Selector")) { AvailableDPTree c_AvailableDPTree; if (m_LastGuid.Equals(Guid.Empty)) { c_AvailableDPTree = new AvailableDPTree(@_CommonBusControl, okcan); } else { c_AvailableDPTree = new AvailableDPTree(@_CommonBusControl, okcan, m_LastSettings, m_LastGuid); } using ( c_AvailableDPTree ) { okcan.SetUserControl = c_AvailableDPTree; okcan.ShowDialog(); if (okcan.DialogResult != DialogResult.OK) { return; } m_DataProviderID = c_AvailableDPTree.GetSelectedDPID; } } using (AddObject <IDataProviderID> _DPSettings = new AddObject <IDataProviderID>()) { _DPSettings.Object = m_DataProviderID; _DPSettings.ShowDialog(); if (_DPSettings.DialogResult != DialogResult.OK) { return; } m_LastGuid = m_DataProviderID.GetDataProviderDescription.Identifier; m_LastSettings = m_DataProviderID.GetSettings(); } this.@_PortSettings.Text = "Protocol settings:\r\n" + m_DataProviderID.GetSettingsHumanReadableFormat(); @_StartMonitoringButton.Enabled = true; @_ResourceComboBox.Items.Clear(); IAddressSpaceDescriptor[] AvailiableAddressspaces = m_DataProviderID.GetAvailiableAddressspaces(); foreach (IAddressSpaceDescriptor item in AvailiableAddressspaces) { @_ResourceComboBox.Items.Add(item.Name); } if (@_ResourceComboBox.Items.Count > 0) { @_ResourceComboBox.SelectedIndex = 0; } }
//TODO Removed dependency of the CAS.UA.Model.Designer.Wrappers on using System.Windows.Forms #38 internal void AddMenuItemAdd_Click(object sender, EventArgs e) { System.Windows.Forms.ToolStripMenuItem mi = (System.Windows.Forms.ToolStripMenuItem)sender; INodeFactory factory = (INodeFactory)mi.Tag; ValidableTreeNode node = factory.Node; this.Add(node); using (AddObject <object> form = new AddObject <object>(node.Wrapper)) { form.Size = new Size(600, 500); if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK) { this.Remove(node); return; } } node.Validate(); }
private void add() { TreeNode tn = m_PNavigator.cn_TreeView.SelectedNode; if (tn == null) { return; } IAction currAct = (IAction)m_PNavigator.cn_TreeView.SelectedNode.Tag; if (!currAct.CanCreateChild) { return; } if (currAct is SegmentsRowWrapper) { IAction newAct = currAct.CreateNewChildObject(); AddInterfaceAndStation fm_AddInterface = new AddInterfaceAndStation(m_configDataBase, newAct); if (fm_AddInterface.ShowDialog(this) != DialogResult.OK) { return; } } else { #if UNDOREDO RTLib.DataBase.UndoRedo.UndoRedoMenager.BeginTransaction(); #endif try { if (!m_configDataBase.EnforceConstraints) { MessageBox.Show(Resources.tx_configDataBaseEnforceConstraints_false, Resources.tx_configtreeview_error_messagebox_title, MessageBoxButtons.OK, MessageBoxIcon.Error); } m_configDataBase.AcceptChanges(); m_configDataBase.EnforceConstraints = false; #if UNDOREDO RTLib.DataBase.UndoRedo.UndoRedoMenager.BeginTransaction(); #endif IAction newAct = currAct.CreateNewChildObject(); AddObject <IAction> fm_AddObj = new AddObject <IAction> { Text = "Add new object for: " + currAct, Object = newAct }; bool ok; do { ok = true; if (fm_AddObj.ShowDialog(this) != DialogResult.OK) { //deleteLastTransaction(); newAct.AddUnfinishedCleanup(); break; } try { newAct.AddObjectToTable(); } catch (Exception ex) { MessageBox.Show ("I cannot add new object to the configuration because: " + ex.Message, Resources.tx_configtreeview_error_messagebox_title, MessageBoxButtons.OK, MessageBoxIcon.Error); ok = false; } }while (!ok); #if UNDOREDO RTLib.DataBase.UndoRedo.UndoRedoMenager.EndTransaction(); #endif try { m_configDataBase.EnforceConstraints = true; } catch (Exception ex) { MessageBox.Show ("I cannot add new object to the configuration because: " + ex.Message, Resources.tx_configtreeview_error_messagebox_title, MessageBoxButtons.OK, MessageBoxIcon.Error); m_configDataBase.RejectChanges(); m_configDataBase.EnforceConstraints = true; } } catch (CreateChildObjectException ex) { MessageBox.Show(ex.Message, Resources.tx_configtreeview_error_messagebox_title, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("I cannot add new object to the configuration becase: " + ex.Message, Resources.tx_configtreeview_error_messagebox_title, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { #if UNDOREDO RTLib.DataBase.UndoRedo.UndoRedoMenager.EndTransaction(); #endif m_configDataBase.EnforceConstraints = true; } } ((IAction)m_PNavigator.cn_TreeView.SelectedNode.Tag).CreateNodes(); //m_PNavigator.cn_TreeView.SelectedNode = tn.Expand(); UpdateTagNumberInfo(); }