Esempio n. 1
0
        private ConnectorEditor GetConnectorEditor(Point editPoint, System.Workflow.ComponentModel.Design.HitTestInfo messageContext)
        {
            Connector         connectorEdited = null;
            ISelectionService service         = base.GetService(typeof(ISelectionService)) as ISelectionService;

            if (service != null)
            {
                Connector connectorFromSelectedObject = Connector.GetConnectorFromSelectedObject(service.PrimarySelection);
                if (((connectorFromSelectedObject != null) && connectorFromSelectedObject.ParentDesigner.EnableUserDrawnConnectors) && new ConnectorEditor(connectorFromSelectedObject).HitTest(editPoint))
                {
                    connectorEdited = connectorFromSelectedObject;
                }
            }
            if (connectorEdited == null)
            {
                ConnectionPointHitTestInfo info = messageContext as ConnectionPointHitTestInfo;
                if ((info != null) && (info.ConnectionPoint != null))
                {
                    FreeformActivityDesigner connectorContainer = GetConnectorContainer(info.AssociatedDesigner);
                    if ((connectorContainer != null) && connectorContainer.EnableUserDrawnConnectors)
                    {
                        connectorEdited = connectorContainer.CreateConnector(info.ConnectionPoint, info.ConnectionPoint);
                    }
                }
            }
            if (connectorEdited == null)
            {
                return(null);
            }
            return(new ConnectorEditor(connectorEdited));
        }
Esempio n. 2
0
        private ConnectorEditor GetConnectorEditor(Point editPoint, HitTestInfo messageContext)
        {
            Connector connector = null;

            //First check if we are editing a existing selected connector
            ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService != null)
            {
                Connector selectedConnector = Connector.GetConnectorFromSelectedObject(selectionService.PrimarySelection);
                if (selectedConnector != null && selectedConnector.ParentDesigner.EnableUserDrawnConnectors && new ConnectorEditor(selectedConnector).HitTest(editPoint))
                {
                    connector = selectedConnector;
                }
            }

            //Then check if the hit is on a ConnectionPoint for drawing new connectors
            if (connector == null)
            {
                ConnectionPointHitTestInfo connectionPointHitTestInfo = messageContext as ConnectionPointHitTestInfo;
                if (connectionPointHitTestInfo != null && connectionPointHitTestInfo.ConnectionPoint != null)
                {
                    FreeformActivityDesigner connectorContainer = ConnectionManager.GetConnectorContainer(connectionPointHitTestInfo.AssociatedDesigner);
                    if (connectorContainer != null && connectorContainer.EnableUserDrawnConnectors)
                    {
                        connector = connectorContainer.CreateConnector(connectionPointHitTestInfo.ConnectionPoint, connectionPointHitTestInfo.ConnectionPoint);
                    }
                }
            }

            return((connector != null) ? new ConnectorEditor(connector) : null);
        }