Working with Visio paint in C #

Source: Internet
Author: User

To draw a Visio diagram through. NET, you would first import the Visio COM component, which is to add the Visio COM component to the reference, and then you can write the code drawing after the import is played. Put a simple sample code to make it easy to understand:

Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.text;using system.windows.forms;using Visio = microsoft.office.interop.visio;using AXVISOCX = axmicrosoft.office.interop.visocx;//using system.web.ui.webcontrols;using Cell =        Microsoft.office.interop.visio.cell;namespace visiotest1{public partial class Form2:form {public Form2 ()        {InitializeComponent ();            } private static void ConnectShapes (Visio.Shape shape1, Visio.Shape shape2, Visio.Shape connector) {            Get the cell from the source side of the connector cell Beginxcell = CONNECTOR.GET_CELLSSRC ( (short) Visio.VisSectionIndices.visSectionObject, (short) Visio.VisRowIndices.visRowXForm1D, (short) Visio.vis            Cellindices.vis1dbeginx);        Glue the source side of the connector to the first shape Beginxcell.glueto (SHAPE1.GET_CELLSSRC (    (short) Visio.VisSectionIndices.visSectionObject, (short) Visio.VisRowIndices.visRowXFormOut, (short) VISIO.VI            Scellindices.visxformpinx)); Get the cell from the destination side of the connector cell Endxcell = CONNECTOR.GET_CELLSSRC ( Short) Visio.VisSectionIndices.visSectionObject, (short) Visio.VisRowIndices.visRowXForm1D, (short) Vis Io.            VISCELLINDICES.VIS1DENDX);            Glue the destination side of the connector to the second shape Endxcell.glueto (SHAPE2.GET_CELLSSRC ( (short) Visio.VisSectionIndices.visSectionObject, (short) Visio.VisRowIndices.visRowXFormOut, (short) VISIO.VI        Scellindices.visxformpinx));            } private void Form2_load (object sender, EventArgs e) {axDrawingControl1.Window.Zoom = 0.5;            AxDrawingControl1.Window.ShowScrollBars = (short) Visio.VisScrollbarStates.visScrollBarBoth; Axdrawingcontrol1.wiNdow.            showrulers = 0;            AxDrawingControl1.Window.BackgroundColor = (UINT) colortranslator.toole (color.red);            AxDrawingControl1.Window.BackgroundColorGradient = (UINT) colortranslator.toole (color.red);                        AxDrawingControl1.Window.ZoomBehavior = Visio.VisZoomBehavior.visZoomVisioExact;            Visio.page currentpage = axdrawingcontrol1.document.pages[1];                                                                         Visio.Document currentstencil = axDrawingControl1.Document.Application.Documents.OpenEx ("Basic_m.vss", (short)                       Visio.VisOpenSaveArgs.visOpenDocked);            Visio.Shape shape1 = Currentpage.drop (currentstencil.masters["triangle"], 1.50, 1.50);            Visio.Shape shape2 = Currentpage.drop (currentstencil.masters["Square"], 2.50, 3.50);            Visio.Shape connector = currentpage.drop (currentstencil.masters["Dynamic connection Line"], 4.50, 4.50);            ConnectShapes (Shape1, shape2, connector); Cell Arrowcell = CONNECTOR.GET_CELLSSRC (short) Visio.VisSectionIndices.visSectionObject, (short) Visio.VisRowIndices.visRowLine, (            short) Visio.VisCellIndices.visLineEndArrow);            Arrowcell.formulau = "5"; Connector.get_cells ("EndArrow").        Formula = "= 5"; }    }}

  

Working with Visio paint in C #

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.