/// <summary>マウス左ボタン離上</summary> /// <param name="sender">対象Control</param> /// <param name="e">マウスボタンイベントデータ</param> private static void OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (_TemporaryData != null) { _TemporaryData = null; } }
/// <summary>対象Control上でマウスカーソル移動</summary> /// <param name="sender">対象Control</param> /// <param name="e">マウスイベントデータ</param> private static void OnPreviewMouseMove(object sender, MouseEventArgs e) { if (_TemporaryData != null && sender is FrameworkElement control && _TemporaryData.CheckStartDragging(e.GetPosition(Window.GetWindow(control)))) { DragDrop.DoDragDrop(control, _TemporaryData.DraggedItem, DragDropEffects.Move); _TemporaryData = null; } }
/// <summary>マウス左ボタン押下</summary> /// <param name="sender">対象Control</param> /// <param name="e">マウスボタンイベントデータ</param> private static void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (sender is FrameworkElement control && e.OriginalSource is FrameworkElement source) { _TemporaryData = new DragAndDropObject() { StartPoint = e.GetPosition(Window.GetWindow(control)), DraggedItem = GetTemplatedRootElement(source) }; } }
public void Init() { _dragAndDrop = GetComponent <DragAndDropObject>(); _interactive = GetComponent <InteractiveObject>(); _dragAndDrop.Init(255 - (byte)MiniGameBase.GameState.PAUSED); _dragAndDrop.onDrag += OnDrag; _dragAndDrop.onDragEnd += OnDragEnd; _dragAndDrop.onDragBegin += OnDragBegin; _collider2D = GetComponent <Collider2D>(); }