Exemple #1
0
        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);
            }
        }
Exemple #2
0
        private void CloseFloatingItemExecuted(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)
        {
            if (!(executedRoutedEventArgs.Parameter is DragablzItem dragablzItem))
            {
                throw new ApplicationException("Parameter must be a DragablzItem");
            }

            var cancel = false;

            if (ClosingFloatingItemCallback != null)
            {
                var callbackArgs = new ItemActionCallbackArgs <Layout>(Window.GetWindow(this), this, dragablzItem);
                ClosingFloatingItemCallback(callbackArgs);
                cancel = callbackArgs.IsCancelled;
            }

            if (cancel)
            {
                return;
            }

            //TODO ...need a similar tp manual inter tab controlller here for the extra hook

            var item = _floatingItems.ItemContainerGenerator.ItemFromContainer(dragablzItem);

            if (CollectionTeaser.TryCreate(_floatingItems.ItemsSource, out CollectionTeaser? collectionTeaser))
            {
                collectionTeaser.Remove(item);
            }
            else
            {
                _floatingItems.Items.Remove(item);
            }
        }
Exemple #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);
        }
Exemple #4
0
        public void WillCreateForCollection()
        {
            var myList = A.Fake <ICollection>();

            CollectionTeaser collectionTeaser;
            var result = CollectionTeaser.TryCreate(myList, out collectionTeaser);

            Assert.IsFalse(result);
            Assert.IsNull(collectionTeaser);
        }
Exemple #5
0
        public void WillCreateForGenericCollection()
        {
            var myList = A.Fake <ICollection <string> >();

            CollectionTeaser collectionTeaser;
            var result = CollectionTeaser.TryCreate(myList, out collectionTeaser);

            Assert.IsTrue(result);
            Assert.IsNotNull(collectionTeaser);
        }
Exemple #6
0
        public void WillCreateForList()
        {
            var myList = new ArrayList();

            CollectionTeaser collectionTeaser;
            var result = CollectionTeaser.TryCreate(myList, out collectionTeaser);

            Assert.IsTrue(result);
            Assert.IsNotNull(collectionTeaser);
        }
Exemple #7
0
        public void WillCreateForCollection()
        {
            var myList = MockRepository.GenerateStub <ICollection>();

            CollectionTeaser collectionTeaser;
            var result = CollectionTeaser.TryCreate(myList, out collectionTeaser);

            Assert.IsFalse(result);
            Assert.IsNull(collectionTeaser);
        }
Exemple #8
0
        public void WillRemoveForGenericCollection()
        {
            var myList = A.Fake <ICollection <string> >();
            CollectionTeaser collectionTeaser;

            Assert.IsTrue(CollectionTeaser.TryCreate(myList, out collectionTeaser));

            collectionTeaser.Remove("bye");

            A.CallTo(() => myList.Remove("bye")).MustHaveHappened();
            A.CallTo(() => myList.Add("bye")).MustNotHaveHappened();
        }
Exemple #9
0
        public void WillAddForList()
        {
            var myList = new ArrayList();
            CollectionTeaser collectionTeaser;

            Assert.IsTrue(CollectionTeaser.TryCreate(myList, out collectionTeaser));

            collectionTeaser.Add("i am going to type this in, manually, twice.");

            CollectionAssert.AreEquivalent(new[] { "i am going to type this in, manually, twice." }, myList);
            //i didnt really.  i copied and pasted it.
        }
Exemple #10
0
        public void WillAddForGenericCollection()
        {
            var myList = MockRepository.GenerateStub <ICollection <string> >();
            CollectionTeaser collectionTeaser;

            Assert.IsTrue(CollectionTeaser.TryCreate(myList, out collectionTeaser));

            collectionTeaser.Add("hello");

            myList.AssertWasCalled(c => c.Add("hello"));
            myList.AssertWasNotCalled(c => c.Remove("hello"));
        }
 /// <summary>
 /// Adds an item to the underlying source, displaying in a specific position in rendered control.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="nearItem"></param>
 /// <param name="addLocationHint"></param>
 public void AddToSource(object item, object nearItem, AddLocationHint addLocationHint)
 {
     if (CollectionTeaser.TryCreate(ItemsSource, out var collectionTeaser))
     {
         collectionTeaser.Add(item);
     }
     else
     {
         Items.Add(item);
     }
     MoveItem(new MoveItemRequest(item, nearItem, addLocationHint));
 }
Exemple #12
0
        public void WillRemoveForList()
        {
            var myList = new ArrayList
            {
                1,
                2,
                3,
                4,
                5
            };
            CollectionTeaser collectionTeaser;

            Assert.IsTrue(CollectionTeaser.TryCreate(myList, out collectionTeaser));

            collectionTeaser.Remove(3);

            CollectionAssert.AreEquivalent(new[] { 1, 2, 4, 5 }, myList);
        }
Exemple #13
0
        private void RemoveFromSource(object item)
        {
            var manualInterTabClient = InterTabController.InterTabClient as IManualInterTabClient;

            if (manualInterTabClient != null)
            {
                manualInterTabClient.Remove(item);
            }
            else
            {
                CollectionTeaser collectionTeaser;
                if (CollectionTeaser.TryCreate(ItemsSource, out collectionTeaser))
                {
                    collectionTeaser.Remove(item);
                }
                else
                {
                    Items.Remove(item);
                }
            }
        }
Exemple #14
0
        internal void AddToSource(object item)
        {
            var manualInterTabClient = InterTabController.InterTabClient as IManualInterTabClient;

            if (manualInterTabClient != null)
            {
                manualInterTabClient.Add(item);
            }
            else
            {
                CollectionTeaser collectionTeaser;
                if (CollectionTeaser.TryCreate(ItemsSource, out collectionTeaser))
                {
                    collectionTeaser.Add(item);
                }
                else
                {
                    Items.Add(item);
                }
            }
        }
Exemple #15
0
        private void UnfloatExecuted(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)
        {
            var dragablzItem = executedRoutedEventArgs.Parameter as DragablzItem;

            if (dragablzItem == null)
            {
                return;
            }

            var containsBranch = this.LogicalTreeDepthFirstTraversal().OfType <Branch>().Any();

            var exemplarTab = containsBranch //use Visual Traversal when branches exist
                ? this.VisualTreeDepthFirstTraversal().OfType <TabablzControl>()
                              .FirstOrDefault(t => t.InterTabController != null && t.InterTabController.Partition == Partition)
                : this.LogicalTreeDepthFirstTraversal().OfType <TabablzControl>()
                              .FirstOrDefault(t => t.InterTabController != null && t.InterTabController.Partition == Partition);

            if (exemplarTab == null)
            {
                return;
            }

            //TODO passing the exemplar tab in here isnt ideal, as strictly speaking there isnt one.
            var newTabHost = exemplarTab.InterTabController.InterTabClient.GetNewHost(exemplarTab.InterTabController.InterTabClient,
                                                                                      exemplarTab.InterTabController.Partition, exemplarTab);

            if (newTabHost == null || newTabHost.TabablzControl == null || newTabHost.Container == null)
            {
                throw new ApplicationException("New tab host was not correctly provided");
            }

            var content = dragablzItem.Content ?? dragablzItem;

            //remove from source
            CollectionTeaser collectionTeaser;

            if (CollectionTeaser.TryCreate(FloatingItemsSource, out collectionTeaser))
            {
                collectionTeaser.Remove(content);
            }
            else
            {
                FloatingItems.Remove(content);
            }

            var myWindow = Window.GetWindow(this);

            if (myWindow == null)
            {
                throw new ApplicationException("Unable to find owning window.");
            }
            newTabHost.Container.Width  = myWindow.RestoreBounds.Width;
            newTabHost.Container.Height = myWindow.RestoreBounds.Height;

            newTabHost.Container.Left = myWindow.Left + 20;
            newTabHost.Container.Top  = myWindow.Top + 20;

            Dispatcher.BeginInvoke(new Action(() =>
            {
                newTabHost.TabablzControl.AddToSource(content);
                newTabHost.TabablzControl.SelectedItem = content;
                newTabHost.Container.Show();
                newTabHost.Container.Activate();
            }), DispatcherPriority.DataBind);
        }