- 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
|
//===============================================================================
// Goal Book.
// Copyright © 2009 Mark Brownsword.
//===============================================================================
#region Using Statements
using System;
using System.Reflection;
using System.Windows.Input;
using GoalBook.Goals.Views;
using GoalBook.Infrastructure;
using GoalBook.Infrastructure.Constants;
using GoalBook.Infrastructure.Enums;
using GoalBook.Infrastructure.Interfaces;
using Microsoft.Practices.Composite.Events;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Presentation.Commands;
#endregion
namespace GoalBook.Goals
{
[Module(ModuleName = "Goals")]
public class GoalsModule : IModule
{
private readonly INavigationService _navigation;
private readonly ILoggerService _logger;
private readonly IDialogService _dialogService;
private readonly IPersistenceService _persistenceService;
private readonly IEventAggregator _eventAggregator;
private readonly IPrintService _printService;
private readonly ISettingsService _settingsService;
private GoalsViewPresenter _goalsViewPresenter;
private string _moduleName;
/// <summary>
/// Constructor.
/// </summary>
public GoalsModule(INavigationService navigation, ILoggerService logger, IDialogService dialogService,
IPersistenceService persistenceService, IEventAggregator eventAggregator, IPrintService printService, ISettingsService settingsService)
{
_navigation = navigation;
_logger = logger;
_dialogService = dialogService;
_persistenceService = persistenceService;
_eventAggregator = eventAggregator;
_printService = printService;
_settingsService = settingsService;
}
/// <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]);
_moduleName = moduleAttribute.ModuleName;
MenuInfo menuInfo = new MenuInfo();
//Initialise the DelegateCommand.
menuInfo.MenuDelegateCommand = new DelegateCommand<CommandInfo>(
ShowModuleExecute_EventHandler, CanShowModuleExecute_EventHandler);
//Initialise the MenuCommandInfo.
menuInfo.MenuCommandInfo = new CommandInfo(_moduleName, 0, ParentMenuType.Go,
new Uri(MenuConstants.MENU_NEW_GOAL_IMAGE_URI, UriKind.Absolute), null);
//Initialise GoalsViewPresenter.
_goalsViewPresenter = new GoalsViewPresenter(_navigation, _dialogService, _logger, _persistenceService, _eventAggregator, _printService);
_goalsViewPresenter.View = new GoalsView();
_goalsViewPresenter.ActionView = new GoalsActionView();
_goalsViewPresenter.InitViews();
//Add Navigation MenuItem to the Shell's Go menu.
_navigation.SetNavigationMetadata(menuInfo, _goalsViewPresenter.GetNewMenuInfo());
}
/// <summary>
/// Handle ShowModuleExecuteHandler event. Load the default view each
/// time the navigation menu item is executed.
/// </summary>
private void ShowModuleExecute_EventHandler(CommandInfo parameter)
{
if (parameter.Title != _moduleName) { return; }
Mouse.SetCursor(Cursors.Wait);
try
{
//Load and Activate the default view.
if (_navigation.LoadModuleView(
_moduleName,
parameter.IconUri,
_goalsViewPresenter.View,
_goalsViewPresenter.ActionView,
_goalsViewPresenter.ViewMenuInfo))
{
_goalsViewPresenter.View.Activate();
_goalsViewPresenter.ActionView.Activate();
}
}
finally { Mouse.UpdateCursor(); }
}
/// <summary>
/// Handle CanShowModuleExecuteHandler event. Disable navigation
/// when default view is currently active.
/// </summary>
private bool CanShowModuleExecute_EventHandler(CommandInfo parameter)
{
if (_goalsViewPresenter == null)
{
return this._settingsService.StartUpModule != this._moduleName;
}
return !_goalsViewPresenter.View.IsActive;
}
}
}
|
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.