- goalbook.zip
- GoalBook
- Dependencies
- CAG WPF 2
- Microsoft.Practices.Composite.dll
- Microsoft.Practices.Composite.Presentation.dll
- Microsoft.Practices.Composite.UnityExtensions.dll
- Microsoft.Practices.ObjectBuilder2.dll
- Microsoft.Practices.ServiceLocation.dll
- Microsoft.Practices.Unity.dll
- vssver2.scc
- CSLA
- Csla.dll
- Csla.XmlSerializers.dll
- vssver2.scc
- Infragistics
- Infragistics3.Wpf.DataPresenter.v9.1.Express.dll
- Infragistics3.Wpf.Editors.v9.1.Express.dll
- Infragistics3.Wpf.v9.1.Express.dll
- vssver2.scc
- WPFToolkit
- vssver2.scc
- WPFToolkit.dll
- GoalBook.Controls
- GoalBook.Goals
- GoalBook.Infrastructure
- GoalBook.Notes
- GoalBook.Public
- GoalBook.Shell
- App.ico
- App.xaml
- App.xaml.cs
- Bootstrapper.cs
- Commands
- GoalBook.Shell.csproj
- GoalBook.Shell.csproj.user
- Journal.ico
- Journal48.ico
- Misc
- Modules
- Properties
- Resources
- arrow_refresh.png
- arrow_undo.png
- checked.gif
- cross.png
- disk.png
- email.png
- erase.png
- error.png
- exclamation.png
- flag_red.png
- group.png
- help.png
- information.png
- magnifier.png
- page_red.png
- pencil.png
- printer.png
- user.png
- vssver2.scc
- Wave.jpg
- world.png
- world_link.png
- Services
- Splash.png
- Views
- vssver2.scc
- Windows
- GoalBook.sln
- GoalBook.snk
- GoalBook.Synchronisation
- GoalBook.Tasks
- License.txt
- ReadMe.txt
- SolutionInfo.cs
- vssver2.scc
|
// <copyright file="NotesModule.cs" company="GoalBook">
// Copyright © 2009 Mark Brownsword. All rights reserved.
// This source code and supporting files are licensed under The Code Project
// Open License (CPOL) as detailed at http://www.codeproject.com/info/cpol10.aspx.
// </copyright>
namespace GoalBook.Notes
{
#region Using Statements
using System;
using System.Reflection;
using System.Windows.Input;
using GoalBook.Infrastructure;
using GoalBook.Infrastructure.Constants;
using GoalBook.Infrastructure.Enums;
using GoalBook.Infrastructure.Interfaces;
using GoalBook.Notes.Views;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Presentation.Commands;
using Microsoft.Practices.Unity;
#endregion
/// <summary>
/// Notes Module.
/// </summary>
[Module(ModuleName = "Notes")]
public class NotesModule : IModule
{
#region Constants and Enums
#endregion
#region Inner Classes and Structures
#endregion
#region Delegates and Events
#endregion
#region Instance and Shared Fields
/// <summary>
/// Declaration for IUnityContainer.
/// </summary>
private readonly IUnityContainer container;
/// <summary>
/// Declaration for INavigationService.
/// </summary>
private readonly INavigationService navigation;
/// <summary>
/// Declaration for ISettingsService.
/// </summary>
private readonly ISettingsService settingsService;
/// <summary>
/// Declaration for moduleName.
/// </summary>
private string moduleName;
/// <summary>
/// Declaration for NotesViewPresenter.
/// </summary>
private NotesViewPresenter notesViewPresenter;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the NotesModule class.
/// </summary>
/// <param name="navigation">navigation parameter</param>
/// <param name="container">container parameter</param>
/// <param name="logger">logger parameter</param>
/// <param name="settingsService">settingsService parameter</param>
public NotesModule(INavigationService navigation, IUnityContainer container, ILoggerService logger, ISettingsService settingsService)
{
this.container = container;
this.navigation = navigation;
this.settingsService = settingsService;
}
#endregion
#region Properties
#endregion
#region Public and internal Methods
/// <summary>
/// Initialize the module.
/// </summary>
public void Initialize()
{
// Get the ModuleName, as set in the ModuleAttribute for this class.
ModuleAttribute moduleAttribute = (ModuleAttribute)this.GetType().GetCustomAttributes(
typeof(ModuleAttribute), false)[0];
this.moduleName = moduleAttribute.ModuleName;
MenuInfo menuInfo = new MenuInfo();
// Initialise the DelegateCommand.
menuInfo.MenuDelegateCommand = new DelegateCommand<CommandInfo>(
this.ShowModuleExecute_EventHandler, this.CanShowModuleExecute_EventHandler);
// Initialise the MenuCommandInfo.
menuInfo.MenuCommandInfo = new CommandInfo(
this.moduleName,
0,
ParentMenuType.Go,
new Uri(MenuConstants.MENU_NEW_NOTE_IMAGE_URI, UriKind.Absolute),
null);
// Initialise NotesViewPresenter.
this.notesViewPresenter = this.container.Resolve<NotesViewPresenter>();
this.notesViewPresenter.View = this.container.Resolve<NotesView>();
this.notesViewPresenter.ActionView = this.container.Resolve<NotesActionView>();
this.notesViewPresenter.InitViews();
// Add Navigation MenuItem to the Shell's Go menu.
this.navigation.SetNavigationMetadata(menuInfo, this.notesViewPresenter.GetNewMenuInfo());
}
#endregion
#region Base Class Overrides
#endregion
#region Private and Protected Methods
/// <summary>
/// Handle ShowModuleExecuteHandler event. Load the default view each
/// time the navigation menu item is executed.
/// </summary>
/// <param name="parameter">CommandInfo parameter</param>
private void ShowModuleExecute_EventHandler(CommandInfo parameter)
{
if (parameter.Title != this.moduleName)
{
return;
}
Mouse.SetCursor(Cursors.Wait);
try
{
// Load and Activate the default view.
if (this.navigation.LoadModuleView(
this.moduleName,
parameter.IconUri,
this.notesViewPresenter.View,
this.notesViewPresenter.ActionView,
this.notesViewPresenter.ViewMenuInfo))
{
this.notesViewPresenter.View.Activate();
this.notesViewPresenter.ActionView.Activate();
}
}
finally
{
Mouse.UpdateCursor();
}
}
/// <summary>
/// Handle CanShowModuleExecuteHandler event. Disable navigation
/// when default view is currently active.
/// </summary>
/// <param name="parameter">CommandInfo parameter</param>
/// <returns>Active status of module</returns>
private bool CanShowModuleExecute_EventHandler(CommandInfo parameter)
{
if (this.notesViewPresenter == null)
{
return this.settingsService.StartUpModule != this.moduleName;
}
return !this.notesViewPresenter.View.IsActive;
}
#endregion
#region Event Handlers
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been working as a software developer since 2000 and hold a Bachelor of Business degree from The Open Polytechnic of New Zealand. Computers are for people and I aim to build applications for people that they would want to use.