XCAD.NET
XCAD.NET
Framework for .NET (C# and VB.NET) to create modern application for CAD systems (SOLIDWORKS, SOLIDWORKS Document Manager, Autodesk Inventor, etc.)
Get technical support Connect to xCAD community on Discord server Explore code and application examples xCAD.NET Templates for Visual Studio and VS Code Access source code

SOLIDWORKS Property Manager Page closing events handling


Pre Closing event

Closing event is raised when property manager page is about to be closed.

Framework passes the reason of close and closing argument which allows to cancel property manager page closing and display error to the user as a tooltip.

m_Page.Closing += OnClosing;
private void OnClosing(PageCloseReasons_e reason, PageClosingArg arg)
{
    if (reason == PageCloseReasons_e.Okay)
    {
        if (string.IsNullOrEmpty(m_Data.Text))
        {
            arg.Cancel = true;
            arg.ErrorTitle = "Insert Note Error";
            arg.ErrorMessage = "Please specify the note text";
        }
    }
}

This event is raised when Property Manager Page dialog is still visible. There should be no rebuild operations performed within this handler, it includes the direct rebuilds but also any new features or geometry creation or modification (with an exception of temp bodies). Note that some operations such as saving may also be unsupported. In general if certain operation cannot be performed from the user interface while property page is opened it shouldn't be called from the closing event via API as well. Otherwise this could cause instability including crashes. Use Post closing event event to perform any rebuild operations.

In some cases it is required to perform this operation while property manager page stays open. Usually this happens when page supports pining (PushpinButton flag of PageOptions_e enumeration in PageOptionsAttribute. In this case it is required to set the LockedPage flag of PageOptions_e enumeration in PageOptionsAttribute. This would enable the support of rebuild operations and feature creation from within the SwPropertyManagerPage::Closing event.

Post closing event

Closed event is raised when property manager page is closed.

Use this handler to perform the required operations.

m_Page.Closed += OnClosed;
private void OnClosed(PageCloseReasons_e reason)
{
    if (reason == PageCloseReasons_e.Okay)
    {
        //do work
    }
    else
    {
        //release resources
    }
}


Powered by Docify