• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Vault Customization

    Reply
    Active Contributor
    Posts: 31
    Registered: 10-31-2005
    Accepted Solution

    How can I know if I am in the Item Record Window or not?

    93 Views, 3 Replies
    01-11-2012 07:56 AM

    If I add a detail tab for items, it will show in both Item master and the Item Record window (right click and select Edit), is there any attribute in the context or sth. so that I can realize whether I am in the Item Record window (where the item is already editable) or not (where I must call EditItems to get it editable)?

    Employee
    Posts: 414
    Registered: 12-12-2006

    Re: How can I know if I am in the Item Record Window or not?

    01-11-2012 09:33 AM in reply to: smilinger

    Unfortunately there is no navigation context for tab views.  It's on our list to fix.

     

    If you are in Vault 2012, I have a workaround for you.  In your OnStartup function, hook to the application.CommandBegin and application.CommandEnd events.  When the Item edit window opens, you will get an event for the "Item.Edit" command.  When the window closes, you get the end event for the "Item.Edit" command.  So the item is in an editable state between these two events.

     

    Here is what the C# code would look like....

    ----------------------------------------------------------------------------

    private bool m_isItemEditable = false;
    public void OnStartup(IApplication application)
    {
        application.CommandBegin += new EventHandler<CommandBeginEventArgs>(application_CommandBegin);
        application.CommandEnd += new EventHandler<CommandEndEventArgs>(application_CommandEnd);
        return;
    }

    void application_CommandBegin(object sender, CommandBeginEventArgs e)
    {
        if (e.CommandId == "Item.Edit")
            m_isItemEditable = true;
    }

    void application_CommandEnd(object sender, CommandEndEventArgs e)
    {
        if (e.CommandId == "Item.Edit")
            m_isItemEditable = false;
    }

     

     

     



    Doug Redmond
    Software Engineer
    Autodesk, Inc.
    http://justonesandzeros.typepad.com/

    Employee
    Posts: 19
    Registered: 10-18-2006

    Re: How can I know if I am in the Item Record Window or not?

    01-11-2012 10:02 AM in reply to: doug.redmond

    Alternate option is to check type name of parent form:

     

    if (ParentForm != null)

    {

        Type formType = ParentForm.GetType();

     

        if (formType.Name.Equals("EditCreateForm", StringComparison.InvariantCulture))

        {

            ...

        }

    }



    Jan Liska
    Technical Consultant
    Autodesk, Inc.
    Active Contributor
    Posts: 31
    Registered: 10-31-2005

    Re: How can I know if I am in the Item Record Window or not?

    01-11-2012 10:12 AM in reply to: smilinger

    Thank you for the reply! I will try these two methods.