Exemple #1
0
        /// <summary>
        /// Changes the pen style of the selected connection.
        /// </summary>
        private void ChangePenStyle()
        {
            //instantiate the style
            LinePenStyle penStyle = new LinePenStyle();
            //fetch the selected cap
            LineCap cap;

            if ((cap = GetRightCap()) == LineCap.Custom)
            {
                penStyle.EndCap       = LineCap.Custom;
                penStyle.CustomEndCap = LinePenStyle.GenerallizationCap;
            }
            else
            {
                penStyle.EndCap = cap;
            }
            if ((cap = GetLeftCap()) == LineCap.Custom)
            {
                penStyle.StartCap       = LineCap.Custom;
                penStyle.CustomStartCap = LinePenStyle.GenerallizationCap;
            }
            else
            {
                penStyle.StartCap = cap;
            }
            //fetch the other properties
            penStyle.DashStyle = this.lineStylePicker.LineStyle;
            penStyle.Width     = this.lineWidthPicker.LineWidth;
            penStyle.Color     = this.lineColorPicker.Color;
            //call the method; it will change the pe style of the selected entities
            Application.Diagram.ChangeStyle(penStyle);
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        /// <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
        }