Exemple #1
0
        public override int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            int hr;

            if (!Exclude(pguidCmdGroup, nCmdID))
            {
                try
                {
                    var    inArg = pvaIn.GetObjectForVariant();
                    object outArg;

                    if (CommandSets.ContainsKey(pguidCmdGroup))
                    {
                        var commandSet = CommandSets[pguidCmdGroup];
                        var setName    = commandSet.Name;

                        if (commandSet.CmdIds.ContainsKey(nCmdID))
                        {
                            var cmdName = commandSet.CmdIds[nCmdID];

                            WriteLine("CommandGroup: {0}\t CommandID: '{1}'\t CommandName: '{2}'\t Options: '{3}'\t Argument: {4}", setName, nCmdID, cmdName, nCmdexecopt, inArg.AsDisplayText());
                            hr = base.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

                            outArg = pvaOut.GetObjectForVariant();
                            WriteLine("CommandGroup: {0}\t CommandID: '{1}'\t CommandName: '{2}'\t Options: '{3}'\t Out Argument: {4}\t hResult: 0x{5:x}", setName, nCmdID, cmdName, nCmdexecopt, outArg.AsDisplayText(), hr);
                        }
                        else
                        {
                            WriteLine("CommandGroup: {0}\t CommandID 0x{1:x}\t Options: {2}\t Argument: {3}", setName, nCmdID, nCmdexecopt, inArg.AsDisplayText());
                            hr = base.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

                            outArg = pvaOut.GetObjectForVariant();
                            WriteLine("CommandGroup: {0}\t CommandID 0x{1:x}\t Options: {2}\t Out Argument: {3}\t hResult: 0x{4:x}", setName, nCmdID, nCmdexecopt, outArg.AsDisplayText(), hr);
                        }
                    }
                    else
                    {
                        WriteLine("CommandGroup: {0}\t CommandID: 0x{1:x}\t Options: {2}\t Argument: {3}", pguidCmdGroup.ToString(), nCmdID, nCmdexecopt, inArg.AsDisplayText());
                        hr = base.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

                        outArg = pvaOut.GetObjectForVariant();
                        WriteLine("CommandGroup: {0}\t CommandID: 0x{1:x}\t Options: {2}\t Out Argument: {3}\t hResult: 0x{4:x}", pguidCmdGroup.ToString(), nCmdID, nCmdexecopt, outArg.AsDisplayText(), hr);
                    }
                }
                catch (Exception ex)
                {
                    WriteLine("Error with OutputGlobalCommandTarget: '{0}'", ex.ToString());
                }
            }

            hr = base.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

            return(hr);
        }