public Dictionary <IVisio.Shape, VA.Shapes.UserDefinedCellDictionary> GetUserDefinedCells(TargetShapes targetshapes, VASS.CellValueType cvt)
        {
            var cmdtarget = this._client.GetCommandTargetPage();
            var dicof_shape_to_udcelldic = new Dictionary <IVisio.Shape, VA.Shapes.UserDefinedCellDictionary>();

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(dicof_shape_to_udcelldic);
            }

            var page             = cmdtarget.ActivePage;
            var shapeidpairs     = targetshapes.ToShapeIDPairs();
            var listof_udcelldic = VA.Shapes.UserDefinedCellHelper.GetCellsAsDictionary((IVisio.Page)page, shapeidpairs, cvt);

            for (int i = 0; i < targetshapes.Shapes.Count; i++)
            {
                var shape = targetshapes.Shapes[i];
                var props = listof_udcelldic[i];
                dicof_shape_to_udcelldic[shape] = props;
            }

            return(dicof_shape_to_udcelldic);
        }
Пример #2
0
        public List <int> AddHyperlink(TargetShapes targetshapes, HyperlinkCells hlink)
        {
            if (hlink == null)
            {
                throw new System.ArgumentNullException(nameof(hlink));
            }

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(new List <int>(0));
            }

            var hyperlink_indices = new List <int>();

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(AddHyperlink)))
            {
                foreach (var shape in targetshapes.Shapes)
                {
                    int hi = HyperlinkHelper.Add(shape, hlink);
                    hyperlink_indices.Add(hi);
                }
            }

            return(hyperlink_indices);
        }
        public void DeleteCustomPropertyWithName(TargetShapes targetshapes, string name)
        {
            if (name == null)
            {
                throw new System.ArgumentNullException(nameof(name));
            }

            if (name.Length < 1)
            {
                throw new System.ArgumentException("name cannot be empty", nameof(name));
            }

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return;
            }

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(DeleteCustomPropertyWithName)))
            {
                foreach (var shape in targetshapes.Shapes)
                {
                    CustomPropertyHelper.Delete(shape, name);
                }
            }
        }
Пример #4
0
        public Dictionary <int, VA.Shapes.LockCells> GetLockCells(TargetShapes targetshapes, VASS.CellValueType cvt)
        {
            targetshapes = targetshapes.Resolve(this._client);
            if (targetshapes.Shapes.Count < 1)
            {
                return(new Dictionary <int, VA.Shapes.LockCells>());
            }

            var dic = new Dictionary <int, VA.Shapes.LockCells>();

            var page = targetshapes.Shapes[0].ContainingPage;

            var target_shapeids = targetshapes.ToShapeIDs();

            var cells = VisioAutomation.Shapes.LockCells.GetCells(page, target_shapeids, cvt);

            for (int i = 0; i < target_shapeids.Count; i++)
            {
                var shapeid   = target_shapeids[i];
                var cur_cells = cells[i];
                dic[shapeid] = cur_cells;
            }

            return(dic);
        }
        public void SetShapeName(TargetShapes targetshapes, IList <string> names)
        {
            if (names == null || names.Count < 1)
            {
                // do nothing
                return;
            }

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return;
            }

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetShapeName)))
            {
                int numnames = names.Count;

                int up_to = System.Math.Min(numnames, targetshapes.Shapes.Count);

                for (int i = 0; i < up_to; i++)
                {
                    var new_name = names[i];

                    if (new_name != null)
                    {
                        var shape = targetshapes.Shapes[i];
                        shape.Name = new_name;
                    }
                }
            }
        }
        public List <int> AddControlToShapes(TargetShapes targetshapes, ControlCells ctrl)
        {
            if (ctrl == null)
            {
                throw new System.ArgumentNullException(nameof(ctrl));
            }

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(new List <int>(0));
            }

            var control_indices = new List <int>();

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(AddControlToShapes)))
            {
                foreach (var shape in targetshapes.Shapes)
                {
                    int ci = ControlHelper.Add(shape, ctrl);
                    control_indices.Add(ci);
                }
            }

            return(control_indices);
        }
        public IDictionary <IVisio.Shape, CustomPropertyDictionary> GetCustomProperties(TargetShapes targetshapes)
        {
            var cmdtarget = this._client.GetCommandTargetPage();

            var dicof_shape_to_cpdic = new Dictionary <IVisio.Shape, CustomPropertyDictionary>();

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(dicof_shape_to_cpdic);
            }

            var shapeidpairs = targetshapes.ToShapeIDPairs();
            var listof_cpdic = CustomPropertyHelper.GetCellsAsDictionary(cmdtarget.ActivePage, shapeidpairs, CellValueType.Formula);


            for (int i = 0; i < targetshapes.Shapes.Count; i++)
            {
                var shape = targetshapes.Shapes[i];
                var cpdic = listof_cpdic[i];
                dicof_shape_to_cpdic[shape] = cpdic;
            }

            return(dicof_shape_to_cpdic);
        }
Пример #8
0
        public void SetShapeText(TargetShapes targetshapes, IList <string> texts)
        {
            if (texts == null || texts.Count < 1)
            {
                return;
            }

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return;
            }

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetShapeText)))
            {
                // Apply text to each shape
                // if there are fewer texts than shapes then
                // start reusing the texts from the beginning

                int count = 0;
                foreach (var shape in targetshapes.Shapes)
                {
                    string text = texts[count % texts.Count];
                    if (text != null)
                    {
                        shape.Text = text;
                    }
                    count++;
                }
            }
        }
Пример #9
0
        public List <string> GetShapeText(TargetShapes targetshapes)
        {
            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(new List <string>(0));
            }

            var texts = targetshapes.Shapes.Select(s => s.Text).ToList();

            return(texts);
        }
        public void DistributeSelectionOnAxis(TargetShapes targetshapes, Models.Axis axis, double spacing)
        {
            var cmdtarget = this._client.GetCommandTargetPage();

            var page = cmdtarget.ActivePage;

            targetshapes = targetshapes.Resolve(this._client);
            var targetshapeids = targetshapes.ToShapeIDs();

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(DistributeSelectionOnAxis)))
            {
                VisioScripting.Helpers.ArrangeHelper._distribute_with_spacing(page, targetshapeids, axis, spacing);
            }
        }
        internal void __SetCells(TargetShapes targetshapes, VASS.CellGroups.CellGroup cellgroup, IVisio.Page page)
        {
            targetshapes = targetshapes.Resolve(this._client);
            var targetshapeids = targetshapes.ToShapeIDs();
            var writer         = new VASS.Writers.SidSrcWriter();

            foreach (var shapeid in targetshapeids)
            {
                var cells_mr = (VASS.CellGroups.CellGroup)cellgroup;
                writer.SetValues((short)shapeid, cells_mr, 0);
            }

            writer.Commit(page, VASS.CellValueType.Formula);
        }
        public List <bool> ContainCustomPropertyWithName(TargetShapes targetshapes, string name)
        {
            if (name == null)
            {
                throw new System.ArgumentNullException(nameof(name));
            }

            targetshapes = targetshapes.Resolve(this._client);

            var results = new List <bool>(targetshapes.Shapes.Count);
            var values  = targetshapes.Shapes.Select(shape => CustomPropertyHelper.Contains(shape, name));

            results.AddRange(values);

            return(results);
        }
Пример #13
0
        public List <VisioAutomation.Text.TextFormat> GetShapeTextFormat(TargetShapes targetshapes)
        {
            var cmdtarget = this._client.GetCommandTargetDocument();

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(new List <VisioAutomation.Text.TextFormat>(0));
            }

            var shapeidpairs = targetshapes.ToShapeIDPairs();
            var application  = cmdtarget.Application;
            var formats      = VisioAutomation.Text.TextFormat.GetFormat(application.ActivePage, shapeidpairs, VASS.CellValueType.Formula);

            return(formats);
        }
        public void SetUserDefinedCell(TargetShapes targetshapes, Models.UserDefinedCell userdefinedcell)
        {
            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return;
            }

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetUserDefinedCell)))
            {
                foreach (var shape in targetshapes.Shapes)
                {
                    VA.Shapes.UserDefinedCellHelper.Set(shape, userdefinedcell.Name, userdefinedcell.Cells);
                }
            }
        }
        public Dictionary <IVisio.Shape, IList <ControlCells> > GetControls(TargetShapes targetshapes, CellValueType cvt)
        {
            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(new Dictionary <IVisio.Shape, IList <ControlCells> >(0));
            }

            var dic = new Dictionary <IVisio.Shape, IList <ControlCells> >(targetshapes.Shapes.Count);

            foreach (var shape in targetshapes.Shapes)
            {
                var controls = ControlCells.GetCells(shape, cvt);
                dic[shape] = controls;
            }
            return(dic);
        }
Пример #16
0
        public Dictionary <IVisio.Shape, IList <HyperlinkCells> > GetHyperlinks(TargetShapes targetshapes, VASS.CellValueType cvt)
        {
            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(new Dictionary <IVisio.Shape, IList <HyperlinkCells> >(0));
            }

            var dic = new Dictionary <IVisio.Shape, IList <HyperlinkCells> >();

            foreach (var shape in targetshapes.Shapes)
            {
                var hyperlinks = HyperlinkCells.GetCells(shape, cvt);
                dic[shape] = hyperlinks;
            }
            return(dic);
        }
Пример #17
0
        public IDictionary <IVisio.Shape, IList <VA.Shapes.ConnectionPointCells> > GetConnectionPoints(TargetShapes targetshapes)
        {
            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(new Dictionary <IVisio.Shape, IList <VA.Shapes.ConnectionPointCells> >());
            }

            var dicof_shape_to_cxnpoint = new Dictionary <IVisio.Shape, IList <VA.Shapes.ConnectionPointCells> >();

            foreach (var shape in targetshapes.Shapes)
            {
                var cp = VisioAutomation.Shapes.ConnectionPointCells.GetCells(shape, VASS.CellValueType.Formula);
                dicof_shape_to_cxnpoint[shape] = cp;
            }

            return(dicof_shape_to_cxnpoint);
        }
        public List <bool> ContainsUserDefinedCellsWithName(TargetShapes targetshapes, string name)
        {
            if (name == null)
            {
                throw new System.ArgumentNullException(nameof(name));
            }

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return(new List <bool>());
            }

            var all_shapes = this._client.Selection.GetShapesInSelection();
            var results    = all_shapes.Select(s => VA.Shapes.UserDefinedCellHelper.Contains(s, name)).ToList();

            return(results);
        }
Пример #19
0
        public void DeleteConnectionPointAtIndex(TargetShapes targetshapes, int index)
        {
            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return;
            }

            // restrict the operation to those shapes that actually have enough
            // connection points to qualify for deleting
            var qualified_shapes = targetshapes.Shapes.Where(shape => VA.Shapes.ConnectionPointHelper.GetCount(shape) > index);

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(DeleteConnectionPointAtIndex)))
            {
                foreach (var shape in qualified_shapes)
                {
                    VA.Shapes.ConnectionPointHelper.Delete(shape, index);
                }
            }
        }
Пример #20
0
        public void SetLockCells(TargetShapes targetshapes, VA.Shapes.LockCells lockcells)
        {
            targetshapes = targetshapes.Resolve(this._client);
            if (targetshapes.Shapes.Count < 1)
            {
                return;
            }

            var page           = targetshapes.Shapes[0].ContainingPage;
            var targetshapeids = targetshapes.ToShapeIDs();
            var writer         = new VASS.Writers.SidSrcWriter();

            foreach (int shapeid in targetshapeids)
            {
                writer.SetValues((short)shapeid, lockcells);
            }

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetLockCells)))
            {
                writer.Commit(page, VASS.CellValueType.Formula);
            }
        }
Пример #21
0
        public List <int> AddConnectionPoint(
            TargetShapes targets,
            string fx,
            string fy,
            Models.ConnectionPointType type)
        {
            targets = targets.Resolve(this._client);

            if (targets.Shapes.Count < 1)
            {
                return(new List <int>(0));
            }

            int dirx = 0;
            int diry = 0;

            var indices = new List <int>(targets.Shapes.Count);

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(AddConnectionPoint)))
            {
                var cxnpointcells = new VA.Shapes.ConnectionPointCells();
                cxnpointcells.X    = fx;
                cxnpointcells.Y    = fy;
                cxnpointcells.DirX = dirx;
                cxnpointcells.DirY = diry;
                cxnpointcells.Type = (int)type;

                foreach (var shape in targets.Shapes)
                {
                    int index = VA.Shapes.ConnectionPointHelper.Add(shape, cxnpointcells);
                    indices.Add(index);
                }
            }

            return(indices);
        }
        public void SetCustomProperty(TargetShapes targetshapes, string name, CustomPropertyCells customprop)
        {
            if (customprop == null)
            {
                throw new System.ArgumentNullException(nameof(customprop));
            }

            targetshapes = targetshapes.Resolve(this._client);

            if (targetshapes.Shapes.Count < 1)
            {
                return;
            }

            customprop.EncodeValues();

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetCustomProperty)))
            {
                foreach (var shape in targetshapes.Shapes)
                {
                    CustomPropertyHelper.Set(shape, name, customprop);
                }
            }
        }