// ------------------------------------------------------------------ /// <summary> /// Initializes the default settings of the connector. Actions /// performed in the ConnectorBase are: /// * Sets the default PaintStyle to be /// 'SolidPaintStyle' with a transparent color. /// * Sets the default PenStyle to be a LinePenStyle whose color /// is Transparent and DashStyle is 'Solid'. /// </summary> // ------------------------------------------------------------------ protected virtual void InitializeConnector() { this.mPaintStyle = new SolidPaintStyle(Color.Transparent); LinePenStyle lineStyle = new LinePenStyle(); lineStyle.Color = Color.Transparent; lineStyle.DashStyle = DashStyle.Solid; }
/// <summary> /// The <see cref="IPenStyle"/> used when the ConnectorStyle is /// 'Simple'. /// </summary> /// <returns></returns> public static IPenStyle GetSimpleConnectorPenStyle() { LinePenStyle penStyle = new LinePenStyle(); penStyle.DashStyle = DashStyle.Solid; penStyle.Color = Color.Blue; return(penStyle); }
public GraphVisualizationInfoView() { InitializeComponent(); this.shapeInfoShapeMapping = new BidirectionalDictionary<IShapeInfo, IShape>(); this.connectionInfoConnectionMapping = new BidirectionalDictionary<IConnectionInfo, IConnection>(); this.connectionPenStyle = new LinePenStyle(); this.connectionPenStyle.EndCap = LineCap.ArrowAnchor; PasteTool pasteTool = (PasteTool)this.Controller.Tools.Where(t => t.Name == ControllerBase.PasteToolName).FirstOrDefault(); CopyTool copyTool = (CopyTool)this.Controller.Tools.Where(t => t.Name == ControllerBase.CopyToolName).FirstOrDefault(); HeuristicLab.Netron.Controller controller = this.Controller as HeuristicLab.Netron.Controller; if (controller != null) { if (pasteTool != null) controller.RemoveTool(pasteTool); if (copyTool != null) controller.RemoveTool(copyTool); } }
/// <summary> /// The <see cref="IPenStyle"/> used when the ConnectorStyle is /// 'Simple'. /// </summary> /// <returns></returns> public static IPenStyle GetSimpleConnectorPenStyle() { LinePenStyle penStyle = new LinePenStyle(); penStyle.DashStyle = DashStyle.Solid; penStyle.Color = Color.Blue; return penStyle; }
/// <summary> /// Updates pens and brushes. /// <remarks>The .Net API allows you to simply set caps but the visual results are less than satisfactory, to say the least. So, there is /// a hack here (unfortunately) which amounts to use two pen for one connection; one pen for the line and one for the (custom) cap. This is /// the easiest way to have visible arrow which otherwise is miniaturistic. There is also a custom shift of the caps since the location is sometime /// inappropriate; the arrow is drawn with the tip at the end of the connection while the diamond or circle caps are drawn with their center at the connection /// end. So, altogether a lot of tweaking and I really find it regrettable that the out-of-the-box caps are not what they should be (besides some obvious bugs like /// the 'not implemented' one if you try to fill a custom cap...). /// </remarks> /// </summary> protected override void UpdatePaintingMaterial() { base.UpdatePaintingMaterial(); #region Hack //see the code comments of the LinePenStyle to understand the problem and this hack if (this.PenStyle is LinePenStyle) { LinePenStyle lp = PenStyle as LinePenStyle; if (lp.StartCap == System.Drawing.Drawing2D.LineCap.NoAnchor) { leftPen = null; } else { if (lp.StartCap == System.Drawing.Drawing2D.LineCap.Custom) { //leftPen.StartCap = System.Drawing.Drawing2D.LineCap.Custom; //AdjustableArrowCap ccap = new AdjustableArrowCap(lp.Width+2, lp.Width+2, true); //leftPen.CustomStartCap = ccap; leftPen = new Pen(lp.Color, lp.Width * generalizationration); leftPen.CustomStartCap = LinePenStyle.GenerallizationCap; //change to something like lp.CustomStartCap if you have more than one custom cap capsshift = standardsshift; } else if (lp.StartCap == LineCap.ArrowAnchor) { leftPen = new Pen(lp.Color, lp.Width * capsratio); leftPen.StartCap = lp.StartCap; capsshift = arrowshift; } else { leftPen = new Pen(lp.Color, lp.Width * capsratio); leftPen.StartCap = lp.StartCap; capsshift = standardsshift; } } if (lp.EndCap == System.Drawing.Drawing2D.LineCap.NoAnchor) { rightPen = null; } else { if (lp.EndCap == System.Drawing.Drawing2D.LineCap.Custom) { //leftPen.StartCap = System.Drawing.Drawing2D.LineCap.Custom; //AdjustableArrowCap ccap = new AdjustableArrowCap(lp.Width+2, lp.Width+2, true); //leftPen.CustomStartCap = ccap; //rightPen = new Pen(lp.Color, lp.Width * generalizationration); //rightPen.CustomEndCap = lp.CustomEndCap; //capsshift = standardsshift; Pen.CustomEndCap = LinePenStyle.GenerallizationCap; } else if (lp.EndCap == LineCap.ArrowAnchor) { rightPen = new Pen(lp.Color, lp.Width * capsratio); rightPen.EndCap = lp.EndCap; capsshift = arrowshift; } else { rightPen = new Pen(lp.Color, lp.Width * capsratio); rightPen.EndCap = lp.EndCap; capsshift = standardsshift; } } } #endregion }
private void AddConnection(ShapeBase rootShape, ImageRectangle child, Point point, DependencyGraphData dGraphData) { IConnector rootConnector = null; IConnector childConnector = null; if (point.X <= rootShape.X) { if (point.Y < rootShape.Y) { rootConnector = rootShape.Connectors[0]; childConnector = child.Connectors[2]; } else if (point.Y < (rootShape.Y + rootShape.Height)) { rootConnector = rootShape.Connectors[3]; childConnector = child.Connectors[1]; } else { rootConnector = rootShape.Connectors[2]; childConnector = child.Connectors[0]; } } else if (point.X > rootShape.X) { if (point.Y < rootShape.Y) { rootConnector = rootShape.Connectors[0]; childConnector = child.Connectors[2]; } else if (point.Y < (rootShape.Y + rootShape.Height)) { rootConnector = rootShape.Connectors[1]; childConnector = child.Connectors[3]; } else { rootConnector = rootShape.Connectors[2]; childConnector = child.Connectors[0]; } } var pS = new LinePenStyle {EndCap = LineCap.DiamondAnchor}; if (dGraphData.SelectedType == SelectionType.INTERFACE || dGraphData.SelectedType == SelectionType.ABSTRACT) { pS.Color = Color.Chocolate; pS.Width = 2; pS.DashStyle = DashStyle.Dash; } IConnection conn; if (dGraphData.Arrow == GraphDataArrow.TO) { conn = canvas.AddConnection(rootConnector, childConnector); } else { conn = canvas.AddConnection(childConnector, rootConnector); } conn.PenStyle = pS; }