Пример #1
0
 protected virtual bool SupportsOwnedCommand([NotNull] QueryStatusArgs queryStatusArgs)
 {
     return(false);
 }
Пример #2
0
        public virtual int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, [CanBeNull] OLECMD[] prgCmds, IntPtr pCmdText)
        {
            // Validate parameters
            if (prgCmds == null || cCmds != 1)
            {
                return(VSConstants.E_INVALIDARG);
            }

            // Wrap parameters into argument type instance
            var statusArgs = new QueryStatusArgs(pguidCmdGroup);

            statusArgs.CommandCount = cCmds;
            statusArgs.Commands     = prgCmds;
            statusArgs.PCmdText     = pCmdText;

            // By default all commands are supported
            var cmdf = OLECMDF.OLECMDF_SUPPORTED;

            if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
            {
                // Process standard Commands
                switch (prgCmds[0].cmdID)
                {
                case (uint)VSConstants.VSStd97CmdID.SelectAll:

                    // ICommonCommandSupport if (_UIControl.SupportsSelectAll) cmdf |= OLECMDF.OLECMDF_ENABLED;
                    break;

                case (uint)VSConstants.VSStd97CmdID.Copy:

                    // ICommonCommandSupport if (_UIControl.SupportsCopy) cmdf |= OLECMDF.OLECMDF_ENABLED;
                    break;

                case (uint)VSConstants.VSStd97CmdID.Cut:

                    // ICommonCommandSupport if (_UIControl.SupportsCut) cmdf |= OLECMDF.OLECMDF_ENABLED;
                    break;

                case (uint)VSConstants.VSStd97CmdID.Paste:

                    // ICommonCommandSupport if (_UIControl.SupportsPaste) cmdf |= OLECMDF.OLECMDF_ENABLED;
                    break;

                case (uint)VSConstants.VSStd97CmdID.Redo:

                    // ICommonCommandSupport if (_UIControl.SupportsRedo) cmdf |= OLECMDF.OLECMDF_ENABLED;
                    break;

                case (uint)VSConstants.VSStd97CmdID.Undo:

                    // ICommonCommandSupport if (_UIControl.SupportsUndo) cmdf |= OLECMDF.OLECMDF_ENABLED;
                    break;

                default:
                    if (!SupportsVSStd97Command(prgCmds[0].cmdID, ref cmdf))
                    {
                        return((int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED);
                    }

                    break;
                }

                // Pass back the commmand support flag
                prgCmds[0].cmdf = (uint)cmdf;
                return(VSConstants.S_OK);
            }

            // Check for commands owned by the editor
            if (pguidCmdGroup == commandSetGuid)
            {
                return(SupportsOwnedCommand(statusArgs) ? VSConstants.S_OK : (int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED);
            }

            // Check for any other commands
            return(SupportsCommand(statusArgs) ? VSConstants.S_OK : (int)Microsoft.VisualStudio.OLE.Interop.Constants.OLECMDERR_E_NOTSUPPORTED);
        }