コード例 #1
0
ファイル: TabablzControl.cs プロジェクト: strohlaj/Dragablz
        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();
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #5
0
ファイル: CanvasOrganiser.cs プロジェクト: CensoredHF/Snappie
        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);
        }
コード例 #6
0
        public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            OrganiseInternal(
                requestor,
                measureBounds,
                items);
        }
コード例 #7
0
ファイル: CanvasOrganiser.cs プロジェクト: CensoredHF/Snappie
        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));
        }
コード例 #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)));
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #11
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);
                currentCoord += _getDesiredSize(newItem) + _itemOffset;
            }
        }
コード例 #12
0
ファイル: StackOrganiser.cs プロジェクト: ntrung90/Dragablz
        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)
                );
        }
コード例 #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)
                       ));
        }
コード例 #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)));
        }
コード例 #15
0
ファイル: StackOrganiser.cs プロジェクト: highway-it/Dragablz
        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;
            }
        }
コード例 #16
0
        public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds,
            List<DragablzItem> siblingItems, DragablzItem dragablzItem)
        {

        }
コード例 #17
0
 public virtual void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable <DragablzItem> siblingItems, DragablzItem dragItem)
 {
 }
コード例 #18
0
 public virtual void OrganiseOnMouseDownWithin(DragablzItemsControl requestor, Size measureBounds,
                                               List <DragablzItem> siblingItems, DragablzItem dragablzItem)
 {
 }
コード例 #19
0
 public virtual Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable <DragablzItem> items)
 {
     return(availableSize);
 }
コード例 #20
0
ファイル: CanvasOrganiser.cs プロジェクト: CensoredHF/Snappie
        public void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable<DragablzItem> items)
        {

        }
コード例 #21
0
ファイル: TabablzControl.cs プロジェクト: strohlaj/Dragablz
 internal static TabablzControl GetOwnerOfHeaderItems(DragablzItemsControl itemsControl)
 {
     return(LoadedInstances.FirstOrDefault(t => Equals(t._dragablzItemsControl, itemsControl)));
 }
コード例 #22
0
ファイル: TabablzControl.cs プロジェクト: jack2060/Dragablz
 private bool ShouldDragWindow(DragablzItemsControl sourceOfDragItemsControl)
 {
     return(Items.Count == 1 &&
            (InterTabController == null || InterTabController.MoveWindowWithSolitaryTabs) &&
            !Layout.IsContainedWithinBranch(sourceOfDragItemsControl));
 }
コード例 #23
0
ファイル: CanvasOrganiser.cs プロジェクト: CensoredHF/Snappie
 public void OrganiseOnDragCompleted(DragablzItemsControl requestor, Size measureBounds, IEnumerable<DragablzItem> siblingItems, DragablzItem dragItem)
 {
     
 }
コード例 #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));            
        }
コード例 #25
0
ファイル: CanvasOrganiser.cs プロジェクト: CensoredHF/Snappie
 public Size Measure(DragablzItemsControl requestor, Size availableSize, IEnumerable<DragablzItem> items)
 {
     return availableSize;
 }
コード例 #26
0
ファイル: TabablzControl.cs プロジェクト: tleviathan/Dragablz
        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();
        }
コード例 #27
0
        public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable<DragablzItem> items)
        {
            if (items == null) throw new ArgumentNullException("items");

            OrganiseInternal(
                requestor,
                measureBounds,
                items);
        }
コード例 #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;
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #31
0
ファイル: TabablzControl.cs プロジェクト: tleviathan/Dragablz
 private bool ShouldDragWindow(DragablzItemsControl sourceOfDragItemsControl)
 {
     return (Items.Count == 1
             && (InterTabController == null || InterTabController.MoveWindowWithSolitaryTabs)
             && !Layout.IsContainedWithinBranch(sourceOfDragItemsControl));
 }
コード例 #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));
        }
コード例 #33
0
ファイル: TabablzControl.cs プロジェクト: tleviathan/Dragablz
 internal static TabablzControl GetOwnerOfHeaderItems(DragablzItemsControl itemsControl)
 {
     return LoadedInstances.FirstOrDefault(t => Equals(t._dragablzItemsControl, itemsControl));
 }
コード例 #34
0
 public virtual void Organise(DragablzItemsControl requestor, Size measureBounds, IOrderedEnumerable <DragablzItem> items)
 {
 }