public static void TextMarkup13() { var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); var segoe_ui = page.Document.Fonts["Segoe UI"]; // Create the Shapes that will hold the text var s1 = page.DrawRectangle(0, 0, 8.5, 11); var e1 = new VAM.Text.Element(); e1.AddText("When, from behind that craggy steep\n"); e1.AddText("till then the horizon’s bound\n"); var f2 = new TextFmt { HAlign = VSM.AlignmentHorizontal.Left, CharStyle = VAM.Text.CharStyle.Italic }; var f3 = new TextFmt { FontID = segoe_ui.ID, HAlign = VSM.AlignmentHorizontal.Center, CharStyle = VAM.Text.CharStyle.Bold }; var f4 = new TextFmt { HAlign = VSM.AlignmentHorizontal.Right, CharStyle = VAM.Text.CharStyle.Italic }; var e2 = e1.AddElementEx("a huge peak, black and huge\n", f2); var e3 = e1.AddElementEx("As if with voluntary power instinct\n", f3); var e4 = e1.AddElementEx("Upreared its head.\n", f4); e1.AddText("-William Wordsworth, the Prelude"); e1.SetText(s1); }
public static void ProgressBar() { var page_a = SampleEnvironment.Application.ActiveDocument.Pages.Add(); // Draw some shapes var background = page_a.DrawRectangle(0, 0, 5, 1); var progress = page_a.DrawRectangle(0, 0, 1, 1); var background_fmt = new VA.Shapes.ShapeFormatCells(); background_fmt.FillForeground = "rgb(240,240,240)"; background_fmt.LineColor = "rgb(100,100,100)"; var progress_fmt = new VA.Shapes.ShapeFormatCells(); progress_fmt.FillForeground = "rgb(100,150,240)"; progress_fmt.LineColor = "rgb(100,100,100)"; // group the two shapes together page_a.Application.ActiveWindow.SelectAll(); var group = page_a.Application.ActiveWindow.Selection.Group(); // Set the progress shape update itself based on its position string bkname = background.NameID; var xfrm = new VA.Shapes.ShapeXFormCells(); xfrm.PinX = string.Format("GUARD({0}!PinX-{0}!LocPinX+LocPinX)", bkname); xfrm.PinY = string.Format("GUARD({0}!PinY)", bkname); xfrm.Width = string.Format("GUARD({0}!Width*(PAGENUMBER()/PAGECOUNT()))", bkname); xfrm.Height = string.Format("GUARD({0}!Height)", bkname); var writer = new SidSrcWriter(); xfrm.SetFormulas(writer, progress.ID16); background_fmt.SetFormulas(writer, progress.ID16); progress_fmt.SetFormulas(writer, progress.ID16); writer.Commit(page_a); var markup1 = new VisioAutomation.Models.Text.Element(); markup1.AddField(VisioAutomation.Models.Text.FieldConstants.PageName); markup1.AddText(" ("); markup1.AddField(VisioAutomation.Models.Text.FieldConstants.PageNumber); markup1.AddText(" of "); markup1.AddField(VisioAutomation.Models.Text.FieldConstants.NumberOfPages); markup1.AddText(") "); markup1.SetText(group); }
public static void TextMarkup14() { var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); // Create the Shapes that will hold the text var s1 = page.DrawRectangle(0, 0, 8.5, 11); var e1 = new VisioAutomation.Models.Text.Element(); e1.AddText("This shape is "); e1.AddField(VisioAutomation.Models.Text.FieldConstants.Width); e1.AddText("inches wide by "); e1.AddField(VisioAutomation.Models.Text.FieldConstants.Height); e1.AddText("inches tall."); e1.SetText(s1); }
public void DomText_CharacterPlain() { var m = new VisioAutomation.Models.Text.Element("{Normal}"); var page1 = this.GetNewPage(new VisioAutomation.Geometry.Size(5, 5)); var s0 = page1.DrawRectangle(0, 0, 4, 4); m.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0, CellValueType.Formula); var charfmt = textfmt.CharacterFormats; Assert.AreEqual(1, charfmt.Count); page1.Delete(0); }
public void DomText_ParagraphDefault() { var m = new VisioAutomation.Models.Text.Element("{DefaultPara}"); var page1 = this.GetNewPage(new VisioAutomation.Geometry.Size(5, 5)); var s0 = page1.DrawRectangle(0, 0, 4, 4); m.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0, CellValueType.Formula); var parafmt = textfmt.ParagraphFormats; Assert.AreEqual(1, parafmt.Count); page1.Delete(0); }
public static void TextFields() { var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); var s0 = page.DrawRectangle(1, 1, 4, 4); var markup1 = new VisioAutomation.Models.Text.Element(); markup1.AddField(VisioAutomation.Models.Text.FieldConstants.PageName); markup1.AddText(" ("); markup1.AddField(VisioAutomation.Models.Text.FieldConstants.PageNumber); markup1.AddText(" of "); markup1.AddField(VisioAutomation.Models.Text.FieldConstants.NumberOfPages); markup1.AddText(") "); markup1.SetText(s0); }
public static void TextMarkup11() { var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); // Create the Shapes that will hold the text var s1 = page.DrawRectangle(0, 0, 8.5, 11); var tnr = page.Document.Fonts["Times New Roman"]; var e1 = new VisioAutomation.Models.Text.Element(); var color_red = new VisioAutomation.Color.ColorRgb(0xff0000); e1.CharacterFormatting.Color = color_red.ToFormula(); e1.CharacterFormatting.Font = tnr.ID; e1.CharacterFormatting.Font = "20pt"; e1.AddText("Hello World"); e1.SetText(s1); }
public void DomText_CharacterItalic() { var m = new VisioAutomation.Models.Text.Element("{Italic}"); m.CharacterFormatting.Style = (int)VA.Models.Text.CharStyle.Italic; var page1 = this.GetNewPage(new VisioAutomation.Geometry.Size(5, 5)); var s0 = page1.DrawRectangle(0, 0, 4, 4); m.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0, CellValueType.Formula); var charfmt = textfmt.CharacterFormats; Assert.AreEqual(1, charfmt.Count); Assert.AreEqual(((int)VA.Models.Text.CharStyle.Italic).ToString(), charfmt[0].Style.Value); page1.Delete(0); }
public void DomText_CharacterBold() { var m = new VisioAutomation.Models.Text.Element("{Bold}"); m.CharacterFormatting.Style = (int)VA.Models.Text.CharStyle.Bold; var page1 = this.GetNewPage(new VisioAutomation.Drawing.Size(5, 5)); var s0 = page1.DrawRectangle(0, 0, 4, 4); m.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0); var charfmt = textfmt.CharacterFormats; Assert.AreEqual(1, charfmt.Count); Assert.AreEqual(((int)VA.Models.Text.CharStyle.Bold).ToString(), charfmt[0].Style.Result); page1.Delete(0); }
public void DomText_ParagraphRight() { var m = new VisioAutomation.Models.Text.Element("{RightHAlign}"); m.ParagraphFormatting.HorizontalAlign = (int)VABOX.AlignmentHorizontal.Right; var page1 = this.GetNewPage(new VisioAutomation.Geometry.Size(5, 5)); var s0 = page1.DrawRectangle(0, 0, 4, 4); m.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0, CellValueType.Formula); var parafmt = textfmt.ParagraphFormats; Assert.AreEqual(1, parafmt.Count); Assert.AreEqual(((int)VABOX.AlignmentHorizontal.Right).ToString(), parafmt[0].HorizontalAlign.Value); page1.Delete(0); }
public void DomText_ParagraphCenter() { var m = new VisioAutomation.Models.Text.Element("{CenterHAlign}"); m.ParagraphFormatting.HorizontalAlign = (int)AlignmentHorizontal.Center; var page1 = this.GetNewPage(new VisioAutomation.Drawing.Size(5, 5)); var s0 = page1.DrawRectangle(0, 0, 4, 4); m.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0); var parafmt = textfmt.ParagraphFormats; Assert.AreEqual(1, parafmt.Count); Assert.AreEqual(((int)AlignmentHorizontal.Center).ToString(), parafmt[0].HorizontalAlign.Result); page1.Delete(0); }
public static void TextMarkup5() { var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); // Create the Shapes that will hold the text var s1 = page.DrawRectangle(0, 0, 8.5, 11); var e1 = new VisioAutomation.Models.Text.Element(); e1.ParagraphFormatting.HorizontalAlign = 0; var e2 = e1.AddElement("Hello Worldline1\nline2\nline3\n"); e2.ParagraphFormatting.IndentFirst = "0.5pt"; e2.ParagraphFormatting.IndentLeft = "0.25pt"; var e3 = e1.AddElement("Goodbye\nline1\nline2\nline3"); e3.ParagraphFormatting.IndentFirst = "1.0pt"; e3.ParagraphFormatting.IndentLeft = "0.75pt"; e1.SetText(s1); }
public void DomText_CharacterFont() { var page1 = this.GetNewPage(new VisioAutomation.Drawing.Size(5, 5)); var impact = page1.Document.Fonts["Arial"]; var m = new VisioAutomation.Models.Text.Element("Normal Text in Impact Font"); m.CharacterFormatting.Font = impact.ID; var s0 = page1.DrawRectangle(0, 0, 4, 4); m.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0); var charfmt = textfmt.CharacterFormats; Assert.AreEqual(1, charfmt.Count); Assert.AreEqual("0", charfmt[0].Style.Result); Assert.AreEqual(impact.ID.ToString(), charfmt[0].Font.Result); page1.Delete(0); }
public void DomText_CharacterFont() { var page1 = this.GetNewPage(new VisioAutomation.Geometry.Size(5, 5)); var impact = page1.Document.Fonts["Arial"]; var m = new VisioAutomation.Models.Text.Element("Normal Text in Impact Font"); m.CharacterFormatting.Font = impact.ID; var s0 = page1.DrawRectangle(0, 0, 4, 4); m.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0, CellValueType.Formula); var charfmt = textfmt.CharacterFormats; Assert.AreEqual(1, charfmt.Count); VisioAutomation_Tests.AssertUtil.OneOf(new[] { "0", "THEMEVAL()" }, charfmt[0].Style.Value); Assert.AreEqual(impact.ID.ToString(), charfmt[0].Font.Value); page1.Delete(0); }
public static void TextMarkup12() { var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); // Create the Shapes that will hold the text var s1 = page.DrawRectangle(0, 0, 8.5, 11); var tnr = page.Document.Fonts["Times New Roman"]; var e1 = new VAM.Text.Element(); var color_red = new VAM.Color.ColorRgb(0xff0000); e1.CharacterFormatting.Color = color_red.ToFormula(); e1.CharacterFormatting.Font = tnr.ID; e1.CharacterFormatting.Font = "20pt"; e1.AddText("Hello "); var f2 = new TextFmt { CharStyle = VAM.Text.CharStyle.Italic }; var e2 = e1.AddElementEx("World", f2); e1.SetText(s1); }
public void DomText_CharacterComplex() { var page1 = this.GetNewPage(new VisioAutomation.Geometry.Size(5, 5)); var doc = page1.Document; var fonts = doc.Fonts; var segoeui = fonts["Segoe UI"]; var impact = fonts["Arial"]; var couriernew = fonts["Courier New"]; var georgia = fonts["Georgia"]; var t1 = new VisioAutomation.Models.Text.Element("{Normal}"); t1.CharacterFormatting.Font = segoeui.ID; var t2 = t1.AddElement("{Italic}"); t2.CharacterFormatting.Style = (int)VA.Models.Text.CharStyle.Italic; t2.CharacterFormatting.Font = impact.ID; var t3 = t2.AddElement("{Bold}"); t3.CharacterFormatting.Style = (int)VA.Models.Text.CharStyle.Bold; t3.CharacterFormatting.Font = couriernew.ID; var t4 = t2.AddElement("{Bold Italic}"); t4.CharacterFormatting.Style = (int)(VA.Models.Text.CharStyle.Bold | VA.Models.Text.CharStyle.Italic); t4.CharacterFormatting.Font = georgia.ID; var s0 = page1.DrawRectangle(0, 0, 4, 4); t1.SetText(s0); var textfmt = VisioAutomation.Text.TextFormat.GetFormat(s0, CellValueType.Formula); var charfmt = textfmt.CharacterFormats; // check the number of character regions Assert.AreEqual(5, charfmt.Count); // check the fonts Assert.AreEqual(segoeui.ID.ToString(), charfmt[0].Font.Value); Assert.AreEqual(impact.ID.ToString(), charfmt[1].Font.Value); Assert.AreEqual(couriernew.ID.ToString(), charfmt[2].Font.Value); Assert.AreEqual(georgia.ID.ToString(), charfmt[3].Font.Value); Assert.AreEqual(segoeui.ID.ToString(), charfmt[4].Font.Value); // check the styles string style_value_0 = charfmt[0].Style.Value; string style_value_4 = charfmt[4].Style.Value; string style_none = ((int)VA.Models.Text.CharStyle.None).ToString(); AssertUtil.OneOf(new[] { style_none, "THEMEVAL()" }, style_value_0); Assert.AreEqual(((int)VA.Models.Text.CharStyle.Italic).ToString(), charfmt[1].Style.Value); Assert.AreEqual(((int)VA.Models.Text.CharStyle.Bold).ToString(), charfmt[2].Style.Value); Assert.AreEqual(((int)(VA.Models.Text.CharStyle.Italic | VA.Models.Text.CharStyle.Bold)).ToString(), charfmt[3].Style.Value); AssertUtil.OneOf(new[] { style_none, "THEMEVAL()" }, style_value_4); // check the text run content var charruns = textfmt.CharacterTextRuns; Assert.AreEqual(4, charruns.Count); Assert.AreEqual("{Normal}", charruns[0].Text); Assert.AreEqual("{Italic}", charruns[1].Text); Assert.AreEqual("{Bold}", charruns[2].Text); Assert.AreEqual("{Bold Italic}", charruns[3].Text); // cleanup page1.Delete(0); }