Exemplo n.º 1
0
        public override void OnApplyTemplate()
        {
            if (_templateSubscription != null)
            {
                _templateSubscription.Dispose();
            }
            _templateSubscription = Disposable.Empty;

            _dragablzItemsControl = GetTemplateChild(HeaderItemsControlPartName) as DragablzItemsControl;
            if (_dragablzItemsControl != null)
            {
                _dragablzItemsControl.ItemContainerGenerator.StatusChanged += ItemContainerGeneratorOnStatusChanged;
                _templateSubscription =
                    Disposable.Create(
                        () =>
                        _dragablzItemsControl.ItemContainerGenerator.StatusChanged -=
                            ItemContainerGeneratorOnStatusChanged);
                if (_dragablzItemsControl.ItemContainerStyleSelector == null)
                {
                    _dragablzItemsControl.ItemContainerStyleSelector = new TabablzItemStyleSelector(DefaultHeaderItemStyle,
                                                                                                    CustomHeaderItemStyle);
                }
            }

            if (SelectedItem == null)
            {
                SetCurrentValue(SelectedItemProperty, Items.OfType <object>().FirstOrDefault());
            }

            _itemsHolder = GetTemplateChild(ItemsHolderPartName) as Panel;
            UpdateSelectedItem();
            MarkInitialSelection();

            base.OnApplyTemplate();
        }
Exemplo n.º 2
0
        public virtual void OrganiseOnDrag(DragablzItemsControl requestor, Size measureBounds,
                                           IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem)
        {
            if (siblingItems == null)
            {
                throw new ArgumentNullException(nameof(siblingItems));
            }
            if (dragItem == null)
            {
                throw new ArgumentNullException(nameof(dragItem));
            }

            var currentLocations = siblingItems
                                   .Select(GetLocationInfo)
                                   .Union(new[] { GetLocationInfo(dragItem) })
                                   .OrderBy(loc => loc.Item == dragItem ? loc.Start : _siblingItemLocationOnDragStart[loc.Item].Start);

            var currentCoord = 0.0;
            var zIndex       = int.MaxValue;

            foreach (var location in currentLocations)
            {
                if (!Equals(location.Item, dragItem))
                {
                    SendToLocation(location.Item, currentCoord);
                    Panel.SetZIndex(location.Item, --zIndex);
                }
                currentCoord += _getDesiredSize(location.Item) + _itemOffset;
            }
            Panel.SetZIndex(dragItem, int.MaxValue);
        }
Exemplo n.º 3
0
        public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds,
                                                    IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem)
        {
            if (siblingItems == null)
            {
                throw new ArgumentNullException("siblingItems");
            }
            var currentLocations = siblingItems
                                   .Select(GetLocationInfo)
                                   .Union(new[] { GetLocationInfo(dragItem) })
                                   .OrderBy(loc => loc.Item == dragItem ? loc.Start : _siblingItemLocationOnDragStart[loc.Item].Start);

            var currentCoord = 0.0;
            var z            = int.MaxValue;
            var logicalIndex = 0;

            foreach (var location in currentLocations)
            {
                SetLocation(location.Item, currentCoord);
                currentCoord += _getDesiredSize(location.Item) + _itemOffset;
                Panel.SetZIndex(location.Item, --z);
                location.Item.LogicalIndex = logicalIndex++;
            }
            Panel.SetZIndex(dragItem, int.MaxValue);
        }
Exemplo n.º 4
0
        public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds, List <DragablzItem> siblingItems, DragablzItem dragablzItem)
        {
            var zIndex = int.MaxValue;

            foreach (var source in siblingItems.OrderByDescending(Panel.GetZIndex))
            {
                Panel.SetZIndex(source, --zIndex);
            }
            Panel.SetZIndex(dragablzItem, int.MaxValue);
        }
Exemplo n.º 5
0
        public void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds, List<DragablzItem> siblingItems, DragablzItem dragablzItem)
        {
            var zIndex = int.MaxValue;
            foreach (var source in siblingItems.OrderByDescending(Panel.GetZIndex))
            {
                Panel.SetZIndex(source, --zIndex);

            }
            Panel.SetZIndex(dragablzItem, int.MaxValue);
        }
Exemplo n.º 6
0
        public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            OrganiseInternal(
                requestor,
                measureBounds,
                items);
        }
Exemplo n.º 7
0
        public Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation, Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize)
        {
            //we will stop it pushing beyond the bounds...unless it's already beyond...
            var reduceBoundsWidth = itemCurrentLocation.X + itemCurrentSize.Width > measureBounds.Width
                ? 0
                : itemDesiredSize.Width;
            var reduceBoundsHeight = itemCurrentLocation.Y + itemCurrentSize.Height > measureBounds.Height
                ? 0
                : itemDesiredSize.Height;

            return new Point(
                Math.Min(Math.Max(itemDesiredLocation.X, 0), measureBounds.Width - reduceBoundsWidth),
                Math.Min(Math.Max(itemDesiredLocation.Y, 0), measureBounds.Height - reduceBoundsHeight));
        }
Exemplo n.º 8
0
        public virtual Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation, Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize)
        {
            //we will stop it pushing beyond the bounds...unless it's already beyond...
            var reduceBoundsWidth = itemCurrentLocation.X + itemCurrentSize.Width > measureBounds.Width
                ? 0
                : itemDesiredSize.Width;
            var reduceBoundsHeight = itemCurrentLocation.Y + itemCurrentSize.Height > measureBounds.Height
                ? 0
                : itemDesiredSize.Height;

            return(new Point(
                       Math.Min(Math.Max(itemDesiredLocation.X, 0), measureBounds.Width - reduceBoundsWidth),
                       Math.Min(Math.Max(itemDesiredLocation.Y, 0), measureBounds.Height - reduceBoundsHeight)));
        }
Exemplo n.º 9
0
        public virtual void OrganiseOnDragStarted(DragablzItemsControl requestor, Size measureBounds,
                                                  IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem)
        {
            if (siblingItems == null)
            {
                throw new ArgumentNullException("siblingItems");
            }
            if (dragItem == null)
            {
                throw new ArgumentNullException("dragItem");
            }

            _siblingItemLocationOnDragStart = siblingItems.Select(GetLocationInfo).ToDictionary(loc => loc.Item);
        }
Exemplo n.º 10
0
        public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> items)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            OrganiseInternal(
                requestor,
                measureBounds,
                items.Select((di, idx) => new Tuple <int, DragablzItem>(idx, di))
                .OrderBy(tuple => tuple,
                         MultiComparer <Tuple <int, DragablzItem> > .Ascending(tuple => _getLocation(tuple.Item2))
                         .ThenAscending(tuple => tuple.Item1))
                .Select(tuple => tuple.Item2));
        }
        private void OrganiseInternal(DragablzItemsControl requestor, Size measureBounds,
                                      IEnumerable <DragablzItem> items)
        {
            var currentCoord = 0.0;
            var z            = int.MaxValue;
            var logicalIndex = 0;

            foreach (var newItem in items)
            {
                Panel.SetZIndex(newItem, newItem.IsSelected ? int.MaxValue : --z);
                SetLocation(newItem, currentCoord);
                newItem.LogicalIndex = logicalIndex++;
                newItem.Measure(measureBounds);
                currentCoord += _getDesiredSize(newItem) + _itemOffset;
            }
        }
Exemplo n.º 12
0
        public virtual Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation,
            Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize)
        {
            var fixedItems = requestor.FixedItemCount;
            var lowerBound = fixedItems == 0
                ? -1d
                : GetLocationInfo(requestor.DragablzItems()
                    .Take(fixedItems)
                    .Last()).End + _itemOffset - 1;

            return new Point(
                _orientation == Orientation.Vertical
                    ? 0
                    : Math.Min(Math.Max(lowerBound, itemDesiredLocation.X), (measureBounds.Width) + 1),
                _orientation == Orientation.Horizontal
                    ? 0
                    : Math.Min(Math.Max(lowerBound, itemDesiredLocation.Y), (measureBounds.Height) + 1)
                );
        }
Exemplo n.º 13
0
        public virtual Point ConstrainLocation(DragablzItemsControl requestor, Size measureBounds, Point itemCurrentLocation,
                                               Size itemCurrentSize, Point itemDesiredLocation, Size itemDesiredSize)
        {
            var fixedItems = requestor.FixedItemCount;
            var lowerBound = fixedItems == 0
                ? -1d
                : GetLocationInfo(requestor.DragablzItems()
                                  .Take(fixedItems)
                                  .Last()).End + _itemOffset - 1;

            return(new Point(
                       _orientation == Orientation.Vertical
                    ? 0
                    : Math.Min(Math.Max(lowerBound, itemDesiredLocation.X), (measureBounds.Width) + 1),
                       _orientation == Orientation.Horizontal
                    ? 0
                    : Math.Min(Math.Max(lowerBound, itemDesiredLocation.Y), (measureBounds.Height) + 1)
                       ));
        }
Exemplo n.º 14
0
        public virtual Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable <DragablzItem> items)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            var size = new Size(double.PositiveInfinity, double.PositiveInfinity);

            double width = 0, height = 0;
            var    isFirst = true;

            foreach (var dragablzItem in items)
            {
                dragablzItem.Measure(size);
                if (_orientation == Orientation.Horizontal)
                {
                    width += !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Width : dragablzItem.ActualWidth;
                    if (!isFirst)
                    {
                        width += _itemOffset;
                    }
                    height = Math.Max(height,
                                      !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Height : dragablzItem.ActualHeight);
                }
                else
                {
                    width = Math.Max(width,
                                     !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Width : dragablzItem.ActualWidth);
                    height += !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Height : dragablzItem.ActualHeight;
                    if (!isFirst)
                    {
                        height += _itemOffset;
                    }
                }

                isFirst = false;
            }

            return(new Size(Math.Max(width, 0), Math.Max(height, 0)));
        }
Exemplo n.º 15
0
        private void OrganiseInternal(DragablzItemsControl requestor, Size measureBounds,
                                      IEnumerable <DragablzItem> items)
        {
            var currentCoord = 0.0;
            var z            = int.MaxValue;
            var logicalIndex = 0;

            foreach (var newItem in items)
            {
                Panel.SetZIndex(newItem, newItem.IsSelected ? int.MaxValue : --z);
                SetLocation(newItem, newItem.IsDropTargetFound ? _getLocation(newItem) : currentCoord);
                newItem.LogicalIndex = logicalIndex++;
                newItem.Measure(measureBounds);
                var desiredSize = _getDesiredSize(newItem);
                if (desiredSize == 0.0)
                {
                    desiredSize = 1.0;                       //no measure? create something to help sorting
                }
                currentCoord += desiredSize + _itemOffset;
            }
        }
Exemplo n.º 16
0
        public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds,
            List<DragablzItem> siblingItems, DragablzItem dragablzItem)
        {

        }
Exemplo n.º 17
0
 public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem)
 {
 }
Exemplo n.º 18
0
 public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds,
                                               List <DragablzItem> siblingItems, DragablzItem dragablzItem)
 {
 }
Exemplo n.º 19
0
 public virtual Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable <DragablzItem> items)
 {
     return(availableSize);
 }
Exemplo n.º 20
0
        public void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable<DragablzItem> items)
        {

        }
Exemplo n.º 21
0
 internal static TabablzControl GetOwnerOfHeaderItems(DragablzItemsControl itemsControl)
 {
     return(LoadedInstances.FirstOrDefault(t => Equals(t._dragablzItemsControl, itemsControl)));
 }
Exemplo n.º 22
0
 private bool ShouldDragWindow(DragablzItemsControl sourceOfDragItemsControl)
 {
     return(Items.Count == 1 &&
            (InterTabController == null || InterTabController.MoveWindowWithSolitaryTabs) &&
            !Layout.IsContainedWithinBranch(sourceOfDragItemsControl));
 }
Exemplo n.º 23
0
 public void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable<DragablzItem> siblingItems, DragablzItem dragItem)
 {
     
 }
Exemplo n.º 24
0
        public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IEnumerable<DragablzItem> items)
        {
            if (items == null) throw new ArgumentNullException("items");

            OrganiseInternal(
                requestor, 
                measureBounds,
                items.Select((di, idx) => new Tuple<int, DragablzItem>(idx, di))
                        .OrderBy(tuple => tuple,
                            MultiComparer<Tuple<int, DragablzItem>>.Ascending(tuple => _getLocation(tuple.Item2))
                                .ThenAscending(tuple => tuple.Item1))
                        .Select(tuple => tuple.Item2));            
        }
Exemplo n.º 25
0
 public Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable<DragablzItem> items)
 {
     return availableSize;
 }
Exemplo n.º 26
0
        public override void OnApplyTemplate()
        {
            if (_templateSubscription != null)
                _templateSubscription.Dispose();
            _templateSubscription = Disposable.Empty;

            _dragablzItemsControl = GetTemplateChild(HeaderItemsControlPartName) as DragablzItemsControl;
            if (_dragablzItemsControl != null)
            {
                _dragablzItemsControl.ItemContainerGenerator.StatusChanged += ItemContainerGeneratorOnStatusChanged;
                _templateSubscription =
                    Disposable.Create(
                        () =>
                            _dragablzItemsControl.ItemContainerGenerator.StatusChanged -=
                                ItemContainerGeneratorOnStatusChanged);

                _dragablzItemsControl.ContainerCustomisations = new ContainerCustomisations(null, PrepareChildContainerForItemOverride);
            }

            if (SelectedItem == null)
                SetCurrentValue(SelectedItemProperty, Items.OfType<object>().FirstOrDefault());

            _itemsHolder = GetTemplateChild(ItemsHolderPartName) as Panel;
            UpdateSelectedItem();
            MarkWrappedTabItems();
            MarkInitialSelection();

            base.OnApplyTemplate();
        }
Exemplo n.º 27
0
        public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable<DragablzItem> items)
        {
            if (items == null) throw new ArgumentNullException("items");

            OrganiseInternal(
                requestor,
                measureBounds,
                items);
        }
Exemplo n.º 28
0
 private void OrganiseInternal(DragablzItemsControl requestor, Size measureBounds,
     IEnumerable<DragablzItem> items)
 {
     var currentCoord = 0.0;
     var z = int.MaxValue;
     var logicalIndex = 0;
     foreach (var newItem in items)
     {
         Panel.SetZIndex(newItem, newItem.IsSelected ? int.MaxValue : --z);
         SetLocation(newItem, currentCoord);
         newItem.LogicalIndex = logicalIndex++;
         newItem.Measure(measureBounds);
         var desiredSize = _getDesiredSize(newItem);
         if (desiredSize == 0.0) desiredSize = 1.0; //no measure? create something to help sorting
         currentCoord += desiredSize + _itemOffset;
     }
 }
Exemplo n.º 29
0
        public virtual void OrganiseOnDragStarted(DragablzItemsControl requestor, Size measureBounds,
            IEnumerable<DragablzItem> siblingItems, DragablzItem dragItem)
        {
            if (siblingItems == null) throw new ArgumentNullException("siblingItems");
            if (dragItem == null) throw new ArgumentNullException("dragItem");

            _siblingItemLocationOnDragStart = siblingItems.Select(GetLocationInfo).ToDictionary(loc => loc.Item);
        }
Exemplo n.º 30
0
        public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds,
            IEnumerable<DragablzItem> siblingItems, DragablzItem dragItem)
        {
            if (siblingItems == null) throw new ArgumentNullException("siblingItems");
            var currentLocations = siblingItems
                .Select(GetLocationInfo)
                .Union(new[] {GetLocationInfo(dragItem)})
                .OrderBy(loc => loc.Item == dragItem ? loc.Start : _siblingItemLocationOnDragStart[loc.Item].Start);

            var currentCoord = 0.0;
            var z = int.MaxValue;
            var logicalIndex = 0;
            foreach (var location in currentLocations)
            {
                SetLocation(location.Item, currentCoord);
                currentCoord += _getDesiredSize(location.Item) + _itemOffset;
                Panel.SetZIndex(location.Item, --z);
                location.Item.LogicalIndex = logicalIndex++;
            }
            Panel.SetZIndex(dragItem, int.MaxValue);
        }
Exemplo n.º 31
0
 private bool ShouldDragWindow(DragablzItemsControl sourceOfDragItemsControl)
 {
     return (Items.Count == 1
             && (InterTabController == null || InterTabController.MoveWindowWithSolitaryTabs)
             && !Layout.IsContainedWithinBranch(sourceOfDragItemsControl));
 }
Exemplo n.º 32
0
        public virtual Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable<DragablzItem> items)
        {
            if (items == null) throw new ArgumentNullException("items");

            var size = new Size(double.PositiveInfinity, double.PositiveInfinity);

            double width = 0, height = 0;
            var isFirst = true;
            foreach (var dragablzItem in items)
            {
                dragablzItem.Measure(size);
                if (_orientation == Orientation.Horizontal)
                {
                    width += !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Width : dragablzItem.ActualWidth;
                    if (!isFirst)
                        width += _itemOffset;
                    height = Math.Max(height,
                        !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Height : dragablzItem.ActualHeight);
                }
                else
                {
                    width = Math.Max(width,
                        !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Width : dragablzItem.ActualWidth);
                    height += !dragablzItem.IsLoaded ? dragablzItem.DesiredSize.Height : dragablzItem.ActualHeight;
                    if (!isFirst)
                        height += _itemOffset;
                }

                isFirst = false;
            }

            return new Size(Math.Max(width, 0), Math.Max(height, 0));
        }
Exemplo n.º 33
0
 internal static TabablzControl GetOwnerOfHeaderItems(DragablzItemsControl itemsControl)
 {
     return LoadedInstances.FirstOrDefault(t => Equals(t._dragablzItemsControl, itemsControl));
 }
Exemplo n.º 34
0
 public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items)
 {
 }