예제 #1
0
        private void ShowContextMenu(int x, int y)
        {
            // show...
            CommandUIObjectBuilder builder = new CommandUIObjectBuilder();

            builder.CreateAndShowContextMenu(this, new Point(x, y), this);
        }
예제 #2
0
        /// <summary>
        /// Handled the keystroke.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="e"></param>
        public static void HandleKeyDown(ListView view, KeyEventArgs e)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            // key...
            if (e.KeyCode == Keys.A && (e.Modifiers & Keys.Control) != 0)
            {
                SelectAll(view, true);
                e.Handled = true;
            }
            else if (e.KeyCode == Keys.Apps)
            {
                if (view is ICommandProvider)
                {
                    // show...
                    CommandUIObjectBuilder builder = new CommandUIObjectBuilder();
                    builder.CreateAndShowContextMenu(view, view.PointToClient(Control.MousePosition), view);

                    // return...
                    e.Handled = true;
                }
            }
        }
예제 #3
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            // context menu?
            if ((int)(e.Button & MouseButtons.Right) != 0)
            {
                // show...
                CommandUIObjectBuilder builder = new CommandUIObjectBuilder();
                builder.CreateAndShowContextMenu(this, new Point(e.X, e.Y), this);
            }
        }
예제 #4
0
        private void labelEntity_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // check...
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // do we have an entity?
            if (this.Entity is ICommandProvider)
            {
                return;
            }

            // show...
            CommandUIObjectBuilder builder = new CommandUIObjectBuilder();

            builder.CreateAndShowContextMenu(this.labelEntity, new Point(e.X, e.Y), (ICommandProvider)this.Entity);
        }
예제 #5
0
        /// <summary>
        /// Raises the <c>EntityRightClick</c> event.
        /// </summary>
        protected virtual void OnEntityRightClick(EntityEventArgs e)
        {
            // nope?
            if (e.Entity is ICommandProvider)
            {
                // track and show...
                CommandUIObjectBuilder builder = new CommandUIObjectBuilder();
                if (e.Entity == null)
                {
                    throw new InvalidOperationException("e.Entity is null.");
                }
                builder.CreateAndShowContextMenu(this, this.PointToClient(new Point(MousePosition.X, MousePosition.Y)), (ICommandProvider)e.Entity);
            }

            // raise...
            if (EntityRightClick != null)
            {
                EntityRightClick(this, e);
            }
        }