//private void OnTouchDown(object sender, TouchEventArgs e) //{ // if (e.TouchDevice.IsFingerRecognized() && e.Source == this) // { // var currentPoint = TouchExtensions.GetCenterPosition(e.TouchDevice, this); // var sv = new StrokeVisual(currentPoint, Colors.Black); // sv.TouchUp += OnTouchUp; // sv.TouchMove += OnTouchMove; // _strokeVisualAdorner.Add(sv); // TouchExtensions.SetUserData(e.TouchDevice, StrokeVisualKey, sv); // e.TouchDevice.Capture(sv); // e.Handled = true; // } //} //private void OnTouchMove(object sender, TouchEventArgs e) //{ // if (e.TouchDevice.IsFingerRecognized()) // { // var currentPoint = TouchExtensions.GetCenterPosition(e.TouchDevice, this); // var sv = e.TouchDevice.GetUserData<StrokeVisual>(StrokeVisualKey); // if (sv != null) // sv.AddPoint(currentPoint); // e.Handled = true; // } //} //private void OnTouchUp(object sender, TouchEventArgs e) //{ // var sv = e.TouchDevice.GetUserData<StrokeVisual>(StrokeVisualKey); // if (sv != null) // { // sv.TouchUp -= OnTouchUp; // sv.TouchLeave -= OnTouchUp; // _strokeVisualAdorner.Remove(sv); // var points = new StylusPointCollection(sv.Points); // var s = new Stroke(points); // if (s.GetBounds().Width > 10 || s.GetBounds().Height > 10) // { // if (StrokeCollected != null) // StrokeCollected(this, new StrokeEventArgs(Device.Touch, s)); // } // e.TouchDevice.Capture(null); // e.Handled = true; // } //} #endregion #region Stylus Events //private StrokeVisual _sv; //private bool _inverted = false; //private void OnStylusDown(object sender, StylusEventArgs e) //{ // if (!Equals(e.Source, this) || !e.StylusDevice.GetIsStylusRecognized()) return; // _strokeVisualAdorner.HideGestureHelp(); // var currentPoint = e.StylusDevice.GetPosition(this); // _inverted = e.Inverted; // _sv = new StrokeVisual(currentPoint, !e.Inverted ? Colors.DeepPink : Colors.DeepSkyBlue); // _sv.StylusUp += OnStylusUp; // _sv.StylusMove += OnStylusMove; // _strokeVisualAdorner.Add(_sv); // e.StylusDevice.Capture(_sv); // e.Handled = true; //} //private void OnStylusMove(object sender, StylusEventArgs e) //{ // if (!e.StylusDevice.GetIsStylusRecognized()) return; // // Use in air to show available gestures // if (!e.InAir) // { // var currentPoint = e.StylusDevice.GetPosition(this); // if (_sv != null) // _sv.AddPoint(currentPoint); // e.Handled = true; // } //} //private void OnStylusUp(object sender, StylusEventArgs e) //{ // if (_sv == null || !e.StylusDevice.GetIsStylusRecognized()) return; // _sv.StylusUp -= OnStylusUp; // _sv.StylusMove -= OnStylusUp; // _strokeVisualAdorner.Remove(_sv); // var points = new StylusPointCollection(_sv.Points); // _sv = null; // var s = new Stroke(points); // if (s.GetBounds().Width > 10 || s.GetBounds().Height > 10) // { // if (StrokeCollected != null) // StrokeCollected(this, new StrokeEventArgs(_inverted ? Device.StylusInverted : Device.Stylus, s)); // } // e.StylusDevice.Capture(null); // e.Handled = true; //} //void OnStylusInAirMove(object sender, StylusEventArgs e) //{ // _strokeVisualAdorner.ShowGestureHelp(e.GetPosition(null)); //} //void OnStylusOutOfRange(object sender, StylusEventArgs e) //{ // _strokeVisualAdorner.HideGestureHelp(); //} #endregion #region Mouse Events private void OnMouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Released || (Keyboard.Modifiers > 0)) { return; } _mouseStrokeVisual = new StrokeVisual(e.GetPosition(this), Colors.Black); _strokeVisualAdorner.Add(_mouseStrokeVisual); _drawing = true; CaptureMouse(); e.Handled = true; }
public void Remove(StrokeVisual sv) { //_strokeVisualCanvas.Targets.Remove(sv); _visuals.Remove(sv); }
public void Add(StrokeVisual sv) { //_strokeVisualCanvas.Targets.Add(sv); _visuals.Add(sv); }
public void Remove(StrokeVisual sv) { //_strokeVisualCanvas.Targets.Remove(sv); _visuals.Remove(sv); }
public void Add(StrokeVisual sv) { //_strokeVisualCanvas.Targets.Add(sv); _visuals.Add(sv); }
private void OnMouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Released || (Keyboard.Modifiers > 0)) return; _mouseStrokeVisual = new StrokeVisual(e.GetPosition(this), Colors.Black); _strokeVisualAdorner.Add(_mouseStrokeVisual); _drawing = true; CaptureMouse(); e.Handled = true; }