Click here to Skip to main content
15,886,806 members
Articles / Desktop Programming / WPF

GoalBook - A Hybrid Smart Client

Rate me:
Please Sign up or sign in to vote.
4.86/5 (24 votes)
25 Sep 2009CPOL10 min read 79.1K   834   69  
A WPF hybrid smart client that synchronises your goals with the Toodledo online To-do service.
//===============================================================================
// Goal Book.
// Copyright © 2009 Mark Brownsword. 
//===============================================================================

#region Using Statements
using System.Configuration;
using System.Windows;
using GoalBook.Infrastructure;
using GoalBook.Infrastructure.Interfaces;
using Microsoft.Practices.Composite.Logging;
#endregion

namespace GoalBook.Shell.Services
{
    /// <summary>
    /// Application settings persistence class.
    /// </summary>
    public sealed class ApplicationSettings : ApplicationSettingsBase, ISettingsService
    {        
        #region Constants and Enums
        private const string LEFT = "Left";
        private const string TOP = "Top";
        private const string WIDTH = "Width";
        private const string HEIGHT = "Height";
        private const string WINDOW_STATE = "WindowState";        
        private const string UPGRADE_SETTINGS = "UpgradeSettings";
        private const string LOGGING_LEVEL = "LoggingLevel";
        private const string CONNECT_INFO = "ConnectInfo";
        private const string HOST_INFO = "HostInfo";              
        private const string TOKEN_INFO = "TokenInfo";        
        private const string STARTUP_MODULE = "StartUpModule";
        private const string ACTION_PANE_EXPANDED = "ActionPaneExpanded";
        #endregion

        #region Inner Classes and Structures
        #endregion

        #region Delegates and Events
        #endregion

        #region Instance and Shared Fields
        #endregion

        #region Constructors
        /// <summary>
        /// Private Constructor.
        /// </summary>
        public ApplicationSettings() : base() 
        {            
            //NOTE: UpgradeSettings  will be true by default when no settings file 
            //exists for the current version of the application.
            if (this.UpgradeSettings)
            {
                //Retrieve settings from previous version settings file if it exists. 
                this.Upgrade();
                this.UpgradeSettings = false;
            }
        }        
        #endregion

        #region Properties        
        /// <summary>
        /// Define SyncTokenInfo for synchronisation.
        /// </summary>
        [UserScopedSetting]
        public SyncTokenInfo TokenInfo
        {
            get { return (SyncTokenInfo)this[TOKEN_INFO]; }
            set { this[TOKEN_INFO] = value; }
        }
        /// <summary>
        /// Define the HostInfo. Proxy settings for synchronisation.
        /// </summary>
        [UserScopedSetting]
        public Proxy HostInfo
        {
            get { return (Proxy)this[HOST_INFO]; }
            set { this[HOST_INFO] = value; } 
        }
        /// <summary>
        /// Define the ConnectInfo. Login details for synchronisation.
        /// </summary>
        [UserScopedSetting]
        public Credentials ConnectInfo
        {
            get { return (Credentials)this[CONNECT_INFO]; }
            set { this[CONNECT_INFO] = value; } 
        }
        /// <summary>
        /// Define the StartUpModule.
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("Goals")]
        public string StartUpModule
        {
            get { return this[STARTUP_MODULE].ToString(); }
            set { this[STARTUP_MODULE] = value; }
        }
        /// <summary>
        /// Define the Left edge location for the MainForm window.
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("100")]
        public double Left 
        {
            get { return (double)this[LEFT]; }
            set { this[LEFT] = value; } 
        }
        /// <summary>
        /// Define the top edge location for the MainForm window.
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("100")]
        public double Top 
        {
            get { return (double)this[TOP]; }
            set { this[TOP] = value; } 
        }
        /// <summary>
        /// Define the width for the MainForm window.
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("800")]
        public double Width
        {
            get { return (double)this[WIDTH]; }
            set { this[WIDTH] = value; }
        }
        /// <summary>
        /// Define the height for the MainForm window.
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("600")]
        public double Height
        {
            get { return (double)this[HEIGHT]; }
            set { this[HEIGHT] = value; }
        }
        /// <summary>
        /// Define the WindowState for the MainForm window.
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("Normal")]
        public WindowState WindowState
        {
            get { return (WindowState)this[WINDOW_STATE]; }
            set { this[WINDOW_STATE] = value; }
        }        
        /// <summary>
        /// Determine if settings need to be upgraded (default value of True
        /// indicates that a new settings file has been created, so attempt
        /// to retrieve settings from a previous version).
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("True")]
        public bool UpgradeSettings
        {
            get { return (bool)this[UPGRADE_SETTINGS]; }
            set { this[UPGRADE_SETTINGS] = value; }
        }
        /// <summary>
        /// Define the Logging Level for GoalBook.
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("None")]
        public Priority LoggingLevel
        {
            get { return (Priority)this[LOGGING_LEVEL]; }
            set { this[LOGGING_LEVEL] = value; }
        }

        /// <summary>
        /// Determine if the ActionPane is expanded.
        /// </summary>
        [UserScopedSetting]
        [DefaultSettingValue("True")]
        public bool ActionPaneExpanded
        {
            get { return (bool)this[ACTION_PANE_EXPANDED]; }
            set { this[ACTION_PANE_EXPANDED] = value; }
        }
        #endregion

        #region Private and Protected Methods
        #endregion

        #region Public and internal Methods
        #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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Australia Australia
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.

Comments and Discussions