protected override void OnPaint(GUI.PaintEventArgs e) { base.OnPaint(e); Bitmap bitmap = Bitmap; if (bitmap != null) { if (m_Opacity < 1) { m_Opacity += OpacityIncrement; if (m_Opacity > 1) { m_Opacity = 1; } Matrix4 mtx = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y); double scale = m_Scale; mtx.Scale(scale, scale, MatrixOrder.Append); mtx.Rotate(m_Rotation, MatrixOrder.Append); mtx.Multiply(Matrix4.CreateSkewing(m_SkewX / 500.0, m_SkewY / 500.0), MatrixOrder.Append); mtx.Translate(m_x, m_y, MatrixOrder.Append); using (Graphics graphics = Graphics.FromImage(bitmap)) { graphics.Opacity = m_Opacity; m_SVGPath.Render(graphics, mtx); } } e.Graphics.DrawImage(bitmap); } }
void OnHtmlLabelHostingPanelPaint(object sender, GUI.PaintEventArgs e) { if (m_TransparentBGBrush != null) { e.Graphics.FillRectangle(m_TransparentBGBrush, _htmlLabelHostingPanel.ClientRectangle); } }
void Client_Paint(object sender, GUI.PaintEventArgs e) { Color color = Color.White; if (m_InvertCheckBox.IsChecked) { color = Color.Black; } e.Graphics.Clear(color); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; string fontFileName = FontFileName; if (string.IsNullOrEmpty(fontFileName)) { return; } double x = 20; double y = 40; double k = m_HeightSlider.Value; y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, k * 12, Color.Black); y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, k * 16, Color.Green); y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, k * 20, Color.YellowGreen); y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, k * 24, Color.Orange); y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, k * 36, Color.Red); y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, k * 48, Color.Blue); }
void DrawingPanel_Paint(object sender, GUI.PaintEventArgs e) { if (m_svgDoc == null) { return; } e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; Matrix4 mtx = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y); double scale = m_ScaleSlider.Value; mtx.Scale(scale, scale, MatrixOrder.Append); mtx.Rotate(m_RotateSlider.Value, MatrixOrder.Append); mtx.Translate(m_x, m_y, MatrixOrder.Append); e.Graphics.Transform = mtx.ToMatrix(); /*m_svgDoc.Transforms = new SvgTransformCollection(); * m_svgDoc.Transforms.Add(new SvgScale(1, 1)); * m_svgDoc.Width = new SvgUnit(m_svgDoc.Width.Type, m_svgDoc.Width * 0.25f); * m_svgDoc.Height = new SvgUnit(m_svgDoc.Height.Type, m_svgDoc.Height);*/ e.Graphics.Opacity = m_OpacitySlider.Value; m_svgDoc.Draw(e.Graphics); }
void DrawingPanel_Paint(object sender, GUI.PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; double scale = m_ScaleSlider.Value; e.Graphics.TranslateTransform(scale * m_x, scale * m_y); Matrix4 mtx = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y); mtx.Scale(scale, scale, MatrixOrder.Append); mtx.Rotate(m_RotateSlider.Value, MatrixOrder.Append); //mtx.Translate(m_x, m_y, MatrixOrder.Append); m_SVGPath.Expand = m_ExpandSlider.Value; e.Graphics.Opacity = m_OpacitySlider.Value; #if GEOMETRY_TRANSFORMATIONS m_SVGPath.Render(e.Graphics, mtx); #else e.Graphics.Transform = mtx.ToMatrix(); m_SVGPath.Render(e.Graphics); #endif }
protected override void OnPaint(GUI.PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; graphics.SmoothingMode = SmoothingMode.AntiAlias; GraphicsPath outlinePath = Common.GraphicsPath_AltSketch; Rect outlinePathBounds = Common.GraphicsPath_AltSketch_Bounds; Point offset = new Point(-5, -5); Rect bounds = Rect.Union(outlinePathBounds, new Rect(offset, outlinePathBounds.Size)); Point textOffset = ((Size - bounds.Size) / 2).ToPoint(); graphics.TranslateTransform(textOffset.X * 0.5, textOffset.Y * 0.63); graphics.FillPath(m_ShadowBrush1, outlinePath); graphics.TranslateTransform(offset); graphics.FillPath(m_FillBrush1, outlinePath); graphics.DrawPath(m_ContourPen1.Color, outlinePath, m_OutlineThicknessSlider.Value); graphics.TranslateTransform(textOffset.X, textOffset.Y * 0.6); graphics.FillPath(m_ShadowBrush2, outlinePath); graphics.TranslateTransform(offset); graphics.FillPath(m_FillBrush2, outlinePath); graphics.DrawPath(m_ContourPen2.Color, outlinePath, m_OutlineThicknessSlider.Value); }
void DrawingPanel_Paint(object sender, GUI.PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; double scale = m_ScaleSlider.Value; e.Graphics.TranslateTransform(scale * m_x, scale * m_y); // Outlined Matrix4 mtx = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y); mtx.Scale(scale, scale, MatrixOrder.Append); mtx.Rotate(m_RotateSlider.Value, MatrixOrder.Append); //mtx.Translate(m_x, m_y, MatrixOrder.Append); GeometryStroke stroke = new GeometryStroke(); stroke.Width = m_ScaleSlider.Value; stroke.LineJoin = LineJoin.Round; e.Graphics.Opacity = m_OpacitySlider.Value; #if GEOMETRY_TRANSFORMATIONS m_SVGPath.Render(e.Graphics, mtx, stroke); #else e.Graphics.Transform = mtx.ToMatrix(); m_SVGPath.Render(e.Graphics, stroke); #endif }
protected override void OnPaint(GUI.PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.None; PolygonElement polygon = m_PolygonElement; if (!polygon.IsModified) { //TEST return; } polygon.close(m_CloseCheckBox.IsChecked); PolylineGeometry poly = new PolylineGeometry(polygon.Polygon, true, m_CloseCheckBox.IsChecked); BSplineGeometry bspline = new BSplineGeometry(poly); bspline.InterpolationStep = 1.0 / m_PointsNumberSlider.Value; SinglePathTransform tcurve = new SinglePathTransform(); tcurve.PreserveXScale = m_PreserveXScaleCheckBox.IsChecked; if (m_FixedLenCheckBox.IsChecked) { tcurve.BaseLength = 1120; } tcurve.AddPath(bspline); GeometryTransformer ftrans = new GeometryTransformer(GetCurveTransformedTextGeometry(tcurve.TotalLength).Item1, tcurve); if (m_FillCheckBox.IsChecked) { Brush brush = m_TextBrush; // Irrlicht Renderer can't render smoothed gradients now if (graphics.RenderSystemName.Contains(Graphics.RSN_Irrlicht)) { if (m_TextBrush_Irrlicht == null) { m_TextBrush_Irrlicht = new SolidColorBrush(Color.Yellow); } brush = m_TextBrush_Irrlicht; } graphics.FillGeometry(brush, ftrans); } if (m_OutlineCheckBox.IsChecked) { graphics.DrawGeometry(m_FillCheckBox.IsChecked ? Color.Red : Color.White, ftrans, m_OutlineThicknessSlider.Value); } graphics.DrawGeometry(m_BSplinePen, bspline); base.OnPaint(e); }
protected override void OnPaint(GUI.PaintEventArgs e) { base.OnPaint(e); if (testSelection != testIndex) { testIndex = testSelection; StartTest(testIndex); ResetView(); m_ExampleNumberLabel.Text = "Ex " + (testIndex + 1).ToString("0") + "/" + testCount.ToString("0"); } Graphics graphics = e.Graphics; if (!DoubleBuffered) { graphics.FillRectangle(Color.FromArgb((graphics is SoftwareGraphics) ? 96 : 192, Color.Black), ClientRectangle); } else { graphics.Clear(Color.FromArgb((graphics is SoftwareGraphics) ? 96 : 192, Color.Black)); } graphics.SmoothingMode = entry.solidDraw ? SmoothingMode.None : SmoothingMode.AntiAlias; test.DebugView.m_Graphics = graphics; test.DebugView.m_Font = m_InfoFont; test.m_Scale = viewZoom * System.Math.Min(ClientWidth, ClientHeight) / 39; test.m_CenterX = ClientWidth / 2 + test.m_OffsetX * test.m_Scale; test.m_CenterY = ClientHeight / 2 + test.m_OffsetY * test.m_Scale; m_TPSCounter.Tick(); settings.Hz = m_TPSCounter.TPS; if (test != null) { test.TextLine = 30; test.Update(settings); } test.m_CenterX = ClientWidth / 2 + test.m_OffsetX * test.m_Scale; test.m_CenterY = ClientHeight / 2 + test.m_OffsetY * test.m_Scale; test.DebugView.SetViewTransform(test.m_CenterX, test.m_CenterY, test.m_Scale); test.DrawTitle(30, 15, entry.Name); test.DebugView.RenderDebugData(); }
void ImagePanel_Paint(object sender, GUI.PaintEventArgs e) { if (m_BGThread != null) { if (m_BGThread.IsAlive) { lock (m_LogCache) { if (m_LogCache.Count > 0) { foreach (string text in m_LogCache) { TableRow row = m_Log.AddRow(text); row.SetTextColor(Color.DarkBlue); } m_LogCache.Clear(); m_Log.ScrollToBottom(); } } } else { m_BGThread = null; m_TopLabel.Text = label_TOP_text; } } Bitmap image; lock (m_ImageLock) { if (m_Image == null) { return; } image = m_Image; if (image == null) { return; } m_ImagePanel.Size = image.PixelSize; e.Graphics.DrawImage(image, PointI.Zero); } }
// Paint points void pointsPanel_Paint(object sender, GUI.PaintEventArgs e) { Graphics g = e.Graphics; using (Brush brush = new SolidColorBrush(Color.Blue)) { // draw all points for (int i = 0, n = points.GetLength(0); i < n; i++) { g.FillEllipse(brush, points[i, 0] - 2, points[i, 1] - 2, 5, 5); } } }
void ImagePanel_Paint(object sender, GUI.PaintEventArgs e) { if (m_NeedRepaint) { CreateBitmap(); m_NeedRepaint = false; } if (m_Image != null) { e.Graphics.DrawImage(m_Image, PointI.Zero); } }
protected override void OnPaint(GUI.PaintEventArgs e) { base.OnPaint(e); if (testSelection != testIndex) { testIndex = testSelection; entry = TestEntries.g_testEntries[testIndex]; test = entry.createFcn(); viewZoom = 1.0; m_OffsetX = 0; m_OffsetY = 0; m_ExampleNumberLabel.Text = "Ex " + (testIndex + 1).ToString("0") + "/" + testCount.ToString("0"); } Graphics graphics = e.Graphics; if (!DoubleBuffered) { graphics.FillRectangle(Color.FromArgb((graphics is SoftwareGraphics) ? 96 : 192, Color.Black), ClientRectangle); } else { graphics.Clear(Color.FromArgb((graphics is SoftwareGraphics) ? 96 : 192, Color.Black)); } graphics.SmoothingMode = entry.solidDraw ? SmoothingMode.None : SmoothingMode.AntiAlias; test._debugDraw.m_Graphics = graphics; test._debugDraw.m_Font = m_InfoFont; m_Scale = viewZoom * System.Math.Min(ClientWidth, ClientHeight) / 39; m_CenterX = ClientWidth / 2 + m_OffsetX; m_CenterY = ClientHeight * 0.85 + m_OffsetY; test._debugDraw.SetViewTransform(m_CenterX, m_CenterY, m_Scale); m_TPSCounter.Tick(); test.SetTextLine(30); settings.hz = m_TPSCounter.TPS;// settingsHz; test.Step(settings); test.DrawTitle(50, 15, entry.name); }
protected override void OnPaint(GUI.PaintEventArgs e) { Alt.Sketch.Graphics graphics = e.Graphics; if (!DoubleBuffered) { graphics.FillRectangle(Alt.Sketch.Color.FromArgb((graphics is SoftwareGraphics) ? 128 : 192, Alt.Sketch.Color.DodgerBlue), ClientRectangle); } else { graphics.Clear(Alt.Sketch.Color.FromArgb((graphics is SoftwareGraphics) ? 128 : 192, Alt.Sketch.Color.DodgerBlue)); } //Paint base.OnPaint(e); }
void PreviewPanel_Paint(object sender, GUI.PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; // Small Filled Matrix4 mtx = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y); double scale = m_SmallScale; mtx.Scale(scale, scale, MatrixOrder.Append); mtx.Rotate(m_RotateSlider.Value, MatrixOrder.Append); mtx.Translate( m_ScaleControl.Right + m_SVGPathBounds.Width * scale / 2 + 10, m_RotateControl.Bottom + m_SVGPathBounds.Height * scale / 2 + 10, MatrixOrder.Append); m_SVGPath.Render(e.Graphics, mtx); }
protected override void OnPaint(GUI.PaintEventArgs e) { base.OnPaint(e); if (!string.IsNullOrEmpty(Info)) { if (m_Font == null) { m_Font = new Font("Arial", 14, FontStyle.Bold); } SizeI size = e.Graphics.MeasureString(Info, m_Font).ToSizeI(); e.Graphics.DrawString(Info, m_Font, Brushes.White, new Point((Width - size.Width) / 2, (Height - size.Height) / 2)); } }
// Paint map void mapPanel_Paint(object sender, GUI.PaintEventArgs e) { if (mapBitmap == null) { return; } Graphics g = e.Graphics; // lock System.Threading.Monitor.Enter(this); // drat image g.DrawImage(mapBitmap, (ClientWidth - mapBitmap.PixelWidth) / 2, (ClientHeight - mapBitmap.PixelHeight) / 2); // unlock System.Threading.Monitor.Exit(this); }
protected override void OnPaint(GUI.PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; graphics.SmoothingMode = SmoothingMode.AntiAlias; Geometry outlinePath = GeometryMatrix4Transformer. CreateOptimizedTransformer(Common.GraphicsPath_AltSketch, Matrix4.CreateScaling(0.9 * ClientWidth / Common.GraphicsPath_AltSketch_Bounds.Width)); Rect outlinePathBounds = outlinePath.Bounds; Point textOffset = ((ClientSize - outlinePathBounds.Size) / 2).ToPoint(); graphics.TranslateTransform(textOffset.X, textOffset.Y - outlinePathBounds.Top); GeometryVertexCommandAndFlags flag = GeometryVertexCommandAndFlags.None; if (rbCloseCW.IsChecked) { flag = GeometryVertexCommandAndFlags.FlagCW; } else if (rbCloseCCW.IsChecked) { flag = GeometryVertexCommandAndFlags.FlagCCW; } SpecialContourGeometry specialContourGeometry = new SpecialContourGeometry(outlinePath, flag); FlattenCurveGeometry curve = new FlattenCurveGeometry(specialContourGeometry); GeometryContour contour = new GeometryContour(curve); contour.Width = m_WidthSlider.Value; contour.AutoDetectOrientation = m_AutoDetectCheckBox.IsChecked; graphics.FillGeometry(m_FillBrush, contour); graphics.DrawGeometry(m_ContourPen, contour); }
void DrawingPanel_Paint(object sender, GUI.PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; // Transformed Matrix4 mtx = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y); double scale = m_ScaleSlider.Value; mtx.Scale(scale, scale, MatrixOrder.Append); mtx.Rotate(m_RotateSlider.Value, MatrixOrder.Append); int k = 30; mtx.Translate(ClientWidth / 2 + k, ClientHeight / 2 + k, MatrixOrder.Append); Point center = new Point(m_x, m_y); WarpMagnifierTransform warpMagnifierTransform = new WarpMagnifierTransform(); warpMagnifierTransform.Center = center; warpMagnifierTransform.Magnification = m_MagnificationSlider.Value; warpMagnifierTransform.Radius = m_RadiusSlider.Value / warpMagnifierTransform.Magnification; SVGWarpMagnifier WarpMagnifier = new SVGWarpMagnifier(warpMagnifierTransform); double opacity = e.Graphics.Opacity; e.Graphics.Opacity = m_OpacitySlider.Value; m_SVGPath.Render(e.Graphics, mtx, WarpMagnifier); e.Graphics.Opacity = opacity; // radius if (m_ShowSightCheckBox.IsChecked) { e.Graphics.DrawCircle(m_RadiusPen, center, m_RadiusSlider.Value); double crossSize = 10; e.Graphics.DrawLine(m_RadiusPen, new Point(center.X - crossSize, center.Y), new Point(center.X + crossSize, center.Y)); e.Graphics.DrawLine(m_RadiusPen, new Point(center.X, center.Y - crossSize), new Point(center.X, center.Y + crossSize)); } }
protected override void OnPaint(GUI.PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; PolygonElement polygon = m_PolygonElement; polygon.close(m_CloseCheckBox.IsChecked); PolylineGeometry poly = new PolylineGeometry(polygon.Polygon, true, m_CloseCheckBox.IsChecked); BSplineGeometry bspline = new BSplineGeometry(poly); bspline.InterpolationStep = 1.0 / m_PointsNumberSlider.Value; e.Graphics.DrawGeometry(m_BSplinePen, bspline); base.OnPaint(e); }
void Client_Paint(object sender, GUI.PaintEventArgs e) { Graphics graphics = e.Graphics; Color color = Color.WhiteSmoke; graphics.Clear(color); if (m_AtlasBitmap != null) { int x = (m_Client.ClientWidth - m_AtlasBitmap.PixelWidth) / 2; int y = (m_Client.ClientHeight - m_AtlasBitmap.PixelHeight) / 2; x = Math.Min(x, y); x = 15; RectI rect = new RectI(x - 1, y - 1, m_AtlasBitmap.PixelSize + SizeI.One); graphics.FillRectangle(Color.White, rect); graphics.DrawImage(m_AtlasBitmap, x, y); graphics.DrawRectangle(Color.DodgerBlue * 0.6, rect); x = x * 2 + m_AtlasBitmap.PixelWidth; y = m_Client.ClientHeight / 2; m_FontAtlas.GetFont(0).DrawString(graphics, x, y - 170, "Font 1"); m_FontAtlas.GetFont(1).DrawString(graphics, x, y - 70, "Font 2"); m_FontAtlas.GetFont(2).DrawString(graphics, x, y - 10, "Font 3"); m_FontAtlas.GetFont(3).DrawString(graphics, x, y + 50, "Font 4"); m_FontAtlas.GetFont(4).DrawString(graphics, x, y + 100, "Font 5"); } Font font = new Font("Times New Roman", 36); string s = "Texture Atlas"; SizeI size = graphics.MeasureString(s, font).ToSizeI(); graphics.DrawString(s, font, Brushes.Red, (m_Client.ClientSize - size).ToPointI() - new Point(10, 3)); }
void Client_Paint(object sender, GUI.PaintEventArgs e) { if (m_HeightSlider.Value != m_OldHeight) { m_OldHeight = m_HeightSlider.Value; m_WidthSlider.Value = m_HeightSlider.Value; } Color color = Color.White; if (m_InvertCheckBox.IsChecked) { color = Color.Black; } e.Graphics.Clear(color); string fontFileName = FontFileName; if (string.IsNullOrEmpty(fontFileName)) { return; } double x = 20; double height = m_HeightSlider.Value; double y = height + 20; y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, height, Color.Black, SimpleFont.GlyphRenderType.Gray8); y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, height, Color.Black, SimpleFont.GlyphRenderType.Mono); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; y = DrawText(e.Graphics, fontFileName, Common.ShortText, x, y, height, Color.Black, SimpleFont.GlyphRenderType.Outline); }
void panel2_Paint(object sender, GUI.PaintEventArgs e) { Graphics graphics = e.Graphics; bool isSoftwareGraphics = graphics is SoftwareGraphics; //if (isSoftwareGraphics) { graphics.SmoothingMode = SmoothingMode.AntiAlias; } // Two simple paths if (rbGeometry5.IsChecked) { GraphicsPath ps1_path = new GraphicsPath(); double x = m_X - m_DrawingPanel.ClientRectangle.Center.X / 2 + 100; double y = m_Y - m_DrawingPanel.ClientRectangle.Center.Y / 2 + 100; ps1_path.MoveTo(x + 140, y + 145); ps1_path.LineTo(x + 225, y + 44); ps1_path.LineTo(x + 296, y + 219); ps1_path.ClosePolygon(); ps1_path.LineTo(x + 226, y + 289); ps1_path.LineTo(x + 82, y + 292); ps1_path.MoveTo(x + 220, y + 222); ps1_path.LineTo(x + 363, y + 249); ps1_path.LineTo(x + 265, y + 331); ps1_path.MoveTo(x + 242, y + 243); ps1_path.LineTo(x + 268, y + 309); ps1_path.LineTo(x + 325, y + 261); ps1_path.MoveTo(x + 259, y + 259); ps1_path.LineTo(x + 273, y + 288); ps1_path.LineTo(x + 298, y + 266); Rect ps1Bounds = ps1_path.Bounds; GeometryTransformer ps1 = GeometryMatrix4Transformer.CreateOptimizedTransformer(ps1_path, Matrix4.CreateTranslation( m_X - ps1Bounds.Center.X, m_Y - ps1Bounds.Center.Y)); GraphicsPath ps2_path = new GraphicsPath(); ps2_path.MoveTo(100 + 32, 100 + 77); ps2_path.LineTo(100 + 473, 100 + 263); ps2_path.LineTo(100 + 351, 100 + 290); ps2_path.LineTo(100 + 354, 100 + 374); Rect ps2Bounds = ps2_path.Bounds; GeometryTransformer ps2 = GeometryMatrix4Transformer.CreateOptimizedTransformer(ps2_path, Matrix4.CreateTranslation( (m_DrawingPanel.Width - ps2Bounds.Width) / 2 - ps2Bounds.Left, (m_DrawingPanel.Height - ps2Bounds.Height) / 2 - ps2Bounds.Top)); graphics.FillGeometry(m_GeometryBColor, ps2); graphics.FillGeometry(m_GeometryAColor, ps1); CombinedGeometry clp = new CombinedGeometry(ps1, ps2, CombinedGeometry.CombineMode.Or, CombinedGeometry.FillType.NonZero, CombinedGeometry.FillType.NonZero); PerformRendering(graphics, clp); } // Closed stroke else if (rbGeometry4.IsChecked) { GraphicsPath ps1_path = new GraphicsPath(); double x = m_X - m_DrawingPanel.ClientRectangle.Center.X / 2 + 100; double y = m_Y - m_DrawingPanel.ClientRectangle.Center.Y / 2 + 100; ps1_path.MoveTo(x + 140, y + 145); ps1_path.LineTo(x + 225, y + 44); ps1_path.LineTo(x + 296, y + 219); ps1_path.ClosePolygon(); ps1_path.LineTo(x + 226, y + 289); ps1_path.LineTo(x + 82, y + 292); ps1_path.MoveTo(x + 220 - 50, y + 222); ps1_path.LineTo(x + 265 - 50, y + 331); ps1_path.LineTo(x + 363 - 50, y + 249); ps1_path.ClosePolygon(GeometryVertexCommandAndFlags.FlagCCW); Rect ps1Bounds = ps1_path.Bounds; GeometryTransformer ps1 = GeometryMatrix4Transformer.CreateOptimizedTransformer(ps1_path, Matrix4.CreateTranslation( m_X - ps1Bounds.Center.X, m_Y - ps1Bounds.Center.Y)); GraphicsPath ps2_path = new GraphicsPath(); ps2_path.MoveTo(100 + 32, 100 + 77); ps2_path.LineTo(100 + 473, 100 + 263); ps2_path.LineTo(100 + 351, 100 + 290); ps2_path.LineTo(100 + 354, 100 + 374); ps2_path.ClosePolygon(); Rect ps2Bounds = ps2_path.Bounds; GeometryTransformer ps2 = GeometryMatrix4Transformer.CreateOptimizedTransformer(ps2_path, Matrix4.CreateTranslation( (m_DrawingPanel.Width - ps2Bounds.Width) / 2 - ps2Bounds.Left, (m_DrawingPanel.Height - ps2Bounds.Height) / 2 - ps2Bounds.Top)); GeometryStroke stroke = new GeometryStroke(ps2, 10); graphics.FillGeometry(m_GeometryBColor, stroke); graphics.FillGeometry(m_GeometryAColor, ps1); CombinedGeometry clp = new CombinedGeometry(ps1, stroke, CombinedGeometry.CombineMode.Or, CombinedGeometry.FillType.NonZero, CombinedGeometry.FillType.NonZero); PerformRendering(graphics, clp); } // Great Britain and Arrows else if (rbGeometry3.IsChecked) { Geometry poly = GreatBritain; Rect polyBounds = poly.Bounds; double scale = 3; Matrix4 mtx = Matrix4.CreateTranslation(-polyBounds.Center.X, -polyBounds.Center.Y); mtx *= Matrix4.CreateScaling(scale, scale); mtx *= Matrix4.CreateTranslation(m_DrawingPanel.Width / 2, m_DrawingPanel.Height / 2); GeometryTransformer trans_gb_poly = GeometryMatrix4Transformer.CreateOptimizedTransformer(poly, mtx); Geometry arrows = Arrows; Rect arrowsBounds = arrows.Bounds; mtx = Matrix4.CreateTranslation(-arrowsBounds.Center.X, -arrowsBounds.Center.Y); mtx *= Matrix4.CreateScaling(scale, scale); mtx *= Matrix4.CreateTranslation(m_X, m_Y); GeometryTransformer trans_arrows = GeometryMatrix4Transformer.CreateOptimizedTransformer(arrows, mtx); CombinedGeometry clp = new CombinedGeometry(trans_gb_poly, trans_arrows, CombinedGeometry.CombineMode.Or, CombinedGeometry.FillType.NonZero, CombinedGeometry.FillType.NonZero); graphics.FillGeometry(m_GeometryBColor, trans_gb_poly); graphics.DrawGeometry(isSoftwareGraphics ? m_GreatBritainContourPen_SWR : m_GreatBritainContourPen_HWR, trans_gb_poly); graphics.FillGeometry(m_GeometryAColor, trans_arrows); PerformRendering(graphics, clp); } // Great Britain and a Spiral else if (rbGeometry2.IsChecked) { Geometry poly = GreatBritain; Rect polyBounds = poly.Bounds; double scale = 3; Matrix4 mtx = Matrix4.CreateTranslation(-polyBounds.Center.X, -polyBounds.Center.Y); mtx *= Matrix4.CreateScaling(scale, scale); mtx *= Matrix4.CreateTranslation(m_DrawingPanel.Width / 2, m_DrawingPanel.Height / 2); GeometryTransformer trans_gb_poly = GeometryMatrix4Transformer.CreateOptimizedTransformer(poly, mtx); Geometry sp = GeometryMatrix4Transformer.CreateOptimizedTransformer(Spiral, Matrix4.CreateTranslation(m_X, m_Y)); GeometryStroke stroke = new GeometryStroke(sp, 15); CombinedGeometry clp = new CombinedGeometry(trans_gb_poly, stroke, CombinedGeometry.CombineMode.Or, CombinedGeometry.FillType.NonZero, CombinedGeometry.FillType.NonZero); graphics.FillGeometry(m_GeometryBColor, trans_gb_poly); graphics.DrawGeometry(isSoftwareGraphics ? m_GreatBritainContourPen_SWR : m_GreatBritainContourPen_HWR, trans_gb_poly); graphics.DrawGeometry(m_SpiralPen, sp); PerformRendering(graphics, clp); } // Spiral and text else if (rbGeometry1.IsChecked) { Geometry text = Text; Rect textBounds = text.Bounds; GeometryTransformer transformedText = GeometryMatrix4Transformer.CreateOptimizedTransformer(text, Matrix4.CreateTranslation( (m_DrawingPanel.Width - textBounds.Width) / 2 - textBounds.Left, (m_DrawingPanel.Height - textBounds.Height) / 2 - textBounds.Top)); Geometry sp = GeometryMatrix4Transformer.CreateOptimizedTransformer(Spiral, Matrix4.CreateTranslation(m_X, m_Y)); GeometryStroke stroke = new GeometryStroke(sp, 15); CombinedGeometry clp = new CombinedGeometry(stroke, transformedText, CombinedGeometry.CombineMode.Or, CombinedGeometry.FillType.NonZero, CombinedGeometry.FillType.NonZero); graphics.FillGeometry(m_GeometryBColor, transformedText); graphics.DrawGeometry(m_SpiralPen, sp); PerformRendering(graphics, clp); } }
protected override void OnPaint(GUI.PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; PolarTransform polarTransform = new PolarTransform(); polarTransform.FullCircle = -600; polarTransform.BaseScale = -1; polarTransform.SetBaseOffset(0, m_BaseYSlider.Value); polarTransform.SetTranslation(ClientWidth / 2.0, ClientHeight / 2.0 - 30.0); polarTransform.Spiral = m_SpiralSlider.Value; // Draw Background RectangleGeometry borderGeometry = new RectangleGeometry(0, 0, m_TextBox.Width, m_TextBox.Height); // Just for little optimization GeometrySegmentator borderGeometrySegmentator = new GeometrySegmentator(borderGeometry); GeometryTransformer borderGeometrySegmentatorPolarTransformer = new GeometryTransformer(borderGeometrySegmentator, polarTransform); graphics.FillGeometry(Color.WhiteSmoke, borderGeometrySegmentatorPolarTransformer); // Selection if (m_TextBox.HasSelectionAndVisible) { RectangleGeometry selectionGeometry = new RectangleGeometry(m_TextBox.SelectionBounds // Just to prevent some artefacts - new PointI(0, 1) + new SizeI(0, 2)); FillGeometry(graphics, polarTransform, m_TextBox.SelectionColor, selectionGeometry); } // Caret if (m_TextBox.IsCaretVisible) { RectangleGeometry caretGeometry = new RectangleGeometry(m_TextBox.CaretBounds); FillGeometry(graphics, polarTransform, Color.Black, caretGeometry); } // Draw Border graphics.DrawGeometry(Color.DodgerBlue, borderGeometrySegmentatorPolarTransformer, 2); // Text Font font = m_TextBox.Font; GraphicsPath textGeometry = new GraphicsPath(); textGeometry.AddString( m_TextBox.Text, font.FontFamily, font.Style, font.Size * 96.0 / 72.0, new Point(4, 1), StringFormat.GenericTypographic); FlattenCurveGeometry textFlattenGeometry = new FlattenCurveGeometry(textGeometry); // Need for clip text Geometry clippedTextFlattenGeometry = new FlattenCurveGeometry( new CombinedGeometry(textFlattenGeometry, new RectangleGeometry(1, 1, m_TextBox.Width - 2, m_TextBox.Height - 2), CombinedGeometry.CombineMode.And)); FillGeometry(graphics, polarTransform, m_TextBox.TextColor, clippedTextFlattenGeometry); }
protected override void OnPaint(GUI.PaintEventArgs e) { UpdateDrawOffset(); Graphics g = e.Graphics; g.TranslateTransform(m_DrawOffset); if (image != null) { //g.DrawImage(image, rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); g.DrawImage(image, PointI.One); RectI r = image.PixelRectangle + SizeI.One; if (r.X > 0) { r.X -= 1; r.Width += 2; } if (r.Y > 0) { r.Y -= 1; r.Height += 2; } g.DrawRectangle(Color.DodgerBlue * 0.6, r); #if !SILVERLIGHT && !UNITY_WEBPLAYER Pen highlightPen = new Pen(Color.Red); Pen highlightPenBold = new Pen(Color.FromArgb(0, 255, 0), 3); Pen rectPen = new Pen(Color.Blue); foreach (Blob blob in blobs) { Pen pen = (blob.ID == selectedBlobID) ? highlightPenBold : highlightPen; if ((showRectangleAroundSelection) && (blob.ID == selectedBlobID)) { g.DrawRectangle(rectPen, blob.Rectangle); } switch (highlighting) { case HightlightType.ConvexHull: g.DrawPolygon(pen, PointsListToArray(hulls[blob.ID])); break; case HightlightType.LeftAndRightEdges: DrawEdge(g, pen, leftEdges[blob.ID]); DrawEdge(g, pen, rightEdges[blob.ID]); break; case HightlightType.TopAndBottomEdges: DrawEdge(g, pen, topEdges[blob.ID]); DrawEdge(g, pen, bottomEdges[blob.ID]); break; case HightlightType.Quadrilateral: g.DrawPolygon(pen, PointsListToArray(quadrilaterals[blob.ID])); break; } } #endif } else { g.FillRectangle(new SolidColorBrush(Color.FromArgb(128, 128, 128)), ClientRectangle);//rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); } base.OnPaint(e); }
protected override void OnPaint(GUI.PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.None; // Polygon1 PolygonElement polygon1 = m_PolygonElement1; PolylineGeometry path1 = new PolylineGeometry(polygon1.Polygon, true, false); BSplineGeometry bspline1 = new BSplineGeometry(path1); bspline1.InterpolationStep = 1.0 / m_PointsNumberSlider.Value; // Polygon2 PolygonElement polygon2 = m_PolygonElement2; PolylineGeometry path2 = new PolylineGeometry(polygon2.Polygon, true, false); BSplineGeometry bspline2 = new BSplineGeometry(path2); bspline1.InterpolationStep = 1.0 / m_PointsNumberSlider.Value; DoublePathTransform tcurve = new DoublePathTransform(); tcurve.PreserveXScale = m_PreserveXScaleCheckBox.IsChecked; if (m_FixedLenCheckBox.IsChecked) { tcurve.BaseLength = 1140.0; } tcurve.AddPaths(bspline1, bspline2); Tuple <Geometry, double> geometry = GetCurveTransformedTextGeometry(tcurve.TotalLength1); tcurve.BaseHeight = FontAscentInPixels + geometry.Item2 + 3; GeometryTransformer ftrans = new GeometryTransformer(geometry.Item1, tcurve); if (m_FillCheckBox.IsChecked) { Brush brush = m_TextBrush; // Irrlicht Renderer can't render smoothed gradients now if (graphics.RenderSystemName.Contains(Graphics.RSN_Irrlicht)) { if (m_TextBrush_Irrlicht == null) { m_TextBrush_Irrlicht = new SolidColorBrush(Color.LawnGreen); } brush = m_TextBrush_Irrlicht; } graphics.FillGeometry(brush, ftrans); } if (m_OutlineCheckBox.IsChecked) { graphics.DrawGeometry(Color.White, ftrans, m_OutlineThicknessSlider.Value); } graphics.DrawGeometry(m_BSplinePen, bspline1); graphics.DrawGeometry(m_BSplinePen, bspline2); base.OnPaint(e); }
void DrawingPanel_Paint(object sender, GUI.PaintEventArgs e) { GUI.Cursor.Current = GUI.Cursors.WaitCursor; Graphics graphics = e.Graphics; SmoothingMode fillSmoothingMode = graphics is SoftwareGraphics ? SmoothingMode.AntiAlias : SmoothingMode.None; SmoothingMode strokeSmoothingMode = SmoothingMode.AntiAlias; graphics.SmoothingMode = fillSmoothingMode; graphics.Clear(Color.White); GraphicsPath path = new GraphicsPath(); if (rbNonZero.IsChecked) { path.FillMode = FillMode.Winding; } //draw subjects ... foreach (Polygon pg in subjects) { Point[] pts = PolygonToPointArray(pg, scale); path.AddPolygon(pts); pts = null; } Pen myPen = new Pen( //Color.FromArgb(196, 0xC3, 0xC9, 0xCF), Color.FromArgb(128, 0, 0, 255), 0.6); SolidColorBrush myBrush = new SolidColorBrush( //Color.FromArgb(127, 0xDD, 0xDD, 0xF0)); //Color.FromArgb(255, 210, 210, 255)); Color.FromArgb(127, Color.LightBlue)); graphics.SmoothingMode = fillSmoothingMode; graphics.FillPath(myBrush, path); graphics.SmoothingMode = strokeSmoothingMode; graphics.DrawPath(myPen, path); path.Reset(); //draw clips ... if (rbNonZero.IsChecked) { path.FillMode = FillMode.Winding; } foreach (Polygon pg in clips) { Point[] pts = PolygonToPointArray(pg, scale); path.AddPolygon(pts); pts = null; } myPen.Color = Color.FromArgb(128, Color.Red); //0xF9, 0xBE, 0xA6); myBrush.Color = //Color.FromArgb(127, 0xFF, 0xE0, 0xE0); Color.FromArgb(50, 255, 0, 0); graphics.SmoothingMode = fillSmoothingMode; graphics.FillPath(myBrush, path); graphics.SmoothingMode = strokeSmoothingMode; graphics.DrawPath(myPen, path); //do the clipping ... if ((clips.Count > 0 || subjects.Count > 0) && !rbNone.IsChecked) { Polygons solution2 = new Polygons(); Clipper c = new Clipper(0); c.AddPaths(subjects, PolyType.ptSubject, true); c.AddPaths(clips, PolyType.ptClip, true); solution.Clear(); bool succeeded = c.Execute(GetClipType(), solution, GetPolyFillType(), GetPolyFillType()); if (succeeded) { myBrush.Color = Color.Black; path.Reset(); //It really shouldn't matter what FillMode is used for solution //polygons because none of the solution polygons overlap. //However, FillMode.Winding will show any orientation errors where //holes will be stroked (outlined) correctly but filled incorrectly ... path.FillMode = FillMode.Winding; //or for something fancy ... if (nudOffset.Value != 0) { //old solution2 = Clipper.OffsetPolygons(solution, (double)nudOffset.Value * scale, JoinType.jtMiter); ClipperOffset co = new ClipperOffset(2, 0.25); co.AddPaths(solution, JoinType.jtMiter, EndType.etClosedPolygon); co.Execute(ref solution2, (double)nudOffset.Value * scale); } else { solution2 = new Polygons(solution); } foreach (Polygon pg in solution2) { Point[] pts = PolygonToPointArray(pg, scale); if (pts.Length//Count() > 2) { path.AddPolygon(pts); } pts = null; } //myBrush.Color = Color.FromArgb(127, 0x66, 0xEF, 0x7F); myBrush.Color = Color.FromArgb(100, 0, 255, 0); myPen.Color = Color.FromArgb(255, 0, 0x33, 0); myPen.Width = 1; graphics.SmoothingMode = fillSmoothingMode; graphics.FillPath(myBrush, path); graphics.SmoothingMode = strokeSmoothingMode; graphics.DrawPath(myPen, path); //now do some fancy testing ... Font f = new Font("Arial", 8); Brush b = Brushes.Navy; double subj_area = 0, clip_area = 0, int_area = 0, union_area = 0; c.Clear(); c.AddPaths(subjects, PolyType.ptSubject, true); c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType()); foreach (Polygon pg in solution2) { subj_area += Clipper.Area(pg); } c.Clear(); c.AddPaths(clips, PolyType.ptClip, true); c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType()); foreach (Polygon pg in solution2) { clip_area += Clipper.Area(pg); } c.AddPaths(subjects, PolyType.ptSubject, true); c.Execute(ClipType.ctIntersection, solution2, GetPolyFillType(), GetPolyFillType()); foreach (Polygon pg in solution2) { int_area += Clipper.Area(pg); } c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType()); foreach (Polygon pg in solution2) { union_area += Clipper.Area(pg); } StringFormat lftStringFormat = new StringFormat(); lftStringFormat.Alignment = StringAlignment.Near; lftStringFormat.LineAlignment = StringAlignment.Near; StringFormat rtStringFormat = new StringFormat(); rtStringFormat.Alignment = StringAlignment.Far; rtStringFormat.LineAlignment = StringAlignment.Near; RectI rec = new RectI(WorkArea.Width - 114, WorkArea.Height - 116, 104, 106); graphics.FillRectangle(new SolidColorBrush(Color.FromArgb(196, Color.WhiteSmoke)), rec); graphics.DrawRectangle(myPen, rec); rec.Inflate(new SizeI(-2, 0)); // because of Alt.Sketch smaller top offset rec += new PointI(0, 1); rec -= new SizeI(0, 1); graphics.DrawString("Areas", f, b, rec, rtStringFormat); rec.Offset(new PointI(0, 14)); graphics.DrawString("subj: ", f, b, rec, lftStringFormat); graphics.DrawString((subj_area / 100000).ToString("0,0"), f, b, rec, rtStringFormat); rec.Offset(new PointI(0, 12)); graphics.DrawString("clip: ", f, b, rec, lftStringFormat); graphics.DrawString((clip_area / 100000).ToString("0,0"), f, b, rec, rtStringFormat); rec.Offset(new PointI(0, 12)); graphics.DrawString("intersect: ", f, b, rec, lftStringFormat); graphics.DrawString((int_area / 100000).ToString("0,0"), f, b, rec, rtStringFormat); rec.Offset(new PointI(0, 12)); graphics.DrawString("---------", f, b, rec, rtStringFormat); rec.Offset(new PointI(0, 10)); graphics.DrawString("s + c - i: ", f, b, rec, lftStringFormat); graphics.DrawString(((subj_area + clip_area - int_area) / 100000).ToString("0,0"), f, b, rec, rtStringFormat); rec.Offset(new PointI(0, 10)); graphics.DrawString("---------", f, b, rec, rtStringFormat); rec.Offset(new PointI(0, 10)); graphics.DrawString("union: ", f, b, rec, lftStringFormat); graphics.DrawString((union_area / 100000).ToString("0,0"), f, b, rec, rtStringFormat); rec.Offset(new PointI(0, 10)); graphics.DrawString("---------", f, b, rec, rtStringFormat); } //end if succeeded } //end if something to clip //TEMP pictureBox1.Image = mybitmap; graphics.Dispose(); GUI.Cursor.Current = GUI.Cursors.Default; }
// Paint map void mapPanel_Paint(object sender, GUI.PaintEventArgs e) { Graphics g = e.Graphics; if (map != null) { // bool showConnections = showConnectionsCheck.IsChecked; bool showInactive = showInactiveCheck.IsChecked; // pens and brushes Brush brush = new SolidColorBrush(Color.Blue); Brush brushGray = new SolidColorBrush(Color.FromArgb(192, 192, 192)); Pen pen = new Pen(Color.Blue, 1); Pen penGray = new Pen(Color.FromArgb(192, 192, 192), 1); // lock System.Threading.Monitor.Enter(this); if (showConnections) { // draw connections for (int i = 0, n = map.GetLength(0); i < n; i++) { for (int j = 0, k = map.GetLength(1); j < k; j++) { if ((!showInactive) && (map[i, j, 2] == 0)) { continue; } // left if ((i > 0) && ((showInactive) || (map[i - 1, j, 2] == 1))) { g.DrawLine(((map[i, j, 2] == 0) || (map[i - 1, j, 2] == 0)) ? penGray : pen, map[i, j, 0], map[i, j, 1], map[i - 1, j, 0], map[i - 1, j, 1]); } // right if ((i < n - 1) && ((showInactive) || (map[i + 1, j, 2] == 1))) { g.DrawLine(((map[i, j, 2] == 0) || (map[i + 1, j, 2] == 0)) ? penGray : pen, map[i, j, 0], map[i, j, 1], map[i + 1, j, 0], map[i + 1, j, 1]); } // top if ((j > 0) && ((showInactive) || (map[i, j - 1, 2] == 1))) { g.DrawLine(((map[i, j, 2] == 0) || (map[i, j - 1, 2] == 0)) ? penGray : pen, map[i, j, 0], map[i, j, 1], map[i, j - 1, 0], map[i, j - 1, 1]); } // bottom if ((j < k - 1) && ((showInactive) || (map[i, j + 1, 2] == 1))) { g.DrawLine(((map[i, j, 2] == 0) || (map[i, j + 1, 2] == 0)) ? penGray : pen, map[i, j, 0], map[i, j, 1], map[i, j + 1, 0], map[i, j + 1, 1]); } } } } // draw the map for (int i = 0, n = map.GetLength(0); i < n; i++) { for (int j = 0, k = map.GetLength(1); j < k; j++) { if ((!showInactive) && (map[i, j, 2] == 0)) { continue; } // draw the point g.FillEllipse((map[i, j, 2] == 0) ? brushGray : brush, map[i, j, 0] - 2, map[i, j, 1] - 2, 5, 5); } } // unlock System.Threading.Monitor.Exit(this); brush.Dispose(); brushGray.Dispose(); pen.Dispose(); penGray.Dispose(); } }