Sunday, January 21, 2007

Showing a Splash Screen

Guys,
The integrated desktop sample code provided by MSDN has been extremely helpful in clarifying a lot of queries I had. Please download this and look at the source code. I had a hard time trying to compile this app and I haven't run it yet because of some missing references to some assemblies, but the code itself is quite helpful for beginners like me.
Check this link out:
http://msdn.microsoft.com//msdnmag/issues/06/09/SmartClients/default.aspx

So from this code, I see how easy it is to create a splash screen. You just need to create a regular form, make it look like your Splash Screen and then add a timer to it to close it after the time interval expires. Here's the code for the Timer_Tick event:

private void splashTimer_Tick(object sender, EventArgs e)
{
if (InvokeRequired)
{
Invoke(new EventHandler(splashTimer_Tick), e);
}
else
{
Close();
}
}

The splash screen can then be invoked from within the Shell application by overriding the BeforeShellCreated method as shown:

base.BeforeShellCreated();
Thread th = new Thread(new ThreadStart(DoSplash));
th.Start();

The DoSplash then creates the form as shown:

private static void DoSplash()
{
Splash sp = new Splash();
sp.ShowDialog();

}

As simple as that.

Sunday, January 14, 2007

TreeView Problems in Smart Client Software Factory + CAB

I was playing around with the new Smart Client Software Study to do a feasibility study on this project I need to accomplish. A lot of my experiments are an effort to understand the SCSF and the CAB so I would highly appreciate it if I were to get any kind of guidance for the same.

So last night, I started playing around with the SCSF by creating a new solution with an additional Interface.Layout project as shown in fig 1.




Once that was done, I modified the ShellLayoutView to contain the Outlook style Navigation Pane created by Ascend.Net Controls (get that from CodePlex). This can be seen in Fig 2. I also added a TreeView control that would help me in navigating to different smart parts or modules based on the selection.


Once that was added, I added the code to expose the TreeView in the ShellLayoutView.cs as shown:

internal TreeView CustomerTreeView
{
get { return customerTreeView; }
}

After that, I wanted to add a command handler to the tree whenever a node was double-clicked. So I went ahead and added the following lines of code in the shellLayoutViewPresenter.cs


WorkItem.Commands[CommandNames.HandleCustomerTreeEvent].AddInvoker(View.CustomerTreeView, "NodeMouseDoubleClick");


Note that the CommandNames was also updated with the HandleCustomerTreeEvent (in the Infrastructure project]

I compiled and ran the solution just to make sure everything showed up correctly and this is how it looked when I did that:



I also added a Business Module to show a Smart Part called CustomerFindView whenever the FindCustomer Node was double clicked.


Here's how that looked:


In the ModuleController, I added the following CommandHandler code in order to process the node mouse double click event:

[CommandHandler(CommandNames.HandleCustomerTreeEvent)]
public void ShowFindCustomerLayout(object sender, System.Windows.Forms.TreeNodeMouseClickEventArgs e)
{
if (e != null && e.Node != null && !String.IsNullOrEmpty(e.Node.Tag.ToString()))
{
switch (e.Node.Tag.ToString())
{
case "findCustomer":
ShowFindCustomerView();
break;
default:
break;
}
}
}

Where the ShowFindCustomerView() method would be as simple as:


FindCustomerView mFindView = WorkItem.SmartParts.AddNew();
WorkItem.Workspaces[WorkspaceNames.RightWorkspace].Show(mFindView);

Now this compiles fine. Everytime I try to run it though, it fails saying:

"Error binding to target method."

I am pretty sure that it cannot bind to the NodeMouseDoubleClick event. I removed the Command Handler code and that seemed to work fine again, but now I cannot handle the double click event.

I tried the same, by replacing the TreeView with a Button. I exposed the Button in the ShellLayoutView.cs, added the CommandHandler to the "click" event in the ShellLayoutViewPresenter.cs and added the CommandHandler for the button in the Modulecontroller.cs for the CustomerModule and that seemed to work fine.

Am I missing something out here? Any help would be appreciated.

Friday, January 12, 2007

Welcome to the blog

This blog will serve as my reference for the Smart Client Software Factory and Composite UI Application Block development.

I have seen several different places that have tutorials or introductory articles but none focus on in-depth development. Hopefully, as I get along with my project on the same topic, I will post more and more stuff. I would recommend everyone to start off with http://www.cabpedia.com as it has some good pointers and resources to begin with.

Once you have enough knowledge on what constitutes the basic Smart Client Software Factory, let's get started with the crux of it.

Cheerz