// Performs custom drop logic for the top ListView. void dragMgr_ProcessDrop( object sender, ProcessDropEventArgs<Task> e ) { // This shows how to customize the behavior of a drop. // Here we perform a swap, instead of just moving the dropped item. int higherIdx = Math.Max( e.OldIndex, e.NewIndex ); int lowerIdx = Math.Min( e.OldIndex, e.NewIndex ); if( lowerIdx < 0 ) { // The item came from the lower ListView // so just insert it. e.ItemsSource.Insert( higherIdx, e.DataItem ); } else { // null values will cause an error when calling Move. // It looks like a bug in ObservableCollection to me. if( e.ItemsSource[lowerIdx] == null || e.ItemsSource[higherIdx] == null ) return; // The item came from the ListView into which // it was dropped, so swap it with the item // at the target index. e.ItemsSource.Move( lowerIdx, higherIdx ); e.ItemsSource.Move( higherIdx - 1, lowerIdx ); } // Set this to 'Move' so that the OnListViewDrop knows to // remove the item from the other ListView. e.Effects = DragDropEffects.Move; }
// Performs custom drop logic for the top ListView. // 自定义Swap拖拽逻辑 void dragMgr_ProcessDrop(object sender, ProcessDropEventArgs <Task> e) { // This shows how to customize the behavior of a drop. // Here we perform a swap, instead of just moving the dropped item. int higherIdx = Math.Max(e.OldIndex, e.NewIndex); int lowerIdx = Math.Min(e.OldIndex, e.NewIndex); if (lowerIdx < 0) { // The item came from the lower ListView // so just insert it. e.ItemsSource.Insert(higherIdx, e.DataItem); } else { // null values will cause an error when calling Move. // It looks like a bug in ObservableCollection to me. if (e.ItemsSource[lowerIdx] == null || e.ItemsSource[higherIdx] == null) { return; } // The item came from the ListView into which // it was dropped, so swap it with the item // at the target index. e.ItemsSource.Move(lowerIdx, higherIdx); // 小索引值移动到大索引值会使受影响项的索引值都减1 e.ItemsSource.Move(higherIdx - 1, lowerIdx); // 大索引值移动到小索引值会使受影响项的索引值都加1 } // Set this to 'Move' so that the OnListViewDrop knows to // remove the item from the other ListView. e.Effects = DragDropEffects.Move; }
private void OnProcessDrop(object sender, ProcessDropEventArgs <ListViewItem> e) { if (e.OldIndex > -1) { mailbox.MoveMail(e.OldIndex, e.NewIndex); } e.Effects = DragDropEffects.Move; }
public void OnProcessDrop(object sender, ProcessDropEventArgs <ListViewItem> e) { if (e.OldIndex > -1) { pocket.MoveItem(e.OldIndex, e.NewIndex); } e.Effects = DragDropEffects.Move; }
public void OnProcessDrop(object sender, ProcessDropEventArgs <ListViewItem> e) { if (e.OldIndex > -1) { blockCase.MovePokeblock(e.OldIndex, e.NewIndex); } e.Effects = DragDropEffects.Move; }
private async void dragMgr_ProcessDrop(object sender, ProcessDropEventArgs <AnimationRigidBody> e) { // This shows how to customize the behavior of a drop. // Here we perform a swap, instead of just moving the dropped item. int higherIdx = Math.Max(e.OldIndex, e.NewIndex); int lowerIdx = Math.Min(e.OldIndex, e.NewIndex); if ((lowerIdx < 0) && (e.DataItem.Name == null)) { var name = await this.ShowInputAsync("Name", "Please specify unique animator name or hit cancel!"); //await this.ShowMessageAsync("Hello", "Hello " + result + "!"); //var sobj= new SpriteObject(txtSpriteName.Text); Debug.WriteLine("=> item = {0} {1}", e.DataItem.GetType().Name, e.DataItem.Name); AnimationRigidBody ani = Activator.CreateInstance(e.DataItem.GetType()) as AnimationRigidBody; ani.Name = name; (GObj as SpriteObject).AddAnimation(ani); // generates unique name if name==null AList.Add(ani); //lstAnimations.Items.Refresh(); // Resize Columns var gridView = lstAnimations.View as GridView; foreach (var column in gridView.Columns.Where(column => Double.IsNaN(column.Width))) { Contract.Assume(column != null); column.Width = column.ActualWidth; column.Width = Double.NaN; } // so just insert it. //e.ItemsSource.Insert(higherIdx, e.DataItem); } else { // null values will cause an error when calling Move. // It looks like a bug in ObservableCollection to me. if (e.ItemsSource[lowerIdx] == null || e.ItemsSource[higherIdx] == null) { return; } // The item came from the ListView into which // it was dropped, so swap it with the item // at the target index. e.ItemsSource.Move(lowerIdx, higherIdx); e.ItemsSource.Move(higherIdx - 1, lowerIdx); // update Sprite animation list (GObj as SpriteObject).SerializableAnimations = AList; } // Set this to 'Move' so that the OnListViewDrop knows to // remove the item from the other ListView. e.Effects = System.Windows.DragDropEffects.Move; }
private async void dragMgr_ProcessDrop(object sender, ProcessDropEventArgs<AnimationRigidBody> e) { // This shows how to customize the behavior of a drop. // Here we perform a swap, instead of just moving the dropped item. int higherIdx = Math.Max(e.OldIndex, e.NewIndex); int lowerIdx = Math.Min(e.OldIndex, e.NewIndex); if ((lowerIdx < 0) && (e.DataItem.Name == null)) { var name = await this.ShowInputAsync("Name", "Please specify unique animator name or hit cancel!"); //await this.ShowMessageAsync("Hello", "Hello " + result + "!"); //var sobj= new SpriteObject(txtSpriteName.Text); Debug.WriteLine("=> item = {0} {1}", e.DataItem.GetType().Name, e.DataItem.Name); AnimationRigidBody ani = Activator.CreateInstance(e.DataItem.GetType()) as AnimationRigidBody; ani.Name = name; (GObj as SpriteObject).AddAnimation(ani); // generates unique name if name==null AList.Add(ani) ; //lstAnimations.Items.Refresh(); // Resize Columns var gridView = lstAnimations.View as GridView; foreach (var column in gridView.Columns.Where(column => Double.IsNaN(column.Width))) { Contract.Assume(column != null); column.Width = column.ActualWidth; column.Width = Double.NaN; } // so just insert it. //e.ItemsSource.Insert(higherIdx, e.DataItem); } else { // null values will cause an error when calling Move. // It looks like a bug in ObservableCollection to me. if (e.ItemsSource[lowerIdx] == null || e.ItemsSource[higherIdx] == null) return; // The item came from the ListView into which // it was dropped, so swap it with the item // at the target index. e.ItemsSource.Move(lowerIdx, higherIdx); e.ItemsSource.Move(higherIdx - 1, lowerIdx); // update Sprite animation list (GObj as SpriteObject).SerializableAnimations = AList; } // Set this to 'Move' so that the OnListViewDrop knows to // remove the item from the other ListView. e.Effects = System.Windows.DragDropEffects.Move; }
public void OnProcessDrop(object sender, ProcessDropEventArgs <ListViewItem> e) { if (e.OldIndex > -1) { pokePC.MoveBox(e.OldIndex, e.NewIndex); boxes.Move(e.OldIndex, e.NewIndex); UpdateBoxNames(); pokeBoxControl.LoadBox(selectedBox, PokeManager.GetIndexOfGame(selectedBox.PokePC.GameSave)); } e.Effects = DragDropEffects.Move; }
void mgr_ProcessDrop(object sender, ProcessDropEventArgs <Stage> e) { e.ItemsSource.Move(e.OldIndex, e.NewIndex); try { foreach (Stage stage in e.ItemsSource) { stage.StageNumber = e.ItemsSource.IndexOf(stage); stage.Update(); } } catch (Exception ex) { MessageBox.Show("Kon stages niet herorderen in database"); Console.WriteLine(ex.Message); } }
void dragMgr_ProcessDrop(object sender, ProcessDropEventArgs <ScriptInfoItem> e) { int higherIdx = Math.Max(e.OldIndex, e.NewIndex); int lowerIdx = Math.Min(e.OldIndex, e.NewIndex); if (lowerIdx < 0) { e.ItemsSource.Insert(higherIdx, e.DataItem); } else { if (e.ItemsSource[lowerIdx] == null || e.ItemsSource[higherIdx] == null) { return; } e.ItemsSource.Move(lowerIdx, higherIdx); e.ItemsSource.Move(higherIdx - 1, lowerIdx); } e.Effects = DragDropEffects.Move; }
//private void lstSprites_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) //{ // // Store the mouse position // dragDropPoint = e.GetPosition(null); //} //private void lstSprites_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) //{ // Point pos = e.GetPosition(null); // Vector diff = dragDropPoint - pos; // if (e.LeftButton == MouseButtonState.Pressed && // ( Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || // Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) // { // // Get dragged item // System.Windows.Controls.ListView listView = sender as System.Windows.Controls.ListView; // var listViewItem = // FindAnchestor<System.Windows.Controls.ListViewItem>((DependencyObject)e.OriginalSource); // // Find the data behind the ListViewItem // SpriteObject sprite = listView.ItemContainerGenerator.ItemFromContainer(listViewItem) as SpriteObject; // // Initialize the drag & drop operation // System.Windows.DataObject dragData = new System.Windows.DataObject("SpriteObject", sprite ); // DragDrop.DoDragDrop(listViewItem, dragData, System.Windows.DragDropEffects.Move); // } //} //private static T FindAnchestor<T>(DependencyObject current) // where T : DependencyObject //{ // do // { // if (current is T) // { // return (T)current; // } // current = VisualTreeHelper.GetParent(current); // } // while (current != null); // return null; //} void dragMgr_ProcessDrop(object sender, ProcessDropEventArgs <IGameObject> e) { // This shows how to customize the behavior of a drop. // Here we perform a swap, instead of just moving the dropped item. int higherIdx = Math.Max(e.OldIndex, e.NewIndex); int lowerIdx = Math.Min(e.OldIndex, e.NewIndex); if (lowerIdx < 0) { Debug.WriteLine("=> item = {0} {1}", lowerIdx, sender.GetType().Name); // The item came from the lower ListView // so just insert it. //e.ItemsSource.Insert(higherIdx, e.DataItem); } else { // null values will cause an error when calling Move. // It looks like a bug in ObservableCollection to me. if (e.ItemsSource[lowerIdx] == null || e.ItemsSource[higherIdx] == null) { return; } // The item came from the ListView into which // it was dropped, so swap it with the item // at the target index. e.ItemsSource.Move(lowerIdx, higherIdx); e.ItemsSource.Move(higherIdx - 1, lowerIdx); } // Set this to 'Move' so that the OnListViewDrop knows to // remove the item from the other ListView. e.Effects = System.Windows.DragDropEffects.Move; ThisLevel.RemoveSpritesFrom(MainGFX); ThisLevel.AddSpritesTo(MainGFX); }
public void OnProcessDrop(object sender, ProcessDropEventArgs<ListViewItem> e) { if (e.OldIndex > -1) { blockCase.MovePokeblock(e.OldIndex, e.NewIndex); } e.Effects = DragDropEffects.Move; }
private void DragDropManager_ProcessDrop(object sender, ProcessDropEventArgs<ChallengeView> e) { e.ItemsSource.Move(e.OldIndex, e.NewIndex); challengesListview.SelectedItem = null; }
private void dragDropManager_ProcessDrop(object sender, ProcessDropEventArgs <ReleaseImagesEditor.ImageInfo> e) { this.release.Images.Clear(); this.release.Images.AddRange(this.Images.Select(i => i.Image)); }
private async void dragMgr_ProcessDrop( object sender, ProcessDropEventArgs<MpdFile> e ) { if (m_Mpc.Connected){ try{ await Task.Factory.StartNew(() => m_Mpc.Move(e.OldIndex, e.NewIndex)); }catch (Exception ex){ ShowException(ex); return; } } }
private void OnDrop(object sender, ProcessDropEventArgs <Tuple <string, string> > e) { AutoModes.Move(e.OldIndex, e.NewIndex); Refresh(); }
private void OnProcessDrop(object sender, ProcessDropEventArgs<ListViewItem> e) { if (e.OldIndex > -1) { mailbox.MoveMail(e.OldIndex, e.NewIndex); } e.Effects = DragDropEffects.Move; }
private void _dragMgr_ProcessDrop(object sender, ProcessDropEventArgs <LayoutForBinding> e) { try { Document mdiActiveDocument = AcApp.DocumentManager.MdiActiveDocument; if (mdiActiveDocument != null) { int newIndex = e.NewIndex; int oldIndex = e.OldIndex; if (e.ItemsSource[oldIndex] != null && e.ItemsSource[newIndex] != null) { if (!_showModel) { e.ItemsSource.Move(oldIndex, newIndex); int num = 1; foreach (LayoutForBinding itemsSource in e.ItemsSource) { itemsSource.TabOrder = num; num++; } } else if (!(oldIndex == 0 | newIndex == -1 | newIndex == 0)) { e.ItemsSource.Move(oldIndex, newIndex); int num1 = 0; foreach (LayoutForBinding layoutForBinding in e.ItemsSource) { layoutForBinding.TabOrder = num1; num1++; } } else { return; } using (mdiActiveDocument.LockDocument()) { using (Transaction transaction = mdiActiveDocument.Database.TransactionManager.StartTransaction()) { LayoutManager current = LayoutManager.Current; foreach (LayoutForBinding itemsSource1 in e.ItemsSource) { ObjectId layoutId = current.GetLayoutId(itemsSource1.LayoutName); Layout obj = transaction.GetObject(layoutId, OpenMode.ForWrite) as Layout; if (obj != null) { obj.TabOrder = itemsSource1.TabOrder; } } transaction.Commit(); } mdiActiveDocument.Editor.Regen(); } e.Effects = DragDropEffects.Move; } } } catch (Exception exception) { ExceptionBox.Show(exception); } }
void ListView_Drop(object sender, DragEventArgs e) { if (ItemUnderDragCursor != null) { ItemUnderDragCursor = null; } e.Effects = DragDropEffects.None; if (!e.Data.GetDataPresent(typeof(ItemType))) { return; } // Get the data object which was dropped. if (!(e.Data.GetData(typeof(ItemType)) is ItemType data)) { return; } // Get the ObservableCollection<ItemType> which contains the dropped data object. if (listView.ItemsSource is Collection.IObservableCollection <ItemType> itemsSource) { int oldIndex = itemsSource.IndexOf(data); int newIndex = IndexUnderDragCursor; if (newIndex < 0) { // The drag started somewhere else, and our ListView is empty // so make the new item the first in the list. if (itemsSource.Count == 0) { newIndex = 0; } // The drag started somewhere else, but our ListView has items // so make the new item the last in the list. else if (oldIndex < 0) { newIndex = itemsSource.Count; } // The user is trying to drop an item from our ListView into // our ListView, but the mouse is not over an item, so don't // let them drop it. else { return; } } // Dropping an item back onto itself is not considered an actual 'drop'. if (oldIndex == newIndex) { return; } if (ProcessDrop != null) { // Let the client code process the drop. ProcessDropEventArgs <ItemType> args = new ProcessDropEventArgs <ItemType>(itemsSource, data, oldIndex, newIndex, e.AllowedEffects); ProcessDrop(this, args); e.Effects = args.Effects; } else { // Move the dragged data object from it's original index to the // new index (according to where the mouse cursor is). If it was // not previously in the ListBox, then insert the item. if (oldIndex > -1) { itemsSource.Move(oldIndex, newIndex); } else { itemsSource.Insert(newIndex, data); } // Set the Effects property so that the call to DoDragDrop will return 'Move'. e.Effects = DragDropEffects.Move; } } else { throw new Exception( "A ListView managed by ListViewDragManager must have its ItemsSource set to an ObservableCollection<ItemType>."); } }
private void dragDropManager_ProcessDrop(object sender, ProcessDropEventArgs<ReleaseImagesEditor.ImageInfo> e) { this.release.Images.Clear(); this.release.Images.AddRange(this.Images.Select(i => i.Image)); }