コード例 #1
0
 /// <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));
 }
コード例 #2
0
        /// <summary>
        /// Helper method to add an item next to an existing item.
        /// </summary>
        /// <remarks>
        /// Due to the organisable nature of the control, the order of items may not reflect the order in the source collection.  This method
        /// will add items to the source collection, managing their initial appearance on screen at the same time.
        /// If you are using a <see cref="InterTabController.InterTabClient" /> this will be used to add the item into the source collection.
        /// </remarks>
        /// <param name="item">New item to add.</param>
        /// <param name="nearItem">Existing object/tab item content which defines which tab control should be used to add the object.</param>
        /// <param name="addLocationHint">Location, relative to the <paramref name="nearItem" /> object</param>
        public static void AddItem(object item, object nearItem, AddLocationHint addLocationHint)
        {
            if (nearItem == null)
            {
                throw new ArgumentNullException(nameof(nearItem));
            }

            var existingLocation = FindItem(item).SingleOrDefault( );

            if (existingLocation == null)
            {
                throw new ArgumentException("Did not find precisely one instance of adjacentTo", nameof(nearItem));
            }

            existingLocation.TabControl.AddToSource(item);
            existingLocation.TabControl._dragablzItemsControl?.MoveItem(new MoveItemRequest(item, nearItem, addLocationHint));
        }
コード例 #3
0
        /// <summary>
        /// Helper method to add an item next to an existing item.
        /// </summary>
        /// <remarks>
        /// Due to the organizable nature of the control, the order of items may not reflect the order in the source collection.  This method
        /// will add items to the source collection, managing their initial appearance on screen at the same time.
        /// If you are using a <see cref="InterTabController.InterTabClient"/> this will be used to add the item into the source collection.
        /// </remarks>
        /// <param name="item">New item to add.</param>
        /// <param name="nearItem">Existing object/tab item content which defines which tab control should be used to add the object.</param>
        /// <param name="addLocationHint">Location, relative to the <paramref name="nearItem"/> object</param>
        public static void AddItem(object item, object nearItem, AddLocationHint addLocationHint)
        {
            if (nearItem == null)
            {
                throw new ArgumentNullException(nameof(nearItem));
            }

            var existingLocation = GetLoadedInstances().SelectMany(dockControl =>
                                                                   (dockControl.Items).OfType <object>()
                                                                   .Select(existingObject => new { docControl = dockControl, existingObject }))
                                   .SingleOrDefault(a => nearItem.Equals(a.existingObject));

            if (existingLocation == null)
            {
                throw new ArgumentException("Did not find precisely one instance of adjacentTo", nameof(nearItem));
            }

            existingLocation.docControl._dockItemsControl?.MoveItem(new MoveItemRequest(item, nearItem, addLocationHint));
        }
コード例 #4
0
ファイル: TabablzControl.cs プロジェクト: tleviathan/Dragablz
        /// <summary>
        /// Helper method to add an item next to an existing item.
        /// </summary>
        /// <remarks>
        /// Due to the organisable nature of the control, the order of items may not reflect the order in the source collection.  This method
        /// will add items to the source collection, managing their initial appearance on screen at the same time. 
        /// If you are using a <see cref="InterTabController.InterTabClient"/> this will be used to add the item into the source collection.
        /// </remarks>
        /// <param name="item">New item to add.</param>
        /// <param name="nearItem">Existing object/tab item content which defines which tab control should be used to add the object.</param>
        /// <param name="addLocationHint">Location, relative to the <paramref name="nearItem"/> object</param>
        public static void AddItem(object item, object nearItem, AddLocationHint addLocationHint)
        {
            if (nearItem == null) throw new ArgumentNullException("nearItem");

            var existingLocation = GetLoadedInstances().SelectMany(tabControl =>
                (tabControl.ItemsSource ?? tabControl.Items).OfType<object>()
                    .Select(existingObject => new {tabControl, existingObject}))
                .SingleOrDefault(a => nearItem.Equals(a.existingObject));

            if (existingLocation == null)
                throw new ArgumentException("Did not find precisely one instance of adjacentTo", "nearItem");

            existingLocation.tabControl.AddToSource(item);
            if (existingLocation.tabControl._dragablzItemsControl != null)
                existingLocation.tabControl._dragablzItemsControl.MoveItem(new MoveItemRequest(item, nearItem, addLocationHint));
        }
コード例 #5
0
 public MoveItemRequest(object item, object context, AddLocationHint addLocationHint)
 {
     _item            = item;
     _context         = context;
     _addLocationHint = addLocationHint;
 }
コード例 #6
0
 /// <summary>
 /// Adds an item to the underlying source, displaying in a specific position in rendered control.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="addLocationHint"></param>
 public void AddToSource(object item, AddLocationHint addLocationHint)
 {
     AddToSource(item, null, addLocationHint);
 }
コード例 #7
0
ファイル: MoveItemRequest.cs プロジェクト: CensoredHF/Snappie
 public MoveItemRequest(object item, object context, AddLocationHint addLocationHint)
 {
     _item = item;
     _context = context;
     _addLocationHint = addLocationHint;
 }