Пример #1
0
        private static void Scramble(StringBuilder sb, IVisio.Shape shape)
        {
            sb.Clear();
            string text         = shape.Text;
            string text_trimmed = text.Trim();

            if (text_trimmed.Length >= 1)
            {
                shape.Text = VPTRibbon.Scramble(sb, shape.Text);
            }
        }
Пример #2
0
        private void buttonScrambleText_Click(object sender, RibbonControlEventArgs e)
        {
            var app = Globals.ThisAddIn.Application;
            var doc = app.ActiveDocument;

            if (doc == null)
            {
                return;
            }

            if (doc.Type != IVisio.VisDocumentTypes.visTypeDrawing)
            {
                MessageBox.Show("Currently Active Document is not a Drawing");
                return;
            }

            var activewindow = app.ActiveWindow;
            var sb           = new StringBuilder();
            var pages        = doc.Pages.AsEnumerable().ToList();

            using (var scope = new VA.Application.UndoScope(app, "Scramble Text"))
            {
                // Begin Undo Scope
                doc.Company  = VPTRibbon.Scramble(sb, doc.Company);
                doc.Category = VPTRibbon.Scramble(sb, doc.Category);
                doc.Title    = VPTRibbon.Scramble(sb, doc.Title);
                doc.Subject  = VPTRibbon.Scramble(sb, doc.Subject);
                doc.Creator  = VPTRibbon.Scramble(sb, doc.Creator);
                doc.Manager  = VPTRibbon.Scramble(sb, doc.Manager);
                doc.Keywords = VPTRibbon.Scramble(sb, doc.Keywords);
                foreach (var page in pages)
                {
                    activewindow.Page = page;
                    var shapes = page.Shapes.AsEnumerable().ToList();
                    foreach (var shape in shapes)
                    {
                        VPTRibbon.Scramble(sb, shape);

                        var shape_shapes = shape.Shapes;
                        if (shape_shapes != null && shape_shapes.Count > 0)
                        {
                            foreach (var nested_shape in VA.Shapes.ShapeHelper.GetNestedShapes(shape))
                            {
                                VPTRibbon.Scramble(sb, nested_shape);
                            }
                        }
                    }
                }
                // End Undo Scope
            }
        }