Link between WorkItem and SmartParts

Topics: CAB & Smart Client Software Factory
Apr 21, 2006 at 10:11 PM
originally posted by: KrijnMichiels

How can I know wich workitem belongs to wich smartpart ?

I have a custom workspace that needs to know wich workitem hosts the smartpart that wants to be shown.
I think I need a shared function GetWorkItem(smartPart as object) somewhere ?

Would it be a good idea to create a shared collection and function and manage the collection from SmartPartAdded and SmartPartRemoved events in workitems ?
Apr 22, 2006 at 4:59 AM
originally posted by: atome

I think I would implement an IPublishWorkItem interface in my smartParts. This interface could contain a property or a method which publish a reference to the parent workItem. In your workspace, you could test the type of smartParts and eventualy get the parents workItems. I think a base class could be fine too.

Btw, a singleton MappingServiceBlahBlah could be ok, but perhaps a bit painful to maintain... I'm not sure.

Why do you want to know which workItems host your smartParts ?
Apr 22, 2006 at 7:43 AM
originally posted by: ChrisHolmes

Something to consider: Controls (thus UserControls) have a Tag property that allows you to attach an object to the Control. This could be a string, boolean, custom object... WorkItem.

My question would be, however, why do you need this coupling? I'd be very cautious about coupling this parts in this way.
Apr 23, 2006 at 9:08 AM
originally posted by: KrijnMichiels

You all wonder why ?

I've created a ShellWorkspace that shows (IWorkspace.Show) a smartpart (mor likely a smartpart with an internal workspace like a deckedworkspace). Every 'Show' will bring up a fully working Shell.
Consider Internet Explorer; every dialog will get standard file-edit-.. menu's and options.

The 'Show' method will create the Shell (looks like GetOrCreateForm in the WindowWorkspace) and now I want to store this created Shell in the managed item collection of the workitem where this smartpart is running. This is needed because the Shell has some UIElements with Commands. The commands need to get registered within the WorkItem of the requested SmartPart.

I don't think I'm going to use the Tag property. I consider Tags as something that doesn't exist.

Guess my only option is the creation of a SmartPartBase class that gets a reference to the correspondent WorkItem. But then I lose some flexibility = everything can be a SmartPart !

Maybe I just put an extra property WorkItem in a CustomSmartPartInfo like Show(mySmartPart,new ShellSmartPartInfo("shell","",MyWorkItem))

Thanks
Apr 25, 2006 at 5:23 AM
originally posted by: ChrisHolmes

"Every 'Show' will bring up a fully working Shell. "

I was under the impression that a Shell couldn't open a Shell. I'd be interested in seeing how you accomplished that.
Apr 25, 2006 at 10:13 AM
originally posted by: KrijnMichiels

A Shell is a standard windows form. No magic here. It's even build in by CAB.

You don't have to use a ShellApplication. Start with a CabApplication, register a WindowWorkspace (maybe name it ShellWorkspace) and start showing some shells (or other forms - views you like).

Look at the WindowSmartPartInfo object. You can specify modal, location, size, etc. properties.
Apr 25, 2006 at 11:42 AM
originally posted by: ChrisHolmes

I see. I take too broad of a view of the Shell then. I was thinking about the Shell in terms of the AppDomain and the RootWorkItem as well as the form itself. My bad.