Beispiel #1
0
        public bool SendCommand(CommandInfo ci)
        {
            Control focusedControl = Sce.Atf.WinFormsUtil.GetFocusedControl();

            while (focusedControl != null && !(focusedControl is ICommandClient))
            {
                focusedControl = focusedControl.Parent;
            }

            ICommandClient focusedCmdClient = focusedControl as ICommandClient;

            if (focusedCmdClient != null)
            {
                if (focusedCmdClient.CanDoCommand(ci.CommandTag))
                {
                    focusedCmdClient.DoCommand(ci.CommandTag);
                    return(true);
                }
            }

            focusedCmdClient = DocumentManager.GetInst().ActiveDocument as ICommandClient;
            if (focusedCmdClient != null)
            {
                if (focusedCmdClient.CanDoCommand(ci.CommandTag))
                {
                    focusedCmdClient.DoCommand(ci.CommandTag);
                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
        private void item_Click(object sender, EventArgs e)
        {
            // See if the user clicked the icon portion of the menu item and set the IconClicked property that
            // interested commands can check.
            IconClicked = IsMouseOverIcon(sender as ToolStripItem);

            // clear status text
            if (m_statusService != null)
            {
                m_statusService.ShowStatus(string.Empty);
            }

            ToolStripItem item = sender as ToolStripItem;
            object        tag  = item.Tag;

            if (tag != null)
            {
                ICommandClient client = GetClient(tag);
                if (client == null)
                {
                    client = m_activeClient;
                }
                if (client != null && client.CanDoCommand(tag))
                {
                    client.DoCommand(tag);
                }
            }

            IconClicked = false;
        }
        private void OscServiceMessageReceived(object sender, OscMessageReceivedArgs e)
        {
            CommandInfo cmdInfo;

            if (m_addressesToCommands.TryGetValue(e.Address, out cmdInfo))
            {
                ICommandClient cmdClient = m_commandService.GetClient(cmdInfo.CommandTag);
                if (cmdClient != null)
                {
                    if (cmdClient.CanDoCommand(cmdInfo.CommandTag))
                    {
                        cmdClient.DoCommand(cmdInfo.CommandTag);
                    }
                }
                e.Handled = true;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Processes the key as a command shortcut</summary>
        /// <param name="key">Key to process</param>
        /// <returns>True iff the key was processed as a command shortcut</returns>
        public virtual bool ProcessKey(Keys key)
        {
            KeyEventArgs keyEventArgs = new KeyEventArgs(key);

            ProcessingKey.Raise(this, keyEventArgs);
            if (keyEventArgs.Handled)
            {
                return(true);
            }

            Keys shortcut = KeysUtil.NumPadToNum(key);

            //if there is no key, return
            if (shortcut == Keys.None)
            {
                return(false);
            }

            //if the key is not a registered shortcut, return
            object tag;

            if (!m_shortcuts.TryGetValue(shortcut, out tag))
            {
                return(false);
            }

            //Is there a client, and if so, can the client do the command?
            ICommandClient client = GetClient(tag);

            if (client == null)
            {
                client = m_activeClient;
            }
            if (client == null || !client.CanDoCommand(tag))
            {
                return(false);
            }

            // do the command
            client.DoCommand(tag);
            return(true);
        }