protected override bool OnPaint(PaintEventArgs e, Rectangle viewPort, AmbientTheme ambientTheme) { Connector connectorEdited = null; ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; foreach (object obj2 in service.GetSelectedComponents()) { Connector connectorFromSelectedObject = Connector.GetConnectorFromSelectedObject(obj2); if (connectorFromSelectedObject != null) { connectorFromSelectedObject.OnPaintSelected(new ActivityDesignerPaintEventArgs(e.Graphics, connectorFromSelectedObject.ParentDesigner.Bounds, viewPort, connectorFromSelectedObject.ParentDesigner.DesignerTheme), obj2 == service.PrimarySelection, new Point[0]); if (obj2 == service.PrimarySelection) { connectorEdited = connectorFromSelectedObject; } } } if (connectorEdited != null) { new ConnectorEditor(connectorEdited).OnPaint(new ActivityDesignerPaintEventArgs(e.Graphics, connectorEdited.ParentDesigner.Bounds, viewPort, connectorEdited.ParentDesigner.DesignerTheme), true, true); } if (this.EditingInProgress) { FreeformActivityDesigner designer = (this.connectorEditor.EditedConnector.ParentDesigner != null) ? this.connectorEditor.EditedConnector.ParentDesigner : GetConnectorContainer(this.connectorEditor.EditedConnector.Source.AssociatedDesigner); this.connectorEditor.OnPaint(new ActivityDesignerPaintEventArgs(e.Graphics, designer.Bounds, viewPort, designer.DesignerTheme), false, false); } return(false); }
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)); }
private bool CanBeginEditing(Point editPoint, HitTestInfo messageContext) { 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)) { return(true); } } ConnectionPointHitTestInfo connectionPointHitTestInfo = messageContext as ConnectionPointHitTestInfo; if (connectionPointHitTestInfo != null && connectionPointHitTestInfo.ConnectionPoint != null) { FreeformActivityDesigner connectorContainer = ConnectionManager.GetConnectorContainer(connectionPointHitTestInfo.AssociatedDesigner); if (connectorContainer != null && connectorContainer.EnableUserDrawnConnectors) { return(true); } } return(false); }
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); }
protected override bool OnPaint(PaintEventArgs e, Rectangle viewPort, AmbientTheme ambientTheme) { //Draw the selected connectors at top of the z level Connector selectedConnector = null; ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService; foreach (object selectedComponents in selectionService.GetSelectedComponents()) { Connector connector = Connector.GetConnectorFromSelectedObject(selectedComponents); if (connector != null) { connector.OnPaintSelected(new ActivityDesignerPaintEventArgs(e.Graphics, connector.ParentDesigner.Bounds, viewPort, connector.ParentDesigner.DesignerTheme), (selectedComponents == selectionService.PrimarySelection), new Point[] { }); if (selectedComponents == selectionService.PrimarySelection) { selectedConnector = connector; } } } //Draw selected connector adorned with the edit points if (selectedConnector != null) { ConnectorEditor editableConnector = new ConnectorEditor(selectedConnector); editableConnector.OnPaint(new ActivityDesignerPaintEventArgs(e.Graphics, selectedConnector.ParentDesigner.Bounds, viewPort, selectedConnector.ParentDesigner.DesignerTheme), true, true); } //If editing is in progress then draw the connector being edited if (EditingInProgress) { FreeformActivityDesigner designer = (this.connectorEditor.EditedConnector.ParentDesigner != null) ? this.connectorEditor.EditedConnector.ParentDesigner : ConnectionManager.GetConnectorContainer(this.connectorEditor.EditedConnector.Source.AssociatedDesigner); this.connectorEditor.OnPaint(new ActivityDesignerPaintEventArgs(e.Graphics, designer.Bounds, viewPort, designer.DesignerTheme), false, false); } return(false); }
private bool UpdateCursor(Nullable <Point> cursorPoint) { Cursor cursorToSet = Cursors.Default; if (cursorPoint != null) { if (EditingInProgress) { cursorToSet = this.connectorEditor.GetCursor(cursorPoint.Value); } //Connector snap cursor always takes precedence over other cursors if (SnappedConnectionPoint != null) { cursorToSet = ConnectionManager.SnappedConnectionCursor; } else if (ConnectablePoints != null) { foreach (ConnectionPoint connectablePoint in ConnectablePoints) { if (connectablePoint.Bounds.Contains(cursorPoint.Value)) { cursorToSet = ConnectionManager.SnappedConnectionCursor; break; } } //Fall back and check if we are hovering on any edit points if (cursorToSet == Cursors.Default) { ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService; if (selectionService != null) { Connector selectedConnector = Connector.GetConnectorFromSelectedObject(selectionService.PrimarySelection); if (selectedConnector != null && selectedConnector.ParentDesigner.EnableUserDrawnConnectors) { ConnectorEditor connectorEditor = new ConnectorEditor(selectedConnector); cursorToSet = connectorEditor.GetCursor(cursorPoint.Value); } } } } } WorkflowView workflowView = ParentView; if (workflowView != null && (cursorToSet != Cursors.Default || workflowView.Cursor == ConnectionManager.SnappedConnectionCursor || workflowView.Cursor == ConnectionManager.NewConnectorCursor)) { workflowView.Cursor = cursorToSet; } return(cursorToSet != Cursors.Default); }
private bool UpdateCursor(Point?cursorPoint) { Cursor snappedConnectionCursor = Cursors.Default; if (cursorPoint.HasValue) { if (this.EditingInProgress) { snappedConnectionCursor = this.connectorEditor.GetCursor(cursorPoint.Value); } if (this.SnappedConnectionPoint != null) { snappedConnectionCursor = SnappedConnectionCursor; } else if (this.ConnectablePoints != null) { foreach (ConnectionPoint point in this.ConnectablePoints) { if (point.Bounds.Contains(cursorPoint.Value)) { snappedConnectionCursor = SnappedConnectionCursor; break; } } if (snappedConnectionCursor == Cursors.Default) { ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService; if (service != null) { Connector connectorFromSelectedObject = Connector.GetConnectorFromSelectedObject(service.PrimarySelection); if ((connectorFromSelectedObject != null) && connectorFromSelectedObject.ParentDesigner.EnableUserDrawnConnectors) { snappedConnectionCursor = new ConnectorEditor(connectorFromSelectedObject).GetCursor(cursorPoint.Value); } } } } } WorkflowView parentView = base.ParentView; if ((parentView != null) && (((snappedConnectionCursor != Cursors.Default) || (parentView.Cursor == SnappedConnectionCursor)) || (parentView.Cursor == NewConnectorCursor))) { parentView.Cursor = snappedConnectionCursor; } return(snappedConnectionCursor != Cursors.Default); }