Sunday, January 28, 2007

Customize a new Home Page

Change Splash to Home
Some easy changes to the Splash pages provides instant customization to your own application.
I prefer the term home to Splash but we only need to change the visible text as follows.
Search for <“Splash> with whole word set true.
The following result of 5 matching lines (replace Splash with home for each case shown below):

Find all ""Splash", Whole word, Subfolders, Find Results 1, "Entire Solution", "*.*"
~\Source\UIModules\UI.Nav\NavBarService.cs(191): /// This happens with Splash when we click the "Splash" menu item.
~\Source\UIModules\UI.Nav\Views\NavSplashViewPresenter.cs(50): smartPartInfo = new OutlookBarSmartPartInfo("Splash", Resources.GetImage(ResourceNames.LogoImage));
~\Source\UIModules\UI.Nav\Views\NavSplashViewPresenter.cs(53): smartPartInfo.Description = "Splash Page";
~\Source\UIModules\UI.Splash\SplashModuleController.cs(55): ToolStripButton splashButton = new ToolStripButton("Splash!");
~\Source\UIModules\UI.Splash\Views\SplashViewPresenter.cs(42): View.SmartPartInfo = new PageSmartPartInfo("Splash", "Splash");
Matching lines: 5 Matching files: 4 Total files searched: 492

Replace the image with a customized Web page
Upgrade the opening view from an image to a browser as follows:
Replace the SetSplashImage control method (comment out) in the SplashViewPresenter

///// Set the SplashImage control with the Splash Image.
//public void SetSplashImage(PictureBox pImageControl)
//{
// pImageControl.Image = Resources.GetImage(ResourceNames.SplashImage);
//}

with a SetHomeBrowser method as shown below:

/// Set the Home Browser control.
public void SetHomeBrowser(WebBrowser pBrowserControl)
{
try
{
pBrowserControl.Url = new Uri(Resources.GetText("MyOpeningPage"));
}
catch
{
pBrowserControl.Url = new Uri(Resources.GetText("HomePage"));
}
}

It is important to keep the test footprint as small as necessary to limit errors and unused functionality. Thus remove all unwanted controls and code that is commented out or not used.


Define the Home Page url address
Add two new string definitions to the resource file for MyOpeningPage and HomePage (~\Source\Infrastructure\Infrastructure.Foundation\Properties\Resources.resx)


Make matching adjustments
To the file ~\Source\UIModules\UI.Splash\Views\SplashView.cs [Design]
Delete the control mSplashImagePictureBox
Add (drag and drop) a webBrowser from the Toolbox and dock (Full) name the control mWebBrowserHome
Set the Url property to the full path name for (say) the SplashImage to provide a control that initializes, e.g. C:\CabanaCS.070124\Source\Infrastructure\Infrastructure.Foundation\Resources\SplashImage.png. If you do not provide a valid url the application will fail to perform the dependency injection required for the step shown next. By selecting an internal image file the application will always start correctly.

In the code behind file SplashView.cs update the code as follows to comment out or remove the SetSplashImage with the new SetWebBrowserHome action. Note

[CreateNew]
public SplashViewPresenter Presenter {
set {
_presenter = value;
_presenter.View = this;
//_presenter.SetSplashImage(mSplashImagePictureBox);
//Tell the presenter about the Browser
_presenter.SetHomeBrowser(mWebBrowserHome);
}
}


The [CreateNew] statement is used to initialize the _presenter property in advance of its use.
This lesson shows how to keep the view and presenter roles clear with the view only managing the visual interface and leaving the presenter to deal with application logic and preferences.

The Shell (_layoutWorkspace)

You can adjust the Shell window initial size by adding a width and height value using the lines shown below after the initialize statement to the file ~\Source\Infrastructure\Shell\ShellForm.cs

public ShellForm() {
InitializeComponent();
//Set default size to meet default your opening page size
this.Width = 950;
this.Height = 600;
_layoutWorkspace.Name = WorkspaceNames.LayoutWorkspace; }

Customize Shell

Add the following lines to SetChrome() in ~\Source\Infrastructure\Infrastructure. Foundation\FoundationModule.cs to identify the Shell version and application title:

private void SetChrome() {
Shell.Icon = Resources.GetIcon(ResourceNames.LogoIcon);
//kjhh: Alternative Shell Title using assembly values
Shell.Text = Shell.CompanyName + " - "
+ Shell.ProductName + " Version "
+ Shell.ProductVersion; }

Update the icon (to correspond to the Splash Screen icon) this should be done by replacing the resource file IdeaBlade image “LogoIcon” with a new ico file (delete first then add an existing file into the same location). The icon is found at ~\Source\Infrastructure\Infrastructure.Foundation\Resources\LogoIcon.ico
Also replace the SplashImage at ~\Source\Infrastructure\Infrastructure.Foundation\Resources\SplashImage.xxx
Where xxx is a valid image file type extension.

Customize the Splash Screen for Startup

Open ..\Source\Infrastructure\Shell\SplashForm.cs in VisualStudio and using the properties window change the background image and the icon to types of your own preferences. Set the Background ImageLayout property to ‘stretch’. Change the Text property to “The Application is loading …”. Open the ..\Source\Infrastructure\Shell\Properties\AssemblyInfo.cs file and make any necessary changes to the assembly: text string values to correspond to your own company and project needs.

Navigation ( see _deckWorkspace)

OutlookBarWorkspace

by Matias Woloski - 1/16/07
Cabana uses the OutlookBarWorkspace from Matias Woloski. The links which served as the starting point are:
Woloski link from which to get the code.
http://staff.southworks.net/blogs/matiaswoloski/archive/2006/05/01/OutlookBar.aspx
John Askew’s advice for upgrading the CAB with this WS.
http://www.gotdotnet.com/codegallery/
Chris Holmes original version as a ToolStrip.
http://www.chrisholmesonline.com/2006/04/21/cab-outlookbar/

Cabana Installation

First Step Notes on Cabana
Preinstall Composite UI Application Block CAB and Smart Client Software Factory SCSF. Just follow the instructions. The home page for all this CAB stuff is now at CodePlex http://www.codeplex.com/smartclient .

Install DevForce-Express for Object Builder and middleware infrastructure. Go to http://www.ideablade.com/downloads.html

Run through the video examples and other tutorials found on IdeaBlade site.

Download the Cabana Project http://www.ideablade.com/Cabana/cabana.html

Installation is as easy as it says just follow the IdeaBlade instructions. Don’t forget to move the two template file to your template folder.

When you run the project you should get the following three windows, the Cabana application, the Visualizer and the Trace Viewer.