TheSwamp

Code Red => .NET => Topic started by: Draftek on February 15, 2006, 03:53:20 PM

Title: Speaking of Context menus...
Post by: Draftek on February 15, 2006, 03:53:20 PM
Glad you asked,

I'm planning on building an extensive menu system for our company. For instance, if the user right clicks a viewport, I'll have a scale view port menu with various scales available and also a rotate viewport with 90, 180, 270 rotation sub menus.

I like the idea of using a switch statement in my event delegates so I don't have to write a freaking event for every item I create. In order to do this I must create my own menu item derived from the autocad one and add either indexing or relevant data. I will have several types of menu extensions - one for each type of object selected - viewports, tables, dynamic blocks, etc.

Obviously each click will perform some function, typically I guess the sub menus may all push the same method with just a different parameter - like the scale viewport one.

So, I have two options - either add a simple index and have the event pass the correct argument to the appropriate method or I could actually store the correct data memebers and call the method using those. For instance the full size viewport scale menu item could contain a scale value of 1, the half size - 0.5 and so on.

Any thoughts on which method would be easier to maintain 2 years from now when they fire me and hire someone who knows what they are doing?

Thanks for allowing me to ramble...
Title: Re: Speaking of Context menus...
Post by: David Hall on February 15, 2006, 03:59:41 PM
c# or something else?
Title: Re: Speaking of Context menus...
Post by: Draftek on February 15, 2006, 04:31:08 PM
oh, sorry David, C#
Title: Re: Speaking of Context menus...
Post by: MickD on February 15, 2006, 04:49:47 PM
I think if I was doing this I would use a .cfg or .ini type file to build the menus and load their settings. This way the user could change the settings as required or even add to them. This would require creating your menus at runtime in code but gives you a very slick and scalable system.
It won't be easy but it will give you a lot more leverage with your code ;)
Title: Re: Speaking of Context menus...
Post by: Draftek on February 15, 2006, 05:31:49 PM
hmm..

I think in some cases that would be very cool. I would allow the user to determine which scale factors are available for instance. That would be nice since different departments would have different requirements.

yeah, more work for me...

Thanks, Mick.

Title: Re: Speaking of Context menus...
Post by: Glenn R on February 15, 2006, 11:02:53 PM
No need if you're using Map (don't know about Vanilla).

In the Map system tray @ bottom right, you will see an icon that looks like an underline. Click this and you will turn on the drawing Status Bars. This is a status for each drawing, separate from the AutoCAD application status bar.

Once these are turned on, flick to a layout and grip select a viewport. In the drawing status bar on the left you will see the words "VP Scale". Click this and up comes a popup menu allowing you to set the scale for the viewport.

I've done a similar thing to what you ask, except mine shows the list of projects going in the office, which is read from XML. In my menu, I derived from MenuItem and Called it ProjectMenuItem and add them to a ContextMenu.

Hope this helps.

Cheers,
Glenn.
Title: Re: Speaking of Context menus...
Post by: MickD on February 15, 2006, 11:16:39 PM
I couldn't find that on mine Glenn (in vanilla) but there is also the viewports toolbar which has a drop down list of std scales and other viewport tools. You can also enter in a custom scale.
Might save you a bit of work ;)
Title: Re: Speaking of Context menus...
Post by: Draftek on February 17, 2006, 08:07:32 AM
doh! I guess I will only have to code the rotation menu then.

As a side note: You must lock the document before opening objects in .ReadMode while coding in menu event.