void Target_MouseMove(object sender, MouseEventArgs e) { if (IsDown) { DeltaDelta = e.GetPosition(null) - CurrentPoint; CurrentPoint += DeltaDelta; if (!IsActive) { if (Math.Abs(Delta.X) >= SystemParameters.MinimumHorizontalDragDistance || Math.Abs(Delta.Y) >= SystemParameters.MinimumVerticalDragDistance) { IsActive = true; CurrentListener = this; if (Started != null) { Started(this); } } } if (IsActive && Changed != null) { Changed(this); } } }
void Complete() { IsActive = false; CurrentListener = null; if (Completed != null) { Completed(this); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); upButton = (DragRepeatButton)Template.FindName("PART_UpButton", this); downButton = (DragRepeatButton)Template.FindName("PART_DownButton", this); textBox = (TextBox)Template.FindName("PART_TextBox", this); upButton.Click += new RoutedEventHandler(upButton_Click); downButton.Click += new RoutedEventHandler(downButton_Click); var upDrag = new DragListener(upButton); var downDrag = new DragListener(downButton); upDrag.Started += drag_Started; upDrag.Changed += drag_Changed; upDrag.Completed += drag_Completed; downDrag.Started += drag_Started; downDrag.Changed += drag_Changed; downDrag.Completed += drag_Completed; Print(); }
void drag_Completed(DragListener drag) { IsDragging = false; OnDragCompleted(); }
void drag_Changed(DragListener drag) { IsDragging = true; MoveValue(-drag.DeltaDelta.Y * SmallChange); }
void drag_Started(DragListener drag) { OnDragStarted(); }