Пример #1
0
 protected override void OnPreviewDragDrop(RadDropEventArgs e)
 {
     base.OnPreviewDragDrop(e);
     if (e.Handled || this.owner.ListSource.IsDataBound)
     {
         return;
     }
     if ((this.owner.EnableGrouping || this.owner.EnableCustomGrouping) && this.owner.ShowGroups || (this.owner.EnableSorting || this.owner.ListSource.IsDataBound))
     {
         int num = (int)RadMessageBox.Show("DragDrop is not supported in grouped, sorted or data-bound mode. \nPlease handle the ListViewElement.DragDropService.PreviewDragDrop event manually \nand set e.Handled = true  or just set the AllowDragDrop property to false to disable this message.", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
     }
     else
     {
         RadElement             hitTarget1         = e.HitTarget as RadElement;
         BaseListViewVisualItem listViewVisualItem = e.HitTarget as BaseListViewVisualItem;
         BaseListViewElement    hitTarget2         = e.HitTarget as BaseListViewElement;
         if (hitTarget1 != null)
         {
             Point control = hitTarget1.PointToControl(e.DropLocation);
             if (listViewVisualItem == null)
             {
                 listViewVisualItem = this.owner.ViewElement.GetVisualItemAt(control);
             }
         }
         if (listViewVisualItem != null && listViewVisualItem.Data.Owner != this.owner || hitTarget2 != null && hitTarget2.Owner != this.owner)
         {
             this.HandleDropBetweenListViews(e);
         }
         else
         {
             this.HandleDragDrop(e);
         }
         this.owner.InvalidateMeasure(true);
     }
 }
Пример #2
0
 public SimpleListViewContainer(BaseListViewElement owner)
     : base(owner)
 {
 }
Пример #3
0
        protected virtual void HandleDragDrop(RadDropEventArgs e)
        {
            RadElement             hitTarget1    = e.HitTarget as RadElement;
            BaseListViewVisualItem targetElement = e.HitTarget as BaseListViewVisualItem;
            BaseListViewElement    hitTarget2    = e.HitTarget as BaseListViewElement;

            if (hitTarget1 != null)
            {
                targetElement = this.owner.ViewElement.GetVisualItemAt(hitTarget1.PointToControl(e.DropLocation));
            }
            ListViewDataItem listViewDataItem = targetElement?.Data;
            bool             flag             = false;

            if (listViewDataItem != null)
            {
                listViewDataItem.Owner.ListSource.BeginUpdate();
                if (this.owner.ViewElement.ShouldDropAfter(targetElement, e.DropLocation))
                {
                    ITraverser <ListViewDataItem> enumerator = this.owner.ViewElement.Scroller.Traverser.GetEnumerator() as ITraverser <ListViewDataItem>;
                    enumerator.Position = (object)listViewDataItem;
                    flag             = !enumerator.MoveNext();
                    listViewDataItem = enumerator.Current;
                }
                int newIndex = this.owner.ListSource.IndexOf(listViewDataItem);
                if (this.draggedItems != null)
                {
                    foreach (ListViewDataItem draggedItem in this.draggedItems)
                    {
                        int oldIndex = this.owner.ListSource.IndexOf(draggedItem);
                        this.owner.ListSource.Move(oldIndex, newIndex);
                        if (oldIndex > newIndex)
                        {
                            ++newIndex;
                        }
                    }
                }
                else if (this.draggedItem != null)
                {
                    int num1 = this.owner.ListSource.IndexOf(this.draggedItem);
                    if (flag)
                    {
                        int num2 = this.owner.ListSource.Count - 1;
                    }
                    else if (num1 < newIndex)
                    {
                        --newIndex;
                    }
                    this.owner.ListSource.Move(this.owner.ListSource.IndexOf(this.draggedItem), newIndex);
                }
                listViewDataItem.Owner.ListSource.EndUpdate();
                listViewDataItem.Owner.ViewElement.Scroller.UpdateScrollValue();
            }
            else
            {
                if (hitTarget2 == null)
                {
                    return;
                }
                hitTarget2.Owner.ListSource.BeginUpdate();
                if (this.draggedItems != null)
                {
                    foreach (ListViewDataItem draggedItem in this.draggedItems)
                    {
                        hitTarget2.Owner.ListSource.Move(this.owner.ListSource.IndexOf(draggedItem), this.owner.ListSource.Count - 1);
                    }
                }
                else if (this.draggedItem != null)
                {
                    hitTarget2.Owner.ListSource.Move(this.owner.ListSource.IndexOf(this.draggedItem), this.owner.ListSource.Count - 1);
                }
                hitTarget2.Owner.ListSource.EndUpdate();
                hitTarget2.Owner.ViewElement.Scroller.UpdateScrollValue();
            }
        }
Пример #4
0
        protected virtual void HandleDropBetweenListViews(RadDropEventArgs e)
        {
            RadElement             hitTarget           = e.HitTarget as RadElement;
            BaseListViewVisualItem listViewVisualItem  = e.HitTarget as BaseListViewVisualItem;
            BaseListViewElement    baseListViewElement = e.HitTarget as BaseListViewElement;

            if (listViewVisualItem != null && baseListViewElement == null)
            {
                baseListViewElement = listViewVisualItem.Data.Owner.ViewElement;
            }
            ListViewDataItem data;

            if (hitTarget != null)
            {
                Point control = hitTarget.PointToControl(e.DropLocation);
                if (listViewVisualItem == null)
                {
                    listViewVisualItem = baseListViewElement.GetVisualItemAt(control);
                }
                data = listViewVisualItem?.Data;
            }
            else
            {
                data = listViewVisualItem?.Data;
            }
            if (data != null)
            {
                data.Owner.ListSource.BeginUpdate();
                int index = data.Owner.ListSource.IndexOf(data);
                if (e.DropLocation.Y > listViewVisualItem.Size.Height / 2)
                {
                    ++index;
                }
                if (this.draggedItems != null)
                {
                    foreach (ListViewDataItem draggedItem in this.draggedItems)
                    {
                        this.owner.ListSource.Remove(draggedItem);
                        data.Owner.ListSource.Insert(index, draggedItem);
                        ++index;
                    }
                }
                else if (this.draggedItem != null)
                {
                    this.owner.ListSource.Remove(this.draggedItem);
                    data.Owner.ListSource.Insert(index, this.draggedItem);
                }
                data.Owner.ListSource.EndUpdate();
                data.Owner.ViewElement.Scroller.UpdateScrollValue();
            }
            else
            {
                if (baseListViewElement == null)
                {
                    return;
                }
                baseListViewElement.Owner.ListSource.BeginUpdate();
                if (this.draggedItems != null)
                {
                    foreach (ListViewDataItem draggedItem in this.draggedItems)
                    {
                        this.owner.ListSource.Remove(draggedItem);
                        baseListViewElement.Owner.ListSource.Add(draggedItem);
                    }
                }
                else if (this.draggedItem != null)
                {
                    this.owner.ListSource.Remove(this.draggedItem);
                    baseListViewElement.Owner.ListSource.Add(this.draggedItem);
                }
                baseListViewElement.Owner.ListSource.EndUpdate();
                baseListViewElement.Owner.ViewElement.Scroller.UpdateScrollValue();
            }
        }
Пример #5
0
 public DetailsListViewContainer(BaseListViewElement owner)
     : base(owner)
 {
 }
Пример #6
0
 public IconListViewContainer(BaseListViewElement owner) : base(owner)
 {
 }
 public ListViewVirtualizedElementProvider(BaseListViewElement owner)
 {
     this.owner = owner;
 }
Пример #8
0
 public BaseListViewContainer(BaseListViewElement owner)
 {
     this.owner = owner;
 }