コード例 #1
0
        public short Render(IVisio.Shape shape)
        {
            short sec_index = GeometryHelper.AddSection(shape);
            short row_count = shape.RowCount[sec_index];

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            var src_nofill      = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoFill.Cell);
            var src_noline      = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoLine.Cell);
            var src_noshow      = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoShow.Cell);
            var src_nosnap      = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoSnap.Cell);
            var src_noquickdrag = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoQuickDrag.Cell);

            writer.SetFormula(src_nofill, this.NoFill);
            writer.SetFormula(src_noline, this.NoLine);
            writer.SetFormula(src_noshow, this.NoShow);
            writer.SetFormula(src_nosnap, this.NoSnap);
            writer.SetFormula(src_noquickdrag, this.NoQuickDrag);

            foreach (var row in this.Rows)
            {
                row.AddTo(shape, writer, row_count, sec_index);
                row_count++;
            }

            writer.Commit(shape);

            return(0);
        }
コード例 #2
0
        internal static void SetSize(IVisio.Page page, Drawing.Size size)
        {
            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, size.Width);
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, size.Height);

            writer.Commit(page.PageSheet);
        }
コード例 #3
0
        public static void Set(IVisio.Shape shape, string name, UserDefinedCellCells cells)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

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

            UserDefinedCellHelper.CheckValidName(name);

            if (UserDefinedCellHelper.Contains(shape, name))
            {
                // The user-defined cell already exists
                string full_prop_name = UserDefinedCellHelper.GetRowName(name);

                if (cells.Value.HasValue)
                {
                    string value_cell_name = full_prop_name;
                    var    cell            = shape.CellsU[value_cell_name];
                    cell.FormulaU = cells.Value.Value;
                }

                if (cells.Prompt.HasValue)
                {
                    string prompt_cell_name = full_prop_name + ".Prompt";
                    var    cell             = shape.CellsU[prompt_cell_name];
                    cell.FormulaU = cells.Prompt.Value;
                }
            }
            else
            {
                // The user-defined cell doesn't already exist
                short row        = shape.AddNamedRow(_udcell_section, name, (short)IVisio.VisRowIndices.visRowUser);
                var   src_value  = new ShapeSheet.Src(_udcell_section, row, (short)IVisio.VisCellIndices.visUserValue);
                var   src_prompt = new ShapeSheet.Src(_udcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt);

                var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

                if (cells.Value.HasValue)
                {
                    writer.SetFormula(src_value, cells.Value.Value);
                }

                if (cells.Prompt.HasValue)
                {
                    writer.SetFormula(src_prompt, cells.Prompt.Value);
                }

                writer.Commit(shape);
            }
        }
コード例 #4
0
        public static void Set(IVisio.Shape shape, string name, ShapeSheet.CellValueLiteral udfcell_value, ShapeSheet.CellValueLiteral udfcell_prompt)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            UserDefinedCellHelper.CheckValidName(name);

            if (UserDefinedCellHelper.Contains(shape, name))
            {
                string full_prop_name = UserDefinedCellHelper.GetRowName(name);

                if (udfcell_value.HasValue)
                {
                    string value_cell_name = full_prop_name;
                    var    cell            = shape.CellsU[value_cell_name];
                    cell.FormulaU = VisioAutomation.Utilities.Convert.StringToFormulaString(udfcell_value.Value);
                }

                if (udfcell_prompt.HasValue)
                {
                    string prompt_cell_name = full_prop_name + ".Prompt";
                    var    cell             = shape.CellsU[prompt_cell_name];
                    cell.FormulaU = VisioAutomation.Utilities.Convert.StringToFormulaString(udfcell_prompt.Value);
                }
                return;
            }

            short row = shape.AddNamedRow(
                UserDefinedCellHelper._userdefinedcell_section,
                name,
                (short)IVisio.VisRowIndices.visRowUser);

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            if (udfcell_value.HasValue)
            {
                var src     = new ShapeSheet.Src(UserDefinedCellHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserValue);
                var formula = VisioAutomation.Utilities.Convert.StringToFormulaString(udfcell_value.Value);
                writer.SetFormula(src, formula);
            }

            if (udfcell_prompt.HasValue)
            {
                var src     = new ShapeSheet.Src(UserDefinedCellHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt);
                var formula = VisioAutomation.Utilities.Convert.StringToFormulaString(udfcell_prompt.Value);
                writer.SetFormula(src, formula);
            }

            writer.Commit(shape);
        }
コード例 #5
0
        public static void SetTabStops(IVisio.Shape shape, IList <TabStop> stops)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

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

            ClearTabStops(shape);
            if (stops.Count < 1)
            {
                return;
            }

            const short row = 0;
            var         invariant_culture  = System.Globalization.CultureInfo.InvariantCulture;
            var         vis_tab_stop_count = (short)IVisio.VisCellIndices.visTabStopCount;
            var         tabstopcountcell   = shape.CellsSRC[tab_section, row, vis_tab_stop_count];

            tabstopcountcell.FormulaU = stops.Count.ToString(invariant_culture);

            // set the number of tab stobs allowed for the shape
            var tagtab = GetTabTagForStops(stops.Count);

            shape.RowType[tab_section, (short)IVisio.VisRowIndices.visRowTab] = (short)tagtab;

            // add tab properties for each stop
            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            for (int stop_index = 0; stop_index < stops.Count; stop_index++)
            {
                int i = stop_index * 3;

                var alignment = ((int)stops[stop_index].Alignment).ToString(invariant_culture);
                var position  = ((int)stops[stop_index].Position).ToString(invariant_culture);

                var src_tabpos   = new ShapeSheet.Src(tab_section, row, (short)(i + 1));
                var src_tabalign = new ShapeSheet.Src(tab_section, row, (short)(i + 2));
                var src_tabother = new ShapeSheet.Src(tab_section, row, (short)(i + 3));

                writer.SetFormula(src_tabpos, position);    // tab position
                writer.SetFormula(src_tabalign, alignment); // tab alignment
                writer.SetFormula(src_tabother, "0");       // tab unknown
            }

            writer.Commit(shape);
        }
コード例 #6
0
        public static void SetPageSize(IVisio.Page page, VisioAutomation.Drawing.Size size)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException(nameof(page));
            }

            var page_sheet = page.PageSheet;

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, size.Width);
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, size.Height);

            writer.Commit(page_sheet);
        }
コード例 #7
0
        /// <summary>
        /// Remove all tab stops on the shape
        /// </summary>
        /// <param name="shape"></param>
        private static void ClearTabStops(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            int num_existing_tabstops = GetTabStopCount(shape);

            if (num_existing_tabstops < 1)
            {
                return;
            }

            var cell_tabstopcount = shape.CellsSRC[ShapeSheet.SrcConstants.TabStopCount.Section, ShapeSheet.SrcConstants.TabStopCount.Row, ShapeSheet.SrcConstants.TabStopCount.Cell];

            cell_tabstopcount.FormulaForce = "0";

            const string formula = "0";

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            for (int i = 1; i < num_existing_tabstops * 3; i++)
            {
                var src = new ShapeSheet.Src(tab_section, (short)IVisio.VisRowIndices.visRowTab,
                                             (short)i);
                writer.SetFormula(src, formula);
            }

            writer.Commit(shape);
        }
コード例 #8
0
        public void Apply(IVisio.Page page)
        {
            var pagecells = new PageLayoutFormulas();

            this.SetPageCells(pagecells);

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageLayoutAvenueSizeX, pagecells.AvenueSizeX);
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageLayoutAvenueSizeY, pagecells.AvenueSizeY);
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageLayoutLineRouteExt, pagecells.LineRouteExt);
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageLayoutRouteStyle, pagecells.RouteStyle);
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageLayoutPlaceStyle, pagecells.PlaceStyle);

            writer.Commit(page.PageSheet);
            page.Layout();
        }
コード例 #9
0
        public void SetSize(VisioAutomation.Drawing.Size new_size)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var application = this._client.Application.Get();

            using (var undoscope = this._client.Application.NewUndoScope("Set Page Size"))
            {
                var active_page = application.ActivePage;
                var page_sheet  = active_page.PageSheet;
                var writer      = new VisioAutomation.ShapeSheet.Writers.SrcWriter();
                writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, new_size.Width);
                writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, new_size.Height);

                writer.Commit(page_sheet);
            }
        }
コード例 #10
0
        public void SetOrientation(VisioScripting.Models.PageOrientation orientation)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var app         = this._client.Application.Get();
            var application = app;

            var active_page = application.ActivePage;

            if (orientation != VisioScripting.Models.PageOrientation.Landscape && orientation != VisioScripting.Models.PageOrientation.Portrait)
            {
                throw new System.ArgumentOutOfRangeException(nameof(orientation), "must be either Portrait or Landscape");
            }

            var old_orientation = PageCommands.GetOrientation(active_page);

            if (old_orientation == orientation)
            {
                // don't need to do anything
                return;
            }

            var old_size = this.GetSize();

            double new_height = old_size.Width;
            double new_width  = old_size.Height;

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, new_width);
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, new_height);
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PrintPageOrientation, (int)orientation);

            using (var undoscope = this._client.Application.NewUndoScope("Set Page Orientation"))
            {
                writer.Commit(active_page.PageSheet);
            }
        }
コード例 #11
0
        public void ResetOrigin(IVisio.Page page)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var application = this._client.Application.Get();

            if (page == null)
            {
                page = application.ActivePage;
            }

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.XGridOrigin, "0.0");
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.YGridOrigin, "0.0");
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.XRulerOrigin, "0.0");
            writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.YRulerOrigin, "0.0");

            using (var undoscope = this._client.Application.NewUndoScope("Reset Page Origin"))
            {
                writer.Commit(page.PageSheet);
            }
        }
コード例 #12
0
 internal void ApplyFormulas(VisioAutomation.ShapeSheet.Writers.SrcWriter writer, short row)
 {
     writer.SetFormula(SrcConstants.ParaIndentLeft.CloneWithNewRow(row), this.IndentLeft);
     writer.SetFormula(SrcConstants.ParaIndentFirst.CloneWithNewRow(row), this.IndentFirst);
     writer.SetFormula(SrcConstants.ParaIndentRight.CloneWithNewRow(row), this.IndentRight);
     writer.SetFormula(SrcConstants.ParaSpacingAfter.CloneWithNewRow(row), this.SpacingAfter);
     writer.SetFormula(SrcConstants.ParaSpacingBefore.CloneWithNewRow(row), this.SpacingBefore);
     writer.SetFormula(SrcConstants.ParaSpacingLine.CloneWithNewRow(row), this.SpacingLine);
     writer.SetFormula(SrcConstants.ParaHorizontalAlign.CloneWithNewRow(row), this.HorizontalAlign);
     writer.SetFormula(SrcConstants.ParaBulletFont.CloneWithNewRow(row), this.BulletFont);
     writer.SetFormula(SrcConstants.ParaBullet.CloneWithNewRow(row), this.Bullet);
     writer.SetFormula(SrcConstants.ParaBulletFontSize.CloneWithNewRow(row), this.BulletFontSize);
     writer.SetFormula(SrcConstants.ParaLocalizeBulletFont.CloneWithNewRow(row), this.LocBulletFont);
     writer.SetFormula(SrcConstants.ParaTextPosAfterBullet.CloneWithNewRow(row), this.TextPosAfterBullet);
     writer.SetFormula(SrcConstants.ParaFlags.CloneWithNewRow(row), this.Flags);
     writer.SetFormula(SrcConstants.ParaBulletString.CloneWithNewRow(row), this.BulletString);
 }
コード例 #13
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 ShapeSheetQuery();
            int i     = 0;

            foreach (var src in page_srcs)
            {
                query.AddCell(src, "Col" + i.ToString());
                i++;
            }

            var src_formulas = query.GetFormulas(src_page.PageSheet);

            // Set the Cells on the Destination

            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            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);
            }
        }
コード例 #14
0
 internal void ApplyFormulas(VisioAutomation.ShapeSheet.Writers.SrcWriter writer, short row)
 {
     writer.SetFormula(SrcConstants.CharColor.CloneWithNewRow(row), this.Color);
     writer.SetFormula(SrcConstants.CharFont.CloneWithNewRow(row), this.Font);
     writer.SetFormula(SrcConstants.CharSize.CloneWithNewRow(row), this.Size);
     writer.SetFormula(SrcConstants.CharStyle.CloneWithNewRow(row), this.Style);
     writer.SetFormula(SrcConstants.CharColorTransparency.CloneWithNewRow(row), this.Transparency);
     writer.SetFormula(SrcConstants.CharAsianFont.CloneWithNewRow(row), this.AsianFont);
     writer.SetFormula(SrcConstants.CharCase.CloneWithNewRow(row), this.Case);
     writer.SetFormula(SrcConstants.CharComplexScriptFont.CloneWithNewRow(row), this.ComplexScriptFont);
     writer.SetFormula(SrcConstants.CharComplexScriptSize.CloneWithNewRow(row), this.ComplexScriptSize);
     writer.SetFormula(SrcConstants.CharDoubleUnderline.CloneWithNewRow(row), this.DoubleUnderline);
     writer.SetFormula(SrcConstants.CharDoubleStrikethrough.CloneWithNewRow(row), this.DoubleStrikeThrough);
     writer.SetFormula(SrcConstants.CharLangID.CloneWithNewRow(row), this.LangID);
     writer.SetFormula(SrcConstants.CharFontScale.CloneWithNewRow(row), this.FontScale);
     writer.SetFormula(SrcConstants.CharLangID.CloneWithNewRow(row), this.LangID);
     writer.SetFormula(SrcConstants.CharLetterspace.CloneWithNewRow(row), this.Letterspace);
     writer.SetFormula(SrcConstants.CharLocale.CloneWithNewRow(row), this.Locale);
     writer.SetFormula(SrcConstants.CharLocalizeFont.CloneWithNewRow(row), this.LocalizeFont);
     writer.SetFormula(SrcConstants.CharOverline.CloneWithNewRow(row), this.Overline);
     writer.SetFormula(SrcConstants.CharPerpendicular.CloneWithNewRow(row), this.Perpendicular);
     writer.SetFormula(SrcConstants.CharPos.CloneWithNewRow(row), this.Pos);
     writer.SetFormula(SrcConstants.CharRTLText.CloneWithNewRow(row), this.RTLText);
     writer.SetFormula(SrcConstants.CharStrikethru.CloneWithNewRow(row), this.Strikethru);
     writer.SetFormula(SrcConstants.CharUseVertical.CloneWithNewRow(row), this.UseVertical);
 }