Exemplo n.º 1
0
        public bool Remove(ViewHostTab tab)
        {
            Verify.Argument.IsNotNull(tab, "tab");

            if (_tabHover.Item == tab)
            {
                _tabHover.Reset(-1, null);
            }
            _length -= tab.Length;
            return(_tabs.Remove(tab));
        }
Exemplo n.º 2
0
        public void SetAvailableButtons(params ViewButtonType[] buttons)
        {
            var viewButtonSize = ViewManager.Renderer.ViewButtonSize;

            _buttonHover.Reset(-1, null);
            _buttonPress.Reset(-1, null);
            if (buttons == null || buttons.Length == 0)
            {
                _buttons = null;
            }
            else
            {
                _buttons = new ViewButton[buttons.Length];
                int x = buttons.Length * viewButtonSize + 2;
                for (int i = 0; i < buttons.Length; ++i)
                {
                    _buttons[i] = new ViewButton(x, buttons[i]);
                    x          -= viewButtonSize;
                }
            }
            _host.Invalidate();
        }
Exemplo n.º 3
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         foreach (var host in _dockedHosts)
         {
             host.ViewAdded   -= OnViewAdded;
             host.ViewRemoved -= OnViewRemoved;
         }
         _dockedHosts.Clear();
         foreach (var tab in _tabs)
         {
             tab.View.TextChanged -= OnViewTextChanged;
             tab.Dispose();
         }
         _tabs.Clear();
         _tabPress.Reset(-1, null);
         _tabHover.Reset(-1, null);
         _autoShowTimer.Dispose();
         _autoHideTimer.Dispose();
         _visibleHost = null;
     }
     base.Dispose(disposing);
 }
Exemplo n.º 4
0
        private void OnViewRemoved(object sender, ViewEventArgs e)
        {
            e.View.TextChanged -= OnViewTextChanged;
            var size  = 0;
            int index = -1;

            for (int i = _tabs.Count - 1; i >= 0; --i)
            {
                if (_tabs[i].View == e.View)
                {
                    size = _tabs[i].Length;
                    _tabs.RemoveAt(i);
                    index = i;
                    break;
                }
            }
            if (index != -1)
            {
                _size -= size;
                size   = _size;
                switch (_orientation)
                {
                case Orientation.Vertical:
                {
                    var space = _grid.VerticalClientSpace;
                    size += _tabs.Count * Renderer.SideTabSpacing;
                    if (size > space)
                    {
                        size = space;
                    }
                    Height = size;
                }
                break;

                case Orientation.Horizontal:
                {
                    var space = _grid.HorizontalClientSpace;
                    size += _tabs.Count * Renderer.SideTabSpacing;
                    if (size > space)
                    {
                        size = space;
                    }
                    Width = size;
                }
                break;

                default:
                    throw new ApplicationException(string.Format(
                                                       CultureInfo.InvariantCulture,
                                                       "Unexpected {0}.Orientation: {1}", GetType().Name, Orientation));
                }
                Invalidate();
                if (_tabHover.Index == index)
                {
                    _tabHover.Reset(-1, null);
                }
                else if (_tabHover.Index > index)
                {
                    _tabHover.ResetIndex(_tabHover.Index - 1);
                }
                if (sender == _visibleHost)
                {
                    DespawnPanel();
                }
            }
        }