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)
pBrowserControl.Url = new Uri(Resources.GetText("MyOpeningPage"));
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

public SplashViewPresenter Presenter {
set {
_presenter = value;
_presenter.View = this;
//Tell the presenter about the Browser

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.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home