protected override void AnalyzeGesture(Util.WinForms.DragState state_, bool mouseUp)
{
// TODO: Analyze on separate thread and maybe even draw on a separate thread.
// Otherwise, on slow computers, mouse input may be missed or laggy due to drawing/analysis
DragState state = (DragState)state_;
var adorners = Control.DragAdornerShapes;
adorners.Clear();
Shape newShape = null;
IEnumerable<Shape> eraseSet = null;
if (state.IsDrag)
{
if (state.ClickedShape != null && state.ClickedShape.AllowsDrag)
HandleShapeDrag(state);
else
{
List<PointT> simplified;
bool cancel;
eraseSet = RecognizeScribbleForEraseOrCancel(state, out cancel, out simplified);
if (eraseSet != null)
{
ShowEraseDuringDrag(state, adorners, eraseSet, simplified, cancel);
}
else
{
bool potentialSelection = false;
newShape = DetectNewShapeDuringDrag(state, adorners, out potentialSelection);
if (potentialSelection)
{
var selecting = ShapesInside(newShape.BBox).ToList();
if (selecting.Count != 0)
newShape.Style = SelectorBoxStyle;
}
}
}
}
if (mouseUp)
{
adorners.Clear();
HandleMouseUp(state, newShape, eraseSet);
}
else if (newShape != null)
{
newShape.AddLLShapesTo(adorners);
newShape.Dispose();
}
Control.DragAdornersChanged();
}