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); }
void PaintGripper(NPaintVisitor pv) { if (m_ArmGripperPath == null) { m_ArmGripperPath = new NGraphicsPath(); m_ArmGripperPath.StartFigure(0, -6); m_ArmGripperPath.LineTo(20, -6); m_ArmGripperPath.LineTo(20, -14); m_ArmGripperPath.LineTo(30, -14); m_ArmGripperPath.LineTo(30, 14); m_ArmGripperPath.LineTo(20, 14); m_ArmGripperPath.LineTo(20, 6); m_ArmGripperPath.LineTo(0, 6); m_ArmGripperPath.CloseFigure(); m_ArmGripperPath.StartFigure(30, -14); m_ArmGripperPath.LineTo(40, -14); m_ArmGripperPath.LineTo(50, -10); m_ArmGripperPath.LineTo(50, -7); m_ArmGripperPath.LineTo(30, -7); m_ArmGripperPath.CloseFigure(); m_ArmGripperPath.StartFigure(30, 14); m_ArmGripperPath.LineTo(40, 14); m_ArmGripperPath.LineTo(50, 10); m_ArmGripperPath.LineTo(50, 7); m_ArmGripperPath.LineTo(30, 7); m_ArmGripperPath.CloseFigure(); } pv.PaintPath(m_ArmGripperPath); }
private void OnCanvasPrePaint(NCanvasPaintEventArgs args) { NCanvas canvas = args.TargetNode as NCanvas; if (canvas == null) { return; } NPaintVisitor pv = args.PaintVisitor; int count = m_Values.Length; // calculate total value double total = 0; for (int i = 0; i < count; i++) { total += m_Values[i]; } // paint the pie slices double beginAngle = 0; pv.ClearStyles(); for (int i = 0; i < count; i++) { double sweepAngle = NMath.PI2 * (m_Values[i] / total); NGraphicsPath path = new NGraphicsPath(); path.AddPie(0.1 * W, 0.1 * H, 0.8 * W, 0.8 * H, beginAngle, sweepAngle); if (i == 0) { const double detachment = 20; double midAngle = beginAngle + sweepAngle / 2; double dx = Math.Cos(midAngle) * detachment; double dy = Math.Sin(midAngle) * detachment; path.Translate(dx, dy); } pv.SetFill(m_ColorFills[i]); pv.PaintPath(path); beginAngle += sweepAngle; } // paint a border around the canvas pv.ClearFill(); pv.SetStroke(NColor.Black, 1); pv.PaintRectangle(0, 0, canvas.Width, canvas.Height); }
void PaintPath(NPaintVisitor paintVisitor, double w, double h) { NGraphicsPath path = new NGraphicsPath(); path.StartFigure(0.1 * w, 0.1 * h); path.LineTo(0.7 * w, 0.2 * h); path.CubicBezierTo(0.9 * w, 0.9 * h, 1 * w, 0.4 * h, 0.5 * w, 0.7 * h); path.LineTo(0.2 * w, 0.8 * h); path.CubicBezierTo(0.1 * w, 0.1 * h, 0.3 * w, 0.7 * h, 0.4 * w, 0.6 * h); path.CloseFigure(); paintVisitor.PaintPath(path); }
/// <summary> /// /// </summary> /// <param name="args"></param> private void OnCanvasPrePaint(NCanvasPaintEventArgs args) { NCanvas canvas = args.TargetNode as NCanvas; if (canvas == null) { return; } NPaintVisitor paintVisitor = args.PaintVisitor; NRectangle contentEge = canvas.GetContentEdge(); // create the text bounds double width = contentEge.Width * m_WidthPercentUpDown.Value / 100.0; double height = contentEge.Height * m_HeightPercentUpDown.Value / 100.0; NPoint center = contentEge.Center; NRectangle textBounds = new NRectangle(center.X - width / 2.0, center.Y - height / 2.0, width, height); // create the settings NPaintTextRectSettings settings = new NPaintTextRectSettings(); settings.SingleLine = m_SingleLineCheckBox.Checked; settings.WrapMode = (ENTextWrapMode)m_WrapModeCombo.SelectedIndex; settings.HorzAlign = (ENTextHorzAlign)m_HorizontalAlignmentCombo.SelectedIndex; settings.VertAlign = (ENTextVertAlign)m_VerticalAlignmentCombo.SelectedIndex; // create the text StringBuilder builder = new StringBuilder(); builder.AppendLine("Paint text at bounds [" + textBounds.X.ToString("0.") + ", " + textBounds.Y.ToString("0.") + "]"); builder.AppendLine("Horizontal Alignment [" + settings.HorzAlign.ToString() + "]"); builder.AppendLine("Vertical Alignment [" + settings.VertAlign.ToString() + "]"); // paint the bounding box paintVisitor.ClearStyles(); paintVisitor.SetFill(NColor.LightBlue); paintVisitor.PaintRectangle(textBounds); // init font and fill paintVisitor.SetFill(NColor.Black); NFont font = new NFont(NFontDescriptor.DefaultSansFamilyName, 10); NGraphicsPath path = font.GetTextPath(builder.ToString(), textBounds, this.OwnerDocument, ref settings); paintVisitor.PaintPath(path); }
void PaintBase(NPaintVisitor pv) { if (m_ArmBasePath == null) { m_ArmBasePath = new NGraphicsPath(); m_ArmBasePath.StartFigure(0, 0); m_ArmBasePath.LineTo(-40, 0); m_ArmBasePath.LineTo(-40, 50); m_ArmBasePath.LineTo(25, 50); m_ArmBasePath.LineTo(25, 20); m_ArmBasePath.CloseFigure(); } pv.PaintPath(m_ArmBasePath); }
void PaintPath(NPaintVisitor paintVisitor, double w, double h) { paintVisitor.SetStroke(new NColor(0, 0, 0, 160), 6); paintVisitor.SetFill(new NColor(NColor.GreenYellow, 128)); NGraphicsPath path = new NGraphicsPath(); path.StartFigure(0.2 * w, 0.2 * h); path.LineTo(0.7 * w, 0.3 * h); path.CubicBezierTo(0.8 * w, 0.8 * h, 1 * w, 0.4 * h, 0.5 * w, 0.7 * h); path.LineTo(0.3 * w, 0.7 * h); path.CubicBezierTo(0.2 * w, 0.2 * h, 0.3 * w, 0.7 * h, 0.4 * w, 0.6 * h); path.CloseFigure(); paintVisitor.PaintPath(path); }