public void ToogleCase(IList <IVisio.Shape> target_shapes) { this.Client.Application.AssertApplicationAvailable(); this.Client.Document.AssertDocumentAvailable(); var shapes = this.GetTargetShapes(target_shapes); if (shapes.Count < 1) { return; } var application = this.Client.Application.Get(); using (var undoscope = this.Client.Application.NewUndoScope("Toggle Shape Text Case")) { var shapeids = shapes.Select(s => s.ID).ToList(); var page = application.ActivePage; // Store all the formatting var formats = Text.TextFormat.GetFormat(page, shapeids); // Change the text - this will wipe out all the character and paragraph formatting foreach (var shape in shapes) { string t = shape.Text; if (t.Length < 1) { continue; } shape.Text = TextCommandsUtil.toggle_case(t); } // Now restore all the formatting - based on any initial formatting from the text var update = new ShapeSheet.Update(); for (int i = 0; i < shapes.Count; i++) { var format = formats[i]; if (format.CharacterFormats.Count > 0) { var fmt = format.CharacterFormats[0]; update.SetFormulas((short)shapeids[i], fmt, 0); } if (format.ParagraphFormats.Count > 0) { var fmt = format.ParagraphFormats[0]; update.SetFormulas((short)shapeids[i], fmt, 0); } } update.Execute(page); } }
public void SetTextWrapping(bool wrap) { if (!this.Client.HasSelectedShapes()) { return; } var selection = this.Client.Selection.Get(); var shapeids = selection.GetIDs(); var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(application, "SetTextWrapping")) { var active_page = application.ActivePage; TextCommandsUtil.set_text_wrapping(active_page, shapeids, wrap); } }
public void SetTextWrapping(IList <IVisio.Shape> target_shapes, bool wrap) { this.Client.Application.AssertApplicationAvailable(); this.Client.Document.AssertDocumentAvailable(); var shapes = this.GetTargetShapes2D(target_shapes); if (shapes.Count < 1) { return; } var shapeids = shapes.Select(s => s.ID).ToList(); var application = this.Client.Application.Get(); using (var undoscope = this.Client.Application.NewUndoScope("SetTextWrapping")) { var active_page = application.ActivePage; TextCommandsUtil.set_text_wrapping(active_page, shapeids, wrap); } }
public IVisio.Document DrawScriptingDocumentation() { this._client.Application.AssertApplicationAvailable(); var formdoc = new Models.Forms.FormDocument(); formdoc.Subject = "VisioAutomation.Scripting Documenation"; formdoc.Title = "VisioAutomation.Scripting Documenation"; formdoc.Creator = ""; formdoc.Company = ""; //docbuilder.BodyParaSpacingAfter = 6.0; var lines = new List <string>(); var cmdst_props = Client.GetProperties().OrderBy(i => i.Name).ToList(); var sb = new System.Text.StringBuilder(); var helpstr = new System.Text.StringBuilder(); foreach (var cmdset_prop in cmdst_props) { var cmdset_type = cmdset_prop.PropertyType; // Calculate the text var commands = CommandSet.GetCommands(cmdset_type); lines.Clear(); foreach (var command in commands) { sb.Length = 0; var method_params = command.MethodInfo.GetParameters(); TextCommandsUtil.Join(sb, ", ", method_params.Select(param => String.Format("{0} {1}", ReflectionUtil.GetNiceTypeName(param.ParameterType), param.Name))); if (command.MethodInfo.ReturnType != typeof(void)) { string line = String.Format("{0}({1}) -> {2}", command.MethodInfo.Name, sb, ReflectionUtil.GetNiceTypeName(command.MethodInfo.ReturnType)); lines.Add(line); } else { string line = String.Format("{0}({1})", command.MethodInfo.Name, sb); lines.Add(line); } } lines.Sort(); helpstr.Length = 0; TextCommandsUtil.Join(helpstr, "\r\n", lines); var formpage = new Models.Forms.FormPage(); formpage.Title = cmdset_prop.Name + " commands"; formpage.Body = helpstr.ToString(); formpage.Name = cmdset_prop.Name + " commands"; formpage.Size = new Drawing.Size(8.5, 11); formpage.Margin = new Drawing.Margin(0.5, 0.5, 0.5, 0.5); formdoc.Pages.Add(formpage); } //hide_ui_stuff(docbuilder.VisioDocument); var app = this._client.Application.Get(); var doc = formdoc.Render(app); return(doc); }