//=============================================================================== // Goal Book. // Copyright © 2009 Mark Brownsword. //=============================================================================== #region Using Statements using System.ComponentModel; using GoalBook.Infrastructure.Interfaces; using GoalBook.Infrastructure.ObjectModel; #endregion namespace GoalBook.Goals.Views { public class GoalsDialogViewPresenter { #region Constants and Enums #endregion #region Inner Classes and Structures #endregion #region Delegates and Events #endregion #region Instance and Shared Fields private readonly IPersistenceService _persistenceService; #endregion #region Constructors /// <summary> /// Constructor. /// </summary> public GoalsDialogViewPresenter(Goal editGoal, IPersistenceService persistenceService) { //Reference to PersistenceService. _persistenceService = persistenceService; //Initialise Model. Model = new GoalsDialogViewPresentationModel(); Model.EditGoal = editGoal; Model.EditGoal.PropertyChanged += new PropertyChangedEventHandler(AddGoal_PropertyChanged); //Initialise ReferenceData Model.LevelList = _persistenceService.FetchLevelList(); Model.ContributesList = _persistenceService.FetchContributesList(editGoal.GoalID, editGoal.LevelID); } #endregion #region Properties /// <summary> /// Reference to Model. /// </summary> public GoalsDialogViewPresentationModel Model { get; private set; } /// <summary> /// Reference to View. /// </summary> public GoalsDialogView View { get; set; } #endregion #region Private and Protected Methods /// <summary> /// Handle AddGoal_PropertyChanged event. /// </summary> private void AddGoal_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { View.RaiseErrorInfoChanged(Model.EditGoal as IDataErrorInfo); } /// <summary> /// Handle View_LevelChanged event. /// </summary> private void View_LevelChanged(GoalBook.Infrastructure.Events.LevelChangedEventArgs e) { //Reset the ContributesList for the selected Level. Model.ContributesList = _persistenceService.FetchContributesList(Model.EditGoal.GoalID, e.LevelID); //Reset ComboBoxContributes with new list. //View.comboBoxContributes.ItemsSource = null; //View.comboBoxContributes.ItemsSource = Model.ContributesList; //View.comboBoxContributes.IsEnabled = (Model.ContributesList.Count > 0); //Model.EditGoal.ContributesID = Guid.Empty; } #endregion #region Public and internal Methods /// <summary> /// Initialise the View. /// </summary> public void InitView() { View.DataContext = Model; View.LevelChanged += new GoalBook.Infrastructure.Events.LevelChangedEventHandler(View_LevelChanged); View.comboBoxContributes.IsEnabled = (Model.ContributesList.Count > 0); } #endregion #region Event Handlers #endregion #region Base Class Overrides #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.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)