예제 #1
0
        public short Render(IVisio.Shape shape)
        {
            short sec_index = GeometryHelper.AddSection(shape);
            short row_count = shape.RowCount[sec_index];

            var writer = new FormulaWriterSRC();

            var src_nofill      = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoFill.Cell);
            var src_noline      = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoLine.Cell);
            var src_noshow      = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoShow.Cell);
            var src_nosnap      = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoSnap.Cell);
            var src_noquickdrag = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoQuickDrag.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
        private static void SetSize(IVisio.Page page, Drawing.Size size)
        {
            var writer = new FormulaWriterSRC();

            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 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 FormulaWriterSRC();

            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);
        }
        public static void Set(IVisio.Shape shape, string name, ShapeSheet.FormulaLiteral value, ShapeSheet.FormulaLiteral 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 (value.HasValue)
                {
                    string value_cell_name = full_prop_name;
                    var    cell            = shape.CellsU[value_cell_name];
                    cell.FormulaU = value.Encode();
                }

                if (prompt.HasValue)
                {
                    string prompt_cell_name = full_prop_name + ".Prompt";
                    var    cell             = shape.CellsU[prompt_cell_name];
                    cell.FormulaU = prompt.Encode();
                }
                return;
            }

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

            var writer = new FormulaWriterSRC();

            if (value.HasValue)
            {
                var src = new ShapeSheet.SRC(UserDefinedCellHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserValue);
                writer.SetFormula(src, value.Encode());
            }

            if (prompt.HasValue)
            {
                var src = new ShapeSheet.SRC(UserDefinedCellHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt);
                writer.SetFormula(src, prompt.Encode());
            }

            writer.Commit(shape);
        }
        public static void SetPageSize(IVisio.Page page, VA.Drawing.Size size)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException(nameof(page));
            }

            var page_sheet = page.PageSheet;

            var writer = new FormulaWriterSRC(2);

            writer.SetFormula(VA.ShapeSheet.SRCConstants.PageWidth, size.Width);
            writer.SetFormula(VA.ShapeSheet.SRCConstants.PageHeight, size.Height);
            writer.Commit(page_sheet);
        }
예제 #6
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.Tabs_StopCount.Section, ShapeSheet.SRCConstants.Tabs_StopCount.Row, ShapeSheet.SRCConstants.Tabs_StopCount.Cell];

            cell_tabstopcount.FormulaForce = "0";

            const string formula = "0";

            var writer = new FormulaWriterSRC();

            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);
        }
예제 #7
0
 public void SetFormulas(FormulaWriterSRC writer)
 {
     foreach (var pair in this.Pairs)
     {
         writer.SetFormula(pair.SRC, pair.Formula);
     }
 }
예제 #8
0
 public void SetFormulas(FormulaWriterSRC writer, short row)
 {
     foreach (var pair in this.Pairs)
     {
         var new_src = pair.SRC.CopyWithNewRow(row);
         writer.SetFormula(new_src, pair.Formula);
     }
 }
예제 #9
0
        public void SetSize(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 FormulaWriterSRC(2);
                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 Apply(IVisio.Page page)
        {
            var pagecells = new PageLayoutFormulas();

            this.SetPageCells(pagecells);

            var writer = new FormulaWriterSRC();

            writer.SetFormula(VisioAutomation.ShapeSheet.SRCConstants.AvenueSizeX, pagecells.AvenueSizeX);
            writer.SetFormula(VisioAutomation.ShapeSheet.SRCConstants.AvenueSizeY, pagecells.AvenueSizeY);
            writer.SetFormula(VisioAutomation.ShapeSheet.SRCConstants.LineRouteExt, pagecells.LineRouteExt);
            writer.SetFormula(VisioAutomation.ShapeSheet.SRCConstants.RouteStyle, pagecells.RouteStyle);
            writer.SetFormula(VisioAutomation.ShapeSheet.SRCConstants.PlaceStyle, pagecells.PlaceStyle);

            var pagesheet = page.PageSheet;

            writer.Commit(pagesheet);
            page.Layout();
        }
예제 #11
0
        public void SetOrientation(Pages.PrintPageOrientation 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 != Pages.PrintPageOrientation.Landscape && orientation != Pages.PrintPageOrientation.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 FormulaWriterSRC(3);

            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);
            }
        }
예제 #12
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 FormulaWriterSRC();

            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);
            }
        }
예제 #13
0
        private void Update(short section_index, short row_index, FormulaWriterSRC writer)
        {
            var x_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_X.Cell);
            var y_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_Y.Cell);
            var a_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_A.Cell);
            var b_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_B.Cell);
            var c_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_C.Cell);
            var d_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_D.Cell);
            var e_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_E.Cell);

            writer.SetFormula(x_src, this.X);
            writer.SetFormula(y_src, this.Y);
            writer.SetFormula(a_src, this.A);
            writer.SetFormula(b_src, this.B);
            writer.SetFormula(c_src, this.C);
            writer.SetFormula(d_src, this.D);
            writer.SetFormula(e_src, this.E);
        }
 internal void ApplyFormulas(FormulaWriterSRC writer, short row)
 {
     writer.SetFormula(SRCCON.Para_IndLeft.CopyWithNewRow(row), this.IndentLeft);
     writer.SetFormula(SRCCON.Para_IndFirst.CopyWithNewRow(row), this.IndentFirst);
     writer.SetFormula(SRCCON.Para_IndRight.CopyWithNewRow(row), this.IndentRight);
     writer.SetFormula(SRCCON.Para_SpAfter.CopyWithNewRow(row), this.SpacingAfter);
     writer.SetFormula(SRCCON.Para_SpBefore.CopyWithNewRow(row), this.SpacingBefore);
     writer.SetFormula(SRCCON.Para_SpLine.CopyWithNewRow(row), this.SpacingLine);
     writer.SetFormula(SRCCON.Para_HorzAlign.CopyWithNewRow(row), this.HorizontalAlign);
     writer.SetFormula(SRCCON.Para_BulletFont.CopyWithNewRow(row), this.BulletFont);
     writer.SetFormula(SRCCON.Para_Bullet.CopyWithNewRow(row), this.Bullet);
     writer.SetFormula(SRCCON.Para_BulletFontSize.CopyWithNewRow(row), this.BulletFontSize);
     writer.SetFormula(SRCCON.Para_LocalizeBulletFont.CopyWithNewRow(row), this.LocBulletFont);
     writer.SetFormula(SRCCON.Para_TextPosAfterBullet.CopyWithNewRow(row), this.TextPosAfterBullet);
     writer.SetFormula(SRCCON.Para_Flags.CopyWithNewRow(row), this.Flags);
     writer.SetFormula(SRCCON.Para_BulletStr.CopyWithNewRow(row), this.BulletString);
 }
예제 #15
0
 internal void ApplyFormulas(FormulaWriterSRC writer, short row)
 {
     writer.SetFormula(SRCCON.CharColor.CopyWithNewRow(row), this.Color);
     writer.SetFormula(SRCCON.CharFont.CopyWithNewRow(row), this.Font);
     writer.SetFormula(SRCCON.CharSize.CopyWithNewRow(row), this.Size);
     writer.SetFormula(SRCCON.CharStyle.CopyWithNewRow(row), this.Style);
     writer.SetFormula(SRCCON.CharColorTrans.CopyWithNewRow(row), this.Transparency);
     writer.SetFormula(SRCCON.CharAsianFont.CopyWithNewRow(row), this.AsianFont);
     writer.SetFormula(SRCCON.CharCase.CopyWithNewRow(row), this.Case);
     writer.SetFormula(SRCCON.CharComplexScriptFont.CopyWithNewRow(row), this.ComplexScriptFont);
     writer.SetFormula(SRCCON.CharComplexScriptSize.CopyWithNewRow(row), this.ComplexScriptSize);
     writer.SetFormula(SRCCON.CharDblUnderline.CopyWithNewRow(row), this.DoubleUnderline);
     writer.SetFormula(SRCCON.CharDoubleStrikethrough.CopyWithNewRow(row), this.DoubleStrikeThrough);
     writer.SetFormula(SRCCON.CharLangID.CopyWithNewRow(row), this.LangID);
     writer.SetFormula(SRCCON.CharFontScale.CopyWithNewRow(row), this.FontScale);
     writer.SetFormula(SRCCON.CharLangID.CopyWithNewRow(row), this.LangID);
     writer.SetFormula(SRCCON.CharLetterspace.CopyWithNewRow(row), this.Letterspace);
     writer.SetFormula(SRCCON.CharLocale.CopyWithNewRow(row), this.Locale);
     writer.SetFormula(SRCCON.CharLocalizeFont.CopyWithNewRow(row), this.LocalizeFont);
     writer.SetFormula(SRCCON.CharOverline.CopyWithNewRow(row), this.Overline);
     writer.SetFormula(SRCCON.CharPerpendicular.CopyWithNewRow(row), this.Perpendicular);
     writer.SetFormula(SRCCON.CharPos.CopyWithNewRow(row), this.Pos);
     writer.SetFormula(SRCCON.CharRTLText.CopyWithNewRow(row), this.RTLText);
     writer.SetFormula(SRCCON.CharStrikethru.CopyWithNewRow(row), this.Strikethru);
     writer.SetFormula(SRCCON.CharUseVertical.CopyWithNewRow(row), this.UseVertical);
 }
예제 #16
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);
            }
        }