예제 #1
0
 protected override void OnKeyPress(KeyPressEventArgs e)
 {
     if (e.KeyChar == (Char)Keys.Delete)
     {
         ReorderEventArgs args    = new ReorderEventArgs();
         List <int>       indexes = new List <int>();
         foreach (CListViewItem item in this.SelectedItems)
         {
             indexes.Add(this.Items.IndexOf(item));
         }
         args.Indexes = indexes.ToArray();
         if (ItemsDeleting != null)
         {
             ItemsDeleting(this, args);
         }
         if (!args.Cancel)
         {
             foreach (int i in indexes)
             {
                 this.Items.RemoveAt(i);
             }
             if (ItemsDeleted != null)
             {
                 ItemsDeleted(this, args);
             }
         }
     }
     base.OnKeyPress(e);
 }
예제 #2
0
 protected virtual void OnReorder(ReorderEventArgs e)
 {
     if (Reorder != null)
     {
         Reorder(this, e);
     }
 }
예제 #3
0
        private void listbox_Reorder(object sender, ReorderEventArgs args)
        {
            var reorderListBox = (ReorderListBox)args.OriginalSource;

            var draggingBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ItemContainer);
            var toBrush       = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ToContainer);

            _brushes.Move(_brushes.IndexOf(draggingBrush), _brushes.IndexOf(toBrush));
        }
예제 #4
0
        private void listbox_Reorder(object sender, ReorderEventArgs args)
        {
            var reorderListBox = (ReorderListBox)args.OriginalSource;

            var draggingBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ItemContainer);
            var toBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ToContainer);

            _brushes.Move(_brushes.IndexOf(draggingBrush), _brushes.IndexOf(toBrush));
        }
예제 #5
0
 void CListView_DragDrop(object sender, DragEventArgs e)
 {
     HoveredElement = GetElementUnderPosition(this.PointToClient(new Point(e.X, e.Y)));
     this.mouseDown = false;
     if (DragElements.Count > 0)
     {
         if (HoveredElement != null && AllowsReoreder)
         {
             CListViewItem    context    = DragElements[0];
             CListViewItem    targetSite = HoveredElement;
             List <int>       indexes    = new List <int>();
             ReorderEventArgs args       = new ReorderEventArgs();
             args.Elements    = DragElements;
             args.Position    = this.Items.IndexOf(DragElements[0]);
             args.NewPosition = this.Items.IndexOf(HoveredElement);
             if (BeforeReorder != null)
             {
                 BeforeReorder(this, args);
             }
             if (BeforeReorder == null || !args.Cancel)
             {
                 // Reorder the elements in reality
                 foreach (CListViewItem elm in DragElements)
                 {
                     indexes.Add(this.Items.IndexOf(elm));
                     this.Items.Remove(elm);
                 }
                 try
                 {
                     for (int i = 0; i < DragElements.Count; i++)
                     {
                         CListViewItem element = DragElements[i];
                         this.Items.Insert(i + args.NewPosition, element);
                     }
                 }
                 catch (Exception ex)
                 {
                     for (int i = 0; i < DragElements.Count; i++)
                     {
                         CListViewItem element = DragElements[i];
                         this.Items.Insert(i + args.Position, element);
                     }
                 }
                 args.Indexes = indexes.ToArray();
                 if (Reordered != null)
                 {
                     Reordered(this, args);
                 }
             }
         }
         this.Refresh();
     }
     this.Parent.Refresh();
 }
예제 #6
0
        private void ListBoxReorderRequested(object sender, ReorderEventArgs e)
        {
            var model          = DataContext as TrackSourceSection;
            var reorderListBox = (ReorderListBox)e.OriginalSource;
            var dragginItem    = (TrackSourceConfig)reorderListBox.ItemContainerGenerator.ItemFromContainer(e.ItemContainer);
            var toItem         = (TrackSourceConfig)reorderListBox.ItemContainerGenerator.ItemFromContainer(e.ToContainer);

            if (model != null)
            {
                model.ChangeTrackSourcePriority(dragginItem, toItem);
            }
        }
예제 #7
0
        private void m_filteredList_ReorderRequested(object sender, ReorderEventArgs args)
        {
            var tasks = DataContext as TaskListViewModel;

            if (tasks != null)
            {
                var item   = ((TaskViewModel)m_filteredList.ItemContainerGenerator.ItemFromContainer(args.ItemContainer)).Task;
                var toItem = ((TaskViewModel)m_filteredList.ItemContainerGenerator.ItemFromContainer(args.ToContainer)).Task;
                tasks.MoveTask(item, toItem);
            }
            m_scrollDecorator.IsDraggingEnabled = true;
        }
예제 #8
0
        void CListView_DragDrop(object sender, DragEventArgs e)
        {
            HoveredElement = GetElementUnderPosition(this.PointToClient(new Point(e.X, e.Y)));
            this.mouseDown = false;
            if (DragElements.Count > 0)
            {
                if (HoveredElement != null && AllowsReoreder)
                {

                    CListViewItem context = DragElements[0];
                    CListViewItem targetSite = HoveredElement;
                    List<int> indexes = new List<int>();
                    ReorderEventArgs args = new ReorderEventArgs();
                    args.Elements = DragElements;
                    args.Position = this.Items.IndexOf(DragElements[0]);
                    args.NewPosition = this.Items.IndexOf(HoveredElement);
                    if (BeforeReorder != null)
                        BeforeReorder(this, args);
                    if (BeforeReorder == null || !args.Cancel)
                    {

                        // Reorder the elements in reality
                        foreach (CListViewItem elm in DragElements)
                        {
                            indexes.Add(this.Items.IndexOf(elm));
                            this.Items.Remove(elm);
                        }
                        try
                        {
                            for (int i = 0; i < DragElements.Count; i++)
                            {
                                CListViewItem element = DragElements[i];
                                this.Items.Insert(i + args.NewPosition, element);
                            }
                        }
                        catch (Exception ex)
                        {
                            for (int i = 0; i < DragElements.Count; i++)
                            {
                                CListViewItem element = DragElements[i];
                                this.Items.Insert(i + args.Position, element);
                            }
                        }
                        args.Indexes = indexes.ToArray();
                        if (Reordered != null)
                            Reordered(this, args);
                    }
                }
                this.Refresh();

            }
            this.Parent.Refresh();
        }
예제 #9
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == (Char)Keys.Delete)
            {
                ReorderEventArgs args = new ReorderEventArgs();
                List<int> indexes = new List<int>();
                foreach (CListViewItem item in this.SelectedItems)
                {
                    indexes.Add(this.Items.IndexOf(item));
                }
                args.Indexes = indexes.ToArray();
                if (ItemsDeleting != null)
                {
                    ItemsDeleting(this, args);

                }
                if (!args.Cancel)
                {
                    foreach (int i in indexes)
                    {
                        this.Items.RemoveAt(i);
                    }
                    if (ItemsDeleted != null)
                    {
                        ItemsDeleted(this, args);

                    }
                }

            } base.OnKeyPress(e);
        }