Example #1
0
        public override void Perform()
        {
            Stroke stroke = InkCanvas.Strokes[StrokeIndex % InkCanvas.Strokes.Count];
            StylusPointDescription commonSPD = StylusPointDescription.GetCommonDescription(stroke.StylusPoints.Description, StylusPointDescription);
            //reformat points and the strokes points so they match, then add them together.
            StylusPointCollection spcReformat    = StylusPointCollection.Reformat(commonSPD);
            StylusPointCollection strokeReformat = stroke.StylusPoints.Reformat(commonSPD);

            stroke.StylusPoints = strokeReformat;
            stroke.StylusPoints.Add(spcReformat);
        }
Example #2
0
        void DescriptionSnippets()
        {
            //<Snippet17>
            StylusPointDescription description1 =
                new StylusPointDescription(new StylusPointPropertyInfo[]
            {
                new StylusPointPropertyInfo(StylusPointProperties.X),
                new StylusPointPropertyInfo(StylusPointProperties.Y),
                new StylusPointPropertyInfo(StylusPointProperties.NormalPressure),
                new StylusPointPropertyInfo(StylusPointProperties.XTiltOrientation),
                new StylusPointPropertyInfo(StylusPointProperties.YTiltOrientation),
                new StylusPointPropertyInfo(StylusPointProperties.BarrelButton)
            });

            // Create a StylusPointCollection that uses description1 as its
            // StylusPointDescription.
            StylusPointCollection points = new StylusPointCollection(description1);

            StylusPointDescription description2 =
                new StylusPointDescription(new StylusPointPropertyInfo[]
            {
                new StylusPointPropertyInfo(StylusPointProperties.X),
                new StylusPointPropertyInfo(StylusPointProperties.Y),
                new StylusPointPropertyInfo(StylusPointProperties.NormalPressure),
                new StylusPointPropertyInfo(StylusPointProperties.ButtonPressure),
                new StylusPointPropertyInfo(StylusPointProperties.BarrelButton)
            });

            // Find the common StylusPointDescription between description1
            // and description2.  Get a StylusPointCollection that uses the
            // common StylusPointDescription.
            StylusPointDescription common =
                StylusPointDescription.GetCommonDescription(description1, description2);

            StylusPointCollection points2 = points.Reformat(common);
            //</Snippet17>

            //Add two styluspoints with different descriptions.  Throws an exception.
            //StylusPoint stylusPoint1 = new StylusPoint(100, 100, .5f, description1, new int[]{0, 0, 1});
            //StylusPoint stylusPoint2 = new StylusPoint(200, 200, .35f, description2, new int[] {0, 1 });

            //StylusPointCollection points3 = new StylusPointCollection(
            //    new StylusPoint[] { stylusPoint1, stylusPoint2 });

            //StylusPointCollection points4 = new StylusPointCollection(description1);
            //StylusPoint stylusPoint1 = new StylusPoint(100, 100, .5f);
            //points4.Add(stylusPoint1);
            //MessageBox.Show(points2.Count.ToString());
        }
 private void InitializeCapture(InputDevice inputDevice, IStylusEditing stylusEditingBehavior, bool userInitiated, bool resetDynamicRenderer)
 {
     this._capturedStylus = (inputDevice as StylusDevice);
     this._capturedMouse  = (inputDevice as MouseDevice);
     if (this._capturedStylus != null)
     {
         StylusPointCollection stylusPoints = this._capturedStylus.GetStylusPoints(this._inkCanvas);
         this._commonDescription = StylusPointDescription.GetCommonDescription(this._inkCanvas.DefaultStylusPointDescription, stylusPoints.Description);
         StylusPointCollection stylusPoints2 = stylusPoints.Reformat(this._commonDescription);
         if (resetDynamicRenderer)
         {
             InkCollectionBehavior inkCollectionBehavior = stylusEditingBehavior as InkCollectionBehavior;
             if (inkCollectionBehavior != null)
             {
                 inkCollectionBehavior.ResetDynamicRenderer();
             }
         }
         stylusEditingBehavior.AddStylusPoints(stylusPoints2, userInitiated);
         this._inkCanvas.CaptureStylus();
         if (this._inkCanvas.IsStylusCaptured && this.ActiveEditingMode != InkCanvasEditingMode.None)
         {
             this._inkCanvas.AddHandler(Stylus.StylusMoveEvent, new StylusEventHandler(this.OnInkCanvasDeviceMove <StylusEventArgs>));
             this._inkCanvas.AddHandler(UIElement.LostStylusCaptureEvent, new StylusEventHandler(this.OnInkCanvasLostDeviceCapture <StylusEventArgs>));
             return;
         }
         this._capturedStylus = null;
         return;
     }
     else
     {
         this._commonDescription = null;
         Point[] points = new Point[]
         {
             this._capturedMouse.GetPosition(this._inkCanvas)
         };
         StylusPointCollection stylusPoints2 = new StylusPointCollection(points);
         stylusEditingBehavior.AddStylusPoints(stylusPoints2, userInitiated);
         this._inkCanvas.CaptureMouse();
         if (this._inkCanvas.IsMouseCaptured && this.ActiveEditingMode != InkCanvasEditingMode.None)
         {
             this._inkCanvas.AddHandler(Mouse.MouseMoveEvent, new MouseEventHandler(this.OnInkCanvasDeviceMove <MouseEventArgs>));
             this._inkCanvas.AddHandler(UIElement.LostMouseCaptureEvent, new MouseEventHandler(this.OnInkCanvasLostDeviceCapture <MouseEventArgs>));
             return;
         }
         this._capturedMouse = null;
         return;
     }
 }
Example #4
0
        void GetDescriptionFromStylusDevice()
        {
            //<Snippet26>
            StylusDevice           currentStylus = Stylus.CurrentStylusDevice;
            StylusPointDescription description1  =
                new StylusPointDescription(new StylusPointPropertyInfo[]
            {
                new StylusPointPropertyInfo(StylusPointProperties.X),
                new StylusPointPropertyInfo(StylusPointProperties.Y),
                new StylusPointPropertyInfo(StylusPointProperties.NormalPressure),
                new StylusPointPropertyInfo(StylusPointProperties.XTiltOrientation),
                new StylusPointPropertyInfo(StylusPointProperties.YTiltOrientation),
                new StylusPointPropertyInfo(StylusPointProperties.BarrelButton)
            });

            StylusPointDescription description2 = currentStylus.GetStylusPoints(inkCanvas1).Description;

            StylusPointDescription description3 =
                StylusPointDescription.GetCommonDescription(description1, description2);

            StylusPointCollection points = currentStylus.GetStylusPoints(inkCanvas1, description3);
            //</Snippet26>
        }