如何隐藏Visio复制到RichTextbox的过程

How to hide copy process of Visio to RichTexbox

全部。我创建了一个项目,该项目通过复制内容并将内容作为图像粘贴到 C# winform 的富文本框中来显示 Visio 文档的内容。问题是当复制过程开始时,Visio 打开几秒钟,然后我的程序复制了内容。虽然我确实希望发生这种情况,但我不希望 Visio 在此过程中可见。有没有办法在隐藏 Visio 的同时帮助完成的操作?

代码如下:

public partial class FrmVisio : Form
{
    public FrmVisio()
    {
        InitializeComponent();         
    }

    private void cboContent_SelectedIndexChanged(object sender, EventArgs e)
    {
    }

    private void FrmVisio_Load(object sender, EventArgs e)
    {
        cboContent.Items.Add("PFD-001_Control of Documented Information Process _(R4)");
        cboContent.Items.Add("PFD-002_Management_Review_Process_(R1)");
        cboContent.Items.Add("PFD-003 Control of Non-conformance Process Flow(R1)");
        cboContent.Items.Add("PFD-004_Internal Audit Process _(R1)");
        cboContent.Items.Add("PFD-008_Risk & Opportunity Process _(R1)");
        cboContent.Items.Add("PFD-010_Change_Control_Process_Flow_Diagram_(R1)");
        cboContent.Items.Add("PFD-011_Determine_Requirements_for_Products_Services_(R2)");
    }

    private void btnOpenWord_Click(object sender, EventArgs e)
    {
        if (cboContent.SelectedItem == null)
            MessageBox.Show("Please select a document", "No Document Selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        else
        {
            var item = cboContent.SelectedItem.ToString();

            MessageBox.Show("IMPORTANT! PLEASE READ: MS Visio allows you to create shapes and diagrams. However, those things, if edited, will not be saved on the " +
                "QMS unless you export the allocated document as a PDF in the same folder and overwrite the default PDF given. DO NOT CHANGE THE FILE NAMES OR THEIR LOCATIONS! Otherwise, the link to the documents and the QMS will be broken", "PLEASE READ!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            Process.Start(@"C:\Program Files (x86)\IMS Global\Quality Management System Application\QMS\QMS\QMS\" + item + @".vsd");   
        }
    }

    /// <summary>
    /// Show the preview of the Visio Document
    /// </summary>
    public void DisplayVsio()
    {
        //TODO: Find Better Alternative to Show Visio Documentation.
        //TODO: If not possible, edit widgets in windows form.
        if(cboContent.SelectedItem == null)
        {
            MessageBox.Show("Please select a document", "No Document Selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);               
        }
        else
        {
            var item = cboContent.SelectedItem.ToString();
            Visio.Application appObject = new Visio.Application();

            Microsoft.Office.Interop.Visio.Document doc = appObject.Documents.Open(@"C:\Program Files (x86)\IMS Global\Quality Management System Application\QMS\QMS\QMS\" + item + @".vsd");
            doc.Application.ActiveWindow.Selection.SelectAll();
            doc.Application.ActiveWindow.Selection.Copy();
            richTextBox1.Paste();

            appObject.Quit();
        }
    }

    private void btnShow_Click(object sender, EventArgs e)
    {
        richTextBox1.Clear();
        DisplayVsio();
    }
}

变化:

Visio.Application appObject = new Visio.Application();

至:

Visio.Application appObject = new Visio.InvisibleApp();