public void UserDefinedCells_GetFromMultipleShapes_WithAdditionalProps()
        {
            var page1 = this.GetNewPage();

            var s1     = page1.DrawRectangle(0, 0, 1, 1);
            var s2     = page1.DrawRectangle(1, 1, 2, 2);
            var shapes = new[] { s1, s2 };

            VAUSERCELL.UserDefinedCellHelper.Set(s1, "foo", "bar", null);

            var queryex = new VisioAutomation.ShapeSheet.Queries.Query();
            var sec     = queryex.AddSubQuery(IVisio.VisSectionIndices.visSectionUser);
            var Value   = sec.AddCell(VisioAutomation.ShapeSheet.SRCConstants.User_Value, "Value");
            var Prompt  = sec.AddCell(VisioAutomation.ShapeSheet.SRCConstants.User_Prompt, "Prompt");

            var surface  = new VisioAutomation.ShapeSheet.ShapeSheetSurface(page1);
            var formulas = queryex.GetFormulas(surface, shapes.Select(s => s.ID).ToList());


            page1.Delete(0);
        }
示例#2
0
        public         TResult[] GetResults_SRC <TResult>(short[] stream, IList <IVisio.VisUnitCodes> unitcodes)
        {
            ShapeSheetSurface.EnforceValidResultType(typeof(TResult));

            int numitems = ShapeSheetSurface.check_stream_size(stream, 3);

            if (numitems < 1)
            {
                return(new TResult[0]);
            }

            var result_type         = typeof(TResult);
            var unitcodes_obj_array = ShapeSheetSurface.get_unit_code_obj_array(unitcodes);
            var flags = ShapeSheetSurface.get_VisGetSetArgs(result_type);

            System.Array results_sa = null;

            if (this.Target.Master != null)
            {
                this.Target.Master.GetResults(stream, (short)flags, unitcodes_obj_array, out results_sa);
            }
            else if (this.Target.Page != null)
            {
                this.Target.Page.GetResults(stream, (short)flags, unitcodes_obj_array, out results_sa);
            }
            else if (this.Target.Shape != null)
            {
                this.Target.Shape.GetResults(stream, (short)flags, unitcodes_obj_array, out results_sa);
            }
            else
            {
                throw new System.ArgumentException("Unhandled Drawing Surface");
            }

            var results = ShapeSheetSurface.get_results_array <TResult>(results_sa, numitems);

            return(results);
        }
示例#3
0
        private void _Execute(ShapeSheetSurface surface)
        {
            // Do nothing if there aren't any updates
            if (this._updates.Count < 1)
            {
                return;
            }

            if (surface.Target.Shape != null)
            {
                if (this._first_update.Value.StreamType == StreamType.SIDSRC)
                {
                    throw new AutomationException("Contains a SIDSRC updates. Need SRC updates");
                }
            }
            else if (surface.Target.Master != null)
            {
                if (this._first_update.Value.StreamType == StreamType.SIDSRC)
                {
                    throw new AutomationException("Contains a SIDSRC updates. Need SRC updates");
                }
            }
            else if (surface.Target.Page != null)
            {
                if (this._first_update.Value.StreamType == StreamType.SRC)
                {
                    throw new AutomationException("Contains a SRC updates. Need SIDSRC updates");
                }
            }

            var stream = this.build_stream();

            if (this._first_update.Value.UpdateType == UpdateType.ResultNumeric || this._first_update.Value.UpdateType == UpdateType.ResultString)
            {
                // Set Results

                // Create the unitcodes and results arrays
                var unitcodes = new object[this._updates.Count];
                var results   = new object[this._updates.Count];
                int i         = 0;
                foreach (var update in this._updates)
                {
                    unitcodes[i] = update.UnitCode;
                    if (update.UpdateType == UpdateType.ResultNumeric)
                    {
                        results[i] = update.ResultNumeric;
                    }
                    else if (update.UpdateType == UpdateType.ResultString)
                    {
                        results[i] = update.ResultString;
                    }
                    else
                    {
                        throw new AutomationException("Unhandled update type");
                    }
                    i++;
                }

                var flags = this.ResultFlags;

                if (this._first_update.Value.UpdateType == UpdateType.ResultNumeric)
                {
                }
                else if (this._first_update.Value.UpdateType == UpdateType.ResultString)
                {
                    flags |= IVisio.VisGetSetArgs.visGetStrings;
                }

                surface.SetResults(stream, unitcodes, results, (short)flags);
            }
            else
            {
                // Set Formulas

                // Create the formulas array
                var formulas = new object[this._updates.Count];
                int i        = 0;
                foreach (var rec in this._updates)
                {
                    formulas[i] = rec.Formula;
                    i++;
                }

                var flags = this.FormulaFlags;

                int c = surface.SetFormulas(stream, formulas, (short)flags);
            }
        }
示例#4
0
 public void Execute(ShapeSheetSurface surface)
 {
     this._Execute(surface);
 }
示例#5
0
        public void Execute(IVisio.Shape shape)
        {
            var surface = new ShapeSheetSurface(shape);

            this._Execute(surface);
        }
示例#6
0
        public void Execute(IVisio.Page page)
        {
            var surface = new ShapeSheetSurface(page);

            this._Execute(surface);
        }
示例#7
0
 public ShapeSheetReader(Client client, IVisio.Page page)
 {
     this.Client  = client;
     this.Surface = new ShapeSheetSurface(page);
     this.SIDSRCs = new List <VisioAutomation.ShapeSheet.SIDSRC>();
 }
示例#8
0
        public static void Duplicate(
            IVisio.Page src_page,
            IVisio.Page dest_page)
        {
            init_page_srcs();

            var   app = src_page.Application;
            short copy_paste_flags = (short)IVisio.VisCutCopyPasteCodes.visCopyPasteNoTranslate;

            // handle the source page
            if (src_page == null)
            {
                throw new System.ArgumentNullException(nameof(src_page));
            }

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

            if (dest_page == src_page)
            {
                throw new System.ArgumentException("Destination Page cannot be Source Page");
            }


            if (src_page != app.ActivePage)
            {
                throw new System.ArgumentException("Source page must be active page.");
            }

            var src_page_shapes = src_page.Shapes;
            int num_src_shapes  = src_page_shapes.Count;

            if (num_src_shapes > 0)
            {
                var active_window = app.ActiveWindow;
                active_window.SelectAll();
                var selection = active_window.Selection;
                selection.Copy(copy_paste_flags);
                active_window.DeselectAll();
            }

            // Get the Cells from the Source
            var query = new VisioAutomation.ShapeSheet.Queries.Query();
            int i     = 0;

            foreach (var src in page_srcs)
            {
                query.AddCell(src, "Col" + i.ToString());
                i++;
            }
            var src_surface  = new VisioAutomation.ShapeSheet.ShapeSheetSurface(src_page.PageSheet);
            var src_formulas = query.GetFormulas(src_surface);

            // Set the Cells on the Destination

            var writer = new FormulaWriterSRC();

            for (i = 0; i < page_srcs.Count; i++)
            {
                writer.SetFormula(page_srcs[i], src_formulas.Cells[i]);
            }
            writer.Commit(dest_page.PageSheet);

            // make sure the new page looks like the old page
            dest_page.Background = src_page.Background;

            // then paste any contents from the first page
            if (num_src_shapes > 0)
            {
                dest_page.Paste(copy_paste_flags);
            }
        }
示例#9
0
 public ShapeSheetReader(Client client, IVisio.Page page)
 {
     this.Client              = client;
     this.Surface             = new ShapeSheetSurface(page);
     this.SidSrcStreamBuilder = new VisioAutomation.ShapeSheet.Streams.SidSrcStreamBuilder();
 }
 public ShapeSheetWriter(Client client, Microsoft.Office.Interop.Visio.Page page)
 {
     this.Client         = client;
     this.Surface        = new ShapeSheetSurface(page);
     this.formula_writer = new FormulaWriterSIDSRC();
 }