SOLIDWORKS Property Manager Page closing events handling

Edit ArticleEdit Article

Pre Closing event

PropertyManagerPageHandlerEx::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.

public class DataModel
{
    public string Text { get; set; }
}

private DataModel m_Data;

private PropertyManagerPageEx<MyPMPageHandler, DataModel> m_Page;

public override bool OnConnect()
{
    m_Data = new DataModel();
    m_Page = new PropertyManagerPageEx<MyPMPageHandler, DataModel>(App);

    m_Page.Handler.Closing += OnClosing;

    return true;
}

private void OnClosing(swPropertyManagerPageCloseReasons_e reason, ClosingArg arg)
{
    if (reason == swPropertyManagerPageCloseReasons_e.swPropertyManagerPageClose_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 (swPropertyManagerOptions_PushpinButton flag of swPropertyManagerPageOptions_e enumeration in PageOptionsAttribute). In this case it is required to set the swPropertyManagerOptions_LockedPage flag of swPropertyManagerPageOptions_e enumeration in PageOptionsAttribute. This would enable the support of rebuild operations and feature creation from within the PropertyManagerPageHandlerEx::Closing event.

Post closing event

PropertyManagerPageHandlerEx::Closed event is raised when property manager page is closed.

Use this handler to perform the required operations.

public class DataModel
{
    public string Text { get; set; }
}

private DataModel m_Data;

private PropertyManagerPageEx<MyPMPageHandler, DataModel> m_Page;

public override bool OnConnect()
{
    m_Data = new DataModel();
    m_Page = new PropertyManagerPageEx<MyPMPageHandler, DataModel>(App);

    m_Page.Handler.Closed += OnClosed;

    return true;
}

private void OnClosed(swPropertyManagerPageCloseReasons_e reason)
{
    if (reason == swPropertyManagerPageCloseReasons_e.swPropertyManagerPageClose_Okay)
    {
        //TODO: do work
    }
    else
    {
        //TODO: release resources
    }
}

Product of Xarial Product of Xarial