Ejemplo n.º 1
0
 private void SetArrowHeads(ArrowHeadCombination heads, Pen pen)
 {
     if (heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.START_POINT)
     {
         pen.CustomStartCap = ARROW_CAP;
     }
     if (heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.END_POINT)
     {
         pen.CustomEndCap = ARROW_CAP;
     }
 }
Ejemplo n.º 2
0
        public override void Draw(Graphics graphics, RenderMode rm)
        {
            int  lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            bool shadow        = GetFieldValueAsBool(FieldType.SHADOW);

            if (lineThickness > 0)
            {
                graphics.SmoothingMode      = SmoothingMode.HighQuality;
                graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                graphics.CompositingQuality = CompositingQuality.HighQuality;
                graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                Color lineColor            = GetFieldValueAsColor(FieldType.LINE_COLOR);
                ArrowHeadCombination heads = (ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS);
                if (shadow)
                {
                    //draw shadow first
                    int basealpha   = 100;
                    int alpha       = basealpha;
                    int steps       = 5;
                    int currentStep = 1;
                    while (currentStep <= steps)
                    {
                        using (Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
                            shadowCapPen.Width = lineThickness;
                            SetArrowHeads(heads, shadowCapPen);

                            graphics.DrawLine(shadowCapPen,
                                              this.Left + currentStep,
                                              this.Top + currentStep,
                                              this.Left + currentStep + this.Width,
                                              this.Top + currentStep + this.Height);

                            currentStep++;
                            alpha = alpha - (basealpha / steps);
                        }
                    }
                }
                using (Pen pen = new Pen(lineColor)) {
                    pen.Width = lineThickness;

                    if (pen.Width > 0)
                    {
                        SetArrowHeads(heads, pen);
                        graphics.DrawLine(pen, this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);
                    }
                }
            }
        }
 private void SetArrowHeads(ArrowHeadCombination heads, Pen pen)
 {
     if ( heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.START_POINT ) {
         pen.CustomStartCap = ARROW_CAP;
     }
     if ( heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.END_POINT ) {
         pen.CustomEndCap = ARROW_CAP;
     }
 }