private Bitmap PaintRightNCArea(Padding ncMetrics) { Size thisSize = this.DesiredSize.ToSize(); int thisWidth = thisSize.Width; int thisHeight = thisSize.Height; SizeF scaleSize = this.ScaleTransform; float angleTransform = this.AngleTransform; int bitmapWidth = ncMetrics.Right; int bitmapHeight = thisHeight - ncMetrics.Vertical; if (bitmapWidth <= 0 || bitmapHeight <= 0) { return(null); } Bitmap rightBitmap = new Bitmap(ncMetrics.Right, thisHeight - ncMetrics.Vertical); Graphics rightGraphics = Graphics.FromImage(rightBitmap); using (rightGraphics) { RadGdiGraphics radGraphics = new RadGdiGraphics(rightGraphics); radGraphics.TranslateTransform(-(thisWidth - ncMetrics.Right), -ncMetrics.Top); this.BorderPrimitiveImpl.PaintBorder(radGraphics, angleTransform, scaleSize); } return(rightBitmap); }
private void PaintWithOpacity(Graphics rawGraphics, Image image, Rectangle bounds, float opacity) { ImageAttributes attributes = RadGdiGraphics.GetOpacityAttributes(opacity); int srcWidth = image.Width; int srcHeight = image.Height; switch (this.ImageLayout) { case ImageLayout.None: srcWidth = bounds.Width; srcHeight = bounds.Height; rawGraphics.DrawImage(image, bounds, 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel, attributes); break; case ImageLayout.Tile: for (int y = bounds.X; y <= bounds.Height; y += image.Height) { for (int x = bounds.Y; x <= bounds.Width; x += image.Width) { Rectangle destRect = new Rectangle(x, y, srcWidth, srcHeight); rawGraphics.DrawImage(image, destRect, 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel, attributes); } } break; default: rawGraphics.DrawImage(image, bounds, 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel, attributes); break; } attributes.Dispose(); }
private void PaintWithOpacity( Graphics rawGraphics, Image image, Rectangle bounds, float opacity) { ImageAttributes opacityAttributes = RadGdiGraphics.GetOpacityAttributes(opacity); int width1 = image.Width; int height1 = image.Height; switch (this.ImageLayout) { case ImageLayout.None: int width2 = bounds.Width; int height2 = bounds.Height; rawGraphics.DrawImage(image, bounds, 0, 0, width2, height2, GraphicsUnit.Pixel, opacityAttributes); break; case ImageLayout.Tile: for (int x = bounds.X; x <= bounds.Height; x += image.Height) { for (int y = bounds.Y; y <= bounds.Width; y += image.Width) { Rectangle destRect = new Rectangle(y, x, width1, height1); rawGraphics.DrawImage(image, destRect, 0, 0, width1, height1, GraphicsUnit.Pixel, opacityAttributes); } } break; default: rawGraphics.DrawImage(image, bounds, 0, 0, width1, height1, GraphicsUnit.Pixel, opacityAttributes); break; } opacityAttributes.Dispose(); }
public void GetAsBitmapEx( Graphics memoryGraphics, RadElement element, Brush backColor, float totalAngle, SizeF totalScale) { Size size = element.Size; if (size.Width <= 0 || size.Height <= 0) { return; } memoryGraphics.FillRectangle(backColor, new Rectangle(Point.Empty, size)); memoryGraphics.SmoothingMode = SmoothingMode.HighQuality; memoryGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; memoryGraphics.PixelOffsetMode = PixelOffsetMode.HighQuality; memoryGraphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; RadGdiGraphics radGdiGraphics = new RadGdiGraphics(memoryGraphics); element.SetBitState(8L, true); element.Paint((IGraphics)radGdiGraphics, new Rectangle(Point.Empty, size) { Location = element.LocationToControl() }, totalAngle, totalScale, true); element.SetBitState(8L, false); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; Padding ncMargin = this.parentPanel.NCMargin; RadGdiGraphics radGdiGraphics = new RadGdiGraphics(graphics); radGdiGraphics.TranslateTransform(-ncMargin.Left, -ncMargin.Top); this.parentPanel.RootElement.Paint((IGraphics)radGdiGraphics, e.ClipRectangle, true); radGdiGraphics.TranslateTransform(ncMargin.Left, ncMargin.Top); }
public void SetGraphics(IGraphics g, SizeF scale) { RadGdiGraphics radGdiGraphics = (RadGdiGraphics)g; this.graphics = radGdiGraphics.Graphics; Graphics graphics = Graphics.FromImage((Image)this.paintBuffer); graphics.ScaleTransform(scale.Width, scale.Height); graphics.SmoothingMode = radGdiGraphics.Graphics.SmoothingMode; ((RadGdiGraphics)g).Graphics = graphics; }
private void SetLabelTextAndSize(string text) { this.radLabel1.Size = new Size(0, 0); this.radLabel1.Text = string.Empty; RadGdiGraphics radGdiGraphics = new RadGdiGraphics(this.CreateGraphics()); SizeF sizeF = radGdiGraphics.MeasureString(text, new Font(this.radLabel1.Font.FontFamily, this.radLabel1.Font.Size * this.RootElement.DpiScaleFactor.Height, this.radLabel1.Font.Style), 650, StringFormat.GenericDefault); radGdiGraphics.Dispose(); this.radLabel1.Size = sizeF.ToSize(); this.radLabel1.Text = text; this.SetSizeAndLocations(); }
public static Size MeasureText(string text, Font font) { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { graphics.TextRenderingHint = TextRenderingHint.SystemDefault; Size size = TextRenderer.MeasureText((IDeviceContext)graphics, text, font, Size.Empty, TextFormatFlags.NoClipping | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.NoPadding); if (TextBoxWrapPanel.IsTab(text)) { size.Width = RadGdiGraphics.GetTextMetric(font).aveCharWidth * 4; } return(size); } }
private void PaintBorders(Graphics hDCGraphics) { Rectangle rectangle1 = new Rectangle(0, this.ClientMargin.Top, this.ClientMargin.Left, this.Form.Height - this.ClientMargin.Top); Rectangle rectangle2 = new Rectangle(this.Form.Width - this.ClientMargin.Right, this.ClientMargin.Top, this.ClientMargin.Right, this.Form.Height - this.ClientMargin.Top); Rectangle rectangle3 = new Rectangle(this.ClientMargin.Left, this.Form.Height - this.ClientMargin.Bottom, this.Form.Width - (this.ClientMargin.Left + this.ClientMargin.Right), this.ClientMargin.Bottom); if (rectangle1.Width > 0 && rectangle1.Height > 0) { Bitmap bitmap = new Bitmap(rectangle1.Width, rectangle1.Height); using (Graphics graphics = Graphics.FromImage((Image)bitmap)) { RadGdiGraphics radGdiGraphics = new RadGdiGraphics(graphics); radGdiGraphics.TranslateTransform(-rectangle1.X, -rectangle1.Y); radGdiGraphics.FillRectangle(rectangle1, this.Form.RootElement.BackColor); this.PaintElement((IGraphics)radGdiGraphics, rectangle1, (VisualElement)this.Form.RootElement); } hDCGraphics.DrawImage((Image)bitmap, rectangle1); bitmap.Dispose(); } if (rectangle2.Width > 0 && rectangle2.Height > 0) { Bitmap bitmap = new Bitmap(rectangle2.Width, rectangle2.Height); using (Graphics graphics = Graphics.FromImage((Image)bitmap)) { RadGdiGraphics radGdiGraphics = new RadGdiGraphics(graphics); radGdiGraphics.TranslateTransform(-rectangle2.X, -rectangle2.Y); radGdiGraphics.FillRectangle(rectangle2, this.Form.RootElement.BackColor); this.PaintElement((IGraphics)radGdiGraphics, rectangle2, (VisualElement)this.Form.RootElement); } hDCGraphics.DrawImage((Image)bitmap, rectangle2); bitmap.Dispose(); } if (rectangle3.Width <= 0 || rectangle3.Height <= 0) { return; } Bitmap bitmap1 = new Bitmap(rectangle3.Width, rectangle3.Height); using (Graphics graphics = Graphics.FromImage((Image)bitmap1)) { RadGdiGraphics radGdiGraphics = new RadGdiGraphics(graphics); radGdiGraphics.TranslateTransform(-rectangle3.X, -rectangle3.Y); radGdiGraphics.FillRectangle(rectangle3, this.Form.RootElement.BackColor); this.PaintElement((IGraphics)radGdiGraphics, rectangle3, (VisualElement)this.Form.RootElement); } hDCGraphics.DrawImage((Image)bitmap1, rectangle3); bitmap1.Dispose(); }
private static float GetBaseLineFromFont(Font font) { int hashCode = font.GetHashCode(); if (FormattedText.baseLines == null) { FormattedText.baseLines = new Dictionary <int, float>(4); } if (FormattedText.baseLines.ContainsKey(hashCode)) { return(FormattedText.baseLines[hashCode]); } FontTextMetrics textMetric = RadGdiGraphics.GetTextMetric(font); FormattedText.baseLines.Add(hashCode, (float)textMetric.ascent); return((float)textMetric.ascent); }
public void PaintFill(IGraphics graphics, GraphicsPath clippingPath, RectangleF paintRect) { graphics.ChangeSmoothingMode(this.fillElement.SmoothingMode); if (clippingPath != null) { graphics.PushCurrentClippingPath(clippingPath); } if (this.fillElement.GradientStyle == GradientStyles.Radial) { RadGdiGraphics radGdiGraphics = graphics as RadGdiGraphics; if (radGdiGraphics != null) { int val2 = 4; int numberOfColors = this.fillElement.NumberOfColors; Color[] colorStops = new Color[Math.Min(Math.Max(numberOfColors, 1), val2)]; float[] colorOffsets = new float[Math.Min(Math.Max(numberOfColors, 1), val2)]; FillPrimitiveImpl.FillColorStopsAndOffsets(colorStops, colorOffsets, numberOfColors, this.fillElement); radGdiGraphics.FillGradientPath(clippingPath, paintRect, colorStops, colorOffsets, this.fillElement.GradientStyle, this.fillElement.GradientAngle, this.fillElement.GradientPercentage, this.fillElement.GradientPercentage2); } } else if (this.fillElement.GradientStyle == GradientStyles.Linear) { using (PathGradientBrush pathGradientBrush = new PathGradientBrush(clippingPath)) { pathGradientBrush.CenterPoint = new PointF(paintRect.X + paintRect.Width / 2f, paintRect.Y + paintRect.Height / 2f); pathGradientBrush.CenterColor = this.fillElement.BackColor2; pathGradientBrush.SurroundColors = new Color[1] { this.fillElement.BackColor }; pathGradientBrush.SetBlendTriangularShape(this.fillElement.GradientPercentage, this.fillElement.GradientPercentage2); ((Graphics)graphics.UnderlayGraphics).FillPath((Brush)pathGradientBrush, clippingPath); } } else { this.FillRectangle(graphics, paintRect); } if (clippingPath != null) { graphics.PopCurrentClippingPath(); } graphics.RestoreSmoothingMode(); }
private void radButton1_Click(object sender, EventArgs e) { Bitmap bitmap = new Bitmap((int)this.radMap1.MapElement.ViewportInPixels.Size.Width, (int)this.radMap1.MapElement.ViewportInPixels.Height); Graphics g = Graphics.FromImage(bitmap); RadGdiGraphics gg = new RadGdiGraphics(g); foreach (MapVisualElement element in this.radMap1.MapElement.Providers[0].GetContent(this.radMap1.MapElement)) { element.Paint(gg, this.radMap1.MapElement); } object state = gg.SaveState(); gg.TranslateTransform(-this.radMap1.MapElement.ViewportInPixels.X, -this.radMap1.MapElement.ViewportInPixels.Y); this.radMap1.MapElement.Layers["PinsLayer"].Paint(gg, this.radMap1.MapElement); gg.RestoreState(state); bitmap.Save(@"..\..\test.png", ImageFormat.Png); }
private void PaintTitleBar(Graphics hDCGraphics) { if (this.ClientMargin.Top <= 0 || this.Form.Width <= 0) { return; } Bitmap offscreenBitMap = new Bitmap(this.Form.Width, this.ClientMargin.Top); Rectangle clipRectangle = new Rectangle(0, 0, offscreenBitMap.Width, offscreenBitMap.Height); using (Graphics g = Graphics.FromImage(offscreenBitMap)) { RadGdiGraphics radGraphics = new RadGdiGraphics(g); this.PaintElement(radGraphics, clipRectangle, this.Form.RootElement); } hDCGraphics.DrawImage(offscreenBitMap, clipRectangle); offscreenBitMap.Dispose(); }
private Bitmap PaintBottomNCArea(Padding ncMetrics) { Size thisSize = this.DesiredSize.ToSize(); int thisWidth = thisSize.Width; int thisHeight = thisSize.Height; SizeF scaleSize = this.ScaleTransform; float angleTransform = this.AngleTransform; int bitmapWidth = thisWidth; int bitmapHeight = ncMetrics.Bottom; if (bitmapWidth <= 0 || bitmapHeight <= 0) { return(null); } Padding borderThickness = this.GetBorderThickness(false); Bitmap bottomBitmap = new Bitmap(thisWidth, ncMetrics.Bottom); Graphics bottomGraphics = Graphics.FromImage(bottomBitmap); using (bottomGraphics) { Padding footerMargin = this.Footer.Margin; RadGdiGraphics radGraphics = new RadGdiGraphics(bottomGraphics); using (SolidBrush backGroundBrush = new SolidBrush(this.BackColor)) { Bitmap footerBitmap = this.Footer.GetAsBitmap(backGroundBrush, angleTransform, scaleSize); if (footerBitmap != null) { bottomGraphics.DrawImage(footerBitmap, new Point(borderThickness.Left + footerMargin.Left, -footerMargin.Bottom - borderThickness.Bottom)); } } radGraphics.TranslateTransform(0, -(thisHeight - ncMetrics.Bottom)); this.BorderPrimitiveImpl.PaintBorder(radGraphics, angleTransform, scaleSize); } return(bottomBitmap); }
public void SetGraphics(IGraphics g, SizeF scale) { RadGdiGraphics gdiGraphics = (RadGdiGraphics)g; this.graphics = gdiGraphics.Graphics; Graphics newGraphics = Graphics.FromImage(this.paintBuffer); newGraphics.ScaleTransform(scale.Width, scale.Height); //Fixed issue with smoothing mode and FillPath by changing SmoothingMode //TODO: should we copy other graphics state properties? //newGraphics.TextRenderingHint = gdiGraphics.Graphics.TextRenderingHint; //newGraphics.InterpolationMode = gdiGraphics.Graphics.InterpolationMode; //newGraphics.TextContrast = gdiGraphics.Graphics.TextContrast; newGraphics.SmoothingMode = gdiGraphics.Graphics.SmoothingMode; ((RadGdiGraphics)g).Graphics = newGraphics; }
private void PaintTitleBar(Graphics hDCGraphics) { if (this.ClientMargin.Top <= 0 || this.Form.Width <= 0) { return; } Bitmap bitmap = new Bitmap(this.Form.Width, this.ClientMargin.Top); Rectangle rectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height); using (Graphics graphics = Graphics.FromImage((Image)bitmap)) { RadGdiGraphics radGdiGraphics = new RadGdiGraphics(graphics); if (this.FormElement != null && ((double)this.FormElement.DpiScaleFactor.Width != 1.0 || (double)this.FormElement.DpiScaleFactor.Height != 1.0)) { graphics.Clear(((VisualElement)this.FormElement).BackColor); } this.PaintElement((IGraphics)radGdiGraphics, rectangle, (VisualElement)this.Form.RootElement); } hDCGraphics.DrawImage((Image)bitmap, rectangle); bitmap.Dispose(); }
private Bitmap PaintTopNCArea(Padding ncMetrics) { Size thisSize = this.DesiredSize.ToSize(); int thisWidth = thisSize.Width; SizeF scaleSize = this.ScaleTransform; float angleTransform = this.AngleTransform; int bitmapWidth = thisWidth; int bitmapHeight = ncMetrics.Top; if (bitmapWidth <= 0 || bitmapHeight <= 0) { return(null); } Padding borderThickness = this.GetBorderThickness(false); Bitmap topBitmap = new Bitmap(thisWidth, ncMetrics.Top); Graphics topGraphics = Graphics.FromImage(topBitmap); using (topGraphics) { Padding headerMargin = this.Header.Margin; RadGdiGraphics radGraphics = new RadGdiGraphics(topGraphics); using (SolidBrush backGroundBrush = new SolidBrush(this.BackColor)) { Bitmap headerBitmap = this.Header.GetAsBitmap(backGroundBrush, angleTransform, scaleSize); if (headerBitmap != null) { topGraphics.DrawImage(headerBitmap, new Point(borderThickness.Left + headerMargin.Left, borderThickness.Top + headerMargin.Top)); } } this.BorderPrimitiveImpl.PaintBorder(radGraphics, angleTransform, scaleSize); } return(topBitmap); }
public override void DrawSeriesParts() { CustomCartesianRenderer customRenderer = this.Renderer as CustomCartesianRenderer; Graphics graphics = customRenderer.Graphics; RadGdiGraphics radGraphics = new RadGdiGraphics(graphics); for (int j = 0; j < this.Element.DataPoints.Count; j++) { DataPoint dataPoint = this.Element.DataPoints[j]; RadRect slot = dataPoint.LayoutSlot; if ((bool)dataPoint.GetType().GetField("isEmpty", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(dataPoint)) { continue; } RectangleF barBounds = new RectangleF((float)(this.OffsetX + slot.X), (float)(this.OffsetY + slot.Y), (float)slot.Width, (float)slot.Height); bool isAreaVertical = (((CartesianSeries)this.Element).Parent as CartesianArea).Orientation == System.Windows.Forms.Orientation.Vertical; DataPointElement childElement = (DataPointElement)this.Element.Children[j]; if (isAreaVertical) { float realHeight = barBounds.Height * childElement.HeightAspectRatio; barBounds.Y += barBounds.Height - realHeight; barBounds.Height = realHeight; } else { float realWidth = barBounds.Width * childElement.HeightAspectRatio; barBounds.Width = realWidth; } barBounds = AdjustBarDataPointBounds(childElement, barBounds); if (isAreaVertical) { barBounds.Width = Math.Max(barBounds.Width, 1f); } else { barBounds.Height = Math.Max(barBounds.Height, 1f); } RadImageShape background = childElement.BackgroundShape; if (background != null) { background.Paint(graphics, barBounds); } FillPrimitiveImpl fill = new FillPrimitiveImpl(childElement, null); fill.PaintFill(radGraphics, 0, new SizeF(1, 1), barBounds); BorderPrimitiveImpl border = new BorderPrimitiveImpl(childElement, null); border.PaintBorder(radGraphics, 0, new SizeF(1, 1), barBounds); if (childElement.Image != null) { graphics.SetClip(barBounds); ImagePrimitiveImpl pointImage = new ImagePrimitiveImpl(childElement); pointImage.PaintImage(radGraphics, childElement.Image, barBounds, childElement.ImageLayout, childElement.ImageAlignment, childElement.ImageOpacity, false); graphics.ResetClip(); } float xOffset = 20; float yOffset = 20; GraphicsPath path = new GraphicsPath(); List <PointF> lines = new List <PointF>(); lines.Add(new PointF(barBounds.Right, barBounds.Y)); lines.Add(new PointF(barBounds.Right + xOffset, barBounds.Y - yOffset)); lines.Add(new PointF(barBounds.Right + xOffset, barBounds.Bottom - yOffset)); lines.Add(new PointF(barBounds.Right, barBounds.Bottom)); path.AddLines(lines.ToArray()); path.CloseFigure(); using (Pen pen = new Pen(this.Element.BorderColor), pen2 = new Pen(Color.FromArgb(100, Color.Black))) { graphics.DrawPath(pen, path); graphics.DrawPath(pen2, path); } using (Brush brush = new SolidBrush(this.Element.BackColor), brush2 = new SolidBrush(Color.FromArgb(100, Color.Black))) { graphics.FillPath(brush, path); graphics.FillPath(brush2, path); } if (this.DrawCap) { path = new GraphicsPath(); lines = new List <PointF>(); lines.Add(new PointF(barBounds.X, barBounds.Y)); lines.Add(new PointF(barBounds.X + xOffset, barBounds.Y - yOffset)); lines.Add(new PointF(barBounds.Right + xOffset, barBounds.Y - yOffset)); lines.Add(new PointF(barBounds.Right, barBounds.Y)); path.AddLines(lines.ToArray()); path.CloseFigure(); using (Pen pen = new Pen(this.Element.BorderColor), pen2 = new Pen(Color.FromArgb(100, Color.White))) { graphics.DrawPath(pen, path); graphics.DrawPath(pen2, path); } using (Brush brush = new SolidBrush(this.Element.BackColor), brush2 = new SolidBrush(Color.FromArgb(100, Color.White))) { graphics.FillPath(brush, path); graphics.FillPath(brush2, path); } using (StringFormat sf = new StringFormat(StringFormat.GenericTypographic)) { object category = ((CategoricalDataPoint)dataPoint).Category; string text = customRenderer.Summaries[category].ToString(); SizeF textSize = graphics.MeasureString(text, this.summaryFont); RectangleF rect = ChartRenderer.ToRectangleF(slot); rect.Offset(this.Element.View.Margin.Right + (rect.Width - textSize.Width) / 2, this.Element.View.Margin.Top + textSize.Height - 10); radGraphics.DrawString(text, rect, this.summaryFont, Color.Black, sf, System.Windows.Forms.Orientation.Horizontal, false); } } } }
protected override void DrawArea() { CartesianRenderer renderer = (CartesianRenderer)this.Renderer; AreaSeries area = this.Element as AreaSeries; Graphics graphics = renderer.Graphics; RadGdiGraphics radGraphics = new RadGdiGraphics(graphics); RectangleF rect = ChartRenderer.ToRectangleF(this.Element.Model.LayoutSlot); RectangleF clipRect = (RectangleF)renderer.Area .GetType() .GetMethod("GetCartesianClipRect", BindingFlags.Instance | BindingFlags.NonPublic) .Invoke(renderer.Area, new object[] { }); PointF topLeft = new PointF(clipRect.X, clipRect.Y); PointF topRight = new PointF(clipRect.Right - 1, clipRect.Y); PointF lowerRight = new PointF(clipRect.Right - 1, clipRect.Bottom - 1); PointF lowerLeft = new PointF(clipRect.X, clipRect.Bottom - 1); List <PointF[]> allPoints = GetPointsPositionsArrays(); float zeroOnTheYAxis = (float)this.GetLocationOfValue(0, (NumericalAxis)area.VerticalAxis); lowerLeft.Y = zeroOnTheYAxis; lowerRight.Y = zeroOnTheYAxis; foreach (PointF[] points in allPoints) { if (points.Length < 2) { continue; } GraphicsPath fillPath = this.GetLinePaths(points); if (fillPath == null) { continue; } if (this.Element.View.GetArea <CartesianArea>().Orientation == System.Windows.Forms.Orientation.Vertical) { if (area.VerticalAxis.IsInverse) { fillPath.AddLine(points[points.Length - 1], new PointF(points[points.Length - 1].X, topRight.Y)); fillPath.AddLine(topRight, topLeft); fillPath.AddLine(new PointF(points[0].X, topLeft.Y), points[0]); } else { fillPath.AddLine(points[points.Length - 1], new PointF(points[points.Length - 1].X, lowerRight.Y)); fillPath.AddLine(lowerRight, lowerLeft); fillPath.AddLine(new PointF(points[0].X, lowerLeft.Y), points[0]); } } else { if (area.HorizontalAxis.IsInverse) { fillPath.AddLine(points[points.Length - 1], topRight); fillPath.AddLine(topRight, lowerRight); fillPath.AddLine(lowerRight, points[0]); } else { fillPath.AddLine(points[points.Length - 1], topLeft); fillPath.AddLine(topLeft, lowerLeft); fillPath.AddLine(lowerLeft, points[0]); } } FillPrimitiveImpl fill = new FillPrimitiveImpl(this.Element, null); fill.PaintFill(radGraphics, fillPath, clipRect); GraphicsPath borderPath = new GraphicsPath(); AreaSeries series = (AreaSeries)this.Element; borderPath = new GraphicsPath(); if (series.StrokeMode == AreaSeriesStrokeMode.All || series.StrokeMode == AreaSeriesStrokeMode.AllButPlotLine || series.StrokeMode == AreaSeriesStrokeMode.LeftAndPoints || series.StrokeMode == AreaSeriesStrokeMode.LeftLine) { if (this.Element.View.GetArea <CartesianArea>().Orientation == System.Windows.Forms.Orientation.Vertical) { if (area.VerticalAxis.IsInverse) { borderPath.AddLine(topLeft, points[0]); } else { borderPath.AddLine(lowerLeft, points[0]); } } else { if (area.HorizontalAxis.IsInverse) { borderPath.AddLine(lowerRight, points[0]); } else { borderPath.AddLine(lowerLeft, points[0]); } } } if (series.StrokeMode == AreaSeriesStrokeMode.All || series.StrokeMode == AreaSeriesStrokeMode.AllButPlotLine || series.StrokeMode == AreaSeriesStrokeMode.LeftAndPoints || series.StrokeMode == AreaSeriesStrokeMode.Points || series.StrokeMode == AreaSeriesStrokeMode.RightAndPoints) { GraphicsPath path = GetLinePaths(points); if (path != null) { borderPath.AddPath(path, true); } } if (series.StrokeMode == AreaSeriesStrokeMode.All || series.StrokeMode == AreaSeriesStrokeMode.AllButPlotLine || series.StrokeMode == AreaSeriesStrokeMode.RightAndPoints || series.StrokeMode == AreaSeriesStrokeMode.RightLine) { if (this.Element.View.GetArea <CartesianArea>().Orientation == System.Windows.Forms.Orientation.Vertical) { if (area.VerticalAxis.IsInverse) { borderPath.AddLine(points[points.Length - 1], topRight); } else { borderPath.AddLine(points[points.Length - 1], lowerRight); } } else { if (area.HorizontalAxis.IsInverse) { borderPath.AddLine(points[points.Length - 1], topRight); } else { borderPath.AddLine(points[points.Length - 1], topLeft); } } } if (series.StrokeMode == AreaSeriesStrokeMode.All || series.StrokeMode == AreaSeriesStrokeMode.PlotLine) { if (this.Element.View.GetArea <CartesianArea>().Orientation == System.Windows.Forms.Orientation.Vertical) { if (area.VerticalAxis.IsInverse) { borderPath.AddLine(topRight, topLeft); } else { borderPath.AddLine(lowerRight, lowerLeft); } } else { if (area.HorizontalAxis.IsInverse) { borderPath.AddLine(topRight, lowerRight); } else { borderPath.AddLine(lowerLeft, topLeft); } } } BorderPrimitiveImpl border = new BorderPrimitiveImpl(this.Element, null); border.PaintBorder(radGraphics, null, borderPath, rect); if (series.Image != null) { graphics.SetClip(fillPath); ImagePrimitiveImpl image = new ImagePrimitiveImpl(series); image.PaintImage(radGraphics, series.Image, clipRect, series.ImageLayout, series.ImageAlignment, series.ImageOpacity, false); graphics.ResetClip(); } } }
private void PaintBorders(Graphics hDCGraphics) { Rectangle leftBorderRect = new Rectangle( 0, this.ClientMargin.Top, this.ClientMargin.Left, this.Form.Height - this.ClientMargin.Top ); Rectangle rightBorderRect = new Rectangle( this.Form.Width - (this.ClientMargin.Right), this.ClientMargin.Top, this.ClientMargin.Right, this.Form.Height - this.ClientMargin.Top); Rectangle bottomBorderRect = new Rectangle( this.ClientMargin.Left, this.Form.Height - (this.ClientMargin.Bottom), this.Form.Width - (this.ClientMargin.Left + this.ClientMargin.Right), this.ClientMargin.Bottom); if (leftBorderRect.Width > 0 && leftBorderRect.Height > 0) { Bitmap leftBorderOffscreen = new Bitmap(leftBorderRect.Width, leftBorderRect.Height); using (Graphics g = Graphics.FromImage(leftBorderOffscreen)) { RadGdiGraphics radGraphics = new RadGdiGraphics(g); radGraphics.TranslateTransform(-leftBorderRect.X, -leftBorderRect.Y); radGraphics.FillRectangle(leftBorderRect, this.Form.RootElement.BackColor); PaintElement(radGraphics, leftBorderRect, this.Form.RootElement); } hDCGraphics.DrawImage(leftBorderOffscreen, leftBorderRect); leftBorderOffscreen.Dispose(); } if (rightBorderRect.Width > 0 && rightBorderRect.Height > 0) { Bitmap rightBorderOffscreen = new Bitmap(rightBorderRect.Width, rightBorderRect.Height); using (Graphics g = Graphics.FromImage(rightBorderOffscreen)) { RadGdiGraphics radGraphics = new RadGdiGraphics(g); radGraphics.TranslateTransform(-rightBorderRect.X, -rightBorderRect.Y); radGraphics.FillRectangle(rightBorderRect, this.Form.RootElement.BackColor); PaintElement(radGraphics, rightBorderRect, this.Form.RootElement); } hDCGraphics.DrawImage(rightBorderOffscreen, rightBorderRect); rightBorderOffscreen.Dispose(); } if (bottomBorderRect.Width > 0 && bottomBorderRect.Height > 0) { Bitmap bottomBorderOffscreen = new Bitmap(bottomBorderRect.Width, bottomBorderRect.Height); using (Graphics g = Graphics.FromImage(bottomBorderOffscreen)) { RadGdiGraphics radGraphics = new RadGdiGraphics(g); radGraphics.TranslateTransform(-bottomBorderRect.X, -bottomBorderRect.Y); radGraphics.FillRectangle(bottomBorderRect, this.Form.RootElement.BackColor); PaintElement(radGraphics, bottomBorderRect, this.Form.RootElement); } hDCGraphics.DrawImage(bottomBorderOffscreen, bottomBorderRect); bottomBorderOffscreen.Dispose(); } }
protected virtual void PaintText(Graphics g, RectangleF rect) { Padding textPadding = this.TextPadding; if (string.IsNullOrEmpty(this.Text) || !this.DrawText) { return; } if (this.EnableHtmlTextRendering && this.Text.Contains("<html>")) { TextPrimitiveHtmlImpl primitiveHtmlImpl = new TextPrimitiveHtmlImpl(); RadGdiGraphics radGdiGraphics = new RadGdiGraphics(g); TextParams textParams = new TextParams(); textParams.alignment = this.TextAlignment; textParams.ClipText = true; textParams.font = this.Font; textParams.foreColor = this.ForeColor; textParams.paintingRectangle = rect; textParams.rightToLeft = this.RightToLeft; textParams.text = this.Text; textParams.textWrap = true; if (textPadding != Padding.Empty) { textParams.paintingRectangle.X += (float)textPadding.Left; textParams.paintingRectangle.Y += (float)textPadding.Top; textParams.paintingRectangle.Width -= (float)textPadding.Horizontal; textParams.paintingRectangle.Height -= (float)textPadding.Vertical; } primitiveHtmlImpl.PaintPrimitive((IGraphics)radGdiGraphics, textParams); } else { using (StringFormat format = new StringFormat()) { using (SolidBrush solidBrush = new SolidBrush(this.ForeColor)) { format.Alignment = this.GetHorizontalAlignment(this.TextAlignment); format.LineAlignment = this.GetVerticalAlignment(this.TextAlignment); format.Trimming = this.StringTrimming; format.FormatFlags = this.StringFormatFlags; if (textPadding != Padding.Empty) { rect.X += (float)textPadding.Left; rect.Y += (float)textPadding.Top; rect.Width -= (float)textPadding.Horizontal; rect.Height -= (float)textPadding.Vertical; } string s = this.Text; if (s.Length > RadGdiGraphics.GdiStringLengthLimit) { s = s.Substring(0, RadGdiGraphics.GdiStringLengthLimit); } try { g.DrawString(s, this.Font, (Brush)solidBrush, rect, format); } catch { try { using (Font font = new Font(this.Font, FontStyle.Regular)) g.DrawString(s, font, (Brush)solidBrush, rect, format); } catch { g.DrawString(s, Control.DefaultFont, (Brush)solidBrush, rect, format); } } } } } }