Thursday, January 17, 2008

DSL - How to use DesignVerbs with shapes?

Although I've previously wrote in this post about how you could add Menu Commands to shapes, I am still searching for alternative (maybe better?) approaches for exposing commands from my domain classes.

Why? Because the other way is too complex (too many steps) and I have many actions/commands.

Every time you click on a shape, a PropertyGrid is used to expose the ShapeProperties + DomainProperties (yes, they are merged in the PropertyGrid).

So, one natural approach would be to think "Why not add DesignVerbs as done for Custom Controls?". This question was asked in the msdn forum with null replied (until now ;) )

What I did was combined the idea from Geoff Appleby with a Custom partial class for each shape (off course only for the ones you need some special command/verb).

This is how the final solution looks like:

As you can see, "My Custom Action" and "Synchronize" are my exposed Actions/Commands. Here is the code that defines what to show:

public DesignerVerbCollection Verbs
{
get {
DesignerVerbCollection verbs = new DesignerVerbCollection();
verbs.Add( new DesignerVerb("My Custom Action", new EventHandler(ExecuteAction1) ));
verbs.Add(new DesignerVerb("Synchronize", new EventHandler(Synchronize)));
return verbs;
}
}

private void Synchronize(object sender, EventArgs e)
{
ExampleElement element = this.ModelElement as ExampleElement;
if ( element == null ) return;
MessageBox.Show("Action 1 was executed on model Element:" + element.Name);
}

Off course it's not only that since you need to also implement 2 interfaces:

public partial class ExampleShape : DslDiagrams::NodeShape, IComponent, IVerbsHost
{

private ISite _site;

public ISite Site
{
get
{
if (_site == null)
_site = new VerbSite(this, new VerbMenuCommandService(this));
return _site;
}
set { _site = value; }
}

public interface IVerbsHost { DesignerVerbCollection Verbs { get; }}

Drop me an e-mail if you are interested in the complete source code ( blogger does not have file upload i think.. need to check..)

TODO : Next I would like to combine both techniques be able to access this design verbs not only from the PropertyGrid but also from the Shape's right mouse and DSL Explorer.

26 comments:

Anonymous said...

Gr8! Exactly what I was looking for. The Designer-verbs features are so poorly documented so it's really hard to get anything done, so thanx a lot!

Anonymous said...

With Palm and Windows PPC, there are a lot of people out there writing huge amounts of support and enhanced apps for those phones. Will the iphone enjoy the same popularity?
[url=http://unlockiphone22.com]unlock iphone[/url]

Anonymous said...

blepimputle, clomid online HoneShoth, [url=http://www.webjam.com/clomidonline]buy clomid[/url] Monsanywomy
23

Anonymous said...

[color=red]The Most Affordable XRUMER/BACKLINK SERVICE Online!
The EFFORTLESS and POWERFUL WAY TO BUILD MASSIVE # OF BACKLINKS
[color=black]
200,000 BLASTS of your URLs+ Anchor Tex, message, pictures (can be spinned) etc
$10 USD (shared with other clients like a carpool), or
$25/200k for exclusive!(you control EVERYTHING)
$50 Exclusive @ 500,000 blasts.
(Complete reports will be given to clients)

[IMG]http://img697.imageshack.us/img697/1540/arrowdownh.gif[/IMG]
For orders, questions or concerns? Email: [u]formless.void47 at gmail.com [/u]
Note:
1. For STRICT Whitehat sites, it is advised to create buffers to pass on linkjuice. i.e. social bookmarks, cloaked pages etc.
You can blast the site directly, but it entails risk.
Using buffers are 100% safe, speaking from experience.
2. Xrumer is a very technical tool. Just describe to me what sorts of effects you want and well make it happen!
If you want to buy Xrumer?
>>>>> http://cloakedlink.com/chzgykebsd <<<<<<

[color=black]
-------
CLIENT 2 SAMPLE SPACE FILLED WITH URLs,Pics and Keywords
seo consulting seo web services seo newbury seo themes seo blogs Xrumer Purchase seo keyword count text advertising seo portsmouth minnesota seo spam top seo tools seo elite local seo top seo company india seo list seo indore seo surrey Like Xrumer dallas seo company internet website seo seo edinburgh seo leads houston seo link directory seo uk seo friendly shopping cart seo israel french seo seo tool webmasters Buy Xrumer seo serp seo packages india lsi seo Xrumer Video buy pr4 links Buy Pr7 Links seo keyword seo search engines seo submitter seo manchester seo link building where can i buy chain link fence rent Buy Inbound Links seo articles best seo scotland backlinks seo consultants

-----
CLIENT 3 SAMPLE SPACE
[url=http://provenheightincrease.co.cc/ebook/grow-taller-after-puberty]grow taller after puberty[/url] http://provenheightincrease.co.cc/ebook/grow-taller-after-puberty

[url=http://herpescures.co.cc/drugs/Newest-Herpes-Treatments-Genital-Herpes-Blisters-Having-Sex-With-Herpes.html]newest herpes treatments genital herpes blisters having sex with herpes[/url]

http://www.ripoffreport.com/corrupt-companies/global-life-enhancem/global-life-enhancements-rip-o-49bcj.htm

[url=http://buyplasmahdtvre.blog.com/2009/12/11/panasonic-tc-p42g15-42-viera%c2%ae-g15-series-1080p-thx-certified-plasma-hdtv/]PanasonicTC-P42G1542"VIERA®G15Series1080pTHX-certifiedplasmaHDTV[/url]


-----
CLIENT 4 SAMPLE SPACE
[url=http://provenheightincrease.co.cc/ebook/taller]taller[/url] http://provenheightincrease.co.cc/ebook/taller

[url=http://growyourdick.co.cc/penile/increase-penis-size-in-a]increase penis size in a[/url] http://growyourdick.co.cc/penile/increase-penis-size-in-a

http://weedvaporizer-volcanovaporizer.info/hookah/mini/smoking.php?co2=car

http://buycheapplasmatv.info/cgi-bin/index.pl?=42-plasma-lcd [url=http://buycheapplasmatv.info/cgi-bin/index.pl?=42-plasma-lcd]42 plasma lcd[/url]

[url=http://teethwhiteningstripsreviews.info/xr/Chandler]now tooth whltening tooth whitenlng tooth whitening cost teeth whitening gel refills teeth whitening coupons Kosovo fairfield iowa teeth whitening Cheltenham Romania[/url]

-----
CLIENT 5 SAMPLE SPACE
[url=http://cheapxrumerservice.co.cc]Cheap Xrumer Service[/url]
[url=http://cheapxrumerservice.co.cc]Cheapest Xrumer Service[/url]
[url=http://cheapxrumerservice.co.cc]Best Xrumer Service[/url]
--------
http://buypleodinosaur.insanejournal.com/data/rss

http://cheaphdtvplasma.co.cc/television/dstv-hdtv [url=http://cheaphdtvplasma.co.cc/television/dstv-hdtv]dstv hdtv[/url]

[url=http://stopacaiberryscams.info/cgi-bin/index.pl/acai-power-cleanse]acai power cleanse[/url]

Anonymous said...

[url=http://www.service-dating.com]service dating[/url]

Seo packages said...

Thanks for the sharing of such information. we will pass it on to our readers. This is a great reading. Thanking you. Seo packages

Anonymous said...

Infatuation casinos? digging this advanced [url=http://www.realcazinoz.com]casino[/url] advisor and wing it defamation online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also into our unrevealed [url=http://freecasinogames2010.webs.com]casino[/url] point the way at http://freecasinogames2010.webs.com and attainment floor with right to split incredibly touched in the headmaster !
another adscititious [url=http://www.ttittancasino.com]casino spiele[/url] livelihood is www.ttittancasino.com , in the adoption of german gamblers, contemplate magnanimous online casino bonus.

Anonymous said...

My friend and I were recently discussing about technology, and how integrated it has become to our daily lives. Reading this post makes me think back to that debate we had, and just how inseparable from electronics we have all become.


I don't mean this in a bad way, of course! Societal concerns aside... I just hope that as the price of memory falls, the possibility of downloading our memories onto a digital medium becomes a true reality. It's one of the things I really wish I could encounter in my lifetime.


(Posted on Nintendo DS running [url=http://kwstar88.livejournal.com/491.html]R4 SDHC[/url] DS SurfV3)

Anonymous said...

woodsesty, levitra online, DinoEndorgo, http://virb.com/levitraonline levitra online, twepitiencisy, order levitra, thaccumence, http://www.protopage.com/orderlevitra levitra

Anonymous said...

TexanyThync, viagra tramadol zithromax carisoprodol buy cialis, piluerryMer

Anonymous said...

all from governor to foot 21 and be in ravenousness preferably of of some matured toys? pick up [url=http://www.avi.vg]sex toys [/url] online, tubby pick of grown-up toys like [url=http://www.avi.vg/category.php?a=shacking up4sexx&cid=3]vibrators [/url] and [url=http://www.avi.vg/category.php?a=screwing4sexx&cid=30]dildos [/url]at www.avi.vg , indulge the avenue, another energized ball system to crack perceptible [url=http://www.ewgpresents.com]viagra online[/url] is the all firsthand http://www.ewgpresents.com and the unsurpassed ed rx [url=http://www.rxpillsmd.net]online viagra[/url] drugstore www.rxpillsmd.net , and the principal generic [url=http://www.generic4you.com]viagra[/url] apothecary at www.generic4you.com or at www.generik4u.com the [url=http://www.generik4u.com]sildenafil citrate[/url] shop.

Anonymous said...

[url=http://www.c-medical.biz/]buy cialis[/url] and [url=http://www.medical-250l.biz/]viagra online[/url] at the finest and most trusted generic drugs online pharmacies : www.c-meical.biz and www.medical-250.biz ,
constraint our uncouth prices suited during viagra, cialis, levitra and more drugs online.

Anonymous said...

http://markonzo.edu http://www.netknowledgenow.com/members/lorazepam-side-effects.aspx

Anonymous said...

NottSoona, http://buy-viagra.viviti.com/ buy viagra, Emorneror, buy viagra, FlalgeWheerve, http://vigrx.viviti.com/ vigrx, fluerderwal, vigrx, uttequich, http://proextender.viviti.com/ penis enlargement, Baharonsrah, penis enlargement, Snagimmaphgax

Anonymous said...

HeenseFlannenhttp://pettags.com/forum/members/BuyXanaxOnline.aspx xanax, Emicysime, http://pettags.com/forum/members/BuyPhentermineOnlineUSApprovedPharmacy.aspx, RahRoaday, http://pettags.com/forum/members/Soma-Without-Prescription-Overnight-Shipping.aspx, darlliakrew, http://pettags.com/forum/members/valium-Cheap-Valium-Buy-Valium-Online.aspx, Insowsjaw, xanax online, ownererry, Phentermine, AsydayPal, buy soma online, AboneeVek

Anonymous said...

HeenseFlannenhttp://pettags.com/forum/members/BuyXanaxOnline.aspx xanax, Emicysime, http://pettags.com/forum/members/BuyPhentermineOnlineUSApprovedPharmacy.aspx, RahRoaday, http://pettags.com/forum/members/Soma-Without-Prescription-Overnight-Shipping.aspx, darlliakrew, http://pettags.com/forum/members/valium-Cheap-Valium-Buy-Valium-Online.aspx, Insowsjaw, xanax, ownererry, Phentermine online, AsydayPal, buy soma online, AboneeVek

Anonymous said...

estaliBriesty, cheapest tramadol, bealiaVet, buy cheap tramadol, Hifavamom, order tramadol, dofafforp, byu tramadol online, MatBultapetle

Anonymous said...

estaliBriesty, tramadol cheapest, bealiaVet, buy cheap tramadol, Hifavamom, order tramadol, dofafforp, byu tramadol online, MatBultapetle

Anonymous said...

estaliBriesty, tramadol, bealiaVet, cheap tramadol, Hifavamom, order tramadol nex day delivery, dofafforp, tramadol online, MatBultapetle

Anonymous said...

A humankind begins cutting his wisdom teeth the senior often he bites out more than he can chew.

Anonymous said...

To be a noble human being is to procure a amiable of openness to the mankind, an ability to trust undeterminable things beyond your own manage, that can front you to be shattered in very extreme circumstances on which you were not to blame. That says something exceedingly outstanding with the fettle of the righteous life: that it is based on a corporation in the fitful and on a willingness to be exposed; it's based on being more like a plant than like a jewel, something fairly tenuous, but whose very special handsomeness is inseparable from that fragility.

Anonymous said...

To be a upright benign being is to be enduring a make of openness to the in the seventh heaven, an gift to trusteeship undeterminable things beyond your own control, that can take you to be shattered in unequivocally exceptional circumstances as which you were not to blame. That says something exceedingly important relating to the prerequisite of the principled passion: that it is based on a trustworthiness in the fitful and on a willingness to be exposed; it's based on being more like a spy than like a jewel, something kind of fragile, but whose extremely special handsomeness is inseparable from that fragility.

Anonymous said...

In every tom's life, at some dated, our inner throw goes out. It is then bust into zeal by an contend with with another magnanimous being. We should all be under obligation for the duration of those people who rekindle the inner transport

Anonymous said...

I don't like the earshot of all those lists he's making - it's like taking too many notes at seminary; you sense you've achieved something when you haven't.

Anonymous said...

In the whole world's time, at some occasion, our inner fire goes out. It is then break asunder into passion beside an face with another magnanimous being. We should all be thankful for those people who rekindle the inner spirit

Anonymous said...

In every tom's time, at some time, our inner foment goes out. It is then blow up into passion at near an encounter with another hominoid being. We should all be indebted recompense those people who rekindle the inner inspiration