private static void Float(Layout layout, DragablzItem dragablzItem) { //TODO we need eq of IManualInterTabClient here, so consumer can control this op'. layout._floatTransfer = FloatTransfer.TakeSnapshot(dragablzItem); //remove from source var sourceOfDragItemsControl = ItemsControl.ItemsControlFromItemContainer(dragablzItem) as DragablzItemsControl; if (sourceOfDragItemsControl == null) { throw new ApplicationException("Unable to determin source items control."); } var sourceTabControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); if (sourceTabControl == null) { throw new ApplicationException("Unable to determin source tab control."); } sourceTabControl.RemoveItem(dragablzItem); //add to float layer CollectionTeaser collectionTeaser; if (CollectionTeaser.TryCreate(layout.FloatingItemsSource, out collectionTeaser)) { collectionTeaser.Add(layout._floatTransfer.Content); } else { layout.FloatingItems.Add(layout._floatTransfer.Content); } }
private void ItemDragStarted(object sender, DragablzDragStartedEventArgs e) { var sourceOfDragItemsControl = ItemsControl.ItemsControlFromItemContainer(e.DragablzItem) as DragablzItemsControl; if (sourceOfDragItemsControl == null) { return; } var sourceTab = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); if (sourceTab == null) { return; } if (sourceOfDragItemsControl.Items.Count != 1 || (sourceTab.InterTabController != null && !sourceTab.InterTabController.MoveWindowWithSolitaryTabs) || Layout.IsContainedWithinBranch(sourceOfDragItemsControl)) { return; } IsBeingDraggedByTab = true; }
private static void Float(Layout layout, DragablzItem dragablzItem) { //TODO we need eq of IManualInterTabClient here, so consumer can control this op'. //remove from source if (!(ItemsControl.ItemsControlFromItemContainer(dragablzItem) is DragablzItemsControl sourceOfDragItemsControl)) { throw new ApplicationException("Unable to determin source items control."); } var sourceTabControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); layout._floatTransfer = FloatTransfer.TakeSnapshot(dragablzItem, sourceTabControl); var floatingItemSnapShots = sourceTabControl.VisualTreeDepthFirstTraversal() .OfType <Layout>() .SelectMany(l => l.FloatingDragablzItems().Select(FloatingItemSnapShot.Take)) .ToList(); if (sourceTabControl == null) { throw new ApplicationException("Unable to determin source tab control."); } sourceTabControl.RemoveItem(dragablzItem); //add to float layer if (CollectionTeaser.TryCreate(layout.FloatingItemsSource, out CollectionTeaser? collectionTeaser)) { collectionTeaser.Add(layout._floatTransfer.Content); } else { layout.FloatingItems.Add(layout._floatTransfer.Content); } layout.Dispatcher.BeginInvoke(new Action(() => RestoreFloatingItemSnapShots(layout, floatingItemSnapShots)), DispatcherPriority.Loaded); }
private static bool TryGetSourceTabControl(DragablzItem dragablzItem, out TabablzControl tabablzControl) { if (!(ItemsControl.ItemsControlFromItemContainer(dragablzItem) is DragablzItemsControl sourceOfDragItemsControl)) { throw new ApplicationException("Unable to determine source items control."); } tabablzControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); return(tabablzControl != null); }
private static TabablzControl AssertGetSourceTabControl(DragablzItem dragablzItem) { var sourceOfDragItemsControl = ItemsControl.ItemsControlFromItemContainer(dragablzItem) as DragablzItemsControl; if (sourceOfDragItemsControl == null) { throw new ApplicationException("Unable to determine source items control."); } var sourceTabControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); if (sourceTabControl == null) { throw new ApplicationException("Unable to determine source tab control."); } return(sourceTabControl); }
private void Branch(DropZoneLocation location, DragablzItem sourceDragablzItem) { if (InterLayoutClient == null) { throw new InvalidOperationException("InterLayoutClient is not set."); } var sourceOfDragItemsControl = ItemsControl.ItemsControlFromItemContainer(sourceDragablzItem) as DragablzItemsControl; if (sourceOfDragItemsControl == null) { throw new ApplicationException("Unable to determin source items control."); } var sourceTabControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl); if (sourceTabControl == null) { throw new ApplicationException("Unable to determin source tab control."); } var sourceItem = sourceOfDragItemsControl.ItemContainerGenerator.ItemFromContainer(sourceDragablzItem); sourceTabControl.RemoveItem(sourceDragablzItem); var branchItem = new Branch { Orientation = (location == DropZoneLocation.Right || location == DropZoneLocation.Left) ? Orientation.Horizontal : Orientation.Vertical }; object newContent; if (BranchTemplate == null) { var newTabHost = InterLayoutClient.GetNewHost(Partition, sourceTabControl); if (newTabHost == null) { throw new ApplicationException("InterLayoutClient did not provide a new tab host."); } newTabHost.TabablzControl.AddToSource(sourceItem); newTabHost.TabablzControl.SelectedItem = sourceItem; newContent = newTabHost.Container; } else { newContent = new ContentControl { Content = new object(), ContentTemplate = BranchTemplate, }; ((ContentControl)newContent).Dispatcher.BeginInvoke(new Action(() => { //TODO might need to improve this a bit, make it a bit more declarative for complex trees var newTabControl = ((ContentControl)newContent).VisualTreeDepthFirstTraversal().OfType <TabablzControl>().FirstOrDefault(); if (newTabControl != null) { newTabControl.DataContext = sourceTabControl.DataContext; newTabControl.AddToSource(sourceItem); newTabControl.SelectedItem = sourceItem; } }), DispatcherPriority.Loaded); } if (location == DropZoneLocation.Right || location == DropZoneLocation.Bottom) { branchItem.FirstItem = Content; branchItem.SecondItem = newContent; } else { branchItem.FirstItem = newContent; branchItem.SecondItem = Content; } SetCurrentValue(ContentProperty, branchItem); }