This project is read-only.

Demo Application Code

Jun 27, 2008 at 5:54 PM
I am trying to work through the Demo script to convert the DemoApp to VB.Net but I am stuck on how to translate this code in the Addviews method of the Notifications/ModuleController.cs to VB

WorkItem.Workspaces[WorkspaceNames.RightWorkspace].SmartPartClosing += new EventHandler<Microsoft.Practices.CompositeUI.SmartParts.WorkspaceCancelEventArgs>(delegate(object workspace, WorkspaceCancelEventArgs e)

    {

           DisposeView(e.SmartPart, WorkItem);

    });

I know you have to use addhandler to add the event this way

AddHandler

WorkItem.Workspaces(WorkspaceNames.RightWorkspace).SmartPartClosing, AddressOf OnSmartPartClosing
What I dont know is what to pass to the OnSmartClosing method to achieve the equivalent of what the C# code above is doing.
Thanks a lot
Bunmi

Jun 27, 2008 at 7:16 PM
Solved
I found thes solution in another post
 I need to create the  OnSmartPartClosing method in the module controller and then follow the step below.

Dim workspace As IWorkspace = WorkItem.Workspaces(WorkspaceNames.ModalWindows)

AddHandler workspace.SmartPartClosing, AddressOf OnSmartPartClosing

Thanks 
Bunmi



bogunjemiyo wrote:
I am trying to work through the Demo script to convert the DemoApp to VB.Net but I am stuck on how to translate this code in the Addviews method of the Notifications/ModuleController.cs to VB

WorkItem.Workspaces[WorkspaceNames.RightWorkspace].SmartPartClosing += new EventHandler<Microsoft.Practices.CompositeUI.SmartParts.WorkspaceCancelEventArgs>(delegate(object workspace, WorkspaceCancelEventArgs e)

    {

           DisposeView(e.SmartPart, WorkItem);

    });

I know you have to use addhandler to add the event this way

AddHandler

WorkItem.Workspaces(WorkspaceNames.RightWorkspace).SmartPartClosing, AddressOf OnSmartPartClosing
What I dont know is what to pass to the OnSmartClosing method to achieve the equivalent of what the C# code above is doing.
Thanks a lot
Bunmi




Oct 24, 2008 at 5:02 PM
Edited Oct 24, 2008 at 5:04 PM
Did you ever complete conversion of the demo script source to VB? Is it available anywhere?
May 31, 2009 at 7:29 AM

You need to create a new sub that takes the parameters of C sharp delegate.

Public sub YourSub()

.....

 

Dim workspace As IWorkspace = WorkItem.Workspaces(WorkspaceNames.ModalWindows)

 

'Here you must handle SmartPartClosing event on OnSmartPartClosing sub

AddHandler workspace.SmartPartClosing, AddressOf OnSmartPartClosing

 

End Sub

 

' Now you must to create a sub that handle this event(in this case: SmartPartClosing event of workspace)

' if the event name is "eventAction" the sub that handles this event will be OnEventAction and will take

' the parameters of this events (the sign of delegate) so SmartPartClosing will be OnSmartPartClosing and

' takes 2 parameters (workspace as object , e as WorkspaceCancelEventArgs)

Public Sub OnSmartPartClosing(workspace as object , e as WorkspaceCancelEventArgs)

    DisposeView(e.SmartPart, WorkItem)

end sub