Click here to Skip to main content
15,892,059 members
Articles / Programming Languages / C#

Command Switchboard for Windows Forms

Rate me:
Please Sign up or sign in to vote.
4.83/5 (16 votes)
12 Jul 2007CPOL8 min read 73.2K   1.4K   93  
Switchboard component for user interface commands with design time support
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.Design;

namespace SundbySoft.Controls.Design
{
    /// <summary>
    /// Provides a user interface that can edit a <see cref="ApplicationCommandCollection"/> at design time.
    /// </summary>
    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
    class ApplicationCommandCollectionEditor : CollectionEditor
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionEditor"/> class using the specified collection type.
        /// </summary>
        /// <param name="type">The type of the collection for this editor to edit.</param>
        public ApplicationCommandCollectionEditor(Type type)
            : base(type)
        {
        }

        /// <summary>
        /// Creates a new instance of the specified collection item type.
        /// </summary>
        /// <param name="itemType">The type of item to create.</param>
        /// <returns>A new instance of the specified object.</returns>
        protected override object CreateInstance(Type itemType)
        {
            ApplicationCommand applicationCommand = base.CreateInstance(itemType) as ApplicationCommand;

            UISwitchboard UISwitchboard = Context.Instance as UISwitchboard;
            applicationCommand.UISwitchboard = UISwitchboard;

            return applicationCommand;
        }
    }
}

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
Founder Sundby Software
Norway Norway
Bjørn has developed software since 1984 mainly in C, C++ and C#.

Bjørn lives in Ormåsen, Buskerud in Norway. To contact Bjørn, email him at bjsundby@online.no. He also has a web site at http://www.sundbysoft.com.

Comments and Discussions