Example #1
0
        private static void Move(object sender, Point point, eDrawingSource drawingSource)
        {
            var casted = (UIElement)sender;

            if (!CanStartDrawingFrom(casted, drawingSource))
            {
                return;
            }

            GetPathInProgress(casted).AddPoint(point);
        }
Example #2
0
        private static UIElement Start(object sender, Point start, eDrawingSource drawingSource)
        {
            var casted = (UIElement)sender;

            if (!CanStartDrawingFrom(casted, drawingSource))
            {
                return(null);
            }

            SetCurrentDrawingSource(casted, drawingSource);
            SetPathInProgress(casted, new PathBuilder(start, GetSegmentSize(casted), GetSmallMovementThreshold(casted)));

            return(casted);
        }
Example #3
0
        private static bool CanStartDrawingFrom(UIElement sender, eDrawingSource drawingSource)
        {
            eDrawingSource currentSource = GetCurrentDrawingSource(sender);

            if (currentSource == eDrawingSource.None)
            {
                return(true);
            }

            // Favor, in order, stylus, touch, then mouse - blocking the others if they exist
            switch (drawingSource)
            {
            case eDrawingSource.Mouse:  return(currentSource == eDrawingSource.Mouse);

            case eDrawingSource.Touch:  return(currentSource == eDrawingSource.Mouse || currentSource == eDrawingSource.Touch);

            case eDrawingSource.Stylus: return(true);

            default:
                return(false);
            }
        }
Example #4
0
 internal static void SetCurrentDrawingSource(DependencyObject obj, eDrawingSource value) => obj.SetValue(CurrentDrawingSourcePropertyKey, value);