/** * @brief calculates the positions and sizes of the child elements using the final size. * @param[in] final_size (Size) max size of the adorner. * @return (Size) actually required size of the adorner as caclulated from its visual children positions and sizez. */ protected override Size ArrangeOverride(Size final_size) { DynamicDockTab c = AdornedElement as DynamicDockTab; children[0].Arrange(new Rect(final_size.Width * 0.5f - 25, final_size.Height * 0.5f - 25, 50, 50)); return(final_size); }
/** * @brief Constructor whicch sets up the window procedure. * @param[in | opt] A tab item to add to the window on startup. * @see sulphur.editor.controls.DynamicDockTab */ public TabWindow(DynamicDockTab item = null) { WindowStyle = WindowStyle.ToolWindow; InitializeComponent(); SizeToContent = SizeToContent.WidthAndHeight; Show(); Owner = Application.Current.MainWindow; HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); source.AddHook(new HwndSourceHook(WndProc)); Content = new DynamicDockTabControl(false); (Content as DynamicDockTabControl).items_changed += TabWindow_items_changed; if (item != null) { (Content as DynamicDockTabControl).Items.Add(item); } }
/** * @brief Called when the conditions for a drag are met. * This removes the currently selected tab from the control and puts it into a seperate window. * @param[in] item (DynamicDockTab) Item to be removed. * @see sulphur.editor.controls.TabWindow. */ private void StartDrag(DynamicDockTab item) { if (Items.Count == 1 && allow_empty_ == false) { return; } Items.Remove(item); if (Items.Count != 0) { SelectedIndex = Items.Count - 1; } TabWindow window = new TabWindow(item); SubscriptionHandler.Register(window); window.Show(); window.Focus(); window.DragMove(); }
List <Pair> paired_children_; //!< All Children of this dockpanel paired up with a splitter. /** * @brief Runs after WPF initialization of the control is complete. This functions puts all childs in their respective tab controls and dockpanels. */ public override void EndInit() { base.EndInit(); for (int i = 0; i < Children.Count; ++i) { UIElement child = Children[i]; uint group = GetGroup(child); DynamicDockTab item = new DynamicDockTab(); item.Header = ((FrameworkElement)child).Name; item.Content = new DynamicDock(); item.Content = child; if (group != uint.MaxValue) { bool group_found = false; foreach (Pair entry in paired_children_) { if (group == GetGroup(entry.element)) { entry.element.Items.Add(item); group_found = true; break; } } if (group_found == true) { continue; } } Dock dockmode = GetDock(child); DynamicDockTabControl tabs = new DynamicDockTabControl(true); tabs.items_changed += TabItemsChanged; tabs.Items.Add(item); SetGroup(tabs, group); Pair pair = new Pair(); pair.splitter = null; pair.element = tabs; pair.dockmode = dockmode; pair.adorner = new DynamicDockAdorner(pair.element); SetDock(pair.element, pair.dockmode); if (paired_children_.Count != 0) { Pair back = paired_children_[paired_children_.Count - 1]; back.CreateSplitter(); back.splitter.resizing_started += (object sender, EventArgs args) => notify_subscribers_?.Invoke( sender, new NotificationEventArgs( null, (uint)Notifications.kLayoutChangeStarted, id <DynamicDock> .type_id_) ); back.splitter.resizing_stopped += (object sender, EventArgs args) => notify_subscribers_?.Invoke( sender, new NotificationEventArgs( null, (uint)Notifications.kLayoutChangeEnded, id <DynamicDock> .type_id_) ); } paired_children_.Add(pair); } Children.Clear(); foreach (Pair pair in paired_children_) { Children.Add(pair.element); if (pair.splitter != null) { Children.Add(pair.splitter); } } }