Exemple #1
0
        protected override void OnStylusDown(StylusDownEventArgs e)
        {
            base.OnStylusDown(e);

            // TJC: only take in stylus ink, not multitouch
            bool isStylus = e.StylusDevice.Id == MyRend.STYLUS_ID || e.StylusDevice.StylusButtons.Count == 2; // tip and barrel

            if (!isStylus)
            {
                _touchCount++;
                if (_touchCount > _maxTouches)
                {
                    _maxTouches = _touchCount;
                }
                //System.Console.WriteLine("DOWN TC: " + _touchCount + " " + _maxTouches);
                //if (_touchCount > 0) return; // don't capture ink if more than one touch // TJC TEST
            }

            if (InkEnabled)
            {
                _stylusPoints = new StylusPointCollection();
                // Capture the stylus so all stylus input is routed to this control.
                Stylus.Capture(this);
                _stylusPoints.Add(e.GetStylusPoints(this, _stylusPoints.Description));
            }
        }
Exemple #2
0
        protected override void OnStylusUp(StylusEventArgs e)
        {
            // Allocate memory for the StylusPointsCollection, if necessary
            if (stylusPoints == null)
            {
                stylusPoints = new StylusPointCollection();
            }

            // Add the StylusPoints that have come in since the last call to OnStylusMove
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);

            // Create a new custom stroke from all the StylusPoints since OnStylusDown
            //Stroke3D stroke = new Stroke3D(stylusPoints);

            Stroke stroke = new Stroke(stylusPoints, currentAttributes.Clone());

            // Add the new stroke to the Strokes collection of the InkPresenter
            inkPresenter1.Strokes.Add(stroke);

            // Clear out the StylusPointsCollection
            stylusPoints = null;

            // Release stylus capture
            Stylus.Capture(null);
        }
Exemple #3
0
        //</Snippet8>

        //<Snippet10>
        protected override void OnStylusUp(StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                return;
            }

            // Add the StylusPoints that have come in since the
            // last call to OnStylusMove.
            StylusPointCollection newStylusPoints =
                e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);

            // Create a new stroke from all the StylusPoints since OnStylusDown.
            Stroke stroke = new Stroke(stylusPoints);

            // Add the new stroke to the Strokes collection of the InkPresenter.
            ip.Strokes.Add(stroke);

            // Clear the StylusPointsCollection.
            stylusPoints = null;

            // Release stylus capture.
            Stylus.Capture(null);
        }
Exemple #4
0
        protected override void OnStylusUp(StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                stylusPoints = new StylusPointCollection();
            }
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);

            Stroke3D stroke = new Stroke3D(stylusPoints);

            if (inPlugins.Contains(customrenderer))
            {
                stroke.AddPropertyData(guidUsingCustomRenderer, 1);
            }
            if (inPlugins.Contains(dynamicRenderer))
            {
                stroke.AddPropertyData(guidUsingStandardRenderer, 1);
            }
            ip.Strokes.Add(stroke);

            stylusPoints = null;
            Stylus.Capture(null);
        }
Exemple #5
0
        protected override void OnStylusDown(StylusDownEventArgs e)
        {
            Stylus.Capture(this);
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this);

            stylusPoints = new StylusPointCollection(newStylusPoints.Description);
            stylusPoints.Add(newStylusPoints);
        }
        private void text_StylusUp(object sender, StylusEventArgs e)
        {
            Text txt = (Text)sender;

            Stylus.Capture(txt, CaptureMode.None);
            int xrel, yrel;

            e.GetPosition(txt, out xrel, out yrel);
            txt.TextContent = "Up, screen={" + e.X + "," + e.Y + "}, relative={" + xrel + "," + yrel + "}";
        }
        private void Pad01_StylusDown(object sender, StylusDownEventArgs e)
        {
            Stylus.Capture(Pad01);
            Point pos = e.GetPosition(Pad01);

            dPadPointX   = Pad01.RenderSize.Width / 2;
            dPadPointY   = Pad01.RenderSize.Height / 2;
            dStartPointX = pos.X - dPadPointX;
            dStartPointY = pos.Y - dPadPointY;
            flg          = true;
        }
Exemple #8
0
            /// <summary>
            /// Handles the touch down event.
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
#if MF_FRAMEWORK_VERSION_V3_0
            protected void Text_StylusDown(object sender, StylusEventArgs e)
            {
                int x;
                int y;

                e.GetPosition((UIElement)sender, out x, out y);
#else
            void Text_TouchDown(object sender, TouchEventArgs e)
            {
                int x;
                int y;

                e.GetPosition((UIElement)sender, 0, out x, out y);
#endif
                Text text = (Text)sender;

                // If we have already captured the touch, show the point.
#if MF_FRAMEWORK_VERSION_V3_0
                if (sender == Stylus.Captured)
#else
                if (sender == TouchCapture.Captured)
#endif
                {
                    // If the user tapped inside the same control that has the
                    // touch captured, release the capture.
                    if ((x >= 0) && (y >= 0) && (x <= text.ActualWidth) && (y <= text.ActualHeight))
                    {
#if MF_FRAMEWORK_VERSION_V3_0
                        Stylus.Capture(text, CaptureMode.None);
#else
                        TouchCapture.Capture(text, CaptureMode.None);
#endif
                        text.ForeColor   = ColorUtility.ColorFromRGB(0, 0, 0);
                        text.TextContent = "Capture Released.";
                    }
                    // Else, show the point as captured.
                    else
                    {
                        text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")";
                    }
                }
                // Else, show the point as captured.
                else
                {
                    text.ForeColor = ColorUtility.ColorFromRGB(255, 0, 0);

                    text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")";
#if MF_FRAMEWORK_VERSION_V3_0
                    Stylus.Capture(text);
#else
                    TouchCapture.Capture(text);
#endif
                }
            }
Exemple #9
0
    //</Snippet10>

    // When the user lifts the stylus, create a Stroke from the
    // collected stylus points and add it to the InkPresenter.
    // When the control is selecting strokes, add the
    // point data to the IncrementalHitTester.
    protected override void OnStylusUp(StylusEventArgs e)
    {
        stylusPoints ??= new StylusPointCollection();
        StylusPointCollection collectedPoints =
            e.GetStylusPoints(this, stylusPoints.Description);

        stylusPoints.Add(collectedPoints);
        AddPointsToHitTester(collectedPoints);
        AddStrokeToPresenter();
        stylusPoints = null;

        Stylus.Capture(null);
    }
Exemple #10
0
        //<Snippet7>
        protected override void OnStylusDown(StylusDownEventArgs e)
        {
            // Capture the stylus so all stylus input is routed to this control.
            Stylus.Capture(this);

            // Allocate memory for the StylusPointsCollection and
            // add the StylusPoints that have come in so far.
            stylusPoints = new StylusPointCollection();
            StylusPointCollection eventPoints =
                e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(eventPoints);
        }
Exemple #11
0
 public void              StartDrawing(StylusDevice stylus)
 {
     if (stylus != null && stylus.InAir)
     {
         return;
     }
     _dynamicRenderer.Reset(stylus, _stylusPoints);
     _dynamicRenderer.Enabled = true;
     _dynamicRenderer.DrawingAttributes.Color = Colors.Black;
     // Capture the stylus so all stylus input is routed to this control.
     Stylus.Capture(this);
     _stylusPoints = new StylusPointCollection();
 }
        private void FirstTouchPad(Image TargetButton)
        {
            MouseDevice myStylusDevice = Mouse.PrimaryDevice;

            Stylus.Capture(TargetButton);
            Point pos = myStylusDevice.GetPosition(TargetButton);

            Stylus.Capture(Pad01);
            dPadPointX   = Pad01.RenderSize.Width / 2;
            dPadPointY   = Pad01.RenderSize.Height / 2;
            dStartPointX = pos.X - dPadPointX;
            dStartPointY = pos.Y - dPadPointY;
            flg          = true;
        }
Exemple #13
0
            protected override void OnTouchDown(TouchEventArgs e)
#endif
            {
                // Flag for the drawing state.
                _pressed = true;

#if MF_FRAMEWORK_VERSION_V3_0
                Stylus.Capture(this);
#else
                TouchCapture.Capture(this);
#endif

                // Trigger a redraw.
                Invalidate();
            }
Exemple #14
0
    // Prepare to collect stylus packets. If Mode is set to Select,
    // get the IncrementalHitTester from the InkPresenter'newStroke
    // StrokeCollection and subscribe to its StrokeHitChanged event.
    protected override void OnStylusDown(StylusDownEventArgs e)
    {
        base.OnStylusDown(e);

        Stylus.Capture(this);

        // Create a new StylusPointCollection using the StylusPointDescription
        // from the stylus points in the StylusDownEventArgs.
        stylusPoints = new StylusPointCollection();
        StylusPointCollection eventPoints = e.GetStylusPoints(this, stylusPoints.Description);

        stylusPoints.Add(eventPoints);

        InitializeHitTester(eventPoints);
    }
        private void ButtonFake_StylusDown(Image TargetButton, FrickData fd, StylusDownEventArgs e)
        {
            Stylus.Capture(TargetButton);
            Point pos = e.GetPosition(TargetButton);

            dStartPointX             = pos.X;
            dStartPointY             = pos.Y;
            FrickPopImage.Source     = PopImageC;
            PopTextC.Text            = fd.PopText[0];
            PopTextU.Text            = fd.PopText[1];
            PopTextD.Text            = fd.PopText[2];
            PopTextL.Text            = fd.PopText[3];
            PopTextR.Text            = fd.PopText[4];
            FrickPop.PlacementTarget = TargetButton;
            FrickPop.IsOpen          = true;
        }
        private void ButtonFake_StylusDown(object sender, StylusDownEventArgs e)
        {
            Stylus.Capture((Image)sender);
            Point pos = e.GetPosition((Image)sender);

            dStartPointX = pos.X;
            dStartPointY = pos.Y;
            int id = fblist.FindIndex(delegate(Image im) { return(sender.Equals(im)); });

            FrickPopImage.Source     = PopImageC;
            PopTextC.Text            = fd[id].PopText[0];
            PopTextU.Text            = fd[id].PopText[1];
            PopTextD.Text            = fd[id].PopText[2];
            PopTextL.Text            = fd[id].PopText[3];
            PopTextR.Text            = fd[id].PopText[4];
            FrickPop.PlacementTarget = (Image)sender;
            FrickPop.IsOpen          = true;
        }
        /// <summary>
        ///アクティブなソフトによってはスタイラスイベントが発生しない場合があるので
        ///ウィンドウメッセージを拾ってこっちを呼び出す
        /// </summary>
        /// <param name="TargetButton">処理対象偽ボタンコントロール</param>
        private void FirstTouch(Image TargetButton, FrickData fd)
        {
            MouseDevice myStylusDevice = Mouse.PrimaryDevice;

            Stylus.Capture(TargetButton);
            Point pos = myStylusDevice.GetPosition(TargetButton);

            dStartPointX             = pos.X;
            dStartPointY             = pos.Y;
            FrickPopImage.Source     = PopImageC;
            PopTextC.Text            = fd.PopText[0];
            PopTextU.Text            = fd.PopText[1];
            PopTextD.Text            = fd.PopText[2];
            PopTextL.Text            = fd.PopText[3];
            PopTextR.Text            = fd.PopText[4];
            FrickPop.PlacementTarget = TargetButton;
            FrickPop.IsOpen          = true;
        }
Exemple #18
0
        private void DrawingCanvas_StylusUp(object sender, StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                return;
            }

            StylusPointCollection newStylusPoints =
                e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);

            Stroke stroke = new Stroke(stylusPoints);

            stylusPoints = null;

            Stylus.Capture(null);
        }
Exemple #19
0
        protected override void OnStylusDown(StylusDownEventArgs e)
        {
            Stylus.Capture(this);

            //Get the StylusPoints that have come in so far
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this);

            // Allocate memory for the StylusPointsCollection and
            // add the StylusPoints that have come in so far
            //stylusPoints = new StylusPointCollection(newStylusPoints.Description);
            //stylusPoints.Add(newStylusPoints);

            //Create a new StylusPointCollection using the StylusPointDescription
            //from the stylus points in the StylusDownEventArgs.
            stylusPoints = new StylusPointCollection();
            StylusPointCollection eventPoints = e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(eventPoints);
        }
Exemple #20
0
        protected override void OnStylusUp(StylusEventArgs e)
        {
            base.OnStylusUp(e);

            // TJC: only take in stylus ink, not multitouch
            bool isStylus = e.StylusDevice.Id == MyRend.STYLUS_ID || e.StylusDevice.StylusButtons.Count == 2; // tip and barrel

            if (!isStylus)
            {
                _touchCount--;
                //System.Console.WriteLine("UP TC: " + _touchCount + " " + _maxTouches);
                //if (_maxTouches > 0) return; // TJC: test

                // reset max touch once we hit 0
                if (_touchCount <= 0)
                {
                    _maxTouches = 0;
                }
            }

            // Release stylus capture.
            if (Stylus.Captured == this) // bcz: uncapturing the stylus will uncapture the mouse.  However, widgets like SelectionFeedback may have Captured just the Mouse and won't get their Up events - so don't uncapture unless the captured object is 'this'
            {
                Stylus.Capture(null);
            }
            if (_stylusPoints == null)
            {
                return;
            }
            _stylusPoints.Add(e.GetStylusPoints(this, _stylusPoints.Description));
            Stroke stroke = new Stroke(_stylusPoints);

            stroke.DrawingAttributes = _dynamicRenderer.DrawingAttributes.Clone();
            Stroq s = new Stroq(stroke);

            if (KeepStroqs)
            {
                _stroqs.Add(s);
            }
            _stylusPoints = null;

            RaiseStroqCollectedEvent(s, !isStylus || e.StylusDevice.SwitchState(InqUtils.BarrelSwitch) == StylusButtonState.Down);
        }
Exemple #21
0
            protected override void OnTouchUp(TouchEventArgs e)
#endif
            {
                // Flag for the drawing state.
                _pressed = false;

#if MF_FRAMEWORK_VERSION_V3_0
                Stylus.Capture(this, CaptureMode.None);
#else
                TouchCapture.Capture(this, CaptureMode.None);
#endif

                // Trigger a redraw.
                Invalidate();

                // Fire a click event.
                EventArgs args = new EventArgs();
                OnClick(args);
            }
Exemple #22
0
        public override void Perform()
        {
            int option = OptionIndex % 2;

            switch (option)
            {
            case 1:
                Stylus.Capture(InkCanvas);
                break;

            case 2:
                if (InkCanvas.Children.Count > 0)
                {
                    int indexToCapture = Index % InkCanvas.Children.Count;
                    Stylus.Capture(InkCanvas.Children[indexToCapture]);
                }
                break;
            }
        }
Exemple #23
0
        //<Snippet3>
        // Create a stroke from the packets and check if it is a gesture.
        protected override void OnStylusUp(StylusEventArgs e)
        {
            base.OnStylusUp(e);

            stylusPoints.Add(e.GetStylusPoints(this));
            Stroke stroke = new Stroke(stylusPoints);

            // If the stroke was a gesture, put the name of the gesture
            // in the title bar.  Otherwise, add the stroke to the control.
            if (recognizer.IsRecognizerAvailable)
            {
                StrokeCollection gestureStrokes = new StrokeCollection();
                gestureStrokes.Add(stroke);

                ReadOnlyCollection <GestureRecognitionResult> results =
                    recognizer.Recognize(gestureStrokes);

                if (results.Count > 0 &&
                    results[0].ApplicationGesture != ApplicationGesture.NoGesture &&
                    results[0].RecognitionConfidence == RecognitionConfidence.Strong)
                {
                    Application.Current.Windows[0].Title =
                        results[0].ApplicationGesture.ToString();
                }
                else
                {
                    presenter.Strokes.Add(stroke);
                    Application.Current.Windows[0].Title = "";
                }
            }
            else
            {
                Application.Current.Windows[0].Title = "Recognizer not available";
                presenter.Strokes.Add(stroke);
            }

            Stylus.Capture(null);
        }
 public override void Perform()
 {
     Stylus.Capture(Element, CaptureMode);
 }
Exemple #25
0
 /// <summary>
 ///     Captures the stylus to this element.
 /// </summary>
 public bool CaptureStylus()
 {
     return(Stylus.Capture(this));
 }
Exemple #26
0
 //<Snippet1>
 void textbox1_StylusDown(object sender, StylusDownEventArgs e)
 {
     Stylus.Capture(textbox1);
 }
Exemple #27
0
 void textbox1_StylusUp(object sender, StylusEventArgs e)
 {
     Stylus.Capture(textbox1, CaptureMode.None);
 }
Exemple #28
0
 /// <summary>
 ///     Releases the stylus capture.
 /// </summary>
 public void ReleaseStylusCapture()
 {
     Stylus.Capture(null);
 }
Exemple #29
0
            /// <summary>
            /// Handles the touch up event.
            /// </summary>
            /// <param name="e"></param>
#if MF_FRAMEWORK_VERSION_V3_0
            protected override void  OnStylusUp(StylusEventArgs e)
            {
                base.OnStylusUp(e);

                Stylus.Capture(this, CaptureMode.None);
Exemple #30
0
            /// <summary>
            /// Handles the touch down event.
            /// </summary>
            /// <param name="e"></param>
#if MF_FRAMEWORK_VERSION_V3_0
            protected override void  OnStylusDown(StylusEventArgs e)
            {
                base.OnStylusDown(e);

                Stylus.Capture(this);