.NET

Reply
Valued Contributor
yaqiz
Posts: 86
Registered: ‎07-14-2010
Message 1 of 9 (490 Views)

what event does the syatem trigger when close a palette(my own palette)

490 Views, 8 Replies
07-25-2011 06:35 AM

Hi Guys,

 

I am using VB.net created a palette。 I need to call refresh drawing(my own function) when user close this palette. But I don't know which event I need to put my code in

 

Any ideas?

 

Thanks very much

*Expert Elite*
norman.yuan
Posts: 946
Registered: ‎04-27-2009
Message 2 of 9 (481 Views)

Re: what event does the syatem trigger when close a palette(my own palette)

07-25-2011 09:32 AM in reply to: yaqiz

Do you mean closing a PaletteSet, or a Palette in a PaletteSet (if so, how your code let user to close a Palette in a PaletteSet? Set the user control invisible, or remove the user control from the PaletteSet)?

 

For the former, PaletteSet fires an event "PaletteSetStateChanged" when its visibility is changed. That is, when user click the "x" on the even fires. So, you can handle this event with information provided in the PaletteSetStateChangedeventArgs.

 

For the latter, you may have to derive your PaletteSet from PaletteSet class and create your own event when user control is added/removed to the PaletteSet, or when the user control's visibility changed. Note, PaletteSet is inheritable only since Acad2009.

 

Also, since PletteSet is a modeless window, it seems odd that you need to "refresh" (by regenerating?) the drawing on its closing. Usually, the drawing should be updated right after the change is done in the paletteset if the change affects the drawing. "Update drawing after winodw closiing" is usually applied to modal window.

Valued Contributor
yaqiz
Posts: 86
Registered: ‎07-14-2010
Message 3 of 9 (459 Views)

Re: what event does the syatem trigger when close a palette(my own palette)

07-26-2011 01:18 AM in reply to: norman.yuan

Thanks for your reply.

 

I meant to close paletteset. on the palette there are 2 buttons on the top right corner. one looks like "-", the other one looks like "x". "-" is for hide and "x" is for close. click either button can trigger statechange event, but new state all =hide.

I would like to do something when user click "x" but not "-"

 

any ideas ?

 

 

Thanks again

*Expert Elite*
norman.yuan
Posts: 946
Registered: ‎04-27-2009
Message 4 of 9 (443 Views)

Re: what event does the syatem trigger when close a palette(my own palette)

07-26-2011 09:13 AM in reply to: yaqiz

Teh StateChanged event always fires when click "x" at the top corner of the PaletteSet.

 

However, clicking "-" to set "auto-hide" on or off that causes the PaletteSet to be hidden partially (e.g. the PaletteSet's window bar is still visible while its working area is hidden. Iin this case, it is arguable to say a PaletteSet is visible or not :-() would cause the StateChanged event firing or not firing, depending on if the PaletteSet is docked or not.

 

In my test, if the PaletteSet is floating (not docked), then when the main part of the PaletteSet becomes hidden (automatically after mouse cursor leaves from it a few seconds), the StateChange event will not fire. When puttiing mouse cursor onto the PaletteSet's winodws bar to cause the PaletteSet working area being shown, the StateChange event also does not fire. That is, when the PaletteSet is floating, StateChanged event only fires when user click "x" or when your code to set PaletteSet.Visible=true.

 

When the PaletteSet is docked, clicking both "x" and "-" cuases StateChanged event fire with NewState index as "Hide". But "x" set entire PaletteSet invisible, while "-" leave the PaletteSet's window bar still docked and visible (auto-hide). Placing mouse curosr on the docked PaletteSet window bar causes the PaletteSet's work area poping out and StateChanged event firing with NewState index as "Show". However, when the PaletteSet's work area automatically hides back, no StateChanged event fires.

 

So, if you need to do something when the PaletteSet becomes fully invisible (clicked "x") or partially (auto-hiding), you need to do it depending on if the PaletteSet is docked or not, by examing PaletteSet.Dock property.

Valued Contributor
yaqiz
Posts: 86
Registered: ‎07-14-2010
Message 5 of 9 (432 Views)

Re: what event does the syatem trigger when close a palette(my own palette)

07-27-2011 01:04 AM in reply to: norman.yuan

Thanks for your reply.

 

I did the same testing. if the paletteset is docked. the first time I click "-" fires statechange and make the paletteset autohide. "x" also fires stagechange and make the paletteset fully invisible. There is no way I can tell the different between those 2 clicks. At least I didn't find any.

 

Any ideas?

 

Thanks

Valued Contributor
yaqiz
Posts: 86
Registered: ‎07-14-2010
Message 6 of 9 (431 Views)

Re: what event does the syatem trigger when close a palette(my own palette)

07-27-2011 01:06 AM in reply to: yaqiz

What I meant is between the first click "hide" and "close" when paletteset docked they both trigger event statechange and both pass new state =hide.

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 7 of 9 (399 Views)

Re: what event does the syatem trigger when close a palette(my own palette)

08-11-2011 07:21 PM in reply to: yaqiz

I don't think you can tell the difference between "hide" and "close" events.

 

Only thing I can think of is to provide your own close button and hide the close button from your PaletteSet. To do this you can set the PaletteSet Style property and omit the PaletteSetStyles.ShowCloseButton enumeration, e.g. in C#:

 

ps.Style = PaletteSetStyles.NameEditable |
                    PaletteSetStyles.ShowPropertiesMenu |
                    PaletteSetStyles.ShowAutoHideButton;

 

Hope this helps.

Valued Contributor
yaqiz
Posts: 86
Registered: ‎07-14-2010
Message 8 of 9 (395 Views)

Re: what event does the syatem trigger when close a palette(my own palette)

08-12-2011 01:50 AM in reply to: Artvegas

Thanks for your reply

 

That what I am doing now. Using my own button

 

Thanks again

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 9 of 9 (295 Views)

Re: what event does the syatem trigger when close a palette(my own palette)

05-19-2012 05:38 AM in reply to: yaqiz

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community