PC Review


Reply
Thread Tools Rate Thread

Command Design pattern - extension.

 
 
Gobi
Guest
Posts: n/a
 
      5th May 2009
Hi,

I have few UI elements shown in a main frame. When selecting a UI element I
want to show a context menu. Used a command pattern for it with the UI
element publishing it's commands and it works fine.

Now when two or more UI elements are selected and we want to show the
context menu, we need a subset of these menus

1) only menus common to both
2) some menus can be common to both but doesn't make sense to show for
multiple selection(e.g. When two are selected we should NOT show rename,
though both of them have rename)

I'm looking at the same functionality of Visual studio, where we get
different context menus when we select one project in the visual studio vs
when we select multiple project in visual studio.


Is there a pattern for the same.


Thanks a lot for your time.

Regards,
Gobi.


 
Reply With Quote
 
 
 
 
Pavel Minaev
Guest
Posts: n/a
 
      5th May 2009
On May 5, 5:21*am, "Gobi" <gobinat...@yahoo.com> wrote:
> Hi,
>
> I have few UI elements shown in a main frame. When selecting a UI elementI
> want to show a context menu. Used a command pattern for it with the UI
> element publishing it's commands and it works fine.
>
> Now when two or more UI elements are selected and we want to show the
> context menu, we need a subset of these menus
>
> 1) only menus common to both
> 2) some menus can be common to both but doesn't make sense to show for
> multiple selection(e.g. When two are selected we should NOT show rename,
> though both of them have rename)
>
> I'm looking at the same functionality of Visual studio, where we get
> different context menus when we select one project in the visual studio vs
> when we select multiple project in visual studio.
>
> Is there a pattern for the same.


Doing #1 is fairly straightforward - just intersect the command lists
of all selected items.

Doing #2 is probably less so, but the most generic way I can think of
handling this is to add a "CanExecute" method to your ICommand (or
whatever it is called), which is invoked with sequence of selected
elements passed as an argument. Then you can return false from that
method on RenameCommand if there's more than one element, for example.
And use that when building the context menu.
 
Reply With Quote
 
Gobi
Guest
Posts: n/a
 
      7th May 2009
Thanks Pavel. I would try to come up with a good design to support it and
post if I find/do something generic
"Pavel Minaev" <(E-Mail Removed)> wrote in message
news:5b5ee3cd-dd9a-4c5b-a64b-(E-Mail Removed)...
On May 5, 5:21 am, "Gobi" <gobinat...@yahoo.com> wrote:
> Hi,
>
> I have few UI elements shown in a main frame. When selecting a UI element
> I
> want to show a context menu. Used a command pattern for it with the UI
> element publishing it's commands and it works fine.
>
> Now when two or more UI elements are selected and we want to show the
> context menu, we need a subset of these menus
>
> 1) only menus common to both
> 2) some menus can be common to both but doesn't make sense to show for
> multiple selection(e.g. When two are selected we should NOT show rename,
> though both of them have rename)
>
> I'm looking at the same functionality of Visual studio, where we get
> different context menus when we select one project in the visual studio vs
> when we select multiple project in visual studio.
>
> Is there a pattern for the same.


Doing #1 is fairly straightforward - just intersect the command lists
of all selected items.

Doing #2 is probably less so, but the most generic way I can think of
handling this is to add a "CanExecute" method to your ICommand (or
whatever it is called), which is invoked with sequence of selected
elements passed as an argument. Then you can return false from that
method on RenameCommand if there's more than one element, for example.
And use that when building the context menu.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What design pattern to use Smith Microsoft C# .NET 4 29th Sep 2009 12:57 PM
Design/Pattern guidance to refector my current design for unit testing sklett Microsoft C# .NET 1 22nd Aug 2007 12:58 PM
Design Pattern Dragon Microsoft C# .NET 3 2nd Mar 2006 10:08 AM
Observer Design Pattern Extension decrypted Microsoft C# .NET 4 16th Oct 2003 06:08 PM
Shell Extension -adding file name/command extension LuckyStrike Microsoft Outlook Discussion 23 13th Sep 2003 02:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:51 PM.