Beispiel #1
0
        void OnConnectAdd(Connects connects)
        {
            if (SuspendConnectHandlingToMoveAConnectionPoint)
            {
                return;
            }

            foreach (Connect c in connects)
            {
                // each connection should be between a 1D shape (connector or comment) and a 2D shape (everything else)
                // The 1D connector is always the To and 2D shapes are always the From
                Shape connector    = null;
                Shape nonConnector = null;
                if (c.FromSheet.OneD != 0)
                {
                    connector = c.FromSheet;
                }
                else
                {
                    nonConnector = c.FromSheet;
                }

                if (connector == null && c.ToSheet.OneD != 0)
                {
                    connector = c.ToSheet;
                }
                else if (nonConnector == null && c.ToSheet.OneD == 0)
                {
                    nonConnector = c.ToSheet;
                }

                // not sure what it is but we don't care about it
                if (connector == null || nonConnector == null)
                {
                    return;
                }

                Shadow connectorShadow    = LookupShadowByShape(connector);
                Shadow nonConnectorShadow = LookupShadowByShape(nonConnector);

                if (connectorShadow == null || nonConnectorShadow == null)
                {
                    Common.ErrorMessage("Adding connector to bogus shapes...");
                    return;
                }

                // an ignored shadow (like a comment) can sometimes have links
                // but shouldn't be added as a transition - it's irrelevant
                IgnoredShadow ignored = connectorShadow as IgnoredShadow;
                if (ignored != null)
                {
                    return;
                }

                // determine which end of the connector is connected to the nonConnectorShadow
                bool arrowSide = false;
                if (c.FromCell.Name.Equals(Strings.EndConnectionPointCellName))
                {
                    arrowSide = true;
                }

                if (arrowSide)
                {
                    connectorShadow.OnConnectAddOutput(nonConnectorShadow);
                    nonConnectorShadow.OnConnectAddInput(connectorShadow);
                }
                else
                {
                    connectorShadow.OnConnectAddInput(nonConnectorShadow);
                    nonConnectorShadow.OnConnectAddOutput(connectorShadow);
                }
            }
        }