コード例 #1
0
        private void UpdatePortGeneralPropertiesControls(NPort port)
        {
            // can only disconnect the port if it is connected to any plugs
            disconnectPortButton.Enabled = (port.Plugs.Count != 0);

            // update port offset
            NSizeF offset = port.Offset;

            portOffsetXNumeric.Value = (decimal)offset.Width;
            portOffsetYNumeric.Value = (decimal)offset.Height;

            // populate the combo with available anchors
            INDiagramElementContainer searchRoot = port.GetRootForReferenceProperty("AnchorUniqueId");
            NFilter filter = port.GetFilterForReferenceProperty("AnchorUniqueId");

            NNodeList anchors = searchRoot.Descendants(null, -1);

            anchors.Insert(0, searchRoot);
            anchors = anchors.Filter(filter);

            anchorIdComboBox.Items.Clear();
            anchorIdComboBox.Items.AddRange((object[])(anchors.ToArray(typeof(object))));

            // select the currently chosen anchor
            for (int i = 0; i < anchorIdComboBox.Items.Count; i++)
            {
                Guid elemendGuid = (anchorIdComboBox.Items[i].Tag as INDiagramElement).UniqueId;
                if (elemendGuid.Equals(port.AnchorUniqueId))
                {
                    anchorIdComboBox.SelectedIndex = i;
                    break;
                }
            }
        }