Пример #1
0
        /// <summary>
        /// Creates a new connector from the specified type
        /// </summary>
        /// <remarks>
        /// The new connector style uses a copy of EdgesUserClass style
        /// </remarks>
        /// <param name="type"></param>
        /// <returns>new connector</returns>
        protected virtual NShape CreateEdge(ENConnectorShape type)
        {
            NConnectorShapeFactory factory = new NConnectorShapeFactory();
            NShape connector = factory.CreateShape(type);

            connector.Name      = m_sName + " Edge " + CurrentEdgeIndex.ToString(CultureInfo.InvariantCulture);
            connector.UserClass = m_EdgesUserClass;
            CurrentEdgeIndex++;
            return(connector);
        }
Пример #2
0
        /// <summary>
        /// Creates a new connector, which connects the specified shapes
        /// </summary>
        /// <param name="fromShape"></param>
        /// <param name="fromPortName"></param>
        /// <param name="toShape"></param>
        /// <param name="toPortName"></param>
        /// <param name="connectorType"></param>
        /// <param name="text"></param>
        /// <returns>new 1D shapes</returns>
        private NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ENConnectorShape connectorType, string text)
        {
            // check arguments
            if (fromShape == null)
            {
                throw new ArgumentNullException("fromShape");
            }

            if (toShape == null)
            {
                throw new ArgumentNullException("toShape");
            }

            // create the connector
            NShape connector = new NConnectorShapeFactory().CreateShape(connectorType);

            // set text and user class
            connector.Text      = text;
            connector.UserClass = NDR.StyleSheetNameConnectors;

            // connect begin
            NPort fromPort = fromShape.Ports.GetPortByName(fromPortName);

            if (fromPort != null)
            {
                connector.GlueBeginToPort(fromPort);
            }
            else
            {
                connector.GlueBeginToShape(fromShape);
            }

            // connect end
            NPort toPort = toShape.Ports.GetPortByName(toPortName);

            if (toPort != null)
            {
                connector.GlueEndToPort(toPort);
            }
            else
            {
                connector.GlueEndToShape(toShape);
            }

            // add to active page
            m_DrawingDocument.Content.ActivePage.Items.Add(connector);

            return(connector);
        }