public static ExecResult <ConnectorData> Execute(ConnectorData connectorData) { var result = new ExecResult <ConnectorData>(); try { var form = new FEditConnector(); form.tbID.Text = connectorData.ConnectorID.ToString(); form.tbGUID.Text = connectorData.Connector.ConnectorGUID; form.tbName.Text = connectorData.Name; form.cbType.SelectedIndex = form.cbType.SelectedIndex = form.cbType.Items.IndexOf(connectorData.LinkType); form.tbClientID.Text = connectorData.SourceElementID.ToString() + " (" + Context.ElementData[connectorData.SourceElementID].DisplayName + ")"; form.tbClientID.Tag = connectorData.SourceElementID; form.tbSupplierID.Text = connectorData.TargetElementID.ToString() + " (" + Context.ElementData[connectorData.TargetElementID].DisplayName + ")"; form.tbSupplierID.Tag = connectorData.TargetElementID; form.cbFlowID.Text = connectorData.FlowID; form.cbSegmentID.Text = connectorData.SegmentID; form.tbNotes.Text = connectorData.Notes; form.lvTaggedValues.Items.Clear(); foreach (EA.ConnectorTag connectorTag in connectorData.Connector.TaggedValues) { ListViewItem item = new ListViewItem(connectorTag.Name); item.SubItems.Add(connectorTag.Value); form.lvTaggedValues.Items.Add(item); } DialogResult res = form.ShowDialog(); if (res != DialogResult.OK) { result.code = (int)res; } else { result.value = new ConnectorData(); result.value.ConnectorID = int.Parse(form.tbID.Text); result.value.Name = form.tbName.Text; result.value.IsLibrary = true; result.value.LinkType = (LinkType)Enum.Parse(typeof(LinkType), form.cbType.Text); result.value.SourceElementID = (int)form.tbClientID.Tag; result.value.TargetElementID = (int)form.tbSupplierID.Tag; result.value.FlowID = form.cbFlowID.Text; result.value.SegmentID = form.cbSegmentID.Text; result.value.Notes = form.tbNotes.Text; } } catch (Exception ex) { result.setException(ex); } return(result); }
private void tsbEditProperties_Click(object sender, EventArgs e) { if (lvConnectors.SelectedItems.Count > 0) { var editResult = FEditConnector.Execute((ConnectorData)lvConnectors.SelectedItems[0].Tag); if (editResult.code == 0) { ConnectorHelper.UpdateConnectorByData(editResult.value); } LoadConnectorList(); } }