private DragEventHandler getDragDropHandler(fromBox box, DragEventHandler proc) { return(new DragEventHandler((sender, e) => { try { if (dStartBox(e) == (box == fromBox.SrcBox ? SourceBox : TargetBox)) { proc(sender, e); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } })); }
private void box_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var box = sender as ListBox; var item = box.GetPlacementItem() as ListBoxItem; if (item == null || item.Content == null) { return; } //ダブルクリックが入る場合もキャンセルする if (dragStartCancel == true || IsMouseDragCondition() == false) { clearDragStartData(); return; } dragStartBox = box == SourceBox ? fromBox.SrcBox : fromBox.TrgBox; //ドロップ位置の上下判定に使用するので、掴んだアイテムを先頭にする。 dragStartItems = new List <object> { item.Content }; if (box.SelectedItems.Contains(item.Content) == true) { dragStartItems.AddRange(box.SelectedItemsList());//重複するが特に問題ない。 } // 一定時間押下で、ドラッグ中と判定をする。 if (notifyTimer.Tag == null) { notifyTimer.Tag = "Initialized"; notifyTimer.Interval = TimeSpan.FromSeconds(0.5); notifyTimer.Tick += (sender_t, e_t) => { notifyTimer.Stop(); boxItem_MouseLeave(null, null); }; } notifyTimer.Start(); }
private DragEventHandler getDragDropHandler(fromBox box, DragEventHandler proc) { return new DragEventHandler((sender, e) => { try { if (dStartBox(e) == (box == fromBox.SrcBox ? SourceBox : TargetBox)) proc(sender, e); } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }); }
private void box_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var box = sender as ListBox; var item = box.GetPlacementItem() as ListBoxItem; if (item == null || item.Content == null) return; //ダブルクリックが入る場合もキャンセルする if (dragStartCancel == true || IsMouseDragCondition() == false) { clearDragStartData(); return; } dragStartBox = box == SourceBox ? fromBox.SrcBox : fromBox.TrgBox; //ドロップ位置の上下判定に使用するので、掴んだアイテムを先頭にする。 dragStartItems = new List<object> { item.Content }; if (box.SelectedItems.Contains(item.Content) == true) { dragStartItems.AddRange(box.SelectedItemsList());//重複するが特に問題ない。 } // 一定時間押下で、ドラッグ中と判定をする。 if (notifyTimer.Tag == null) { notifyTimer.Tag = "Initialized"; notifyTimer.Interval = TimeSpan.FromSeconds(0.5); notifyTimer.Tick += (sender_t, e_t) => { notifyTimer.Stop(); boxItem_MouseLeave(null, null); }; } notifyTimer.Start(); }