Click here to Skip to main content
15,891,136 members
Articles / Desktop Programming / Windows Forms

Task Manager

Rate me:
Please Sign up or sign in to vote.
4.90/5 (105 votes)
1 Jan 2010CPOL4 min read 204.4K   21K   229  
Manage your daily tasks and To-Do list using some exciting features of Windows 7.
//Copyright (c) Microsoft Corporation.  All rights reserved.

using System;

namespace Microsoft.WindowsAPICodePack.Dialogs
{
    // ContentProperty allows us to specify the text 
    // of the button as the child text of
    // a button element in XAML, as well as explicitly 
    // set with 'Text="<text>"'
    // Note that this attribute is inherited, so it 
    // applies to command-links and radio buttons as well.
    /// <summary>
    /// Defines the abstract base class for task dialog buttons. 
    /// Classes that inherit from this class will inherit 
    /// the Text property defined in this class.
    /// </summary>
    public abstract class TaskDialogButtonBase : TaskDialogControl
    {
        
        /// <summary>
        /// Creates a new instance on a task dialog button.
        /// </summary>
        protected TaskDialogButtonBase() { }
        /// <summary>
        /// Creates a new instance on a task dialog button with
        /// the specified name and text.
        /// </summary>
        /// <param name="name">The name for this button.</param>
        /// <param name="text">The label for this button.</param>
        protected TaskDialogButtonBase(string name, string text) : base(name)
        {
            this.text = text;
        }

        // Note that we don't need to explicitly 
        // implement the add/remove delegate for the Click event;
        // the hosting dialog only needs the delegate 
        // information when the Click event is 
        // raised (indirectly) by NativeTaskDialog, 
        // so the latest delegate is always available.
        /// <summary>
        /// Raised when the task dialog button is clicked.
        /// </summary>
        public event EventHandler Click;
        internal void RaiseClickEvent()
        {
            // Only perform click if the button is enabled.
            if (!enabled)
                return;

            EventHandler handler = Click;
            if (handler != null)
                handler(this, EventArgs.Empty);
        }

        private string text;
        /// <summary>
        /// Gets or sets the button text.
        /// </summary>
        public string Text
        {
            get { return text; }
            set 
            {
                CheckPropertyChangeAllowed("Text");
                text = value;
                ApplyPropertyChange("Text");
            }
        }

        private bool enabled = true;
        /// <summary>
        /// Gets or sets a value that determines whether the
        /// button is enabled. The enabled state can cannot be changed
        /// before the dialog is shown.
        /// </summary>
        public bool Enabled
        {
            get { return enabled; }
            set 
            {
                CheckPropertyChangeAllowed("Enabled");
                enabled = value;
                ApplyPropertyChange("Enabled");
            }
        }

        private bool defaultControl;
        /// <summary>
        /// Gets or sets a value that indicates whether
        /// this button is the default button.
        /// </summary>
        public bool Default
        {
            get { return defaultControl; }
            set
            {
                CheckPropertyChangeAllowed("Default");
                defaultControl = value;
                ApplyPropertyChange("Default");
            }
        }
        /// <summary>
        /// Returns the Text property value for this button.
        /// </summary>
        /// <returns>A <see cref="System.String"/>.</returns>
        public override string ToString()
        {
            if (text == null)
                return "";
            return text;
        }
    }
}

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
Chief Technology Officer
Pakistan Pakistan
Passion and positive dedication is essential part of success. I believe on hardworking and sharing knowledge with others. I always try to be a better than I am and think positive for positive result.

My Blogs

My Linked-In Profile

Comments and Discussions