public void setupByForm(IDataItem aDataItem, IConnection aConnection, IWin32Window aOwner) { DataItem lItem = (DataItem)aDataItem; Connection lConnection = (Connection)aConnection; bool lModified = false; using (var lSetupForm = new ItemSetupForm(lConnection, lItem.mTagName)) { do { lSetupForm.ShowDialog(aOwner); if (lSetupForm.DialogResult == DialogResult.OK) { try { lConnection.modifyItem(lItem, lSetupForm.TagName); lModified = true; } catch (Exception lExc) { Log.Error("Error while user was configuring data item for PLC '" + lConnection.mPLCName + "'. " + lExc.Message, lExc.ToString()); MessageForm.showMessage(lExc.Message, aOwner); } } }while (lSetupForm.DialogResult == DialogResult.OK && lModified == false); } }
public IDataItem createByForm(IConnection aConnection, IWin32Window aOwner) { Connection lConnection = (Connection)aConnection; DataItem lItem = null; using (var lSetupForm = new ItemSetupForm(lConnection, "")) { do { try { lSetupForm.ShowDialog(aOwner); if (lSetupForm.DialogResult == DialogResult.OK) { lItem = lConnection.addItem(lSetupForm.TagName); } } catch (Exception lExc) { Log.Error("Error while user was creating new data item for PLC '" + lConnection.mPLCName + "'. " + lExc.Message, lExc.ToString()); MessageForm.showMessage(lExc.Message, aOwner); } }while (lSetupForm.DialogResult == DialogResult.OK && lItem == null); } return(lItem); }