Example #1
0
        /// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary>
        /// <param term='commandName'>The name of the command to execute.</param>
        /// <param term='executeOption'>Describes how the command should be run.</param>
        /// <param term='varIn'>Parameters passed from the caller to the command handler.</param>
        /// <param term='varOut'>Parameters passed from the command handler to the caller.</param>
        /// <param term='handled'>Informs the caller if the command was handled or not.</param>
        /// <seealso class='Exec' />
        public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
        {
            //System.Windows.Forms.MessageBox.Show("exec");

            handled = false;
            if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault && AcceptedCommand(commandName))
            {
                bool bForward = true;
                if(commandName == "FileSwitch2008.Connect.PrevFile")
                {
                    bForward = false;
                }

                Project fileproject = _addInInstance.DTE.ActiveDocument.ProjectItem.ContainingProject;
                string fullname =_addInInstance.DTE.ActiveDocument.FullName;

                FileGroup group = new FileGroup(fileproject, fullname.ToLower());

                string newfile = bForward ? group.Next() : group.Prev();

                _applicationObject.ItemOperations.OpenFile(newfile, Constants.vsViewKindCode);

                handled = true;
                return;
            }
        }