public Brush GetBackBrush(MapGraphics g, GraphicsPath path)
        {
            RectangleF    bounds        = path.GetBounds();
            Brush         brush         = null;
            Color         color         = this.ApplyLayerTransparency(this.ColorInt);
            Color         color2        = this.ApplyLayerTransparency(this.SecondaryColorInt);
            GradientType  gradientType  = this.GradientTypeInt;
            MapHatchStyle mapHatchStyle = this.HatchStyleInt;

            if (mapHatchStyle != 0)
            {
                return(MapGraphics.GetHatchBrush(mapHatchStyle, color, color2));
            }
            if (gradientType != 0)
            {
                return(g.GetGradientBrush(bounds, color, color2, gradientType));
            }
            return(new SolidBrush(color));
        }
        public Brush GetBackBrush(MapGraphics g)
        {
            RectangleF    absoluteRectangle  = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            Brush         brush              = null;
            Color         backColor          = this.BackColor;
            Color         backSecondaryColor = this.BackSecondaryColor;
            GradientType  backGradientType   = this.BackGradientType;
            MapHatchStyle backHatchStyle     = this.BackHatchStyle;

            if (backHatchStyle != 0)
            {
                brush = MapGraphics.GetHatchBrush(backHatchStyle, backColor, backSecondaryColor);
            }
            else if (backGradientType != 0)
            {
                brush = g.GetGradientBrush(absoluteRectangle, backColor, backSecondaryColor, backGradientType);
                float num = this.DetermineAngle();
                if (num != 0.0)
                {
                    PointF pointF = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0));
                    if (brush is LinearGradientBrush)
                    {
                        ((LinearGradientBrush)brush).TranslateTransform((float)(0.0 - pointF.X), (float)(0.0 - pointF.Y), MatrixOrder.Append);
                        ((LinearGradientBrush)brush).RotateTransform(num, MatrixOrder.Append);
                        ((LinearGradientBrush)brush).TranslateTransform(pointF.X, pointF.Y, MatrixOrder.Append);
                    }
                    else if (brush is PathGradientBrush)
                    {
                        ((PathGradientBrush)brush).TranslateTransform((float)(0.0 - pointF.X), (float)(0.0 - pointF.Y), MatrixOrder.Append);
                        ((PathGradientBrush)brush).RotateTransform(num, MatrixOrder.Append);
                        ((PathGradientBrush)brush).TranslateTransform(pointF.X, pointF.Y, MatrixOrder.Append);
                    }
                }
            }
            else
            {
                brush = new SolidBrush(backColor);
            }
            return(brush);
        }
        private Brush CreateColorBoxBrush(MapGraphics g, RectangleF colorBoxBoundsAbs, int colorIndex)
        {
            if (colorIndex < 0)
            {
                return(new SolidBrush(this.RangeGapColor));
            }
            Brush         brush          = null;
            SwatchColor   swatchColor    = this.Colors[colorIndex];
            Color         color          = swatchColor.Color;
            Color         secondaryColor = swatchColor.SecondaryColor;
            GradientType  gradientType   = swatchColor.GradientType;
            MapHatchStyle hatchStyle     = swatchColor.HatchStyle;

            if (hatchStyle != 0)
            {
                return(MapGraphics.GetHatchBrush(hatchStyle, color, secondaryColor));
            }
            if (gradientType != 0)
            {
                return(g.GetGradientBrush(colorBoxBoundsAbs, color, secondaryColor, gradientType));
            }
            return(new SolidBrush(color));
        }
Exemple #4
0
 public override void PaintValue(PaintValueEventArgs e)
 {
     if (e.Value is MapHatchStyle)
     {
         Color color  = Color.Black;
         Color color2 = Color.White;
         if (e.Context != null && e.Context.PropertyDescriptor != null && e.Context.Instance != null)
         {
             if (e.Context.PropertyDescriptor.Name == "FillHatchStyle")
             {
                 PropertyInfo property = e.Context.Instance.GetType().GetProperty("FillColor");
                 if (property != null)
                 {
                     color = (Color)property.GetValue(e.Context.Instance, null);
                 }
                 property = e.Context.Instance.GetType().GetProperty("FillSecondaryColor");
                 if (property != null)
                 {
                     color2 = (Color)property.GetValue(e.Context.Instance, null);
                 }
             }
             else if (e.Context.PropertyDescriptor.Name == "BackHatchStyle")
             {
                 PropertyInfo property2 = e.Context.Instance.GetType().GetProperty("BackColor");
                 if (property2 != null)
                 {
                     color = (Color)property2.GetValue(e.Context.Instance, null);
                 }
                 property2 = e.Context.Instance.GetType().GetProperty("BackSecondaryColor");
                 if (property2 != null)
                 {
                     color2 = (Color)property2.GetValue(e.Context.Instance, null);
                 }
             }
             else if (e.Context.PropertyDescriptor.Name == "FrameHatchStyle")
             {
                 PropertyInfo property3 = e.Context.Instance.GetType().GetProperty("FrameColor");
                 if (property3 != null)
                 {
                     color = (Color)property3.GetValue(e.Context.Instance, null);
                 }
                 property3 = e.Context.Instance.GetType().GetProperty("FrameSecondaryColor");
                 if (property3 != null)
                 {
                     color2 = (Color)property3.GetValue(e.Context.Instance, null);
                 }
             }
             else if (e.Context.PropertyDescriptor.Name == "NeedleCapFillHatchStyle")
             {
                 PropertyInfo property4 = e.Context.Instance.GetType().GetProperty("NeedleCapFillColor");
                 if (property4 != null)
                 {
                     color = (Color)property4.GetValue(e.Context.Instance, null);
                 }
                 property4 = e.Context.Instance.GetType().GetProperty("NeedleCapFillSecondaryColor");
                 if (property4 != null)
                 {
                     color2 = (Color)property4.GetValue(e.Context.Instance, null);
                 }
             }
             else if (e.Context.PropertyDescriptor.Name == "ThermometerBackHatchStyle")
             {
                 PropertyInfo property5 = e.Context.Instance.GetType().GetProperty("ThermometerBackColor");
                 if (property5 != null)
                 {
                     color = (Color)property5.GetValue(e.Context.Instance, null);
                 }
                 property5 = e.Context.Instance.GetType().GetProperty("ThermometerBackSecondaryColor");
                 if (property5 != null)
                 {
                     color2 = (Color)property5.GetValue(e.Context.Instance, null);
                 }
             }
         }
         if (color == Color.Empty)
         {
             color = Color.Black;
         }
         if (color2 == Color.Empty)
         {
             color2 = Color.White;
         }
         if (color == color2)
         {
             color2 = Color.FromArgb(color.B, color.R, color.G);
         }
         if ((MapHatchStyle)e.Value != 0)
         {
             Brush hatchBrush = MapGraphics.GetHatchBrush((MapHatchStyle)e.Value, color, color2);
             e.Graphics.FillRectangle(hatchBrush, e.Bounds);
             hatchBrush.Dispose();
         }
     }
 }