Exemple #1
0
        private void ActivateEntries(int position)
        {
            if (_entries == null)
            {
                return;
            }

            int currentModuleIndex;

            _dropDownBar.GetCurrentSelection(ModuleComboBoxId, out currentModuleIndex);

            ModuleEntry newModule = _entries.LocateModule(position);

            Debug.Assert(newModule != null);

            MethodEntry newMethod      = newModule.LocateMethod(position);
            int         newMethodIndex = newMethod != null ? newMethod.Index : -1;

            if (newModule.Index != currentModuleIndex)
            {
                _dropDownBar.SetCurrentSelection(ModuleComboBoxId, newModule.Index);
                _dropDownBar.RefreshCombo(MethodComboBoxId, newMethodIndex);
            }
            else
            {
                int currentMethodIndex;
                _dropDownBar.GetCurrentSelection(MethodComboBoxId, out currentMethodIndex);
                if (newMethodIndex != currentMethodIndex)
                {
                    _dropDownBar.SetCurrentSelection(MethodComboBoxId, newMethodIndex);
                }
            }
        }
        private void FindActiveTopLevelComboSelection(int newPosition, ReadOnlyCollection <DropDownEntryInfo> topLevel)
        {
            if (_dropDownBar == null)
            {
                return;
            }

            int oldTopLevel = _curTopLevelIndex;

            // left side has changed
            bool found = false;

            for (int i = 0; i < topLevel.Count; i++)
            {
                if (newPosition >= topLevel[i].Start.Index && newPosition <= topLevel[i].End.Index)
                {
                    _curTopLevelIndex = i;

                    // we found a new left hand side
                    if (oldTopLevel == -1)
                    {
                        // we've selected something new, we need to refresh the combo to
                        // to remove the grayed out entry
                        _dropDownBar.RefreshCombo(TopLevelComboBoxId, i);
                    }
                    else
                    {
                        // changing from one top-level to another, just update the selection
                        _dropDownBar.SetCurrentSelection(TopLevelComboBoxId, i);
                    }

                    // update the nested entries
                    CalculateNestedEntries();
                    _dropDownBar.RefreshCombo(NestedComboBoxId, 0);
                    UpdateNestedComboSelection(newPosition);
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                // there's no associated entry, we should disable the bar
                _curTopLevelIndex = -1;
                _curNestedIndex   = -1;

                if (oldTopLevel != -1)
                {
                    // we need to refresh to clear both combo boxes since there is no associated entry
                    _dropDownBar.RefreshCombo(TopLevelComboBoxId, -1);
                    _dropDownBar.RefreshCombo(NestedComboBoxId, -1);
                }
            }

            UpdateNestedComboSelection(newPosition);
        }
Exemple #3
0
        private void CaretPositionChanged(object sender, CaretPositionChangedEventArgs e)
        {
            int newPosition = e.NewPosition.BufferPosition.Position;

            List <KeyValuePair <int, int> > changes = new List <KeyValuePair <int, int> >();

            lock (_navigationsLock) {
                var cur = _navigations;
                for (int level = 0; level < _curSelection.Length; level++)
                {
                    if (cur == null)
                    {
                        // no valid children, we'll invalidate these...
                        changes.Add(new KeyValuePair <int, int>(_curSelection[level], -1));
                        continue;
                    }

                    bool found = false;
                    if (cur.Children != null)
                    {
                        for (int i = 0; i < cur.Children.Length; i++)
                        {
                            if (newPosition >= cur.Children[i].Span.Start && newPosition <= cur.Children[i].Span.End)
                            {
                                changes.Add(new KeyValuePair <int, int>(_curSelection[level], i));
                                _curSelection[level] = i;
                                cur   = cur.Children[i];
                                found = true;
                                break;
                            }
                        }
                    }

                    if (!found)
                    {
                        // continue processing to update the subselections...
                        cur = null;
                        changes.Add(new KeyValuePair <int, int>(_curSelection[level], -1));
                        _curSelection[level] = -1;
                    }
                }
            }

            for (int i = 0; i < changes.Count; i++)
            {
                var change   = changes[i];
                var oldValue = change.Key;
                var newValue = change.Value;

                if (_dropDownBar != null && oldValue != newValue)
                {
                    if (oldValue == -1 || newValue == -1)
                    {
                        // we've selected something new, we need to refresh the combo to
                        // to remove the grayed out entry
                        _dropDownBar.RefreshCombo(i, newValue);
                    }
                    else
                    {
                        // changing from one top-level to another, just update the selection
                        _dropDownBar.SetCurrentSelection(i, newValue);
                    }
                }
            }
        }