コード例 #1
0
        public static FloatingItemSnapShot Take(DragablzItem dragablzItem)
        {
            if (dragablzItem == null) throw new ArgumentNullException("dragablzItem");

            return new FloatingItemSnapShot(
                dragablzItem.Content, 
                new Rect(dragablzItem.X, dragablzItem.Y, dragablzItem.ActualWidth, dragablzItem.ActualHeight), 
                Panel.GetZIndex(dragablzItem),
                Layout.GetFloatingItemState(dragablzItem));
        }
コード例 #2
0
        public void Apply(DragablzItem dragablzItem)
        {
            if (dragablzItem == null) throw new ArgumentNullException("dragablzItem");

            dragablzItem.SetCurrentValue(DragablzItem.XProperty, Location.Left);
            dragablzItem.SetCurrentValue(DragablzItem.YProperty, Location.Top);
            dragablzItem.SetCurrentValue(FrameworkElement.WidthProperty, Location.Width);
            dragablzItem.SetCurrentValue(FrameworkElement.HeightProperty, Location.Height);
            Layout.SetFloatingItemState(dragablzItem, State);
            Panel.SetZIndex(dragablzItem, ZIndex);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        internal void AddTabablzData(string header0, IEnumerable <TabablzControl> tctrl, TabContent tc1)
        {
            TabablzControl lastTabablzControl = tctrl.Last();

            // adds a new tab after the last right tab
            IEnumerable <DragablzItem> orderedDragablzItem = lastTabablzControl.GetOrderedHeaders();
            DragablzItem lastTab = orderedDragablzItem.Last();

            TabablzControl.AddItem(tc1, lastTab.DataContext, AddLocationHint.After);

            TabablzControl.SelectItem(tc1);
        }
コード例 #5
0
        internal void AddTabablzData(string header0, IEnumerable <TabablzControl> tctrl, TabContent tc1)
        {
            TabablzControl lastTabablzControl = tctrl.Last();

            // dodaje novi tab iza zadnjeg tab-a koji se vidi
            IEnumerable <DragablzItem> orderedDragablzItem = lastTabablzControl.GetOrderedHeaders();
            DragablzItem lastTab = orderedDragablzItem.Last();

            TabablzControl.AddItem(tc1, lastTab.DataContext, AddLocationHint.After);

            TabablzControl.SelectItem(tc1);
        }
コード例 #6
0
        public TabHeaderDragStartInformation(
            DragablzItem dragItem,
            double dragablzItemsControlHorizontalOffset, double dragablzItemControlVerticalOffset, double dragablzItemHorizontalOffset, double dragablzItemVerticalOffset)
        {
            if (dragItem == null) throw new ArgumentNullException("dragItem");

            _dragItem = dragItem;
            _dragablzItemsControlHorizontalOffset = dragablzItemsControlHorizontalOffset;
            _dragablzItemControlVerticalOffset = dragablzItemControlVerticalOffset;
            _dragablzItemHorizontalOffset = dragablzItemHorizontalOffset;
            _dragablzItemVerticalOffset = dragablzItemVerticalOffset;
        }
コード例 #7
0
        public static FloatingItemSnapShot Take(DragablzItem dragablzItem)
        {
            if (dragablzItem == null)
            {
                throw new ArgumentNullException(nameof(dragablzItem));
            }

            return(new FloatingItemSnapShot(
                       dragablzItem.Content,
                       new Rect(dragablzItem.X, dragablzItem.Y, dragablzItem.ActualWidth, dragablzItem.ActualHeight),
                       Panel.GetZIndex(dragablzItem),
                       Layout.GetFloatingItemState(dragablzItem)));
        }
コード例 #8
0
        public InterTabTransfer(object item, DragablzItem originatorContainer, Orientation breachOrientation, Point dragStartWindowOffset, Point dragStartItemOffset, Size itemSize, IList <FloatingItemSnapShot> floatingItemSnapShots, bool isTransposing)
        {
            TransferReason = InterTabTransferReason.Breach;

            Item = item ?? throw new ArgumentNullException(nameof(item));
            OriginatorContainer   = originatorContainer ?? throw new ArgumentNullException(nameof(originatorContainer));
            BreachOrientation     = breachOrientation;
            DragStartWindowOffset = dragStartWindowOffset;
            DragStartItemOffset   = dragStartItemOffset;
            ItemSize = itemSize;
            FloatingItemSnapShots = floatingItemSnapShots ?? throw new ArgumentNullException(nameof(floatingItemSnapShots));
            IsTransposing         = isTransposing;
        }
コード例 #9
0
        public InterTabTransfer(object item, DragablzItem originatorContainer, Point dragStartItemOffset,
            IList<FloatingItemSnapShot> floatingItemSnapShots)
        {
            if (item == null) throw new ArgumentNullException("item");
            if (originatorContainer == null) throw new ArgumentNullException("originatorContainer");
            if (floatingItemSnapShots == null) throw new ArgumentNullException("floatingItemSnapShots");

            _transferReason = InterTabTransferReason.Reentry;

            _item = item;
            _originatorContainer = originatorContainer;
            _dragStartItemOffset = dragStartItemOffset;
            _floatingItemSnapShots = floatingItemSnapShots;
        }
コード例 #10
0
        public void Apply(DragablzItem dragablzItem)
        {
            if (dragablzItem == null)
            {
                throw new ArgumentNullException(nameof(dragablzItem));
            }

            dragablzItem.SetCurrentValue(DragablzItem.XProperty, Location.Left);
            dragablzItem.SetCurrentValue(DragablzItem.YProperty, Location.Top);
            dragablzItem.SetCurrentValue(FrameworkElement.WidthProperty, Location.Width);
            dragablzItem.SetCurrentValue(FrameworkElement.HeightProperty, Location.Height);
            Layout.SetFloatingItemState(dragablzItem, State);
            Panel.SetZIndex(dragablzItem, ZIndex);
        }
コード例 #11
0
        public TabHeaderDragStartInformation(
            DragablzItem dragItem,
            double dragablzItemsControlHorizontalOffset, double dragablzItemControlVerticalOffset, double dragablzItemHorizontalOffset, double dragablzItemVerticalOffset)
        {
            if (dragItem == null)
            {
                throw new ArgumentNullException("dragItem");
            }

            _dragItem = dragItem;
            _dragablzItemsControlHorizontalOffset = dragablzItemsControlHorizontalOffset;
            _dragablzItemControlVerticalOffset    = dragablzItemControlVerticalOffset;
            _dragablzItemHorizontalOffset         = dragablzItemHorizontalOffset;
            _dragablzItemVerticalOffset           = dragablzItemVerticalOffset;
        }
コード例 #12
0
ファイル: InterTabTransfer.cs プロジェクト: strohlaj/Dragablz
        public InterTabTransfer(object item, DragablzItem originatorContainer, Point dragStartItemOffset)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (originatorContainer == null)
            {
                throw new ArgumentNullException("originatorContainer");
            }

            _transferReason = InterTabTransferReason.Reentry;

            _item = item;
            _originatorContainer = originatorContainer;
            _dragStartItemOffset = dragStartItemOffset;
        }
コード例 #13
0
ファイル: Layout.cs プロジェクト: strohlaj/Dragablz
        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);
        }
コード例 #14
0
        public InterTabTransfer(object item, DragablzItem originatorContainer, Orientation breachOrientation, Point dragStartWindowOffset, Point dragStartItemOffset, Point itemPositionWithinHeader, Size itemSize, IList<FloatingItemSnapShot> floatingItemSnapShots, bool isTransposing)
        {
            if (item == null) throw new ArgumentNullException("item");
            if (originatorContainer == null) throw new ArgumentNullException("originatorContainer");
            if (floatingItemSnapShots == null) throw new ArgumentNullException("floatingItemSnapShots");

            _transferReason = InterTabTransferReason.Breach;

            _item = item;
            _originatorContainer = originatorContainer;
            _breachOrientation = breachOrientation;
            _dragStartWindowOffset = dragStartWindowOffset;
            _dragStartItemOffset = dragStartItemOffset;
            _itemPositionWithinHeader = itemPositionWithinHeader;
            _itemSize = itemSize;
            _floatingItemSnapShots = floatingItemSnapShots;
            _isTransposing = isTransposing;
        }
コード例 #15
0
ファイル: Layout.cs プロジェクト: ntrung90/Dragablz
        private static void Float(Layout layout, DragablzItem dragablzItem)
        {
            //TODO we need eq of IManualInterTabClient here, so consumer can control this op'.

            //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);

            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
            CollectionTeaser collectionTeaser;

            if (CollectionTeaser.TryCreate(layout.FloatingItemsSource, out collectionTeaser))
            {
                collectionTeaser.Add(layout._floatTransfer.Content);
            }
            else
            {
                layout.FloatingItems.Add(layout._floatTransfer.Content);
            }

            layout.Dispatcher.BeginInvoke(new Action(() => RestoreFloatingItemSnapShots(layout, floatingItemSnapShots)), DispatcherPriority.Loaded);
        }
コード例 #16
0
        private static void SetupParticipatingLayouts(DragablzItem dragablzItem)
        {
            if (!(ItemsControl.ItemsControlFromItemContainer(dragablzItem) is DragablzItemsControl sourceOfDragItemsControl) || sourceOfDragItemsControl.Items.Count != 1)
            {
                return;
            }

            var draggingWindow = Window.GetWindow(dragablzItem);

            if (draggingWindow == null)
            {
                return;
            }

            foreach (var loadedLayout in LoadedLayouts.Where(l =>
                                                             l.Partition == dragablzItem.PartitionAtDragStart &&
                                                             !Equals(Window.GetWindow(l), draggingWindow)))

            {
                loadedLayout.IsParticipatingInDrag = true;
            }
        }
コード例 #17
0
        public InterTabTransfer(object item, DragablzItem originatorContainer, Point dragStartItemOffset,
                                IList <FloatingItemSnapShot> floatingItemSnapShots)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (originatorContainer == null)
            {
                throw new ArgumentNullException("originatorContainer");
            }
            if (floatingItemSnapShots == null)
            {
                throw new ArgumentNullException("floatingItemSnapShots");
            }

            _transferReason = InterTabTransferReason.Reentry;

            _item = item;
            _originatorContainer   = originatorContainer;
            _dragStartItemOffset   = dragStartItemOffset;
            _floatingItemSnapShots = floatingItemSnapShots;
        }
コード例 #18
0
ファイル: Layout.cs プロジェクト: CensoredHF/Snappie
        private static bool TryGetSourceTabControl(DragablzItem dragablzItem, out TabablzControl tabablzControl)
        {
            var sourceOfDragItemsControl = ItemsControl.ItemsControlFromItemContainer(dragablzItem) as DragablzItemsControl;
            if (sourceOfDragItemsControl == null) throw new ApplicationException("Unable to determine source items control.");

            tabablzControl = TabablzControl.GetOwnerOfHeaderItems(sourceOfDragItemsControl);
            
            return tabablzControl != null;
        }
コード例 #19
0
ファイル: Layout.cs プロジェクト: CensoredHF/Snappie
        private static void SetupParticipatingLayouts(DragablzItem dragablzItem)
        {
            var sourceOfDragItemsControl = ItemsControl.ItemsControlFromItemContainer(dragablzItem) as DragablzItemsControl;
            if (sourceOfDragItemsControl == null || sourceOfDragItemsControl.Items.Count != 1) return;

            var draggingWindow = Window.GetWindow(dragablzItem);
            if (draggingWindow == null) return;

            foreach (var loadedLayout in LoadedLayouts.Where(l =>
                l.Partition == dragablzItem.PartitionAtDragStart &&
                !Equals(Window.GetWindow(l), draggingWindow)))

            {
                loadedLayout.IsParticipatingInDrag = true;
            }
        }
コード例 #20
0
 public FloatRequestedEventArgs(RoutedEvent routedEvent, object source, DragablzItem dragablzItem) 
     : base(routedEvent, source, dragablzItem)
 { }
コード例 #21
0
 public FloatRequestedEventArgs(RoutedEvent routedEvent, DragablzItem dragablzItem) 
     : base(routedEvent, dragablzItem)
 { }
コード例 #22
0
 public FloatRequestedEventArgs(RoutedEvent routedEvent, object source, DragablzItem dragablzItem)
     : base(routedEvent, source, dragablzItem)
 {
 }
コード例 #23
0
 public FloatRequestedEventArgs(RoutedEvent routedEvent, DragablzItem dragablzItem)
     : base(routedEvent, dragablzItem)
 {
 }
コード例 #24
0
 public static void SetIcon(DragablzItem item, object value)
 {
     item.SetValue(IconProperty, value);
 }
コード例 #25
0
ファイル: Layout.cs プロジェクト: CensoredHF/Snappie
        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 floatingItemSnapShots = sourceTabControl.VisualTreeDepthFirstTraversal()
                    .OfType<Layout>()
                    .SelectMany(l => l.FloatingDragablzItems().Select(FloatingItemSnapShot.Take))
                    .ToList();

            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;

                Dispatcher.BeginInvoke(new Action(() => RestoreFloatingItemSnapShots(newTabHost.TabablzControl, floatingItemSnapShots)), DispatcherPriority.Loaded);
            }
            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) return;

                    newTabControl.DataContext = sourceTabControl.DataContext;
                    newTabControl.AddToSource(sourceItem);
                    newTabControl.SelectedItem = sourceItem;
                    Dispatcher.BeginInvoke(new Action(() => RestoreFloatingItemSnapShots(newTabControl, floatingItemSnapShots)), DispatcherPriority.Loaded);
                }), 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);            
        }
コード例 #26
0
 public override void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem)
 {
     DragCompleted?.Invoke();
     base.OrganiseOnDragCompleted(requestor, measureBounds, siblingItems, dragItem);
 }
コード例 #27
0
ファイル: Layout.cs プロジェクト: CensoredHF/Snappie
        private static void Float(Layout layout, DragablzItem dragablzItem)
        {
            //TODO we need eq of IManualInterTabClient here, so consumer can control this op'.            

            //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);
            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            
            CollectionTeaser collectionTeaser;
            if (CollectionTeaser.TryCreate(layout.FloatingItemsSource, out collectionTeaser))
                collectionTeaser.Add(layout._floatTransfer.Content);
            else
                layout.FloatingItems.Add(layout._floatTransfer.Content);

            layout.Dispatcher.BeginInvoke(new Action(() => RestoreFloatingItemSnapShots(layout, floatingItemSnapShots)), DispatcherPriority.Loaded);
        }
コード例 #28
0
ファイル: FloatTransfer.cs プロジェクト: CensoredHF/Snappie
        public static FloatTransfer TakeSnapshot(DragablzItem dragablzItem, TabablzControl sourceTabControl)
        {
            if (dragablzItem == null) throw new ArgumentNullException("dragablzItem");

            return new FloatTransfer(sourceTabControl.ActualWidth, sourceTabControl.ActualHeight, dragablzItem.UnderlyingContent ?? dragablzItem.Content ?? dragablzItem);
        }
コード例 #29
0
ファイル: Layout.cs プロジェクト: strohlaj/Dragablz
        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);
        }
コード例 #30
0
 public static object GetIcon(DragablzItem item)
 {
     return(item.GetValue(IconProperty));
 }