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(); } }
public void DrawImage(GaugeGraphics g, string imageName, bool drawShadow) { if (drawShadow && this.ShadowOffset == 0.0) { return; } Image image = this.Common.ImageLoader.LoadImage(imageName); if (image.Width != 0 && image.Height != 0) { RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); Rectangle rectangle = Rectangle.Empty; if (this.ResizeMode == ResizeMode.AutoFit) { rectangle = new Rectangle((int)absoluteRectangle.X, (int)absoluteRectangle.Y, (int)absoluteRectangle.Width, (int)absoluteRectangle.Height); } else { rectangle = new Rectangle(0, 0, image.Width, image.Height); PointF absolutePoint = g.GetAbsolutePoint(new PointF(50f, 50f)); rectangle.X = (int)(absolutePoint.X - (float)(rectangle.Size.Width / 2)); rectangle.Y = (int)(absolutePoint.Y - (float)(rectangle.Size.Height / 2)); } ImageAttributes imageAttributes = new ImageAttributes(); if (this.ImageTransColor != Color.Empty) { imageAttributes.SetColorKey(this.ImageTransColor, this.ImageTransColor, ColorAdjustType.Default); } float num = (float)((100.0 - this.Transparency) / 100.0); float num2 = (float)(this.Common.GaugeCore.ShadowIntensity / 100.0); if (drawShadow) { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = 0f; colorMatrix.Matrix11 = 0f; colorMatrix.Matrix22 = 0f; colorMatrix.Matrix33 = num2 * num; imageAttributes.SetColorMatrix(colorMatrix); } else if (this.Transparency > 0.0) { ColorMatrix colorMatrix2 = new ColorMatrix(); colorMatrix2.Matrix33 = num; imageAttributes.SetColorMatrix(colorMatrix2); } if (this.Angle != 0.0) { PointF point = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0)); Matrix transform = g.Transform; Matrix matrix = g.Transform.Clone(); float offsetX = matrix.OffsetX; float offsetY = matrix.OffsetY; point.X += offsetX; point.Y += offsetY; matrix.RotateAt(this.Angle, point, MatrixOrder.Append); if (drawShadow) { matrix.Translate(this.ShadowOffset, this.ShadowOffset, MatrixOrder.Append); } 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; } else { if (drawShadow) { rectangle.X += (int)this.ShadowOffset; rectangle.Y += (int)this.ShadowOffset; } ImageSmoothingState imageSmoothingState2 = new ImageSmoothingState(g); imageSmoothingState2.Set(); g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); imageSmoothingState2.Restore(); } if (!drawShadow) { GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddRectangle(rectangle); if (this.Angle != 0.0) { PointF point2 = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0)); using (Matrix matrix2 = new Matrix()) { matrix2.RotateAt(this.Angle, point2, MatrixOrder.Append); graphicsPath.Transform(matrix2); } } this.Common.GaugeCore.HotRegionList.SetHotRegion(this, Point.Empty, graphicsPath); } } }
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); } } } } }
public void DrawFrameImage(GaugeGraphics g) { GraphicsPath graphicsPath = null; Pen pen = null; Region region = null; try { graphicsPath = this.GetFramePath(g, 0f); RectangleF frameRectangle = this.GetFrameRectangle(g); Region clip = null; if (this.ClipImage) { this.RenderShadow(g); region = new Region(graphicsPath); clip = g.Clip; g.Clip = region; } else if (this.ShadowOffset != 0.0) { using (Brush brush = g.GetShadowBrush()) { RectangleF rect = frameRectangle; rect.Offset(this.ShadowOffset, this.ShadowOffset); g.FillRectangle(brush, rect); } } ImageAttributes imageAttributes = new ImageAttributes(); if (this.ImageTransColor != Color.Empty) { imageAttributes.SetColorKey(this.ImageTransColor, this.ImageTransColor, ColorAdjustType.Default); } Image image = this.Common.ImageLoader.LoadImage(this.Image); Rectangle destRect = new Rectangle((int)Math.Round((double)frameRectangle.X), (int)Math.Round((double)frameRectangle.Y), (int)Math.Round((double)frameRectangle.Width), (int)Math.Round((double)frameRectangle.Height)); if (!this.ImageHueColor.IsEmpty) { Color color = g.TransformHueColor(this.ImageHueColor); 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(); if (this.ClipImage) { g.Clip = clip; } if (this.BorderWidth > 0 && this.BorderStyle != 0) { pen = new Pen(this.BorderColor, (float)this.BorderWidth); pen.DashStyle = g.GetPenStyle(this.BorderStyle); pen.Alignment = PenAlignment.Center; if (this.ClipImage) { g.DrawPath(pen, graphicsPath); } else { g.DrawRectangle(pen, frameRectangle.X, frameRectangle.Y, frameRectangle.Width, frameRectangle.Height); } } } finally { if (graphicsPath != null) { graphicsPath.Dispose(); } if (pen != null) { pen.Dispose(); } if (region != null) { region.Dispose(); } } }