Revit.SDK.Samples.ObjectViewer.CS.Sketch3D.Draw C# (CSharp) Method

Draw() public method

draw the line contain in m_lines in 2d Preview
public Draw ( Graphics graphics ) : void
graphics System.Drawing.Graphics Graphics to draw
return void
        public void Draw(Graphics graphics)
        {
            if (m_data3D.NumPoints == 0 && m_data2D.NumPoints == 0)
            {
                graphics.Clear(System.Drawing.Color.LightGray);
                return;
            }

            graphics.Clear(System.Drawing.Color.White);
            DrawCurves(graphics, m_curve3Ds, m_transform3D, new Pen(System.Drawing.Color.DarkGreen));
            DrawCurves(graphics, m_curve2Ds, m_transform2D, new Pen(System.Drawing.Color.DarkBlue));
            if (m_data2D.NumPoints > 0)
            {
                GraphicsPath gPath = new GraphicsPath();
                gPath.AddRectangle(m_data2D.BBox);
                gPath.Transform(m_transform2D);
                SolidBrush brush = new SolidBrush(System.Drawing.Color.FromArgb(70, System.Drawing.Color.LightSkyBlue));
                graphics.FillPath(brush, gPath);
            }
        }

Usage Example

Example #1
0
 /// <summary>
 /// previewBox redraw
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void previewBox_Paint(object sender, PaintEventArgs e)
 {
     m_currentSketch.Draw(e.Graphics);
 }