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