示例#1
0
        /// <summary>
        /// Handles the Click event of the RowCopy control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void RowCopy_Click(object sender, EventArgs e)
        {
            VirtualTreeGridItem item = GetRowValue(_contextMenuRowIndex);
            ArrayList           list = new ArrayList();

            list.Add(item.DataItem);

            CopyCommand cc = new CopyCommand(((ModelElement)_root).Store, list);

            if (cc.Enabled && cc.Visible())
            {
                cc.Exec();
            }
        }
示例#2
0
        ///// <summary>
        ///// Add the support for the standard Copy Command
        ///// </summary>
        ///// <param name="commands">CommandList, we want to add the Copy command to</param>
        ///// <typeparam name="T">A ModelElement derived type which is used to restrict the kind of model element
        ///// that can be copied to the clipboard</typeparam>
        //public void AddCopyCommand(IList<MenuCommand> commands)
        //{
        //    commands.Add(new DynamicStatusMenuCommand(new EventHandler(OnStatusCopy),
        //                                              new EventHandler(OnMenuCopy),
        //                                              StandardCommands.Copy));
        //}

        /// <summary>
        /// Status for the Copy command
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OnStatusCopy(object sender, EventArgs e)
        {
            MenuCommand command = sender as MenuCommand;
            Diagram     diagram = null;

            if (CurrentDocView != null)
            {
                diagram = this.CurrentDocView.CurrentDiagram;
            }
            ICollection selection = this.CurrentSelection;

            CopyCommand copy = new CopyCommand(diagram.Store, selection);

            command.Enabled = copy.Enabled;
            command.Visible = copy.Visible();
        }