public void CreateSheetsforMscReferences() { List <IVShape> references = new List <IVShape>(); foreach (var s in this._application.ActivePage.Shapes) { if (s.Name.Contains("MSC Reference")) { bool exists = false; foreach (var sh in references) { if (sh.Text == s.Text) { exists = true; System.Windows.Forms.MessageBox.Show(sh.Text + " exists twice ore more as a MSC Reference."); } } if (exists == false) { references.Add(s); } } } if (references.Count >= 1) { this._application.Documents.OpenEx("SMT_bMSC.vssx", 4); foreach (var r in references) { bool exist = false; foreach (var p in this._application.ActiveDocument.Pages) { if (p.Name == r.Text) { exist = true; System.Windows.Forms.MessageBox.Show(r.Text + " already exists."); } } if (exist == false) { IVPage p = this._application.ActiveDocument.Pages.Add(); p.Name = r.Text; IVHyperlink hl = r.Hyperlinks.Add(); hl.SubAddress = p.Name; } } } else { System.Windows.Forms.MessageBox.Show("No MSC Reference found."); }; }
public void EntitytoPage() { List <IVShape> shapes = new List <IVShape>(); foreach (IVShape shape in this._application.ActivePage.Shapes) { if (shape.Name.Contains("Context Entity (CE)")) { bool exists = false; foreach (var s in shapes) { if (s.Text == shape.Text) { exists = true; System.Windows.Forms.MessageBox.Show(shape.Text + " already exists."); } } if (exists == false) { shapes.Add(shape); } } } if (shapes.Count >= 1) { foreach (var shape in shapes) { IVPage page = this._application.ActiveDocument.Pages.Add(); page.Name = shape.Text; IVDocument stencil = this._application.Documents.OpenEx("SMT_BeC.vssx", 4); IVMaster masterentity = new IVMaster(); foreach (var m in stencil.Masters) { if (m.Name == "Context Entity/ Function") { masterentity = m; } } IVShape shapeh = page.Drop(masterentity, 10.3 / 2.54, 20.5 / 2.54); shapeh.Text = shape.Text; shapeh.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))"; IVHyperlink hl = shape.Hyperlinks.Add(); hl.SubAddress = page.Name; } } else { System.Windows.Forms.MessageBox.Show("No Context Entity found."); }; }
public void SetHyperlink() { //NUr verwenden, wenn noch keine Hyperlinks gesetzt sind IVPage overview = new IVPage(); foreach (IVPage p in this._application.ActiveDocument.Pages) { if (p.Name == "System Overview") { overview = p; } } foreach (IVShape s in overview.Shapes) { foreach (IVPage p in this._application.ActiveDocument.Pages) { if (s.Text == p.Name) { IVHyperlink hl = s.Hyperlinks.Add(); hl.SubAddress = p.Name; } } } }
public void CreateSubsystems(SPES_DocumentReferencer pReferencer) { //bestimme Namen des übergeordneten Systems anhand des Seitennamens IVPage active = this._application.ActivePage; string systemname = active.Name.Substring(4); //TODO: check if file is LVP_Overview datei (Logical Viewpoint) / Logical Design if (this._application.ActiveDocument.Name != $"{systemname}_LVP.vsdx") { throw new Exception("Active Document is not the LVP overview file."); } IVSelection selects = this._application.ActiveWindow.Selection; List <IVShape> shapes = new List <IVShape>(); foreach (var shape in selects.SelectionForDragCopy) { if (shape.Shapes != null) { bool firstshape = true; int count = 0; foreach (var subshape in shape.Shapes) { count++; if (count % 2 == 1) { if (firstshape == true) { shapes.Add(subshape); } firstshape = false; } } } else { shapes.Add(shape); } } //System.Windows.Forms.MessageBox.Show("Create Documents?"); //getPage "Systemübersicht"--> dazu Document holen mit passender Page //speichere aktuelle Applikation ab und suche Applikation mit der Page "Systemübersicht" IVDocument systemdoc = null; IVPage systemoverview = null; Application subapplic = this._application; IntPtr subapplickey = new IntPtr(0); IntPtr applickey = new IntPtr(0); Application applic = null;; bool found = false; foreach (var window in OpenWindowGetter.GetOpenWindows()) { if (found == false) { if (window.Value.Contains("Visio Professional") || window.Value.Contains("Microsoft Visio")) { OpenWindowGetter.SetForegroundWindow(window.Key); applic = NetOffice.VisioApi.Application.GetActiveInstance(); if (subapplic == applic) { subapplickey = window.Key; } ; foreach (var doc in applic.Documents) { foreach (var page in doc.Pages) { if (page.Name == "System Overview") { systemdoc = doc; systemoverview = page; applickey = window.Key; found = true; } } } } } } if (found == false) { var file = new System.IO.DirectoryInfo( new System.IO.FileInfo(_application.ActiveDocument.FullName).Directory.FullName) .GetFiles().First(t => t.Name.Contains("_Overview.vsdx")); _application.Documents.Open(file.FullName); foreach (var window in OpenWindowGetter.GetOpenWindows()) { if (found == false) { if (window.Value.Contains("Visio Professional") || window.Value.Contains("Microsoft Visio")) { OpenWindowGetter.SetForegroundWindow(window.Key); applic = NetOffice.VisioApi.Application.GetActiveInstance(); if (subapplic == applic) { subapplickey = window.Key; } ; foreach (var doc in applic.Documents) { foreach (var page in doc.Pages) { if (page.Name == "System Overview") { systemdoc = doc; systemoverview = page; applickey = window.Key; found = true; } } } } } } } //erstelle für jede ausgewählte Shape/Subsystem auf dem Zeichenblatt "Systemübersicht" ein Rechteck und verbinde dieses mit dem höher gelegenen System int counter = 0; int sum = shapes.Count; IVShape preshape = null; foreach (var shape in systemoverview.Shapes) { if (shape.Text == systemname) { preshape = shape; } } double xvalue = (Convert.ToDouble(preshape.CellsSRC(1, 1, 0).FormulaU.Substring(0, preshape.CellsSRC(1, 1, 0).FormulaU.IndexOf(' ')))) / 10; double yvalue = (Convert.ToDouble(preshape.CellsSRC(1, 1, 1).FormulaU.Substring(0, preshape.CellsSRC(1, 1, 1).FormulaU.IndexOf(' ')))) / 10; foreach (var shape in shapes) { IVShape subsystem = systemoverview.DrawRectangle(1, 1, 3, 1.5); subsystem.Text = shape.Text; subsystem.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))"; subsystem.SetCenter(BerechneXPosition(xvalue, sum, counter) / 2.54, (yvalue - 3.0) / 2.54); counter++; //verbinde zu übergeordnetem System preshape.AutoConnect(subsystem, 0); //erstelle neues Zeichenblatt und erstelle Hyperlink IVPage shapePage = systemdoc.Pages.Add(); shapePage.Name = shape.Text; IVHyperlink hl = subsystem.Hyperlinks.Add(); hl.SubAddress = shapePage.Name; //geht nur wenn, Page in selber Dokumentebene ist. //rufe Methode auf, die für die gespeicherten Pages, die benötigten Dokumente erstellt und einbindet CreateSubSystemElements(shapePage, applickey, pReferencer); } //setze Verbinder als gerade/straight foreach (var connects in systemoverview.Shapes) { if (connects.Name.Contains("Dynamic connector") || connects.Name.Contains("Dynamischer Verbinder")) { connects.CellsSRC(1, 23, 10).Formula = "16"; } } //systemoverview.CreateSelection(VisSelectionTypes.visSelTypeAll).Align(VisHorizontalAlignTypes.visHorzAlignLeft, VisVerticalAlignTypes.visVertAlignMiddle) ; OpenWindowGetter.SetForegroundWindow(subapplickey); }