public static short[] DropManyU( IVisio.Page page, IList<IVisio.Master> masters, IEnumerable<VA.Drawing.Point> points) { if (masters == null) { throw new System.ArgumentNullException("masters"); } if (masters.Count < 1) { return new short[0]; } if (points == null) { throw new System.ArgumentNullException("points"); } // NOTE: DropMany will fail if you pass in zero items to drop var masters_obj_array = masters.Cast<object>().ToArray(); var xy_array = VA.Drawing.Point.ToDoubles(points).ToArray(); System.Array outids_sa; page.DropManyU(masters_obj_array, xy_array, out outids_sa); short[] outids = (short[])outids_sa; return outids; }
public SRC( IVisio.VisSectionIndices section, IVisio.VisRowIndices row, IVisio.VisCellIndices cell) : this((short)section,(short)row,(short)cell) { }
public IVisio.Document Render(IVisio.Application app) { var docs = app.Documents; var doc = docs.Add(""); var ctx = new FormRenderingContext(app); ctx.Application = app; ctx.Document = doc; ctx.Pages = doc.Pages; ctx.Fonts = doc.Fonts; this.VisioDocument = doc; doc.Subject = this.Subject; doc.Title = this.Title; doc.Creator = this.Creator; doc.Company = this.Company; var pages = doc.Pages; foreach (var formpage in this.Pages) { var page = formpage.Draw(ctx); } if (pages.Count > 0) { // Delete the empty first page var first_page = VisioDocument.Pages[1]; first_page.Delete(1); first_page = pages[1]; var active_window = app.ActiveWindow; active_window.Page = first_page; } return doc; }
/// <summary> /// Gets all the user properties defined on a shape /// </summary> /// <remarks> /// If there are no user properties then null will be returned</remarks> /// <param name="shape"></param> /// <returns>A list of user properties</returns> public static IList<UserDefinedCell> Get(IVisio.Shape shape) { if (shape == null) { throw new System.ArgumentNullException("shape"); } var prop_count = GetCount(shape); if (prop_count < 1) { return new List<UserDefinedCell>(0); } var prop_names = GetNames(shape); if (prop_names.Count != prop_count) { throw new AutomationException("Unexpected number of prop names"); } var shape_data = UserDefinedCell.GetCells(shape); var list = new List<UserDefinedCell>(prop_count); for (int i = 0; i < prop_count; i++) { shape_data[i].Name = prop_names[i]; list.Add(shape_data[i]); } return list; }
public PageComparer(Visio.Application app, Visio.Page page1, Visio.Page page2, Visio.Page resultPage) { _page1 = page1; _page2 = page2; _resultPage = resultPage; _app = app; }
public static void Duplicate( IVisio.Page src_page, IVisio.Page dest_page) { 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("src_page"); } if (dest_page == null) { throw new System.ArgumentNullException("dest_page"); } if (dest_page == src_page) { throw new VA.AutomationException("Destination Page cannot be Source Page"); } if (src_page != app.ActivePage) { throw new VA.AutomationException("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(); } var src_pagesheet = src_page.PageSheet; var pagecells = VA.Pages.PageCells.GetCells(src_pagesheet); // handle the dest page // first update all the page cells var dest_pagesheet = dest_page.PageSheet; var update = new VisioAutomation.ShapeSheet.Update(); update.SetFormulas(pagecells); update.Execute(dest_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); } }
private void connect(IVisio.Shape a, IVisio.Shape b, bool a_arrow, bool b_arrow) { var page = a.ContainingPage; var connectors_stencil = page.Application.Documents.OpenStencil("connec_u.vss"); var connectors_masters = connectors_stencil.Masters; var dcm = connectors_masters["Dynamic Connector"]; var drop_point = new VADRAW.Point(-2, -2); var c1 = page.Drop(dcm, drop_point); VACONNECT.ConnectorHelper.ConnectShapes(a, b, c1); //a.AutoConnect(b, connect_dir_none, null); if (a_arrow || b_arrow) { var update = new VASS.Update(); if (a_arrow) { update.SetFormula(c1.ID16, VASS.SRCConstants.BeginArrow, "13"); } if (b_arrow) { update.SetFormula(c1.ID16, VASS.SRCConstants.EndArrow, "13"); } update.Execute(page); } }
internal SectionColumn(int ordinal, IVisio.VisSectionIndices section) { this.Name = ShapeSheetHelper.GetSectionName(section); this.Ordinal = ordinal; this.SectionIndex = section; this.CellColumns = new CellColumnList(); }
public void Render(IVisio.Page page) { var dic = GetDayOfWeekDic(); // calcualte actual days in month int weekday = 0 + dic[this.MonthYear.FirstDay.DayOfWeek]; int week = 0; foreach (int day in Enumerable.Range(0,this.MonthYear.DaysInMonth)) { double x = 0.0 + weekday*1.0; double y = 6.0 - week*1.0; var shape = page.DrawRectangle(x, y, x + 0.9, y + 0.9); weekday++; if (weekday >= 7) { week++; weekday = 0; } shape.Text = string.Format("{0}", new System.DateTime(this.MonthYear.Year, this.MonthYear.Month, day+1)); } }
public Client(IVisio.Application app, Context context) { if (context == null) { throw new System.ArgumentNullException(); } this._context = context; this.VisioApplication = app; this.Application = new VA.Scripting.Commands.ApplicationCommands(this); this.View = new VA.Scripting.Commands.ViewCommands(this); this.Format = new VA.Scripting.Commands.FormatCommands(this); this.Layer = new VA.Scripting.Commands.LayerCommands(this); this.Control = new VA.Scripting.Commands.ControlCommands(this); this.CustomProp = new VA.Scripting.Commands.CustomPropCommands(this); this.Export = new VA.Scripting.Commands.ExportCommands(this); this.Connection = new VA.Scripting.Commands.ConnectionCommands(this); this.ConnectionPoint = new VA.Scripting.Commands.ConnectionPointCommands(this); this.Draw = new VA.Scripting.Commands.DrawCommands(this); this.Master = new VA.Scripting.Commands.MasterCommands(this); this.Arrange = new VA.Scripting.Commands.ArrangeCommands(this); this.Page = new VA.Scripting.Commands.PageCommands(this); this.Selection = new VA.Scripting.Commands.SelectionCommands(this); this.ShapeSheet = new VA.Scripting.Commands.ShapeSheetCommands(this); this.Text = new VA.Scripting.Commands.TextCommands(this); this.UserDefinedCell = new VA.Scripting.Commands.UserDefinedCellCommands(this); this.Document = new VA.Scripting.Commands.DocumentCommands(this); this.Developer = new VA.Scripting.Commands.DeveloperCommands(this); this.Output = new VA.Scripting.Commands.OutputCommands(this); }
private static void BuildDiagram(Visio.Page page, List<Category> categories, List<Formula> formulae, List<Rule> rules, List<List> lists, List<Lookup> lookups) { Console.WriteLine("Drawing {0} categories...", categories.Count); DrawCategories(page, categories); Console.WriteLine("Drawing {0} rules...", rules.Count); DrawRules(page, rules); var listsToDraw = lists.Where(l => usedListNames.Contains(l.ListName.ToUpperInvariant())); Console.WriteLine("Drawing {0} lists...", listsToDraw.Count()); DrawLists(page, listsToDraw); var lookupsToDraw = lookups.Where(l => usedLookupNames.Contains(l.TableName.ToUpperInvariant())); Console.WriteLine("Drawing {0} lookup tables...", lookupsToDraw.Count()); DrawLookups(page, lookupsToDraw); var formulaeToDraw = formulae.Where(f => usedFormulaNames.Contains(f.FormulaName.ToUpperInvariant())); Console.WriteLine("Drawing {0} formulas...", formulaeToDraw.Count()); DrawFormulae(page, formulaeToDraw); Console.WriteLine("Drawing {0} relations...", relations.Count); DrawRelations(page); Console.WriteLine(); Console.WriteLine("Laying out the page..."); page.Layout(); Console.WriteLine("Resizing to fit to contents..."); page.ResizeToFitContents(); }
internal SectionQuery(CellQuery parent, int ordinal, IVisio.VisSectionIndices section) { this.Parent = parent; this.Ordinal = ordinal; this.SectionIndex = section; this.Columns = new ColumnList(); }
public Connector(BaseShape from, BaseShape to, IVisio.Master master) : base(master,-3,-3) { this.Master = new VA.DOM.MasterRef(master); this.From = from; this.To = to; }
public static int Set( IVisio.Shape shape, short row, ControlCells ctrl) { if (shape == null) { throw new ArgumentNullException(nameof(shape)); } if (!ctrl.XDynamics.Formula.HasValue) { ctrl.XDynamics = $"Controls.Row_{row + 1}"; } if (!ctrl.YDynamics.Formula.HasValue) { ctrl.YDynamics = $"Controls.Row_{row + 1}.Y"; } var update = new ShapeSheet.Update(); update.SetFormulas(ctrl, row); update.Execute(shape); return row; }
public Field(IVisio.VisFieldCategories category, IVisio.VisFieldCodes code, IVisio.VisFieldFormats format) : base(NodeType.Field) { this.Category = category; this.Code = code; this.Format = format; }
public IVisio.Page Duplicate(IVisio.Document dest_doc) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); if (dest_doc==null) { throw new System.ArgumentNullException("dest_doc"); } var application = this.Client.VisioApplication; if (application.ActiveDocument == dest_doc) { throw new VA.Scripting.ScriptingException("dest doc is same as active doc"); } var src_page = application.ActivePage; var dest_pages = dest_doc.Pages; var dest_page = dest_pages[1]; VA.Pages.PageHelper.Duplicate(src_page, dest_page); // the active window will be to the new document var active_window = application.ActiveWindow; //active_window.Page = dest_page; return dest_page; }
public static void Activate(IVisio.Document doc) { var app = doc.Application; var cur_active_doc = app.ActiveDocument; // if the doc is already active do nothing if (doc == cur_active_doc) { // do nothing return; } // go through each window and check if it is assigned // to the target document var appwindows = app.Windows; var allwindows = appwindows.AsEnumerable(); foreach (var curwin in allwindows) { if (curwin.Document == doc) { // we did find one, so activate that window // and then exit the method curwin.Activate(); if (app.ActiveDocument != doc) { throw new AutomationException("failed to activate document"); } return; } } // If we get here, we couldn't find any matching window throw new VA.AutomationException("could not find window for document"); }
public static IVisio.Page CreateStandardPage(IVisio.Document doc, string pagename) { var pages = doc.Pages; var page = pages.Add(); page.NameU = pagename; return page; }
public static int Set( IVisio.Shape shape, short row, VACONTROL.ControlCells ctrl) { if (shape == null) { throw new ArgumentNullException("shape"); } if (!ctrl.XDynamics.Formula.HasValue) { ctrl.XDynamics = String.Format("Controls.Row_{0}", row + 1); } if (!ctrl.YDynamics.Formula.HasValue) { ctrl.YDynamics = String.Format("Controls.Row_{0}.Y", row + 1); } var update = new VA.ShapeSheet.Update(); update.SetFormulas(ctrl, row); update.Execute(shape); return row; }
public IList<IVisio.Master> Get(IVisio.Document doc) { this.Client.Application.AssertApplicationAvailable(); var doc_masters = doc.Masters; var masters = doc_masters.AsEnumerable().ToList(); return masters; }
public void Render(IVisio.Page page) { if (page == null) { throw new System.ArgumentNullException("page"); } var page_node = new VA.DOM.Page(); double x = 0; double y = 1; foreach (var shape in this.Shapes) { var shape_nodes = page_node.Shapes.Drop(shape.MasterName, shape.StencilName, x, y); shape.DOMNode = shape_nodes; shape.DOMNode.Text = new VA.Text.Markup.TextElement( shape.Label ) ; x += 1.0; } foreach (var connector in this.Connectors) { var connector_node = page_node.Shapes.Connect("Dynamic Connector", "basic_u.vss", connector.From.DOMNode, connector.To.DOMNode); connector.DOMNode = connector_node; connector.DOMNode.Text = new VA.Text.Markup.TextElement( connector.Label ); } page_node.ResizeToFit = true; page_node.ResizeToFitMargin = new VA.Drawing.Size(0.5, 0.5); page_node.Render(page); }
public static string GetXMLErrorLogFilename(IVisio.Application app) { // the location of the xml error log file is specific to the user // we need to retrieve it from the registry var hkcu = Microsoft.Win32.Registry.CurrentUser; // The reg path is specific to the version of visio being used string path = GetHKCUApplicationPath(app); var key_visio_application = hkcu.OpenSubKey(path); if (key_visio_application == null) { // key doesn't exist - can't continue throw new AutomationException("Could not find the key visio application key in hkcu"); } var subkeynames = key_visio_application.GetValueNames(); if (!subkeynames.Contains("XMLErrorLogName")) { return null; } string logfilename = (string)key_visio_application.GetValue("XMLErrorLogName"); key_visio_application.Close(); // the folder that contains the file is located in the users internet cache // C:\Users\<your alias>\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.MSO\VisioLogFiles string internetcache = System.Environment.GetFolderPath(System.Environment.SpecialFolder.InternetCache); string folder = System.IO.Path.Combine(internetcache, @"Content.MSO\VisioLogFiles"); return System.IO.Path.Combine(folder, logfilename); }
private static void TestResize(IVisio.Document doc, VA.Drawing.Size bottomleft_margin, VA.Drawing.Size upperright_margin, VA.Drawing.Size shape_size, VA.Drawing.Size padding_size, double expected_pinx, double expected_piny) { var page = doc.Pages.Add(); var pagecells = new VA.Pages.PageCells(); pagecells.PageTopMargin = upperright_margin.Height; pagecells.PageBottomMargin = bottomleft_margin.Height; pagecells.PageLeftMargin = bottomleft_margin.Width; pagecells.PageRightMargin = upperright_margin.Width; var pageupdate = new VA.ShapeSheet.Update(); pageupdate.SetFormulas(pagecells); pageupdate.Execute(page.PageSheet); var shape = page.DrawRectangle(5, 5, 5 + shape_size.Width, 5+shape_size.Height); page.ResizeToFitContents(padding_size); var xform = VA.Shapes.XFormCells.GetCells(shape); AssertVA.AreEqual(expected_pinx, expected_piny, xform.Pin(), 0.1); page.Delete(0); }
public static Drawing.Rectangle GetBoundingBox(this IVisio.Selection selection, IVisio.VisBoundingBoxArgs args) { double bbx0, bby0, bbx1, bby1; selection.BoundingBox((short) args, out bbx0, out bby0, out bbx1, out bby1); var r = new Drawing.Rectangle(bbx0, bby0, bbx1, bby1); return r; }
public static int Add( IVisio.Shape shape, ConnectionPointCells cp) { if (shape == null) { throw new System.ArgumentNullException(nameof(shape)); } if (!cp.X.Formula.HasValue) { throw new System.ArgumentException("Must provide an X Formula"); } if (!cp.Y.Formula.HasValue) { throw new System.ArgumentException("Must provide an Y Formula"); } var n = shape.AddRow((short)IVisio.VisSectionIndices.visSectionConnectionPts, (short)IVisio.VisRowIndices.visRowLast, (short)IVisio.VisRowTags.visTagCnnctPt); var update = new ShapeSheet.Update(); update.SetFormulas(cp,n); update.Execute(shape); return n; }
public static void DrawNode( BoxL.Node node, VA.Drawing.Rectangle rect, IVisio.Page page) { var shape = page.DrawRectangle(rect); node.Data = shape; }
public static void Delete(IVisio.Shape shape) { int num = shape.GeometryCount; for (int i = num-1; i >=0; i--) { GeometryHelper.DeleteSection(shape, (short)i); } }
public static Drawing.Rectangle GetBoundingBox(this IVisio.Master master, IVisio.VisBoundingBoxArgs args) { // MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vissdk11/html/vimthBoundingBox_HV81900422.asp double bbx0, bby0, bbx1, bby1; master.BoundingBox((short) args, out bbx0, out bby0, out bbx1, out bby1); var r = new Drawing.Rectangle(bbx0, bby0, bbx1, bby1); return r; }
public IVisio.Document TryOpen(IVisio.Documents docs, string filename) { using (var scope = new VA.Application.AlertResponseScope(docs.Application, VA.Application.AlertResponseCode.No)) { var doc = docs.Open(filename); return doc; } }
public static IVisio.Shape Drop( this IVisio.Page page, IVisio.Master master, Drawing.Point point) { var surface = new Drawing.DrawingSurface(page); return surface.Drop(master, point); }