コード例 #1
0
ファイル: Layout.cs プロジェクト: strohlaj/Dragablz
        private void PrepareFloatingContainerForItemOverride(DependencyObject dependencyObject, object o)
        {
            var headeredDragablzItem = dependencyObject as HeaderedDragablzItem;

            if (headeredDragablzItem == null)
            {
                return;
            }

            SetIsFloatingInLayout(dependencyObject, true);

            var headerBinding = new Binding(FloatingItemHeaderMemberPath)
            {
                Source = o
            };

            headeredDragablzItem.SetBinding(HeaderedDragablzItem.HeaderContentProperty, headerBinding);

            if (_floatTransfer != null && (o == _floatTransfer.Content || dependencyObject == _floatTransfer.Content))
            {
                //TODO might be nice to allow user a bit of control over sizing

                var dragablzItem = (DragablzItem)dependencyObject;
                dragablzItem.SetCurrentValue(DragablzItem.XProperty, _floatingItems.ActualWidth / 2 - _floatTransfer.Width / 2);
                dragablzItem.SetCurrentValue(DragablzItem.YProperty, _floatingItems.ActualHeight / 2 - _floatTransfer.Height / 2);

                _floatTransfer = null;
            }
        }
コード例 #2
0
ファイル: Layout.cs プロジェクト: strohlaj/Dragablz
        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);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: Layout.cs プロジェクト: ntrung90/Dragablz
        private void PrepareFloatingContainerForItemOverride(DependencyObject dependencyObject, object o)
        {
            var headeredDragablzItem = dependencyObject as HeaderedDragablzItem;

            if (headeredDragablzItem == null)
            {
                return;
            }

            SetIsFloatingInLayout(dependencyObject, true);

            var headerBinding = new Binding(FloatingItemHeaderMemberPath)
            {
                Source = o
            };

            headeredDragablzItem.SetBinding(HeaderedDragablzItem.HeaderContentProperty, headerBinding);

            if (!string.IsNullOrWhiteSpace(FloatingItemDisplayMemberPath))
            {
                var contentBinding = new Binding(FloatingItemDisplayMemberPath)
                {
                    Source = o
                };
                headeredDragablzItem.SetBinding(ContentProperty, contentBinding);
            }

            if (_floatTransfer == null || (o != _floatTransfer.Content && dependencyObject != _floatTransfer.Content))
            {
                return;
            }

            var dragablzItem = (DragablzItem)dependencyObject;

            Dispatcher.BeginInvoke(new Action(() =>
            {
                //TODO might be nice to allow user a bit of control over sizing...especially the .75 thing i have handily hard coded.  shoot me.
                dragablzItem.Measure(new Size(_floatingItems.ActualWidth, _floatingItems.ActualHeight));
                var newWidth  = Math.Min(_floatingItems.ActualWidth * .75, dragablzItem.DesiredSize.Width);
                var newHeight = Math.Min(_floatingItems.ActualHeight * .75, dragablzItem.DesiredSize.Height);
                dragablzItem.SetCurrentValue(DragablzItem.XProperty, _floatingItems.ActualWidth / 2 - newWidth / 2);
                dragablzItem.SetCurrentValue(DragablzItem.YProperty, _floatingItems.ActualHeight / 2 - newHeight / 2);
                dragablzItem.SetCurrentValue(WidthProperty, newWidth);
                dragablzItem.SetCurrentValue(HeightProperty, newHeight);
            }), DispatcherPriority.Loaded);

            _floatTransfer = null;
        }
コード例 #5
0
ファイル: Layout.cs プロジェクト: CensoredHF/Snappie
        private void PrepareFloatingContainerForItemOverride(DependencyObject dependencyObject, object o)
        {
            var headeredDragablzItem = dependencyObject as HeaderedDragablzItem;
            if (headeredDragablzItem == null) return;

            SetIsFloatingInLayout(dependencyObject, true);

            var headerBinding = new Binding(FloatingItemHeaderMemberPath) {Source = o};
            headeredDragablzItem.SetBinding(HeaderedDragablzItem.HeaderContentProperty, headerBinding);

            if (!string.IsNullOrWhiteSpace(FloatingItemDisplayMemberPath))
            {
                var contentBinding = new Binding(FloatingItemDisplayMemberPath) {Source = o};
                headeredDragablzItem.SetBinding(ContentProperty, contentBinding);
            }

            if (_floatTransfer == null || (o != _floatTransfer.Content && dependencyObject != _floatTransfer.Content))
                return;

            var dragablzItem = (DragablzItem) dependencyObject;

            Dispatcher.BeginInvoke(new Action(() =>
            {
                //TODO might be nice to allow user a bit of control over sizing...especially the .75 thing i have handily hard coded.  shoot me.
                dragablzItem.Measure(new Size(_floatingItems.ActualWidth, _floatingItems.ActualHeight));
                var newWidth = Math.Min(_floatingItems.ActualWidth*.75, dragablzItem.DesiredSize.Width);
                var newHeight = Math.Min(_floatingItems.ActualHeight * .75, dragablzItem.DesiredSize.Height);
                dragablzItem.SetCurrentValue(DragablzItem.XProperty, _floatingItems.ActualWidth/2 - newWidth/2);
                dragablzItem.SetCurrentValue(DragablzItem.YProperty, _floatingItems.ActualHeight/2 - newHeight/2);
                dragablzItem.SetCurrentValue(WidthProperty, newWidth);
                dragablzItem.SetCurrentValue(HeightProperty, newHeight);
            }), DispatcherPriority.Loaded);                
                
            _floatTransfer = null;
        }