private void OnCanvasPrePaint(NCanvasPaintEventArgs args) { NCanvas canvas = args.TargetNode as NCanvas; if (canvas == null) { return; } // Create a transform matrix for the graphics path NMatrix matrix = NMatrix.CreateRotationMatrix(m_PathAngle * NAngle.Degree2Rad, NPoint.Zero); matrix.Translate(m_PathPositionX, m_PathPositionY); // Create a graphics path containing a rectangle and transform it NGraphicsPath path = new NGraphicsPath(); path.AddRectangle(0, 0, RectWidth, RectHeight); path.Transform(matrix); // Paint the graphics path NPaintVisitor pv = args.PaintVisitor; pv.SetStroke(m_Stroke); pv.SetFill(m_ImageFill); pv.PaintPath(path); // Paint a border around the canvas pv.ClearFill(); pv.SetStroke(NColor.Black, 1); pv.PaintRectangle(0, 0, canvas.Width, canvas.Height); }
public override NMatrix Calibrate(NPaintVisitor visitor, double imgWidth, double imgHeight, NRectangle targetRect) { // Initialize the image transform NMatrix matrix = NMatrix.Identity; // Scale the image so that it fits 2 times in width and 3 times in height matrix.Scale( NCustomTextureMappingExample.RectWidth / (2.0 * imgWidth), NCustomTextureMappingExample.RectHeight / (3.0 * imgHeight)); // Rotate the image to the specified angle matrix.Rotate(m_TextureMapping.TextureAngle * NAngle.Degree2Rad); // Translate the image to the specfied pin point matrix.Translate(m_TextureMapping.PinPoint.X, m_TextureMapping.PinPoint.Y); return(matrix); }
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); }