コード例 #1
0
 public void RenderTopImage(GaugeGraphics g)
 {
     if (base.TopImage != "")
     {
         ImageAttributes imageAttributes = new ImageAttributes();
         if (base.TopImageTransColor != Color.Empty)
         {
             imageAttributes.SetColorKey(base.TopImageTransColor, base.TopImageTransColor, ColorAdjustType.Default);
         }
         Image     image    = this.Common.ImageLoader.LoadImage(base.TopImage);
         Rectangle destRect = Rectangle.Round(g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)));
         if (!base.TopImageHueColor.IsEmpty)
         {
             Color       color       = g.TransformHueColor(base.TopImageHueColor);
             ColorMatrix colorMatrix = new ColorMatrix();
             colorMatrix.Matrix00 = (float)((float)(int)color.R / 255.0);
             colorMatrix.Matrix11 = (float)((float)(int)color.G / 255.0);
             colorMatrix.Matrix22 = (float)((float)(int)color.B / 255.0);
             imageAttributes.SetColorMatrix(colorMatrix);
         }
         ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g);
         imageSmoothingState.Set();
         g.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
         imageSmoothingState.Restore();
     }
 }
コード例 #2
0
        internal void DrawImage(GaugeGraphics g, bool drawShadow)
        {
            if (!Visible || (drawShadow && base.ShadowOffset == 0f))
            {
                return;
            }
            Image image = Common.ImageLoader.LoadImage(Image);

            if (image.Width == 0 || image.Height == 0)
            {
                return;
            }
            Point point = new Point(ImageOrigin.X, ImageOrigin.Y);

            if (point.X == 0)
            {
                point.X = image.Width / 2;
            }
            if (point.Y == 0)
            {
                point.Y = image.Height / 2;
            }
            float  absoluteDimension  = g.GetAbsoluteDimension(Width);
            float  absoluteDimension2 = g.GetAbsoluteDimension(MarkerLength);
            float  num  = absoluteDimension / (float)image.Width;
            float  num2 = absoluteDimension2 / (float)image.Height;
            float  num3 = CalculateMarkerDistance();
            float  positionFromValue = GetScale().GetPositionFromValue(base.Position);
            PointF pointF            = Point.Empty;

            pointF = ((GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num3, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num3)));
            Matrix          transform       = g.Transform;
            Matrix          matrix          = g.Transform.Clone();
            Rectangle       rectangle       = new Rectangle((int)(pointF.X - (float)point.X * num) + 1, (int)(pointF.Y - (float)point.Y * num2) + 1, (int)((float)image.Width * num) + 1, (int)((float)image.Height * num2) + 1);
            ImageAttributes imageAttributes = new ImageAttributes();

            if (ImageTransColor != Color.Empty)
            {
                imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default);
            }
            if (drawShadow)
            {
                ColorMatrix colorMatrix = new ColorMatrix();
                colorMatrix.Matrix00 = 0f;
                colorMatrix.Matrix11 = 0f;
                colorMatrix.Matrix22 = 0f;
                colorMatrix.Matrix33 = Common.GaugeCore.ShadowIntensity / 100f;
                imageAttributes.SetColorMatrix(colorMatrix);
                matrix.Translate(base.ShadowOffset, base.ShadowOffset, MatrixOrder.Append);
            }
            else
            {
                ColorMatrix colorMatrix2 = new ColorMatrix();
                if (!ImageHueColor.IsEmpty)
                {
                    Color color = g.TransformHueColor(ImageHueColor);
                    colorMatrix2.Matrix00 = (float)(int)color.R / 255f;
                    colorMatrix2.Matrix11 = (float)(int)color.G / 255f;
                    colorMatrix2.Matrix22 = (float)(int)color.B / 255f;
                }
                colorMatrix2.Matrix33 = 1f - ImageTransparency / 100f;
                imageAttributes.SetColorMatrix(colorMatrix2);
            }
            g.Transform = matrix;
            g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
            g.Transform = transform;
            if (!drawShadow)
            {
                GraphicsPath graphicsPath = new GraphicsPath();
                graphicsPath.AddRectangle(rectangle);
                AddHotRegion(graphicsPath, primary: true);
            }
        }
コード例 #3
0
 public void DrawImage(GaugeGraphics g, bool primary, bool drawShadow)
 {
     if (this.Visible)
     {
         if (drawShadow && base.ShadowOffset == 0.0)
         {
             return;
         }
         float width = this.Width;
         width = g.GetAbsoluteDimension(width);
         Image image = null;
         image = ((!primary) ? this.Common.ImageLoader.LoadImage(this.CapImage) : this.Common.ImageLoader.LoadImage(this.Image));
         if (image.Width != 0 && image.Height != 0)
         {
             Point point = Point.Empty;
             point = ((!primary) ? this.CapImageOrigin : this.ImageOrigin);
             if (point.IsEmpty)
             {
                 point.X = image.Width / 2;
                 point.Y = image.Height / 2;
             }
             int num = (image.Height <= image.Width) ? image.Width : image.Height;
             if (num != 0)
             {
                 float           num2            = (!primary) ? (g.GetAbsoluteDimension((float)(this.CapWidth * 2.0)) / (float)num) : (g.GetAbsoluteDimension((float)(this.Width * 2.0)) / (float)num);
                 Rectangle       rectangle       = new Rectangle(0, 0, (int)((float)image.Width * num2), (int)((float)image.Height * num2));
                 ImageAttributes imageAttributes = new ImageAttributes();
                 if (primary && this.ImageTransColor != Color.Empty)
                 {
                     imageAttributes.SetColorKey(this.ImageTransColor, this.ImageTransColor, ColorAdjustType.Default);
                 }
                 if (!primary && this.CapImageTransColor != Color.Empty)
                 {
                     imageAttributes.SetColorKey(this.CapImageTransColor, this.CapImageTransColor, ColorAdjustType.Default);
                 }
                 Matrix transform         = g.Transform;
                 Matrix matrix            = g.Transform.Clone();
                 float  positionFromValue = this.GetScale().GetPositionFromValue(base.Position);
                 PointF absolutePoint     = g.GetAbsolutePoint(this.GetScale().GetPivotPoint());
                 PointF pointF            = new PointF((float)point.X * num2, (float)point.Y * num2);
                 float  offsetX           = matrix.OffsetX;
                 float  offsetY           = matrix.OffsetY;
                 matrix.Translate(absolutePoint.X - pointF.X, absolutePoint.Y - pointF.Y, MatrixOrder.Append);
                 absolutePoint.X += offsetX;
                 absolutePoint.Y += offsetY;
                 matrix.RotateAt(positionFromValue, absolutePoint, MatrixOrder.Append);
                 if (drawShadow)
                 {
                     ColorMatrix colorMatrix = new ColorMatrix();
                     colorMatrix.Matrix00 = 0f;
                     colorMatrix.Matrix11 = 0f;
                     colorMatrix.Matrix22 = 0f;
                     colorMatrix.Matrix33 = (float)(this.Common.GaugeCore.ShadowIntensity / 100.0);
                     imageAttributes.SetColorMatrix(colorMatrix);
                     matrix.Translate(base.ShadowOffset, base.ShadowOffset, MatrixOrder.Append);
                 }
                 else if (primary && !this.ImageHueColor.IsEmpty)
                 {
                     Color       color        = g.TransformHueColor(this.ImageHueColor);
                     ColorMatrix colorMatrix2 = new ColorMatrix();
                     colorMatrix2.Matrix00 = (float)((float)(int)color.R / 255.0);
                     colorMatrix2.Matrix11 = (float)((float)(int)color.G / 255.0);
                     colorMatrix2.Matrix22 = (float)((float)(int)color.B / 255.0);
                     imageAttributes.SetColorMatrix(colorMatrix2);
                 }
                 else if (!primary && !this.CapImageHueColor.IsEmpty)
                 {
                     Color       color2       = g.TransformHueColor(this.CapImageHueColor);
                     ColorMatrix colorMatrix3 = new ColorMatrix();
                     colorMatrix3.Matrix00 = (float)((float)(int)color2.R / 255.0);
                     colorMatrix3.Matrix11 = (float)((float)(int)color2.G / 255.0);
                     colorMatrix3.Matrix22 = (float)((float)(int)color2.B / 255.0);
                     imageAttributes.SetColorMatrix(colorMatrix3);
                 }
                 g.Transform = matrix;
                 ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g);
                 imageSmoothingState.Set();
                 g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
                 imageSmoothingState.Restore();
                 g.Transform = transform;
                 if (!drawShadow)
                 {
                     matrix.Translate((float)(0.0 - offsetX), (float)(0.0 - offsetY), MatrixOrder.Append);
                     GraphicsPath graphicsPath = new GraphicsPath();
                     graphicsPath.AddRectangle(rectangle);
                     graphicsPath.Transform(matrix);
                     this.AddHotRegion(graphicsPath, primary);
                 }
             }
         }
     }
 }
コード例 #4
0
        internal void DrawFrameImage(GaugeGraphics g)
        {
            GraphicsPath graphicsPath = null;
            Pen          pen          = null;
            Region       region       = null;

            try
            {
                graphicsPath = GetFramePath(g, 0f);
                RectangleF frameRectangle = GetFrameRectangle(g);
                Region     clip           = null;
                if (ClipImage)
                {
                    RenderShadow(g);
                    region = new Region(graphicsPath);
                    clip   = g.Clip;
                    g.Clip = region;
                }
                else if (ShadowOffset != 0f)
                {
                    using (Brush brush = g.GetShadowBrush())
                    {
                        RectangleF rect = frameRectangle;
                        rect.Offset(ShadowOffset, ShadowOffset);
                        g.FillRectangle(brush, rect);
                    }
                }
                ImageAttributes imageAttributes = new ImageAttributes();
                if (ImageTransColor != Color.Empty)
                {
                    imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default);
                }
                Image     image    = Common.ImageLoader.LoadImage(Image);
                Rectangle destRect = new Rectangle((int)Math.Round(frameRectangle.X), (int)Math.Round(frameRectangle.Y), (int)Math.Round(frameRectangle.Width), (int)Math.Round(frameRectangle.Height));
                if (!ImageHueColor.IsEmpty)
                {
                    Color       color       = g.TransformHueColor(ImageHueColor);
                    ColorMatrix colorMatrix = new ColorMatrix();
                    colorMatrix.Matrix00 = (float)(int)color.R / 255f;
                    colorMatrix.Matrix11 = (float)(int)color.G / 255f;
                    colorMatrix.Matrix22 = (float)(int)color.B / 255f;
                    imageAttributes.SetColorMatrix(colorMatrix);
                }
                ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g);
                imageSmoothingState.Set();
                g.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
                imageSmoothingState.Restore();
                if (ClipImage)
                {
                    g.Clip = clip;
                }
                if (BorderWidth > 0 && BorderStyle != 0)
                {
                    pen           = new Pen(BorderColor, BorderWidth);
                    pen.DashStyle = g.GetPenStyle(BorderStyle);
                    pen.Alignment = PenAlignment.Center;
                    if (ClipImage)
                    {
                        g.DrawPath(pen, graphicsPath);
                    }
                    else
                    {
                        g.DrawRectangle(pen, frameRectangle.X, frameRectangle.Y, frameRectangle.Width, frameRectangle.Height);
                    }
                }
            }
            finally
            {
                graphicsPath?.Dispose();
                pen?.Dispose();
                region?.Dispose();
            }
        }