public Pen GetPen() { if (this.BorderWidth > 0 && this.BorderStyle != 0) { Color borderColor = this.BorderColor; int borderWidth = this.BorderWidth; MapDashStyle borderStyle = this.BorderStyle; Pen pen = new Pen(this.BorderColor, (float)this.BorderWidth); pen.DashStyle = MapGraphics.GetPenStyle(this.BorderStyle); pen.Alignment = PenAlignment.Center; return(pen); } return(null); }
internal override void Render(MapGraphics g) { g.StartHotRegion(this); MapDashStyle mapDashStyle = BorderStyle; if (!string.IsNullOrEmpty(Image)) { ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g); imageSmoothingState.Set(); DrawImage(g, image, drawShadow: true); DrawImage(g, image, drawShadow: false); imageSmoothingState.Restore(); } else { string text = "No image."; Font font = new Font("Microsoft Sans Serif", 8.25f); SizeF sizeF = g.MeasureString(text, font); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); PointF absolutePoint = g.GetAbsolutePoint(new PointF(50f, 50f)); new RectangleF(absolutePoint.X, absolutePoint.Y, 0f, 0f).Inflate(sizeF.Width / 2f, sizeF.Height / 2f); using (Brush brush = new SolidBrush(Color.Gray)) { g.DrawString(text, font, brush, absoluteRectangle, stringFormat); } mapDashStyle = MapDashStyle.Solid; } if (mapDashStyle != 0 && BorderColor != Color.Transparent && BorderWidth != 0) { using (GraphicsPath path = GetPath(g)) { using (Pen pen = GetPen()) { AntiAliasing antiAliasing = g.AntiAliasing; if (Angle % 90f == 0f) { g.AntiAliasing = AntiAliasing.None; } g.DrawPath(pen, path); g.AntiAliasing = antiAliasing; } } } g.EndHotRegion(); }
public virtual void DrawBorder(MapGraphics graph, Frame borderSkin, RectangleF rect, Color backColor, MapHatchStyle backHatchStyle, string backImage, MapImageWrapMode backImageMode, Color backImageTranspColor, MapImageAlign backImageAlign, GradientType backGradientType, Color backSecondaryColor, Color borderColor, int borderWidth, MapDashStyle borderStyle) { RectangleF rectangleF = MapGraphics.Round(rect); RectangleF rectangleF2 = rectangleF; float num = (float)(0.30000001192092896 + 0.40000000596046448 * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765.0); Color color = Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num)); num = (float)(num + 0.20000000298023224); Color centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num)); if (borderSkin.PageColor == Color.Transparent) { centerColor = Color.FromArgb(60, 0, 0, 0); } Color.FromArgb((int)((float)(int)backColor.R * num), (int)((float)(int)backColor.G * num), (int)((float)(int)backColor.B * num)); float val = this.defaultRadiusSize; val = Math.Max(val, 2f); val = Math.Min(val, (float)(rect.Width / 2.0)); val = Math.Min(val, (float)(rect.Height / 2.0)); val = (float)Math.Ceiling((double)val); graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect); if (this.drawOutsideTopLeftShadow) { rectangleF2 = rectangleF; rectangleF2.X -= (float)(val * 0.30000001192092896); rectangleF2.Y -= (float)(val * 0.30000001192092896); rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, Color.FromArgb(128, Color.Black), borderSkin.PageColor, this.outsideShadowRate); } rectangleF2 = rectangleF; rectangleF2.X += (float)(val * 0.30000001192092896); rectangleF2.Y += (float)(val * 0.30000001192092896); rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, centerColor, borderSkin.PageColor, this.outsideShadowRate); rectangleF2 = rectangleF; rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius); graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backSecondaryColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset); if (graphicsPath != null) { graphicsPath.Dispose(); } if (this.drawScrews) { RectangleF empty = RectangleF.Empty; float num2 = (float)(val * 0.40000000596046448); empty.X = rectangleF2.X + num2; empty.Y = rectangleF2.Y + num2; empty.Width = (float)(val * 0.550000011920929); empty.Height = empty.Width; this.DrawScrew(graph, empty); empty.X = rectangleF2.Right - num2 - empty.Width; this.DrawScrew(graph, empty); empty.X = rectangleF2.Right - num2 - empty.Width; empty.Y = rectangleF2.Bottom - num2 - empty.Height; this.DrawScrew(graph, empty); empty.X = rectangleF2.X + num2; empty.Y = rectangleF2.Bottom - num2 - empty.Height; this.DrawScrew(graph, empty); } if (this.drawBottomShadow) { rectangleF2 = rectangleF; rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); using (Region region = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X - val, rectangleF2.Y - val, (float)(rectangleF2.Width + 0.5 * val), (float)(rectangleF2.Height + 0.5 * val)), this.cornerRadius))) { region.Complement(graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius)); Region clip = graph.Clip; graph.Clip = region; rectangleF2.X -= (float)(0.5 * val); rectangleF2.Width += (float)(0.5 * val); rectangleF2.Y -= (float)(0.5 * val); rectangleF2.Height += (float)(0.5 * val); graph.DrawRoundedRectShadowAbs(rectangleF2, this.cornerRadius, val, Color.Transparent, Color.FromArgb(175, this.sunken ? Color.White : color), 1f); graph.Clip = clip; } } rectangleF2 = rectangleF; rectangleF2.Width -= (float)(val * 0.30000001192092896); rectangleF2.Height -= (float)(val * 0.30000001192092896); using (Region region2 = new Region(graph.CreateRoundedRectPath(new RectangleF((float)(rectangleF2.X + val * 0.5), (float)(rectangleF2.Y + val * 0.5), (float)(rectangleF2.Width - 0.20000000298023224 * val), (float)(rectangleF2.Height - 0.20000000298023224 * val)), this.cornerRadius))) { RectangleF rect2 = rectangleF2; rect2.Width += val; rect2.Height += val; region2.Complement(graph.CreateRoundedRectPath(rect2, this.cornerRadius)); region2.Intersect(graph.CreateRoundedRectPath(rectangleF2, this.cornerRadius)); Region clip2 = graph.Clip; graph.Clip = region2; graph.DrawRoundedRectShadowAbs(rect2, this.cornerRadius, val, Color.Transparent, Color.FromArgb(175, this.sunken ? color : Color.White), 1f); graph.Clip = clip2; } }
public virtual void DrawBorder(MapGraphics graph, Frame borderSkin, RectangleF rect, Color backColor, MapHatchStyle backHatchStyle, string backImage, MapImageWrapMode backImageMode, Color backImageTranspColor, MapImageAlign backImageAlign, GradientType backGradientType, Color backSecondaryColor, Color borderColor, int borderWidth, MapDashStyle borderStyle) { RectangleF rectangleF = MapGraphics.Round(rect); RectangleF rectangleF2 = rectangleF; float num = 0.2f + 0.4f * (float)(borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f; Color centerColor = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num)); if (borderSkin.PageColor == Color.Transparent) { centerColor = Color.FromArgb(60, 0, 0, 0); } num += 0.2f; Color centerColor2 = Color.FromArgb((int)((float)(int)borderSkin.PageColor.R * num), (int)((float)(int)borderSkin.PageColor.G * num), (int)((float)(int)borderSkin.PageColor.B * num)); float val = 15f; val = Math.Max(val, 2f); val = Math.Min(val, rect.Width / 2f); val = Math.Min(val, rect.Height / 2f); val = (float)Math.Ceiling(val); graph.FillRectangle(new SolidBrush(borderSkin.PageColor), rect); rectangleF2 = rectangleF; rectangleF2.Width -= val * 0.3f; rectangleF2.Height -= val * 0.3f; graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val + 1f, centerColor2, borderSkin.PageColor, 1.4f); rectangleF2 = rectangleF; rectangleF2.X = rectangleF.X + val / 3f; rectangleF2.Y = rectangleF.Y + val / 3f; rectangleF2.Width -= val / 3.5f; rectangleF2.Height -= val / 3.5f; graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, centerColor, borderSkin.PageColor, 1.3f); rectangleF2 = rectangleF; rectangleF2.X = rectangleF.X + 3f; rectangleF2.Y = rectangleF.Y + 3f; rectangleF2.Width -= val * 0.75f; rectangleF2.Height -= val * 0.75f; GraphicsPath graphicsPath = graph.CreateRoundedRectPath(rectangleF2, cornerRadius); graph.DrawPathAbs(graphicsPath, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backSecondaryColor, borderColor, borderWidth, borderStyle, PenAlignment.Inset); graphicsPath?.Dispose(); using (Region region = new Region(graph.CreateRoundedRectPath(new RectangleF(rectangleF2.X - val, rectangleF2.Y - val, rectangleF2.Width + val - val * 0.25f, rectangleF2.Height + val - val * 0.25f), cornerRadius))) { region.Complement(graph.CreateRoundedRectPath(rectangleF2, cornerRadius)); Region clip = graph.Clip; graph.Clip = region; graph.DrawRoundedRectShadowAbs(rectangleF2, cornerRadius, val, Color.Transparent, Color.FromArgb(128, Color.Gray), 0.5f); graph.Clip = clip; } }
public override void DrawBorder(MapGraphics graph, Frame borderSkin, RectangleF rect, Color backColor, MapHatchStyle backHatchStyle, string backImage, MapImageWrapMode backImageMode, Color backImageTranspColor, MapImageAlign backImageAlign, GradientType backGradientType, Color backSecondaryColor, Color borderColor, int borderWidth, MapDashStyle borderStyle) { base.drawBottomShadow = true; base.sunken = false; base.outsideShadowRate = 0.9f; base.drawOutsideTopLeftShadow = false; bool drawScrews = base.drawScrews; base.drawScrews = false; base.DrawBorder(graph, borderSkin, rect, borderSkin.BackColor, borderSkin.BackHatchStyle, borderSkin.BackImage, borderSkin.BackImageMode, borderSkin.BackImageTranspColor, borderSkin.BackImageAlign, borderSkin.BackGradientType, borderSkin.BackSecondaryColor, borderSkin.BorderColor, borderSkin.BorderWidth, borderSkin.BorderStyle); base.drawScrews = drawScrews; rect.X += base.sizeLeftTop.Width; rect.Y += base.sizeLeftTop.Height; rect.Width -= base.sizeRightBottom.Width + base.sizeLeftTop.Width; rect.Height -= base.sizeRightBottom.Height + base.sizeLeftTop.Height; if (rect.Width > 0.0 && rect.Height > 0.0) { float[] array = new float[8]; array = (float[])base.cornerRadius.Clone(); base.cornerRadius = this.innerCorners; base.drawBottomShadow = false; base.sunken = true; base.drawOutsideTopLeftShadow = true; base.outsideShadowRate = 1.4f; Color pageColor = borderSkin.PageColor; borderSkin.PageColor = Color.Transparent; base.DrawBorder(graph, borderSkin, rect, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backSecondaryColor, borderColor, borderWidth, borderStyle); borderSkin.PageColor = pageColor; base.cornerRadius = array; } }