Exemplo n.º 1
0
        /// <inheritdoc/>
        int IOleCommandTarget.QueryStatus(ref Guid guidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            using (OleCommandText oleCommandText = OleCommandText.FromQueryStatus(pCmdText))
            {
                Guid cmdGroup = guidCmdGroup;
                for (uint i = 0; i < cCmds; i++)
                {
                    OLECMDF status = QueryCommandStatus(ref cmdGroup, prgCmds[i].cmdID, oleCommandText);
                    if (status == default(OLECMDF) && _next != null)
                    {
                        int hr = _next.QueryStatus(ref cmdGroup, cCmds, prgCmds, pCmdText);
                        if (ErrorHandler.Failed(hr))
                        {
                            return(hr);
                        }
                    }
                    else
                    {
                        prgCmds[i].cmdf = (uint)status;
                    }
                }

                return(VSConstants.S_OK);
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        /// <remarks>
        /// This command filter supports the <see cref="VsCommands2K.COMMENT_BLOCK"/>
        /// and <see cref="VsCommands2K.UNCOMMENT_BLOCK"/> commands. The commands are
        /// enabled when <see cref="ITextBuffer.CheckEditAccess"/> is <see langword="true"/>.
        /// </remarks>
        protected override OLECMDF QueryCommandStatus(ref Guid group, uint id, OleCommandText oleCommandText)
        {
            if (group == typeof(VsCommands2K).GUID)
            {
                VsCommands2K cmd = (VsCommands2K)id;
                switch (cmd)
                {
                case VsCommands2K.COMMENT_BLOCK:
                case VsCommands2K.UNCOMMENT_BLOCK:
                    if (TextView.TextBuffer.CheckEditAccess())
                        return OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED;
                    else
                        return OLECMDF.OLECMDF_SUPPORTED;
                }
            }

            return base.QueryCommandStatus(ref group, id, oleCommandText);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the current status of a particular command.
 /// </summary>
 /// <remarks>
 /// The base implementation returns 0 for all commands, indicating the command is not supported by this command
 /// filter.
 /// </remarks>
 /// <param name="commandGroup">The command group.</param>
 /// <param name="commandId">The command ID.</param>
 /// <param name="oleCommandText">A wrapper around the <see cref="OLECMDTEXT"/> object passed to
 /// <see cref="IOleCommandTarget.QueryStatus"/>, or <see langword="null"/> if this parameter should be
 /// ignored.</param>
 /// <returns>A combination of values from the <see cref="OLECMDF"/> enumeration indicating the current status of
 /// a particular command, or 0 if the command is not recognized by the current command filter.</returns>
 protected virtual OLECMDF QueryCommandStatus(ref Guid commandGroup, uint commandId, OleCommandText oleCommandText)
 {
     return(default(OLECMDF));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the current status of a particular command.
 /// </summary>
 /// <remarks>
 /// The base implementation returns 0 for all commands, indicating the command is not supported by this command
 /// filter.
 /// </remarks>
 /// <param name="commandGroup">The command group.</param>
 /// <param name="commandId">The command ID.</param>
 /// <param name="oleCommandText">A wrapper around the <see cref="OLECMDTEXT"/> object passed to
 /// <see cref="IOleCommandTarget.QueryStatus"/>, or <see langword="null"/> if this parameter should be
 /// ignored.</param>
 /// <returns>A combination of values from the <see cref="OLECMDF"/> enumeration indicating the current status of
 /// a particular command, or 0 if the command is not recognized by the current command filter.</returns>
 protected virtual OLECMDF QueryCommandStatus(ref Guid commandGroup, uint commandId, OleCommandText oleCommandText)
 {
     return default(OLECMDF);
 }