Example #1
0
        public void OnComboGetList(EventArgs args)
        {
            MsVsShell.OleMenuCmdEventArgs eventArgs = args as MsVsShell.OleMenuCmdEventArgs;

            if (eventArgs == null)
            {
                return;
            }

            IntPtr vOut = eventArgs.OutValue;

            if (vOut == IntPtr.Zero)
            {
                return;
            }

            SetupChannelNames();

            int size = m_ChannelNames.Count();

            string[] names = new string[size];
            for (int i = 0; i < size; ++i)
            {
                names[i] = m_ChannelNames[i];
            }

            Marshal.GetNativeVariantForObject(names, vOut);
        }
        // DynamicCombo
        //   A DYNAMICCOMBO allows the user to type into the edit box or pick from the list. The
        //     list of choices is usually fixed and is managed by the command handler for the command.
        //     For example, this type of combo is used for the "Zoom" combo on the "Class Designer" toolbar.
        //
        //   A Combo box requires two commands:
        //     One command is used to ask for the current value of the combo box and to set the new value when the user
        //     makes a choice in the combo box.
        //
        //     The second command is used to retrieve this list of choices for the combo box.
        protected override void Execute(object sender, OleMenuCmdEventArgs e)
        {
            var input = e.InValue;
            var vOut = e.OutValue;

            if (vOut != IntPtr.Zero)
            {
                // when vOut is non-NULL, the IDE is requesting the current value for the combo
                Marshal.GetNativeVariantForObject(_branchManager.CurrentBranch.Name, vOut);
            }
            else if (input != null)
            {
                // new branch name was selected or typed in
                var newBranch = input.ToString();
                if (newBranch != _branchManager.CurrentBranch.Name)
                {
                    if (!_branchManager.Branches.Any(b => b.Name == newBranch))
                        _commandService.ExecuteLater<CommandNewBranch>(newBranch);
                    else
                    {
                        _branchManager.Checkout(newBranch);
                        _commandService.ExecuteLater<CommandReloadSolution>();
                    }
                }
            }
        }
Example #3
0
 protected override void Execute(object sender, OleMenuCmdEventArgs e)
 {
     _viewService.ShowDialog(
         new NewBranchViewModel(_branchManager.CurrentBranch.Name)
         {
             NewBranchName = e.InValue as string
         },
         onSuccess: vm => _branchManager.Create(vm.NewBranchName, vm.CheckoutAfterCreating)
     );
 }
        protected override void Execute(object sender, OleMenuCmdEventArgs e)
        {
            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            var window = HostPackage.FindToolWindow(typeof(PendingChangesWindow), 0, true) as PendingChangesWindow;
            if (window == null || window.Frame == null)
                throw new NotSupportedException(Resources.CanNotCreateWindow);

            var windowFrame = (IVsWindowFrame)window.Frame;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Example #5
0
        //
        // A DropDownCombo combobox requires two commands:
        //   One command (cmdidCombo) is used to ask for the current value for the
        //    display area of the combo box and to set the new value when the user
        //    makes a choice in the combo box.
        //
        //   The second command (cmdidComboGetList) is used to retrieve the list of
        //    choices for the combo box drop down area.
        //
        // Normally IOleCommandTarget::QueryStatus is used to determine the state of
        // a command, e.g. enable vs. disable, shown vs. hidden, etc. The QueryStatus
        // method does not have enough flexibility for combos which need to be able
        // to indicate a currently selected (displayed) item as well as provide a list
        // of items for their dropdown area. In order to communicate this information
        // actually IOleCommandTarget::Exec is used with a non-NULL varOut parameter.
        // You can think of these Exec calls as extended QueryStatus calls. There are
        // two pieces of information needed for a combo, thus it takes two commands
        // to retrieve this information. The main command id for the command is used
        // to retrieve the current value and the second command is used to retrieve
        // the full list of choices to be displayed as an array of strings.
        //

        public void OnCombo(EventArgs args)
        {
            MsVsShell.OleMenuCmdEventArgs eventArgs = args as MsVsShell.OleMenuCmdEventArgs;

            if (eventArgs == null)
            {
                return;
            }

            object input = eventArgs.InValue;
            IntPtr vOut  = eventArgs.OutValue;

            if (vOut != IntPtr.Zero)
            {
                // when vOut is non-NULL, the IDE is requesting the current value
                // for the combo
                SetupChannelNames();
                Marshal.GetNativeVariantForObject(m_ChannelNames[m_ChannelIdx], vOut);
            }

            else if (input != null)
            {
                int newChoice = -1;
                if (!int.TryParse(input.ToString(), out newChoice))
                {
                    // user typed a string argument in command window.
                    int i = 0;
                    foreach (string name in m_ChannelNames)
                    {
                        if (string.Compare(name, input.ToString(), StringComparison.CurrentCultureIgnoreCase) == 0)
                        {
                            newChoice = i;
                            break;
                        }
                        i += 1;
                    }
                }

                // new value was selected or typed in
                if (newChoice != -1 && newChoice != m_ChannelIdx)
                {
                    m_ChannelIdx = newChoice;
                    SwitchPipe(m_ChannelIdx == 0, m_ChannelNames[m_ChannelIdx], m_ChannelGuids[m_ChannelIdx]);
                }
            }
        }
 public virtual void Invoke(object inArg, IntPtr outArg)
 {
     try
     {
         OleMenuCmdEventArgs args = new OleMenuCmdEventArgs(inArg, outArg);
         execHandler(this, args);
     }
     catch (CheckoutException ex)
     {
         if (CheckoutException.Canceled != ex)
             throw;
     }
 }
 public override void Invoke(object inArg)
 {
     try
     {
         OleMenuCmdEventArgs args = new OleMenuCmdEventArgs(inArg, NativeMethods.InvalidIntPtr);
         execHandler(this, args);
     }
     catch (CheckoutException ex)
     {
         if (CheckoutException.Canceled != ex)
             throw;
     }
 }
 protected override void Execute(object sender, OleMenuCmdEventArgs e)
 {
     Marshal.GetNativeVariantForObject(_branchManager.Branches.Select(b => b.Name).ToArray(), e.OutValue);
 }
Example #9
0
 protected abstract void Execute(object sender, OleMenuCmdEventArgs e);
 protected override void Execute(object sender, OleMenuCmdEventArgs e)
 {
     _solutionService.RefreshSourceControlIcons();
 }
        public void Search(OleMenuCmdEventArgs eventArgs)
        {
            var input = eventArgs.InValue;

            var vOut = eventArgs.OutValue;

            if (vOut != IntPtr.Zero)
            {
                Marshal.GetNativeVariantForObject(CurrentSearchString, vOut);
            }

            else if (input != null)
            {
                CurrentSearchString = input.ToString().Trim().ToLower();

                if (!string.IsNullOrWhiteSpace(CurrentSearchString))
                {
                    if (!SearchValues.Contains(CurrentSearchString))
                    {
                        SearchValues.Add(CurrentSearchString);
                    }

                    PagedSchemesView.Filter += delegate(object obj)
                    {
                        var scheme = obj as Scheme;

                        if (scheme == null)
                        {
                            return false;
                        }

                        var matchingTitle = false;
                        var matchingAuthor = false;

                        if (!string.IsNullOrWhiteSpace(scheme.Title))
                        {
                            matchingTitle = scheme.Title.ToLower().Contains(CurrentSearchString);
                        }

                        if (!string.IsNullOrWhiteSpace(scheme.Author))
                        {
                            matchingAuthor = scheme.Author.ToLower().Contains(CurrentSearchString);
                        }

                        return matchingTitle || matchingAuthor;
                    };
                }
                else
                {
                    PagedSchemesView.Filter = null;
                }
            }

            UpdateInfoBar();
        }
        public void SearchTerm(OleMenuCmdEventArgs eventArgs)
        {
            var vOut = eventArgs.OutValue;

            if (vOut != IntPtr.Zero)
            {
                Marshal.GetNativeVariantForObject(SearchValues.ToArray(), vOut);
            }
        }