protected void OnExportWithDirect2DMenuItemClick(NEventArgs args) { #if SUPPORT_DIRECT2D && DEBUG string fileName = "d:\\D2D_output.png"; NSize imgSize = new NSize(this.Width, this.Height); try { Nevron.Windows.DirectX.ND2DGraphicsHelper gh = new Nevron.Windows.DirectX.ND2DGraphicsHelper(); INGraphics2D pdfG = gh.CreateGraphics((int)imgSize.Width, (int)imgSize.Height); NRegion clip = NRegion.FromRectangle(new NRectangle(0, 0, imgSize.Width, imgSize.Height)); NMatrix canvasTransform = NMatrix.Identity; NMatrix invertedCT = canvasTransform; invertedCT.Invert(); NPaintVisitor visitor = new NPaintVisitor(pdfG, 96, invertedCT, clip); // assign media // forward traverse the display tree visitor.BeginPainting(); VisitDisplaySubtree(visitor); visitor.EndPainting(); gh.SaveToFileAndDispose(fileName); System.Diagnostics.Process.Start(fileName); } catch (Exception x) { NMessageBox.Show(null, x.Message, "Exception", ENMessageBoxButtons.OK); } #endif }
private void UpdateOuputPath() { NRectangle bounds = new NRectangle(); int count = m_InputPaths.Count; // compute the ouput path and the bounds if (count != 0) { NRegion result = NRegion.FromPath(m_InputPaths[0], ENFillRule.EvenOdd); bounds = result.Bounds; for (int i = 1; i < count; i++) { NRegion operand = NRegion.FromPath(m_InputPaths[i], ENFillRule.EvenOdd); bounds = NRectangle.Union(bounds, operand.Bounds); switch (m_OperatorCombo.SelectedIndex) { case 0: // union result = result.Union(operand); break; case 1: // intersection result = result.Intersect(operand); break; case 2: result = result.Subtract(operand); break; case 3: result = result.ExclusiveOr(operand); break; } } m_OutputPath = new NGraphicsPath(result.GetPath()); } else { m_OutputPath = new NGraphicsPath(); } // normalize the coordinates for (int i = 0; i < count; i++) { NGraphicsPath path = m_InputPaths[i]; //NRectangle pathBounds = path.GetBounds(); path.Translate(-bounds.X, -bounds.Y); } m_OutputPath.Translate(-bounds.X, -bounds.Y); m_Canvas.PreferredSize = new NSize(bounds.Width + 20, bounds.Height + 20); m_Canvas.InvalidateDisplay(); }
private void OnPrintPage(NPrintDocument sender, NPrintPageEventArgs e) { NSize pageSizeDIP = new NSize(this.Width, this.Height); try { NMargins pageMargins = NMargins.Zero; NRegion clip = NRegion.FromRectangle(new NRectangle(0, 0, e.PrintableArea.Width, e.PrintableArea.Height)); NMatrix transform = new NMatrix(e.PrintableArea.X, e.PrintableArea.Y); NPaintVisitor visitor = new NPaintVisitor(e.Graphics, 300, transform, clip); // forward traverse the display tree this.OwnerWindow.VisitDisplaySubtree(visitor); e.HasMorePages = false; } catch (Exception x) { NMessageBox.Show(x.Message, "Exception", ENMessageBoxButtons.OK, ENMessageBoxIcon.Error); } }
protected void OnPrintPage(NPrintDocument sender, NPrintPageEventArgs e) { NSize pageSizeDIP = new NSize(this.Width, this.Height); try { double clipW = e.PrintableArea.Width; double clipH = e.PrintableArea.Height; NRegion clip = NRegion.FromRectangle(new NRectangle(0, 0, clipW, clipH)); NMatrix transform = new NMatrix(e.PrintableArea.X, e.PrintableArea.Y); NPaintVisitor visitor = new NPaintVisitor(e.Graphics, 300, transform, clip); // forward traverse the display tree VisitDisplaySubtree(visitor); e.HasMorePages = false; } catch (Exception ex) { NMessageBox.Show(null, ex.Message, "Exception", ENMessageBoxButtons.OK, ENMessageBoxIcon.Error); } }
private void OnCanvasPrePaint(NCanvasPaintEventArgs args) { NCanvas canvas = args.TargetNode as NCanvas; if (canvas == null) { return; } canvas.HorizontalPlacement = ENHorizontalPlacement.Center; canvas.VerticalPlacement = ENVerticalPlacement.Center; NPaintVisitor pv = args.PaintVisitor; pv.ClearStyles(); pv.SetStroke(NColor.MidnightBlue, 1); pv.SetFill(NColor.LightSteelBlue); NMatrix m1 = NMatrix.Identity; m1.Rotate(NAngle.Degree2Rad * m_Angle1); NMatrix m2 = NMatrix.Identity; m2.Rotate(NAngle.Degree2Rad * m_Angle2); m2.Translate(100, 0); NMatrix m3 = NMatrix.Identity; m3.Rotate(NAngle.Degree2Rad * m_Angle3); m3.Translate(100, 0); NRegion clipRegion = NRegion.FromRectangle(m_ClipRect); pv.PushClip(clipRegion); pv.PushTransform(new NMatrix(m_PositionX, 0)); PaintVerticalBar(pv); pv.PushTransform(new NMatrix(0, m_PositionY)); PaintBase(pv); pv.PushTransform(m1); PaintLink(pv, 20); PaintJoint(pv, 20); pv.PushSnapToPixels(false); pv.PushTransform(m2); PaintLink(pv, 16); PaintJoint(pv, 16); pv.PushTransform(m3); PaintGripper(pv); PaintJoint(pv, 12); pv.PopTransform(); // m3 pv.PopTransform(); // m2 pv.PopTransform(); // m1 pv.PopTransform(); // mTY pv.PopTransform(); // mTX pv.PopSnapToPixels(); pv.PopClip(); // paint a border around the clip rectangle pv.ClearFill(); pv.SetStroke(NColor.Red, 1); pv.PaintRectangle(m_ClipRect); // paint a border around the canvas pv.SetStroke(NColor.Black, 1); pv.PaintRectangle(0, 0, canvas.Width, canvas.Height); }