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(); } } }
private void OnViewAdded(object sender, ViewEventArgs e) { var host = (ViewHost)sender; int i = _tabs.Count - 1; for (; i >= 0; --i) { if (_tabs[i].ViewHost == host) { break; } } var tab = new ViewDockSideTab(this, host, e.View); tab.ResetLength(); var size = tab.Length; _tabs.Insert(i, tab); switch (_orientation) { case Orientation.Vertical: { var space = _grid.VerticalClientSpace; var height = _size + size; _size = height; if (_tabs.Count != 1) { height += Renderer.SideTabSpacing; } if (height > space) { height = space; } Height = height; } break; case Orientation.Horizontal: { var space = _grid.HorizontalClientSpace; var width = _size + size; _size = width; if (_tabs.Count != 1) { width += Renderer.SideTabSpacing; } if (width > space) { width = space; } Width = width; } break; default: throw new ApplicationException(string.Format( CultureInfo.InvariantCulture, "Unexpected {0}.Orientation: {1}", GetType().Name, Orientation)); } e.View.TextChanged += OnViewTextChanged; Invalidate(); }