/// <summary> /// Visio文档关闭 /// </summary> /// <param name="Doc"></param> /// <remarks></remarks> private void F_vsoDoc_BeforeDocumentClose(Microsoft.Office.Interop.Visio.Document Doc) { this.F_vsoDoc = null; this.F_vsoDoc.BeforeDocumentClose += this.F_vsoDoc_BeforeDocumentClose; this.F_vsoDataRs = null; // ClearUI(); }
public VisioShapes() { db = new AccesoDatos(); Microsoft.Office.Interop.Visio.Application Application = new Microsoft.Office.Interop.Visio.Application(); Application.Documents.Add(""); Microsoft.Office.Interop.Visio.Documents visioDocs = Application.Documents; visioStencil = visioDocs.OpenEx("Basic Shapes.vss", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked); visioPage = Application.ActivePage; }
/// <summary> /// Visio文档改变 /// </summary> /// <param name="vsoDoc"></param> /// <remarks></remarks> public void DocumentChanged(Microsoft.Office.Interop.Visio.Document vsoDoc) { // this.ComboBox_Page.DataSource = GetPagesFromDoc(vsoDoc); this.ComboBox_DataRs.DataSource = GetDataRsFromDoc(vsoDoc); // this.btnValidate.Enabled = true; this.btnLink.Enabled = false; // }
public override void Run(dynamic declaration) { try { Microsoft.Office.Interop.Visio.Document doc = Application.Documents[declaration.ProjectDisplayName]; var call = GenerateMethodCall(declaration.QualifiedName); doc.ExecuteLine(call); } catch { //Failed to run } }
/// <summary> /// 从Visio文档中返回其中的所有DataRecordset对象的数组 /// </summary> /// <param name="Doc"></param> /// <returns></returns> /// <remarks></remarks> private LstbxDisplayAndItem[] GetDataRsFromDoc(Microsoft.Office.Interop.Visio.Document Doc) { short DRSsCount = (short)Doc.DataRecordsets.Count; LstbxDisplayAndItem[] arrItems = new LstbxDisplayAndItem[DRSsCount - 1 + 1]; short i = (short)0; foreach (Microsoft.Office.Interop.Visio.DataRecordset DRS in Doc.DataRecordsets) { arrItems[i] = new LstbxDisplayAndItem(DRS.Name, DRS); i++; } return(arrItems); }
/// <summary> /// 从Visio文档中返回其中的所有Page对象的数组 /// </summary> /// <param name="Doc"></param> /// <returns></returns> /// <remarks></remarks> private LstbxDisplayAndItem[] GetPagesFromDoc(Microsoft.Office.Interop.Visio.Document Doc) { short pagesCount = Doc.Pages.Count; LstbxDisplayAndItem[] arrItems = new LstbxDisplayAndItem[pagesCount - 1 + 1]; short i = (short)0; foreach (Microsoft.Office.Interop.Visio.Page page in Doc.Pages) { arrItems[i] = new LstbxDisplayAndItem(page.Name, page); i++; } return(arrItems); }
public void Visio_DataRecordsetLinkToShape_Load(object sender, EventArgs e) { //如果程序中已经有打开的Visio文档,则将此文档作为默认的进行形状链接的文档 GlobalApplication GlobalApp = GlobalApplication.Application; if (GlobalApp != null) { if (GlobalApp.PlanView_VisioWindow != null) { Microsoft.Office.Interop.Visio.Document doc = GlobalApp.PlanView_VisioWindow.Page.Document; this.vsoDoc = doc; this.txtbxVsoDoc.Text = doc.FullName; } } }
private static void Main(string[] args) { if (args.Length < 1) { System.Console.WriteLine("Syntax is: VisioExportPagesToDocs <filename.vsd> [<outptufolder>]"); System.Environment.Exit(0); } string input_filename = args[0]; input_filename = System.IO.Path.GetFullPath(input_filename); var visioapp = new Microsoft.Office.Interop.Visio.Application(); var docs = visioapp.Documents; Microsoft.Office.Interop.Visio.Document doc = null; try { doc = docs.Open(input_filename); var settings = new ExporterSettings(); settings.InputDocument = doc; if (args.Length >= 2) { settings.DestinationPath = args[1]; } else { settings.DestinationPath = System.IO.Path.GetDirectoryName(input_filename); } var exporter = new Exporter(settings); foreach (var rec in exporter.Run()) { Console.WriteLine(); Console.WriteLine("Page Index: {0}", rec.PageIndex); Console.WriteLine("Page Name: {0}", rec.PageName); Console.WriteLine("Output document: {0}", rec.OutputFilename); Console.WriteLine("Output document already exists: {0}", rec.OutputFileAlreadyExists); Console.WriteLine("Wrote output document: {0}", rec.OutputFileWritten); } } catch (System.Runtime.InteropServices.COMException comexc) { throw new System.ArgumentException(string.Format("Failed to open file: {0}", comexc.Message)); } }
public static void Render(BoxLayout layout, Microsoft.Office.Interop.Visio.Document doc) { layout.PerformLayout(); var page1 = doc.Pages.Add(); // and tinker with it // render var nodes = layout.Nodes.ToList(); foreach (var node in nodes) { var shape = page1.DrawRectangle(node.Rectangle); node.Data = shape; } var root_shape = (Microsoft.Office.Interop.Visio.Shape)layout.Root.Data; root_shape.CellsU["FillForegnd"].FormulaForceU = "rgb(240,240,240)"; var margin = new VisioAutomation.Drawing.Size(0.5, 0.5); page1.ResizeToFitContents(margin); }
//选择新的Visio文档 /// <summary> /// 选择新的Visio文档 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks></remarks> public void BtnChooseVsoDoc_Click(object sender, EventArgs e) { string FilePath = ""; this.OpenFileDialog1.Title = "选择进行数据链接的Visio文档"; this.OpenFileDialog1.Filter = "Visio文件(*.vsd)|*.vsd"; this.OpenFileDialog1.FilterIndex = 2; this.OpenFileDialog1.Multiselect = false; if (this.OpenFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FilePath = this.OpenFileDialog1.FileName; } else { return; } if (FilePath.Length > 0) { // this.txtbxVsoDoc.Text = FilePath; // if (this.F_vsoApplication == null) { this.F_vsoApplication = new Microsoft.Office.Interop.Visio.Application(); this.F_vsoApplication.BeforeQuit += this.F_vsoApplication_BeforeQuit; } // try { this.vsoDoc = this.F_vsoApplication.Documents.Open(FilePath); } catch (Exception) { MessageBox.Show("Visio文档打开出错,请检查后重新打开。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.F_vsoApplication.Visible = true; } }
public override bool Parse(FileInfo sourceFile, DirectoryInfo targetDir) { int index = 1; if (!IsTargetFileOutdated(sourceFile, BuildTargetFileName(sourceFile, targetDir, index))) { // if the first slide of a file is not invalid all other slides are still valid, too return(false); } Microsoft.Office.Interop.Visio.Application visio = visioTL.Value; if (visio == null) { visio = new Microsoft.Office.Interop.Visio.Application(); visio.Visible = false; visioTL.Value = visio; } Microsoft.Office.Interop.Visio.Document vsd = visioTL.Value.Documents.Open(sourceFile.FullName); try { foreach (Microsoft.Office.Interop.Visio.Page page in vsd.Pages) { DoExport(sourceFile, targetDir, index, delegate(FileInfo targetFile) { page.Export(targetFile.FullName); }); index++; } return(true); } finally { vsd.Saved = true; vsd.Close(); } }
private void Visio_DocOpened(Microsoft.Office.Interop.Visio.Document doc) { MessageBox.Show(string.Format("DocOpened {0} with DpiThreadAwarenessContext {1}", doc.Name, DPIHelper.GetThreadDpiAwarenessContext().ToString())); }
void _VisioApplication_AfterRemoveHiddenInformation(Microsoft.Office.Interop.Visio.Document Doc) { DisplayInWatchWindow(countAfterRemoveHiddenInformation++, System.Reflection.MethodInfo.GetCurrentMethod().Name); }
void _VisioApplication_BeforeDocumentClose(Microsoft.Office.Interop.Visio.Document Doc) { DisplayInWatchWindow(countBeforeDocumentClose++, System.Reflection.MethodInfo.GetCurrentMethod().Name); }
void _VisioApplication_DesignModeEntered(Microsoft.Office.Interop.Visio.Document Doc) { DisplayInWatchWindow(countDesignModeEntered++, System.Reflection.MethodInfo.GetCurrentMethod().Name); }
bool _VisioApplication_QueryCancelDocumentClose(Microsoft.Office.Interop.Visio.Document Doc) { DisplayInWatchWindow(countQueryCancelDocumentClose++, System.Reflection.MethodInfo.GetCurrentMethod().Name); return(false); }