C # for Visio two development judgment whether the drawing has a device

Source: Internet
Author: User
Tags bool

To determine whether a drawing on a Visio drawing has a device (there are entities), there are two methods, one is through the Window object's SelectAll method, in determining whether the selected collection is not empty, as follows:

/**////<summary>
        ///to determine if there are objects selected
        ///</summary>
        ///<param name= "window" ></param >
        ///<returns></returns>
        [CLSCompliant (false)] public
        static BOOL Hasshapeinwindow ( Window window)
        {
            bool result = false;
            Try
            {
                window. SelectAll ();
                result = (window. Selection.count > 0);
                Window. Deselectall ();
            }
            Catch
            {;}
            return result;
        }

Another method is to determine whether the page object's collection of shapes objects is greater than 0, as follows:

 visio.page Page = Visioutility.getpage (visdocument, "feeder map"); if (page.
                Shapes.count <= 0) {messageutil.showtips ("no equipment on the drawing");
            Return /**////<summary>///Gets the page objects made by the Visio document///</summary>///<param name= "VI Sdocument "></param>///<param name=" PageType "></param>///<returns></retur
            Ns> [CLSCompliant (false)] public static Page GetPage (Document visdocument, string pagetype) {
            Page Vispage;
                for (int i = 1; I <= visDocument.Pages.Count i++) {vispage = visdocument.pages[i]; if (formulastringtostring visPage.PageSheet.get_Cells (cust_prop_prefix + drawing page).
                Formula) = = PageType) {return vispage;
        } return null; }

The two methods are essentially the same, and the second method may be faster, if you have processing logic in the Document object event of Visio, as shown below, and in some cases you cannot judge in the first way:

This. Ctrldrawing.selectionchanged + = new Evisocx_selectionchangedeventhandler (ctrldrawing_selectionchanged);

Hope you can find more interesting things, hehe

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.