public void Page_Draw_DoughnutSlices() { var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); var page = app.ActivePage; int n = 36; double start_angle = 0.0; double radius = 1.0; double cx = 0.0; double cy = 2.0; double angle_step = System.Math.PI * 2.0 / (n - 1); foreach (double end_angle in Enumerable.Range(0, n).Select(i => i * angle_step)) { var center = new VA.Drawing.Point(cx, cy); var slice = new VA.Models.Charting.PieSlice(center, start_angle, end_angle, radius - 0.2, radius); slice.Render(page); cx += 2.5; } var bordersize = new VA.Drawing.Size(1, 1); page.ResizeToFitContents(bordersize); doc.Close(true); }
public void Page_Draw_PieSlices() { var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); var page = app.ActivePage; int n = 36; double start_angle = 0.0; double radius = 1.0; double cx = 0.0; double cy = 2.0; double angle_step = System.Math.PI * 2.0 / (n - 1); foreach (double end_angle in Enumerable.Range(0, n).Select(i => i * angle_step)) { var center = new VA.Drawing.Point(cx, cy); var ps = new VA.Models.Charting.PieSlice(center, radius, start_angle, end_angle); ps.Render(page); cx += 2.5; } var bordersize = new VA.Drawing.Size(1, 1); page.ResizeToFitContents(bordersize); doc.Close(true); }
public IVisio.Shape PieSlice(VisioAutomation.Drawing.Point center, double radius, double start_angle, double end_angle) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var application = this._client.Application.Get(); using (var undoscope = this._client.Application.NewUndoScope("Draw Pie Slice")) { var active_page = application.ActivePage; var slice = new VisioAutomation.Models.Charting.PieSlice(center, radius, start_angle, end_angle); var shape = slice.Render(active_page); return(shape); } }
public static List <PieSlice> GetSlicesFromValues(VA.Drawing.Point center, double radius, IList <double> values) { double sectors_sum = values.Sum(); var slices = new List <PieSlice>(values.Count); double start_angle = 0; foreach (int i in Enumerable.Range(0, values.Count)) { double cur_val = values[i]; double cur_val_norm = cur_val / sectors_sum; double cur_angle = cur_val_norm * System.Math.PI * 2.0; double end_angle = start_angle + cur_angle; var ps = new VA.Models.Charting.PieSlice(center, radius, start_angle, end_angle); slices.Add(ps); start_angle += cur_angle; } return(slices); }
public static List<PieSlice> GetSlicesFromValues(VA.Drawing.Point center, double radius, IList<double> values) { double sectors_sum = values.Sum(); var slices = new List<PieSlice>(values.Count); double start_angle = 0; foreach (int i in Enumerable.Range(0, values.Count)) { double cur_val = values[i]; double cur_val_norm = cur_val / sectors_sum; double cur_angle = cur_val_norm * System.Math.PI * 2.0; double end_angle = start_angle + cur_angle; var ps = new VA.Models.Charting.PieSlice(center,radius,start_angle, end_angle); slices.Add(ps); start_angle += cur_angle; } return slices; }
private void _draw_non_masters(RenderContext ctx, List <BaseShape> non_masters) { foreach (var shape in non_masters) { if (shape is Line) { var line = (Line)shape; var line_shape = ctx.VisioPage.DrawLine(line.P0, line.P1); line.VisioShapeID = line_shape.ID16; line.VisioShape = line_shape; } else if (shape is Rectangle) { var rect = (Rectangle)shape; var rect_shape = ctx.VisioPage.DrawRectangle(rect.P0.X, rect.P0.Y, rect.P1.X, rect.P1.Y); rect.VisioShapeID = rect_shape.ID16; rect.VisioShape = rect_shape; } else if (shape is Oval) { var oval = (Oval)shape; var oval_shape = ctx.VisioPage.DrawOval(oval.P0.X, oval.P0.Y, oval.P1.X, oval.P1.Y); oval.VisioShapeID = oval_shape.ID16; oval.VisioShape = oval_shape; } else if (shape is Arc) { var ps = (Arc)shape; var vad_arcslice = new VA.Models.Charting.PieSlice(ps.Center, ps.StartAngle, ps.EndAngle, ps.InnerRadius, ps.OuterRadius); var ps_shape = vad_arcslice.Render(ctx.VisioPage); ps.VisioShapeID = ps_shape.ID16; ps.VisioShape = ps_shape; } else if (shape is PieSlice) { var ps = (PieSlice)shape; var vad_ps = new VA.Models.Charting.PieSlice(ps.Center, ps.Start, ps.End, ps.Radius); var ps_shape = vad_ps.Render(ctx.VisioPage); ps.VisioShapeID = ps_shape.ID16; ps.VisioShape = ps_shape; } else if (shape is BezierCurve) { var bez = (BezierCurve)shape; var bez_shape = ctx.VisioPage.DrawBezier(bez.ControlPoints); bez.VisioShapeID = bez_shape.ID16; bez.VisioShape = bez_shape; } else if (shape is PolyLine) { var pl = (PolyLine)shape; var pl_shape = ctx.VisioPage.DrawPolyline(pl.Points); pl.VisioShapeID = pl_shape.ID16; pl.VisioShape = pl_shape; } else if (shape is Connector) { // skip these will be specially drawn } else { string msg = string.Format("Internal Error: Unhandled DOM node type: {0}", shape.GetType()); throw new AutomationException(msg); } } }