Example #1
0
        /// <summary>
        /// Does not call OnSelectedVerticesChanged()!
        /// </summary>
        private void SelectVertices(IObject o, ModelPanel panel)
        {
            foreach (Vertex3 v in o.Vertices)
            {
                //Project each vertex into screen coordinates.
                //Then check to see if the 2D coordinates lie within the selection box.
                //In Soviet Russia, vertices come to YOUUUUU
                Vector3 screenTemp = panel.CurrentViewport.Camera.Project(v.WeightedPosition);
                Vector2 screenPos  = (Vector2)screenTemp;

                //This is the absolute depth value, regardless of obstructions
                float vertexDepth = screenTemp._z;

                Drawing.Point start = panel.CurrentViewport.SelectionStart, end = panel.CurrentViewport.SelectionEnd;
                Vector2       min = new Vector2((float)Math.Min(start.X, end.X), (float)Math.Min(start.Y, end.Y));
                Vector2       max = new Vector2((float)Math.Max(start.X, end.X), (float)Math.Max(start.Y, end.Y));
                if (screenPos <= max && screenPos >= min)
                {
                    //Test visible depth, this time taking obstructions into consideration
                    //The tested visible depth must be very close to the actual depth
                    //if (Math.Abs(panel.GetDepth(screenPos) - vertexDepth) < 0.001f)
                    {
                        if (Alt)
                        {
                            SelectVertex(v, false);
                        }
                        else if (!v._selected)
                        {
                            SelectVertex(v, true);
                        }
                    }
                }
            }
        }
        public static IVisio.Shape DrawLine(this IVisio.Shape shape, Drawing.Point p1, Drawing.Point p2)
        {
            var surface = new Drawing.DrawingSurface(shape);
            var s       = surface.DrawLine(p1, p2);

            return(s);
        }
        public IVisio.Shape AddShape(TextBlock block)
        {
            // Remember this Block
            this.Blocks.Add(block);

            // Calculate the Correct Full Rectangle
            var ll = new Drawing.Point(this.InsertionPoint.X, this.InsertionPoint.Y - block.Size.Height);
            var tr = new Drawing.Point(this.InsertionPoint.X + block.Size.Width, this.InsertionPoint.Y);
            var rect = new Drawing.Rectangle(ll, tr);

            // Draw the Shape
            var newshape = this.page.DrawRectangle(rect);
            block.VisioShape = newshape;
            block.VisioShapeID = newshape.ID;
            block.Rectangle = rect;

            // Handle Text If Needed
            if (block.Text != null)
            {
                newshape.Text = block.Text;
            }

            this.AdjustInsertionPoint(block.Size);

            return newshape;
        }
Example #4
0
        private void _draw_connectors(RenderContext context)
        {
            var connector_nodes = this._shapes.Where(s => s is Connector).Cast <Connector>().ToList();

            // if no dynamic connectors then do nothing
            if (connector_nodes.Count < 1)
            {
                return;
            }

            // Drop the number of connectors needed somewhere on the page
            var masters = connector_nodes.Select(i => i.Master.VisioMaster).ToArray();
            var origin  = new Drawing.Point(-2, -2);
            var points  = Enumerable.Range(0, connector_nodes.Count)
                          .Select(i => origin + new Drawing.Point(1.10, 0))
                          .ToList();
            var connector_shapeids = context.VisioPage.DropManyU(masters, points);
            var page_shapes        = context.VisioPage.Shapes;

            // Perform the connection
            for (int i = 0; i < connector_shapeids.Length; i++)
            {
                var connector_shapeid = connector_shapeids[i];
                var vis_connector     = page_shapes.ItemFromID[connector_shapeid];
                var dyncon_shape      = connector_nodes[i];

                var from_shape = context.GetShape(dyncon_shape.From.VisioShapeID);
                var to_shape   = context.GetShape(dyncon_shape.To.VisioShapeID);

                ConnectorHelper.ConnectShapes(from_shape, to_shape, vis_connector);
                dyncon_shape.VisioShape   = vis_connector;
                dyncon_shape.VisioShapeID = connector_shapeids[i];
            }
        }
        public void PerformLayout()
        {
            /*------------------------------------------------------
             * Determine the coordinates for each node in a tree.
             * Input: Pointer to the apex node of the tree
             * Assumption: The x & y coordinates of the apex node
             * are already correct, since the tree underneath it
             * will be positioned with respect to those coordinates.
             * Returns: TRUE if no errors, otherwise returns FALSE.
             *----------------------------------------------------*/

            this.max_level_height    = new Dictionary <int, double>();
            this.max_level_width     = new Dictionary <int, double>();
            this.previous_level_node = new Dictionary <int, Node <T> >();

            this.first_walk(this.root, 0);

            //adjust the root_offset
            // NOTE: in the original code this was a case statement on Options.Direction that did the same thing for each direction
            this.root_offset = this.Options.TopAdjustment + this.root.Position;

            this.second_walk(this.root, 0, new Drawing.Point(0, 0));

            this.max_level_height    = null;
            this.max_level_width     = null;
            this.previous_level_node = null;

            this.correct_tree_bounding_box();
        }
        public Drawing.LineSegment GetConnectionLine(ParentChildConnection <Node <T> > connection)
        {
            var parent_rect = connection.Parent.Rect;
            var child_rect  = connection.Child.Rect;

            double parent_x, parent_y;
            double child_x, child_y;

            if (TreeLayout <T> .IsVertical(this.Options.Direction))
            {
                parent_x = parent_rect.Center.X;
                child_x  = child_rect.Center.X;

                parent_y = TreeLayout <T> .GetSide(parent_rect, this.Options.Direction);

                child_y = TreeLayout <T> .GetSide(child_rect, TreeLayout <T> .GetOpposite(this.Options.Direction));
            }
            else
            {
                var parent_dir = this.Options.Direction;
                var child_dir  = TreeLayout <T> .GetOpposite(parent_dir);

                parent_x = TreeLayout <T> .GetSide(parent_rect, parent_dir);

                child_x = TreeLayout <T> .GetSide(child_rect, child_dir);

                parent_y = parent_rect.Center.Y;
                child_y  = child_rect.Center.Y;
            }

            var parent_attach_point = new Drawing.Point(parent_x, parent_y);
            var child_attach_point  = new Drawing.Point(child_x, child_y);

            return(new Drawing.LineSegment(parent_attach_point, child_attach_point));
        }
Example #7
0
        public IVisio.Shape AddShape(TextBlock block)
        {
            // Remember this Block
            this.Blocks.Add(block);

            // Calculate the Correct Full Rectangle
            var ll   = new Drawing.Point(this.InsertionPoint.X, this.InsertionPoint.Y - block.Size.Height);
            var tr   = new Drawing.Point(this.InsertionPoint.X + block.Size.Width, this.InsertionPoint.Y);
            var rect = new Drawing.Rectangle(ll, tr);

            // Draw the Shape
            var newshape = this._page.DrawRectangle(rect);

            block.VisioShape   = newshape;
            block.VisioShapeID = newshape.ID;
            block.Rectangle    = rect;

            // Handle Text If Needed
            if (block.Text != null)
            {
                newshape.Text = block.Text;
            }

            this.AdjustInsertionPoint(block.Size);

            return(newshape);
        }
Example #8
0
        private static Drawing.Point GetPinPositionForCorner(ShapeXFormData input_xfrm, Drawing.Point new_lower_left, SnapCornerPosition corner)
        {
            var size   = new Drawing.Size(input_xfrm.Width, input_xfrm.Height);
            var locpin = new Drawing.Point(input_xfrm.LocPinX, input_xfrm.LocPinY);

            switch (corner)
            {
            case SnapCornerPosition.LowerLeft:
            {
                return(new_lower_left.Add(locpin.X, locpin.Y));
            }

            case SnapCornerPosition.UpperRight:
            {
                return(new_lower_left.Subtract(size.Width, size.Height).Add(locpin.X, locpin.Y));
            }

            case SnapCornerPosition.LowerRight:
            {
                return(new_lower_left.Subtract(size.Width, 0).Add(locpin.X, locpin.Y));
            }

            case SnapCornerPosition.UpperLeft:
            {
                return(new_lower_left.Subtract(0, size.Height).Add(locpin.X, locpin.Y));
            }

            default:
            {
                throw new System.ArgumentOutOfRangeException(nameof(corner), "Unsupported corner");
            }
            }
        }
Example #9
0
        public Line DrawLine(Drawing.Point p0, Drawing.Point p1)
        {
            var line = new Line(p0, p1);

            this.Add(line);
            return(line);
        }
Example #10
0
        public PieSlice DrawPieSlice(Drawing.Point center, double radius, double start, double end)
        {
            var pieslice = new PieSlice(center, radius, start, end);

            this.Add(pieslice);
            return(pieslice);
        }
Example #11
0
        public Rectangle DrawRectangle(Drawing.Point p0, Drawing.Point p1)
        {
            var rectangle = new Rectangle(p0, p1);

            this.Add(rectangle);
            return(rectangle);
        }
Example #12
0
        public Shape Drop(IVisio.Master master, Drawing.Point pos)
        {
            var m = new Shape(master, pos);

            this.Add(m);
            return(m);
        }
Example #13
0
        public Arc DrawArc(Drawing.Point center, double inner_radius, double outer_radius, double start, double end)
        {
            var arc = new Arc(center, inner_radius, outer_radius, start, end);

            this.Add(arc);
            return(arc);
        }
Example #14
0
        private static Drawing.Point RotateAroundOrigin(Drawing.Point p1, double theta)
        {
            double nx = (System.Math.Cos(theta) * p1.X) - (System.Math.Sin(theta) * p1.Y);
            double ny = (System.Math.Sin(theta) * p1.X) + (System.Math.Cos(theta) * p1.Y);

            return(new Drawing.Point(nx, ny));
        }
Example #15
0
        public Shape Drop(string master, string stencil, Drawing.Point pos)
        {
            var m = new Shape(master, stencil, pos);

            this.Add(m);
            return(m);
        }
Example #16
0
 public PieSlice(Drawing.Point p0, double r, double start, double end)
 {
     this.Center = p0;
     this.Radius = r;
     this.Start  = start;
     this.End    = end;
 }
            /// <summary>
            /// Gets called when the mouse enters the control while dragging.
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void _DragEnter(object sender, DragEventArgs e)
            {
                var treeView = sender as TreeView;

                if (treeView == null || treeView != this._treeView)
                {
                    return;
                }

                if (!e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false) || (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode") != this._draggedNode)
                {
                    e.Effect = DragDropEffects.None;
                    return;
                }

                var screen = new Drawing.Point(e.X, e.Y);
                var client = treeView.PointToClient(screen);
                var window = client;

                DragHelper.ImageList_DragEnter(treeView.Handle, window.X, window.Y);

                // Enable timer for scrolling dragged item
                this._dragScrollTimer.Enabled = true;

                e.Effect = DragDropEffects.Move;
            }
 private static Drawing.Rectangle GetRectangle(Shapes.XFormCells xform)
 {
     var pin = new Drawing.Point(xform.PinX.Result, xform.PinY.Result);
     var locpin = new Drawing.Point(xform.LocPinX.Result, xform.LocPinY.Result);
     var size = new Drawing.Size(xform.Width.Result, xform.Height.Result);
     return new Drawing.Rectangle(pin - locpin, size);
 }
        public static IVisio.Shape DrawQuarterArc(this IVisio.Shape shape, Drawing.Point p0, Drawing.Point p1, IVisio.VisArcSweepFlags flags)
        {
            var surface = new Drawing.DrawingSurface(shape);
            var s       = surface.DrawQuarterArc(p0, p1, flags);

            return(s);
        }
        public static IVisio.Shape DrawLine(this IVisio.Page page, Drawing.Point p1, Drawing.Point p2)
        {
            var surface = new Drawing.DrawingSurface(page);
            var shape   = surface.DrawLine(p1.X, p1.Y, p2.X, p2.Y);

            return(shape);
        }
Example #21
0
        public Drawing.Point[] GetConnectionPolyline(ParentChildConnection <Node <T> > connection)
        {
            var lineseg = this.GetConnectionLine(connection);

            Drawing.Point m0, m1;

            var parent_attach_point = lineseg.Start;
            var child_attach_point  = lineseg.End;
            var dif = lineseg.End - lineseg.Start;
            var a   = (this.Options.LevelSeparation / 2.0);
            var b   = (this.Options.LevelSeparation / 2.0);

            if (TreeLayout <T> .IsVertical(this.Options.Direction))
            {
                if (this.Options.Direction == LayoutDirection.Up)
                {
                    b = -b;
                }
                m0 = new Drawing.Point(lineseg.Start.X, lineseg.End.Y + b);
                m1 = new Drawing.Point(lineseg.End.X, lineseg.End.Y + b);
            }
            else
            {
                if (this.Options.Direction == LayoutDirection.Left)
                {
                    a = -a;
                }
                m0 = new Drawing.Point(lineseg.End.X - a, lineseg.Start.Y);
                m1 = new Drawing.Point(lineseg.End.X - a, lineseg.End.Y);
            }

            return(new[] { lineseg.Start, m0, m1, lineseg.End });
        }
Example #22
0
 public static IVisio.Shape Drop(
     this IVisio.Page page,
     IVisio.Master master,
     Drawing.Point point)
 {
     return(VA.Pages.PageHelper.Drop(page, master, point));
 }
Example #23
0
 public Arc(Drawing.Point p0, double ri, double ro, double start, double end)
 {
     this.Center      = p0;
     this.InnerRadius = ri;
     this.OuterRadius = ro;
     this.StartAngle  = start;
     this.EndAngle    = end;
 }
Example #24
0
        public FXTabStyleProvider(FXTabControl tabControl) : base(tabControl)
        {
            radius = 1;
            showTabCloser = false;

            // Must set after the _Radius as this is used in the calculations of the actual padding
            Padding = new Drawing.Point(8, 3);
        }
Example #25
0
 public PieChart(Drawing.Rectangle rect)
 {
     var center = rect.Center;
     var radius = System.Math.Min(rect.Width,rect.Height)/2.0;
     this.DataPoints = new DataPointList();
     this.Center = center;
     this.Radius = radius;
 }
Example #26
0
        private static Drawing.Rectangle GetRectangle(Shapes.XFormCells xFormCells)
        {
            var pin    = new Drawing.Point(xFormCells.PinX.Result, xFormCells.PinY.Result);
            var locpin = new Drawing.Point(xFormCells.LocPinX.Result, xFormCells.LocPinY.Result);
            var size   = new Drawing.Size(xFormCells.Width.Result, xFormCells.Height.Result);

            return(new Drawing.Rectangle(pin - locpin, size));
        }
Example #27
0
        public Drawing.Rectangle GetRectangle()
        {
            var pin    = new Drawing.Point(this.PinX, this.PinY);
            var locpin = new Drawing.Point(this.LocPinX, this.LocPinY);
            var size   = new Drawing.Size(this.Width, this.Height);

            return(new Drawing.Rectangle(pin - locpin, size));
        }
Example #28
0
        public FXTabStyleProvider(FXTabControl tabControl) : base(tabControl)
        {
            radius        = 1;
            showTabCloser = false;

            // Must set after the _Radius as this is used in the calculations of the actual padding
            Padding = new Drawing.Point(8, 3);
        }
        public static Drawing.Point XYToPage(this IVisio.Shape shape, Drawing.Point xy)
        {
            // MSDN: http://msdn.microsoft.com/en-us/library/office/ff766239.aspx
            double xprime;
            double yprime;

            shape.XYToPage(xy.X, xy.Y, out xprime, out yprime);
            return(new Drawing.Point(xprime, yprime));
        }
Example #30
0
        public PieChart(Drawing.Rectangle rect)
        {
            var center = rect.Center;
            var radius = System.Math.Min(rect.Width, rect.Height) / 2.0;

            this.DataPoints = new DataPointList();
            this.Center     = center;
            this.Radius     = radius;
        }
Example #31
0
        public static IVisio.Shape Drop(
            this IVisio.Page page,
            IVisio.Master master,
            Drawing.Point point)
        {
            var surface = new Drawing.DrawingSurface(page);

            return(surface.Drop(master, point));
        }
Example #32
0
        protected Drawing.Point GetPointAtRadius(Drawing.Point origin, double angle, double radius)
        {
            double x         = radius * System.Math.Cos(angle);
            double y         = radius * System.Math.Sin(angle);
            var    new_point = new Drawing.Point(x, y);

            new_point = origin + new_point;
            return(new_point);
        }
Example #33
0
        public IVisio.Shape Oval(Drawing.Point center, double radius)
        {
            var surface = this.GetDrawingSurface();

            using (var undoscope = this._client.Application.NewUndoScope("Draw Oval"))
            {
                var shape = surface.DrawOval(center, radius);
                return(shape);
            }
        }
Example #34
0
        public PieSlice(Drawing.Point center, double radius, double start, double end) :
            this(center, start, end)
        {
            if (radius < 0.0)
            {
                throw new System.ArgumentOutOfRangeException(nameof(radius), "must be non-negative");
            }

            this.Radius = radius;
        }
Example #35
0
        protected TabStyleProvider(FXTabControl tabControl)
        {
            this.tabControl = tabControl;
            
            borderColor = Color.Empty;
            borderColorSelected = Color.Empty;
            focusColor = Color.Orange;

            imageAlign = tabControl.RightToLeftLayout
                ? ContentAlignment.MiddleRight : ContentAlignment.MiddleLeft;
            
            HotTrack = true;
            
            // Must set after the _Overlap as this is used
            // in the calculations of the actual padding
            Padding = new Drawing.Point(6 + (ShowTabCloser ? 6 : 0), 3);
        }
 public Oval(Drawing.Point p0, Drawing.Point p1)
 {
     this.P0 = p0;
     this.P1 = p1;
 }
        public void Render(IVisio.Application app)
        {
            var orgchartdrawing = this;

            if (orgchartdrawing == null)
            {
                throw new System.ArgumentNullException("orgchartdrawing");
            }

            if (app == null)
            {
                throw new System.ArgumentNullException(nameof(app));
            }

            if (orgchartdrawing.OrgCharts.Count < 1)
            {
                throw new System.ArgumentException("orgchart must have at least one root");
            }

            foreach (var root in orgchartdrawing.OrgCharts)
            {
                if (root == null)
                {
                    throw new System.ArgumentException("Org chart has root node set to null");
                }
            }

            var ver = Application.ApplicationHelper.GetVersion(app);
            int majorver = ver.Major;
            bool is_visio_2013 = majorver >= 15;

            const string orgchart_vst = "orgch_u.vst";
            string orgchart_master_node_name = is_visio_2013 ? "Position Belt" : "Position";
            const string dyncon_master_name = "Dynamic connector";
            const double border_width = 0.5;

            var doc_node = new DOM.Document(orgchart_vst, IVisio.VisMeasurementSystem.visMSUS);

            var trees = new List<IList<InternalTree.Node<object>>>();

            foreach (var root in orgchartdrawing.OrgCharts)
            {
                // Construct a layout tree from the hierarchy
                var treenodes = Internal.TreeOps.CopyTree(
                    orgchartdrawing.OrgCharts[0],
                    n => n.Children,
                    n => this.node_to_layout_node(n),
                    (p, c) => p.AddChild(c));

                trees.Add(treenodes);

                // Perform the layout
                var layout = new InternalTree.TreeLayout<object>();

                layout.Options.Direction = this.map_direction2(this.LayoutOptions.Direction);
                layout.Options.LevelSeparation = 1;
                layout.Options.SiblingSeparation = 0.25;
                layout.Options.SubtreeSeparation = 1;

                layout.Root.AddChild(treenodes[0]);
                layout.PerformLayout();

                // Render the Document in Visio
                var bb = layout.GetBoundingBoxOfTree();

                // vis.ActiveWindow.ShowConnectPoints = 0;

                var page_node = new DOM.Page();
                doc_node.Pages.Add(page_node);

                // fixup the nodes so that they render on the page
                foreach (var i in treenodes)
                {
                    i.Position = i.Position.Add(border_width, border_width);
                }

                var centerpoints = new Drawing.Point[treenodes.Count];
                foreach (int i in Enumerable.Range(0, treenodes.Count))
                {
                    centerpoints[i] = treenodes[i].Rect.Center;
                }

                // TODO: Add support for Left to right , Right to Left, and Bottom to Top Layouts

                var vmasters = centerpoints
                    .Select(centerpoint => page_node.Shapes.Drop(orgchart_master_node_name, null, centerpoint))
                    .ToList();


                // For each OrgChart object, attach the shape that corresponds to it
                foreach (int i in Enumerable.Range(0, treenodes.Count))
                {
                    var orgnode = (Node)treenodes[i].Data;
                    orgnode.DOMNode = vmasters[i];
                    vmasters[i].Cells.Width = treenodes[i].Size.Width;
                    vmasters[i].Cells.Height = treenodes[i].Size.Height;
                }

                if (this.LayoutOptions.UseDynamicConnectors)
                {
                    var orgchart_nodes = treenodes.Select(tn => tn.Data).Cast<Node>();

                    foreach (var parent in orgchart_nodes)
                    {
                        foreach (var child in parent.Children)
                        {
                            var parent_shape = (DOM.BaseShape)parent.DOMNode;
                            var child_shape = (DOM.BaseShape)child.DOMNode;
                            var connector = page_node.Shapes.Connect(dyncon_master_name, null, parent_shape, child_shape);
                        }
                    }
                }
                else
                {
                    foreach (var connection in layout.EnumConnections())
                    {
                        var bez = layout.GetConnectionBezier(connection);
                        page_node.Shapes.DrawBezier(bez);
                    }
                }

                // Set the Text Labels on each Org node
                foreach (int i in Enumerable.Range(0, treenodes.Count))
                {
                    var orgnode = (Node)treenodes[i].Data;
                    var shape = (DOM.BaseShape)orgnode.DOMNode;
                    shape.Text = new Text.Markup.TextElement(orgnode.Text);
                }

                var page_size_with_border = bb.Size.Add(border_width * 2, border_width * 2.0);
                page_node.Size = page_size_with_border;
                page_node.ResizeToFit = true;
                page_node.ResizeToFitMargin = new Drawing.Size(border_width * 2, border_width * 2.0);
            } // finish handling root node

            var doc = doc_node.Render(app);

            foreach (var treenodes in trees)
            {
                var orgnodes = treenodes.Select(i => i.Data).Cast<Node>();
                var orgnodes_with_urls = orgnodes.Where(n => n.URL != null);
                var all_urls = orgnodes_with_urls.Select(n => new { orgnode = n, shape = (DOM.BaseShape)n.DOMNode, url = n.URL.Trim() });

                foreach (var url in all_urls)
                {
                    var hlink = url.orgnode.VisioShape.Hyperlinks.Add();
                    hlink.Name = "Row_1";
                    hlink.Address = url.orgnode.URL;
                }

                // Attach all the orgchart nodes to the Visio shapes that were created
                foreach (int i in Enumerable.Range(0, treenodes.Count))
                {
                    var orgnode = (Node)treenodes[i].Data;
                    var shape = (DOM.BaseShape)orgnode.DOMNode;
                    orgnode.VisioShape = shape.VisioShape;
                }
            }
        }
 public Rectangle(Drawing.Point p0, Drawing.Point p1)
 {
     this.P0 = p0;
     this.P1 = p1;
 }
 public Rectangle(Drawing.Rectangle r0)
 {
     this.P0 = r0.LowerLeft;
     this.P1 = r0.UpperRight;
 }
Example #40
0
        public void Render(IVisio.Page page)
        {
            this.TotalMarginWidth = this.Rectangle.Width*(0.10);

            int num_points = this.DataPoints.Count;
            double bar_spacing = num_points > 1 ? (this.Rectangle.Width-this.TotalBarWidth)/num_points : 0.0;

            // Calculate min & max which will be used many times later
            double max = this.DataPoints.Select(i => i.Value).Max();
            double min = this.DataPoints.Select(i => i.Value).Min();
            var range = ChartUtil.GetValueRangeDistance(min, max);

            // Determine the leftmost part of the drawing area
            double base_x = this.Rectangle.Left + (this.TotalMarginWidth / 2.0);

            // Determine the baseline height a.k.a the y axis location
            double base_y = this.Rectangle.Bottom;
            if (min < 0.0)
            {
                // if the min value is negative then we have to "raise" the baseline to accomodate it
                base_y += System.Math.Abs(this.Rectangle.Height * (min / range));
            }

            var category_axis_start_point = new Drawing.Point(this.Rectangle.Left, base_y);
            var category_axis_end_point = new Drawing.Point(this.Rectangle.Right, base_y);
            var category_axis_shape = page.DrawLine(category_axis_start_point, category_axis_end_point);

            double cur_x = base_x;

            var points = new List<Drawing.Point>();
            for (int i = 0; i < this.DataPoints.Count; i++)
            {
                if (i == 0)
                {
                    points.Add( new Drawing.Point(cur_x,base_y));
                }

                var p = this.DataPoints[i];

                var value_height = System.Math.Abs(this.Rectangle.Height*(p.Value/range));

                if (p.Value >= 0.0)
                {
                    points.Add(new Drawing.Point(cur_x, base_y+value_height));
                }
                else
                {
                    points.Add(new Drawing.Point(cur_x , base_y - value_height));

                }

                if (i == this.DataPoints.Count - 1)
                {
                    points.Add(new Drawing.Point(cur_x, base_y));
                }

                cur_x += bar_spacing;
            }

            points.Add(new Drawing.Point(base_x, base_y));

            var area_shape = page.DrawPolyline(points);

            var allshapes = this.DataPoints.Select(dp => dp.VisioShape).Where(s => s != null).ToList();
            allshapes.Add(category_axis_shape);

            ChartUtil.GroupShapesIfNeeded(page, allshapes);
        }
Example #41
0
 public TabStyleRoundedProvider(FXTabControl tabControl) : base(tabControl)
 {
     radius = 10;
     //	Must set after the _Radius as this is used in the calculations of the actual padding
     Padding = new Drawing.Point(6, 3);
 }
        public void Render(IVisio.Page page)
        {
            this.TotalMarginWidth = this.Rectangle.Width*(0.10);
            this.TotalBarSpacingWidth = this.Rectangle.Width * (0.10);
            this.TotalBarWidth = this.Rectangle.Width*(0.80);

            int num_points = this.DataPoints.Count;

            double bar_spacing = num_points > 1 ? this.TotalBarSpacingWidth/num_points : 0.0;
            double bar_width = num_points > 0 ? this.TotalBarWidth/num_points : this.TotalBarWidth;

            double cur_x = this.Rectangle.Left + (this.TotalMarginWidth/2.0);

            double max = this.DataPoints.Select(i => i.Value).Max();
            double min = this.DataPoints.Select(i => i.Value).Min();
            var range = ChartUtil.GetValueRangeDistance(min, max);

            double base_y = this.Rectangle.Bottom;

            if (min < 0.0)
            {
                base_y += System.Math.Abs(this.Rectangle.Height * (min / range));
            }

            var category_axis_start_point = new Drawing.Point(this.Rectangle.Left, base_y);
            var category_axis_end_point = new Drawing.Point(this.Rectangle.Right, base_y);
            var category_axis_shape = page.DrawLine(category_axis_start_point, category_axis_end_point);

            foreach (var p in this.DataPoints)
            {
                var value_height = System.Math.Abs(this.Rectangle.Height*(p.Value/range));

                Drawing.Point bar_p0;
                Drawing.Point bar_p1;

                if (p.Value >= 0.0)
                {
                    bar_p0 = new Drawing.Point(cur_x, base_y);
                    bar_p1 = new Drawing.Point(cur_x + bar_width, base_y + value_height);
                }
                else
                {
                    bar_p0 = new Drawing.Point(cur_x, base_y - value_height);
                    bar_p1 = new Drawing.Point(cur_x + bar_width, base_y);                    
                }
                
                var bar_rect = new Drawing.Rectangle(bar_p0, bar_p1);
                var shape = page.DrawRectangle(bar_rect);
                p.VisioShape = shape;

                if (p.Label != null)
                {
                    shape.Text = p.Label;
                }

                cur_x += bar_width + bar_spacing;
            }

            var allshapes = this.DataPoints.Select(dp => dp.VisioShape).Where(s => s != null).ToList();
            allshapes.Add(category_axis_shape);

            ChartUtil.GroupShapesIfNeeded(page, allshapes);

        }
Example #43
0
        public IVisio.Shape RenderDoughnut(IVisio.Page page)
        {
            double total_angle = this.Angle;

            if (total_angle == 0.0)
            {
                var p1 = this.GetPointAtRadius(this.Center, this.SectorStartAngle, this.InnerRadius);
                var p2 = this.GetPointAtRadius(this.Center, this.SectorStartAngle, this.Radius);
                var shape = page.DrawLine(p1, p2);
                return shape;
            }
            else if (total_angle >= System.Math.PI)
            {
                var outer_radius_point = new Drawing.Point(this.Radius, this.Radius);
                var C = this.Center - outer_radius_point;
                var D = this.Center + outer_radius_point;
                var outer_rect = new Drawing.Rectangle(C, D);

                var inner_radius_point = new Drawing.Point(this.InnerRadius, this.InnerRadius);
                var A = this.Center - inner_radius_point - C;
                var B = this.Center + inner_radius_point - C;
                var inner_rect = new Drawing.Rectangle(A, B);

                var shape = page.DrawOval(outer_rect);
                shape.DrawOval(inner_rect.Left, inner_rect.Bottom, inner_rect.Right, inner_rect.Top);

                return shape;
            }
            else
            {
                int degree;
                var thickarc = this.GetShapeBezierForDoughnut(out degree);

                // Render the bezier
                var doubles_array = Drawing.Point.ToDoubles(thickarc).ToArray();
                var pie_slice = page.DrawBezier(doubles_array, (short)degree, 0);
                return pie_slice;
            }
        }
Example #44
0
 protected Drawing.Point GetPointAtRadius(Drawing.Point origin, double angle, double radius)
 {
     double x = radius * System.Math.Cos(angle);
     double y = radius * System.Math.Sin(angle);
     var new_point = new Drawing.Point(x, y);
     new_point = origin + new_point;
     return new_point;
 }
Example #45
0
 public PieChart(Drawing.Point center, double radius)
 {
     this.DataPoints = new DataPointList();
     this.Center = center;
     this.Radius = radius;
 }
        public static void DistributeWithSpacing(IVisio.Page page, IList<int> shapeids, Drawing.Axis axis, double spacing)
        {
            if (spacing < 0.0)
            {
                throw new System.ArgumentOutOfRangeException(nameof(spacing));
            }

            if (shapeids.Count < 2)
            {
                return;
            }

            // Calculate the new Xfrms
            var sortpos = axis == Drawing.Axis.XAxis
                ? RelativePosition.PinX
                : RelativePosition.PinY;

            var delta = axis == Drawing.Axis.XAxis
                ? new Drawing.Size(spacing, 0)
                : new Drawing.Size(0, spacing);


            var sorted_shape_ids = ArrangeHelper.SortShapesByPosition(page, shapeids, sortpos);
            var input_xfrms = Shapes.XFormCells.GetCells(page, sorted_shape_ids);
            var output_xfrms = new List<Shapes.XFormCells>(input_xfrms.Count);
            var bb = ArrangeHelper.GetBoundingBox(input_xfrms);
            var cur_pos = new Drawing.Point(bb.Left, bb.Bottom);

            foreach (var input_xfrm in input_xfrms)
            {
                var new_pinpos = axis == Drawing.Axis.XAxis
                    ? new Drawing.Point(cur_pos.X + input_xfrm.LocPinX.Result, input_xfrm.PinY.Result)
                    : new Drawing.Point(input_xfrm.PinX.Result, cur_pos.Y + input_xfrm.LocPinY.Result);

                var output_xfrm = new Shapes.XFormCells();
                output_xfrm.PinX = new_pinpos.X;
                output_xfrm.PinY = new_pinpos.Y;
                output_xfrms.Add(output_xfrm);

                cur_pos = cur_pos.Add(input_xfrm.Width.Result, input_xfrm.Height.Result).Add(delta);
            }

            // Apply the changes
            ArrangeHelper.update_xfrms(page, sorted_shape_ids, output_xfrms);
        }
 public void CarriageReturn()
 {
     this.InsertionPoint = new Drawing.Point(this.FormPage.Margin.Left, this.InsertionPoint.Y);
 }
        private static Drawing.Point GetPinPositionForCorner(Shapes.XFormCells input_xfrm, Drawing.Point new_lower_left, SnapCornerPosition corner)
        {
            var size = new Drawing.Size(input_xfrm.Width.Result, input_xfrm.Height.Result);
            var locpin = new Drawing.Point(input_xfrm.LocPinX.Result, input_xfrm.LocPinY.Result);

            switch (corner)
            {
                case SnapCornerPosition.LowerLeft:
                    {
                        return new_lower_left.Add(locpin.X, locpin.Y);
                    }
                case SnapCornerPosition.UpperRight:
                    {
                        return new_lower_left.Subtract(size.Width, size.Height).Add(locpin.X, locpin.Y);
                    }
                case SnapCornerPosition.LowerRight:
                    {
                        return new_lower_left.Subtract(size.Width, 0).Add(locpin.X, locpin.Y);
                    }
                case SnapCornerPosition.UpperLeft:
                    {
                        return new_lower_left.Subtract(0, size.Height).Add(locpin.X, locpin.Y);
                    }
                default:
                    {
                        throw new System.ArgumentOutOfRangeException(nameof(corner), "Unsupported corner");
                    }
            }
        }
 public Line(Drawing.Point p0, Drawing.Point p1)
 {
     this.P0 = p0;
     this.P1 = p1;
 }
 private void ResetInsertionPoint()
 {
     this.InsertionPoint = new Drawing.Point(this.FormPage.Margin.Left,
         this.FormPage.Size.Height - this.FormPage.Margin.Top);
 }
 public void MoveRight(double advance)
 {
     this.InsertionPoint = new Drawing.Point(this.InsertionPoint.X + advance, this.InsertionPoint.Y);
 }
 private void AdjustInsertionPoint(Drawing.Size size)
 {
     this.InsertionPoint = this.InsertionPoint.Add(size.Width, 0);
     this.CurrentLineHeight = System.Math.Max(this.CurrentLineHeight, size.Height);
 }
 public Line(double x0, double y0, double x1, double y1)
 {
     this.P0 = new Drawing.Point(x0, y0);
     this.P1 = new Drawing.Point(x1, y1);
 }
 public void Linefeed(double advance)
 {
     this.InsertionPoint = new Drawing.Point(this.FormPage.Margin.Left, this.InsertionPoint.Y - this.CurrentLineHeight - advance);
     this.CurrentLineHeight = 0;
 }