/// <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)
        {
            NuGenApplicationCommand applicationCommand = base.CreateInstance(itemType) as NuGenApplicationCommand;
            NuGenCommandManagerBase commandManager     = Context.Instance as NuGenCommandManagerBase;

            applicationCommand.CommandManager = commandManager;

            return(applicationCommand);
        }
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the GetEditStyle method.
        /// </summary>
        /// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
        /// <param name="provider">An IServiceProvider that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>The new value of the object. If the value of the object has not changed, this should return the same object it was passed.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            // Get associated items list
            NuGenUIItemCollection uiItemCollection = value as NuGenUIItemCollection;
            Collection <object>   associatedItems  = new Collection <object>();

            foreach (object item in uiItemCollection)
            {
                associatedItems.Add(item);
            }

            // Get command switchboard
            NuGenApplicationCommand command       = uiItemCollection.ApplicationCommand;
            NuGenCommandManagerBase UISwitchboard = command.CommandManager;

            // Get available items list
            Collection <object> availableItems = new Collection <object>();

            foreach (object item in UISwitchboard.UIItemAdapter.GetAvailableUIItems())
            {
                availableItems.Add(item);
            }

            // Get editor service
            IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (editorService != null)
            {
                // Show form
                NuGenUIItemsForm formUIItems = new NuGenUIItemsForm(command, associatedItems, availableItems);
                if (editorService.ShowDialog(formUIItems) == DialogResult.OK)
                {
                    NuGenUIItemCollection modifiedUIItemCollection = new NuGenUIItemCollection(command);
                    foreach (Object item in associatedItems)
                    {
                        modifiedUIItemCollection.Add(item);
                    }
                    return(modifiedUIItemCollection);
                }
            }
            return(value);
        }
Example #3
0
        private void _commandManager_ApplicationCommandUpdate(object sender, NuGenApplicationCommandEventArgs e)
        {
            Control owner = sender as Control;
            NuGenApplicationCommand command = e.ApplicationCommand;
            ToolStripItem           item    = e.Item as ToolStripItem;

            switch (command.ApplicationCommandName)
            {
            case "New":
            {
                e.ApplicationCommand.Enabled = _enableNewCheckBox.Checked;
                break;
            }

            case "FileCopy":
            {
                e.ApplicationCommand.Enabled = _enableGlobalCopyCheckBox.Checked;
                break;
            }

            case "ContextCopy":
            {
                e.ApplicationCommand.Enabled = _enableLocalCopyCheckBox.Checked;
                break;
            }

            case "Save":
            {
                e.ApplicationCommand.Visible = _showSaveCheckBox.Checked;
                break;
            }

            case "TrackBar":
            {
                _progressBar.Value = _trackBar.Value;
                break;
            }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenUIItemsForm"/> class.
        /// </summary>
        /// <param name="applicationCommand">The command to edit.</param>
        /// <param name="associatedItems">Items associated with the command.</param>
        /// <param name="availableItems">Itemas available for association with the command.</param>
        public NuGenUIItemsForm(NuGenApplicationCommand applicationCommand, Collection<object> associatedItems, Collection<object> availableItems)
        {
            UISwitchboard = applicationCommand.CommandManager;

            this.associatedItems = associatedItems;
            this.availableItems = availableItems;

            InitializeComponent();

            // Set command information
            labelCommandName.Text = applicationCommand.ApplicationCommandName;

            // Fill listview with associated items
            foreach (object item in associatedItems)
            {
                string name = UISwitchboard.UIItemAdapter.GetUIItemName(item);
                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Text = name;
                listViewItem.Tag = item;
                listViewAssociatedItems.Items.Add(listViewItem);
            }

            // Fill listview with available items
            foreach (object item in availableItems)
            {
                if (!associatedItems.Contains(item))
                {
                    string name = UISwitchboard.UIItemAdapter.GetUIItemName(item);
                    ListViewItem listViewItem = new ListViewItem();
                    listViewItem.Text = name;
                    listViewItem.Tag = item;
                    listViewAvailableItems.Items.Add(listViewItem);
                }
            }

            columnHeaderAvailableItems.Width = listViewAvailableItems.ClientSize.Width;
            columnHeaderAssociatedItems.Width = listViewAssociatedItems.ClientSize.Width;
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenUIItemsForm"/> class.
        /// </summary>
        /// <param name="applicationCommand">The command to edit.</param>
        /// <param name="associatedItems">Items associated with the command.</param>
        /// <param name="availableItems">Itemas available for association with the command.</param>
        public NuGenUIItemsForm(NuGenApplicationCommand applicationCommand, Collection <object> associatedItems, Collection <object> availableItems)
        {
            UISwitchboard = applicationCommand.CommandManager;

            this.associatedItems = associatedItems;
            this.availableItems  = availableItems;

            InitializeComponent();

            // Set command information
            labelCommandName.Text = applicationCommand.ApplicationCommandName;

            // Fill listview with associated items
            foreach (object item in associatedItems)
            {
                string       name         = UISwitchboard.UIItemAdapter.GetUIItemName(item);
                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Text = name;
                listViewItem.Tag  = item;
                listViewAssociatedItems.Items.Add(listViewItem);
            }

            // Fill listview with available items
            foreach (object item in availableItems)
            {
                if (!associatedItems.Contains(item))
                {
                    string       name         = UISwitchboard.UIItemAdapter.GetUIItemName(item);
                    ListViewItem listViewItem = new ListViewItem();
                    listViewItem.Text = name;
                    listViewItem.Tag  = item;
                    listViewAvailableItems.Items.Add(listViewItem);
                }
            }

            columnHeaderAvailableItems.Width  = listViewAvailableItems.ClientSize.Width;
            columnHeaderAssociatedItems.Width = listViewAssociatedItems.ClientSize.Width;
        }