Esempio n. 1
0
		public UnmanagedStylusPoint (StylusPoint p)
			: this ()
		{
			SetValue (PressureFactorProperty, (double) p.PressureFactor);
			SetValue (XProperty, p.X);
			SetValue (YProperty, p.Y);
		}
Esempio n. 2
0
        void annotoPenReceiver_PenDown(object sender, AnnotoPenMotionEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)delegate()
            {
                StylusPoint pt = new StylusPoint((e.X - 5.0) / 204.0 * 363.0, (e.Y - 5.0) / 173.0 * 309.0, e.Force / 256.0f);
                //currentPts.Add(pt);

                if (currentStroke == null)
                {
                    StylusPointCollection pts = new StylusPointCollection();
                    pts.Add(pt);

                    DrawingAttributes attr = new DrawingAttributes()
                    {
                        Color = Colors.White, 
                    };

                    currentStroke = new Stroke(pts, attr);
                    inkCanvas.Strokes.Add(currentStroke);
                }
                else
                {
                    currentStroke.StylusPoints.Add(pt);
                }
                //Trace.WriteLine("Pen Down");
            }, null);
        }
Esempio n. 3
0
        private Rect GetBounds(StylusPoint stylusPoint, 
            Point position,
            IInputElement relativeTo, 
            GeneralTransform elementToRoot,
            GeneralTransform rootToElement)
        {
            // Get width and heith in pixel value 
            double width = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ true);
            double height = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ false); 
 
            // Get the position with respect to root
            Point rootPoint; 
            if (elementToRoot == null ||
                !elementToRoot.TryTransform(position, out rootPoint))
            {
                rootPoint = position; 
            }
 
            // Create a Rect with respect to root and transform it to element coordinate space 
            Rect rectBounds = new Rect(rootPoint.X - width * 0.5, rootPoint.Y - height * 0.5, width, height);
            if (rootToElement != null) 
            {
                rectBounds = rootToElement.TransformBounds(rectBounds);
            }
            return rectBounds; 
        }
Esempio n. 4
0
 private Rect GetBounds(StylusPoint stylusPoint, Point position, IInputElement relativeTo)
 { 
     GeneralTransform elementToRoot;
     GeneralTransform rootToElement;
     GetRootTransforms(relativeTo, out elementToRoot, out rootToElement);
     return GetBounds(stylusPoint, position, relativeTo, elementToRoot, rootToElement); 
 }
Esempio n. 5
0
		public void StylusPoint_LargeValues ()
		{
			var p = new StylusPoint { X = 1000, Y = 1000 };
			Assert.AreEqual (1000, p.X, "#1");
			Assert.AreEqual (1000, p.Y, "#2");
			Assert.Throws<ArgumentOutOfRangeException> (() => p.PressureFactor = 1.1f, "#3");
		}
Esempio n. 6
0
        private double GetStylusPointWidthOrHeight(StylusPoint stylusPoint, bool isWidth)
        {
            const double CentimeterPerInch = 2.54d;
            const double PixelPerInch      = 96d;

            StylusPointProperty property = (isWidth ? StylusPointProperties.Width : StylusPointProperties.Height);
            double value = 0d;

            if (stylusPoint.HasProperty(property))
            {
                // Get the property value in the corresponding units
                value = (double)stylusPoint.GetPropertyValue(property);
                StylusPointPropertyInfo propertyInfo = stylusPoint.Description.GetPropertyInfo(property);
                if (!DoubleUtil.AreClose(propertyInfo.Resolution, 0d))
                {
                    value /= propertyInfo.Resolution;
                }
                else
                {
                    value = 0;
                }

                // Convert the value to Inches
                if (propertyInfo.Unit == StylusPointPropertyUnit.Centimeters)
                {
                    value /= CentimeterPerInch;
                }

                // Convert the value to pixels
                value *= PixelPerInch;
            }
            return(value);
        }
Esempio n. 7
0
        private Rect GetBounds(StylusPoint stylusPoint,
                               Point position,
                               IInputElement relativeTo,
                               GeneralTransform elementToRoot,
                               GeneralTransform rootToElement)
        {
            // Get width and heith in pixel value
            double width  = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ true);
            double height = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ false);

            // Get the position with respect to root
            Point rootPoint;

            if (elementToRoot == null ||
                !elementToRoot.TryTransform(position, out rootPoint))
            {
                rootPoint = position;
            }

            // Create a Rect with respect to root and transform it to element coordinate space
            Rect rectBounds = new Rect(rootPoint.X - width * 0.5, rootPoint.Y - height * 0.5, width, height);

            if (rootToElement != null)
            {
                rectBounds = rootToElement.TransformBounds(rectBounds);
            }
            return(rectBounds);
        }
Esempio n. 8
0
 public UnmanagedStylusPoint(StylusPoint p)
     : this()
 {
     SetValue(PressureFactorProperty, (double)p.PressureFactor);
     SetValue(XProperty, p.X);
     SetValue(YProperty, p.Y);
 }
Esempio n. 9
0
        /// <summary>
        ///     Provides all of the known points the device hit since the last reported position update.
        /// </summary>
        /// <param name="relativeTo">Defines the coordinate space.</param>
        /// <returns>A list of points in the coordinate space of relativeTo.</returns>
        public override TouchPointCollection GetIntermediateTouchPoints(IInputElement relativeTo)
        {
            // Retrieve the stylus points
            StylusPointCollection stylusPoints = StylusDevice.GetStylusPoints(relativeTo, _stylusPointDescription);
            int count = stylusPoints.Count;
            TouchPointCollection touchPoints = new TouchPointCollection();

            GeneralTransform elementToRoot;
            GeneralTransform rootToElement;

            GetRootTransforms(relativeTo, out elementToRoot, out rootToElement);

            // Convert the stylus points into touch points
            for (int i = 0; i < count; i++)
            {
                StylusPoint stylusPoint = stylusPoints[i];
                Point       position    = new Point(stylusPoint.X, stylusPoint.Y);
                Rect        rectBounds  = GetBounds(stylusPoint, position, relativeTo, elementToRoot, rootToElement);

                TouchPoint touchPoint = new TouchPoint(this, position, rectBounds, _lastAction);
                touchPoints.Add(touchPoint);
            }

            return(touchPoints);
        }
Esempio n. 10
0
        private Rect GetBounds(StylusPoint stylusPoint, Point position, IInputElement relativeTo)
        {
            GeneralTransform elementToRoot;
            GeneralTransform rootToElement;

            GetRootTransforms(relativeTo, out elementToRoot, out rootToElement);
            return(GetBounds(stylusPoint, position, relativeTo, elementToRoot, rootToElement));
        }
        public static double GetDistanceBetweenPoints(StylusPoint p1, StylusPoint p2)
        {
            double xDiff = p1.X - p2.X;
            double yDiff = p1.Y - p2.Y;

            double distance = Math.Sqrt(xDiff * xDiff + yDiff * yDiff);

            return Math.Abs(distance);
        }
Esempio n. 12
0
		public void StylusPoint_DefaultValues ()
		{
			var p = new StylusPoint ();
			Assert.AreEqual (0, p.X, "#1");
			Assert.AreEqual (0, p.Y, "#2");
			Assert.AreEqual (0, p.PressureFactor, "#3");

			p = new StylusPoint (1, 2);
			Assert.AreEqual (1, p.X, "#4");
			Assert.AreEqual (2, p.Y, "#5");
			Assert.AreEqual (0.5, p.PressureFactor, "#6");
		}
Esempio n. 13
0
		public void ModifyValuesInManaged ()
		{
			var c = (StylusPointCollection) XamlReader.Load (@"
<StylusPointCollection	xmlns=""http://schemas.microsoft.com/client/2007""
						xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
	<StylusPoint X=""1"" Y=""2"" /> 
</StylusPointCollection>
");
			var expected = new StylusPoint(1, 2);
			Assert.AreEqual (1, c.Count, "#1");
			Assert.AreEqual (expected, c [0], "#2");

			var p = c [0];
			p.X = 10;
			Assert.AreEqual (expected, c [0], "#3");
		}
Esempio n. 14
0
        public CircleRecognizer(TouchPoint2 points)
        {
            //Estimate the center (ie. the average: x,y coords)
            double xavg = 0;
            double yavg = 0;
            foreach (var p in points.Stroke.StylusPoints)
            {
                xavg += p.X;
                yavg += p.Y;
            }
            xavg = xavg / points.Stroke.StylusPoints.Count;
            yavg = yavg / points.Stroke.StylusPoints.Count;
            Y_Center = yavg;
            X_Center = xavg;
            StylusPoint center = new StylusPoint(X_Center, Y_Center);

            //Estimate the radius (ie. the avg distance from center)
            Radius = 0;
            foreach (var p in points.Stroke.StylusPoints)
            {
                Radius += TrigonometricCalculationHelper.GetDistanceBetweenPoints(center, p);
            }
            Radius = Radius / points.Stroke.StylusPoints.Count;

            //Calculate the average distance from the estimated circle

            double avgDist = 0;
            foreach (var p in points.Stroke.StylusPoints)
            {
                avgDist += TrigonometricCalculationHelper.GetDistanceBetweenPoints(p, center) - Radius;
            }
            avgDist = avgDist / points.Stroke.StylusPoints.Count;

            //Calculate the 'correlation'

            double residual = 0;
            double total = 0;
            foreach (var p in points.Stroke.StylusPoints)
            {
                double dist = TrigonometricCalculationHelper.GetDistanceBetweenPoints(p,center);
                residual += Math.Pow(dist - Radius, 2);
                total += Math.Pow(dist - avgDist,2);
            }

            R = 1 - (residual / total);
        }
        protected void Update( object sender, EventArgs e )
        {
            paintCanvas.Strokes.Clear();
            windowWidth = (float)this.Width;
            windowHeight = (float)this.Height;

            Leap.Frame frame = leap.Frame();
            InteractionBox interactionBox = leap.Frame().InteractionBox;

            foreach ( Pointable pointable in leap.Frame().Pointables ) {
                // ここから追加
                // 伸びている指、ツール以外は無視する
                //if ( !pointable.IsExtended ) {
                //    continue;
                //}
                // ここまで追加

                Leap.Vector normalizedPosition =
                    interactionBox.NormalizePoint( pointable.StabilizedTipPosition );
                float tx = normalizedPosition.x * windowWidth;
                float ty = windowHeight - normalizedPosition.y * windowHeight;

                int alpha = 255;
                if ( (pointable.TouchDistance > 0 && pointable.TouchZone != Pointable.Zone.ZONENONE ) ) {
                    alpha = 255 - (int)(255 * pointable.TouchDistance);
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0x0, 0xff, 0x0 );
                }
                else if ( pointable.TouchDistance <= 0 ) {
                    alpha = -(int)(255 * pointable.TouchDistance);
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0xff, 0x0, 0x0 );
                }
                else {
                    alpha = 50;
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0x0, 0x0, 0xff );
                }

                StylusPoint touchPoint = new StylusPoint( tx, ty );
                StylusPointCollection tips =
                    new StylusPointCollection( new StylusPoint[] { touchPoint } );
                Stroke touchStroke = new Stroke( tips, touchIndicator );
                paintCanvas.Strokes.Add( touchStroke );
            }
        }
Esempio n. 16
0
        public static StrokeCollection ConvertToStrokeCollection(SerializableStrokeCollection strokeCollection)
        {
            StrokeCollection resultCollection = new StrokeCollection();
            foreach (var stroke in strokeCollection)
            {
                DrawingAttributes drawingAttr = new DrawingAttributes
                {
                    Color = stroke.DrawingAttributes.Color,
                    FitToCurve = stroke.DrawingAttributes.FitToCurve,
                    Height = stroke.DrawingAttributes.Height,
                    Width = stroke.DrawingAttributes.Width,
                    IgnorePressure = stroke.DrawingAttributes.IgnorePressure,
                    IsHighlighter = stroke.DrawingAttributes.IsHighlighter,
                    StylusTipTransform = stroke.DrawingAttributes.StylusTipTransform
                };
                switch (stroke.DrawingAttributes.StylusTip)
                {
                    case SerializableDrawingAttributes.StylusTips.Ellipse:
                        drawingAttr.StylusTip = StylusTip.Ellipse;
                        break;
                    case SerializableDrawingAttributes.StylusTips.Rectangle:
                        drawingAttr.StylusTip = StylusTip.Rectangle;
                        break;
                    default:
                        break;
                }

                StylusPointCollection spc = new StylusPointCollection();
                foreach (var stylusPoint in stroke.StylusPoints)
                {
                    StylusPoint sp = new StylusPoint { X = stylusPoint.X, Y = stylusPoint.Y, PressureFactor = stylusPoint.PressureFactor };
                    spc.Add(sp);
                }
                Stroke newStroke = new Stroke(spc);
                newStroke.DrawingAttributes = drawingAttr;
                resultCollection.Add(newStroke);
            }
            return resultCollection;
        }
Esempio n. 17
0
		public void Add_StylusPoint_Validation ()
		{
			StylusPointCollection spc = new StylusPointCollection ();
			StylusPoint sp = new StylusPoint ();
			spc.Add (sp);
			Assert.AreEqual (1, spc.Count, "Count");
		}
Esempio n. 18
0
    private void addNextPDF()
    {

        PdfPage page = new PdfPage();
        page.Size = PageSize.A4;

        double h = SystemParameters.PrimaryScreenHeight;
        double w = SystemParameters.PrimaryScreenWidth;
        //XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
        var rateW = page.Width / w;
        var rateH = page.Height / h;

        var strokes = CanvasStroke.ToList();
        List<Point[]> pl = new List<Point[]>();
        foreach (Stroke stroke in strokes)
        {

            StylusPointCollection points = stroke.StylusPoints;
            StylusPointCollection newPoints = new StylusPointCollection();
            var pointList = points.ToList();
            foreach (StylusPoint pt in pointList)
            {

                StylusPoint newPt = new StylusPoint(pt.X * rateW, pt.Y * rateH);
                newPoints.Add(newPt);
            }
            Point[] p = (Point[])newPoints;
            pList.Add(p);
            pl.Add(p);
            CanvasStroke.Remove(stroke);
        }

        pointL.Add(pl);

    }
        // Sets up the houses and roads for test three
        private void SetupTestThree()
        {
            List<Point> testPoints = new List<Point>();
            int count = 0;

            // Draw house locations
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    int x = 350 + (i * 450);
                    int y = 400 + (j * 150);
                    Point center = new Point(x, y);

                    ScatterViewItem house = setBuildingType(i, 0);
                    house.CanMove = false;
                    house.CanRotate = false;
                    house.CanScale = false;
                    house.Center = center;
                    house.Opacity = 0.5;

                    TestScatterView.Items.Add(house);
                    testPoints.Add(center);
                }
            }

            for (int k = 0; k < 4; k++)
            {
                int x = 500;
                int y = 250 + (k * 150);
                Point center = new Point(x, y);

                ScatterViewItem house = SetSVHouseImage("HouseEMI");
                house.CanMove = false;
                house.CanRotate = false;
                house.CanScale = false;
                house.Center = center;
                house.Opacity = 0.5;

                TestScatterView.Items.Add(house);
                testPoints.Add(center);
            }

            for (int l = 0; l < 2; l++)
            {
                int x = 650;
                int y = 250 + (l * 450);
                Point center = new Point(x, y);

                ScatterViewItem house = SetSVHouseImage("BuildingEMI");
                house.CanMove = false;
                house.CanRotate = false;
                house.CanScale = false;
                house.Center = center;
                house.Opacity = 0.5;

                TestScatterView.Items.Add(house);
                testPoints.Add(center);
            }

                int xSky = 650;
                int ySky = 475;
                Point centerSky = new Point(xSky, ySky);

                ScatterViewItem skyscraper = SetSVHouseImage("SkyscraperEMI");
                skyscraper.CanMove = false;
                skyscraper.CanRotate = false;
                skyscraper.CanScale = false;
                skyscraper.Center = centerSky;
                skyscraper.Opacity = 0.5;

                TestScatterView.Items.Add(skyscraper);
                testPoints.Add(centerSky);

            // Draw road locations
            DrawingAttributes roadAttributes = new DrawingAttributes();
            roadAttributes.Color = Colors.LightGray;
            roadAttributes.IgnorePressure = true;
            roadAttributes.StylusTip = StylusTip.Rectangle;
            roadAttributes.Width = 15;
            roadAttributes.Height = 15;

            // Add bounding rectangle road
            StylusPoint point1 = new StylusPoint(420, 180);
            StylusPoint point2 = new StylusPoint(720, 180);
            StylusPoint point3 = new StylusPoint(870, 330);
            StylusPoint point4 = new StylusPoint(870, 630);
            StylusPoint point5 = new StylusPoint(720, 780);
            StylusPoint point6 = new StylusPoint(420, 780);
            StylusPoint point7 = new StylusPoint(270, 630);
            StylusPoint point8 = new StylusPoint(270, 330);
            StylusPoint point9 = new StylusPoint(420, 180);

            StylusPointCollection points = new StylusPointCollection(
                new StylusPoint[] { point1, point2, point3, point4, point5, point6, point7, point8, point9 });
            Stroke newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);

            Point road = new Point(0, 0);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            point1 = new StylusPoint(420, 181);
            point2 = new StylusPoint(420, 779);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            point1 = new StylusPoint(570, 181);
            point2 = new StylusPoint(570, 779);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            point1 = new StylusPoint(720, 181);
            point2 = new StylusPoint(720, 779);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            point1 = new StylusPoint(270, 330);
            point2 = new StylusPoint(869, 330);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            point1 = new StylusPoint(270, 630);
            point2 = new StylusPoint(869, 630);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            point1 = new StylusPoint(270, 480);
            point2 = new StylusPoint(570, 480);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            point1 = new StylusPoint(720, 480);
            point2 = new StylusPoint(869, 480);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            meanTestPoint = NormalizeAndSumPoints(testPoints);
            meanRoadPoint = road;
            TestMeanPoint.Text = "(" + Math.Round(meanTestPoint.X, 3) + "," + Math.Round(meanTestPoint.Y, 3) + ")";
            TestMeanRoadPoint.Text = "(" + Math.Round(meanRoadPoint.X, 3) + "," + Math.Round(meanRoadPoint.Y, 3) + ")";
        }
        //======================================================================
        //                       Test Functions
        //======================================================================

        // Sets up the houses and roads for test one
        private void SetupTestOne()
        {
            List<Point> testPoints = new List<Point>();
            int count = 0;

            // Draw house locations
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    int x = 500 + (i * 150);
                    int y = 250 + (j * 150);
                    Point center = new Point(x, y);

                    ScatterViewItem house = SetSVHouseImage("HouseEMI");
                    house.CanMove = false;
                    house.CanRotate = false;
                    house.CanScale = false;
                    house.Center = center;
                    house.Opacity = 0.5;

                    TestScatterView.Items.Add(house);
                    testPoints.Add(center);
                }
            }

            // Draw road locations
            DrawingAttributes roadAttributes = new DrawingAttributes();
            roadAttributes.Color = Colors.LightGray;
            roadAttributes.IgnorePressure = true;
            roadAttributes.StylusTip = StylusTip.Rectangle;
            roadAttributes.Width = 15;
            roadAttributes.Height = 15;

            // Add bounding rectangle road
            StylusPoint point1 = new StylusPoint(420, 180);
            StylusPoint point2 = new StylusPoint(880, 180);
            StylusPoint point3 = new StylusPoint(880, 480);
            StylusPoint point4 = new StylusPoint(420, 480);
            StylusPoint point5 = new StylusPoint(420, 180);
            StylusPointCollection points = new StylusPointCollection(
                new StylusPoint[] { point1, point2, point3, point4, point5 });
            Stroke newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);

            Point road = new Point(0, 0);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            point1 = new StylusPoint(575, 181);
            point2 = new StylusPoint(575, 479);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;
            
            // Add verticle roads
            point1 = new StylusPoint(725, 181);
            point2 = new StylusPoint(725, 479);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;

            // Add middle road
            point1 = new StylusPoint(420, 325);
            point2 = new StylusPoint(880, 325);
            points = new StylusPointCollection(
                new StylusPoint[] { point1, point2 });
            newStroke = new Stroke(points, roadAttributes);
            TestRoadCanvas.Strokes.Add(newStroke);
            for (int i = 0; i < points.Count; i++)
            {
                road.X += points[i].X;
                road.Y += points[i].Y;
            }
            count += points.Count;
            road.X /= count;
            road.Y /= count;

            meanTestPoint = NormalizeAndSumPoints(testPoints);
            meanRoadPoint = road;
            TestMeanPoint.Text = "(" + Math.Round(meanTestPoint.X, 3) + "," + Math.Round(meanTestPoint.Y, 3) + ")";
            TestMeanRoadPoint.Text = "(" + Math.Round(meanRoadPoint.X, 3) + "," + Math.Round(meanRoadPoint.Y, 3) + ")";
        }
Esempio n. 21
0
        private double GetStylusPointWidthOrHeight(StylusPoint stylusPoint, bool isWidth) 
        {
            const double CentimeterPerInch = 2.54d; 
            const double PixelPerInch = 96d;

            StylusPointProperty property = (isWidth ? StylusPointProperties.Width : StylusPointProperties.Height);
            double value = 0d; 
            if (stylusPoint.HasProperty(property))
            { 
                // Get the property value in the corresponding units 
                value = (double)stylusPoint.GetPropertyValue(property);
                StylusPointPropertyInfo propertyInfo = stylusPoint.Description.GetPropertyInfo(property); 
                if (!DoubleUtil.AreClose(propertyInfo.Resolution, 0d))
                {
                    value /= propertyInfo.Resolution;
                } 
                else
                { 
                    value = 0; 
                }
 
                // Convert the value to Inches
                if (propertyInfo.Unit == StylusPointPropertyUnit.Centimeters)
                {
                    value /= CentimeterPerInch; 
                }
 
                // Convert the value to pixels 
                value *= PixelPerInch;
            } 
            return value;
        }
Esempio n. 22
0
        /// <summary>
        /// Private helper that will generate a new point between two points at an findex
        /// </summary>
        private Point GetIntermediatePoint(StylusPoint p1, StylusPoint p2, double findex) 
        {
            double xDistance = p2.X - p1.X; 
            double yDistance = p2.Y - p1.Y; 

            double xFDistance = xDistance * findex; 
            double yFDistance = yDistance * findex;

            return new Point(p1.X + xFDistance, p1.Y + yFDistance);
        } 
Esempio n. 23
0
        private void PlaybackSession(object sender, RoutedEventArgs e)
        {
            playback = true;

            Microsoft.Win32.OpenFileDialog dialogBox = new Microsoft.Win32.OpenFileDialog();

            dialogBox.DefaultExt = ".xml";

            Nullable<bool> result = dialogBox.ShowDialog();

            String filename;

            if (result == true)
            {
                filename = dialogBox.FileName;

                if (File.Exists(filename))
                {
                    XmlDocument xmlDoc = new XmlDocument();

                    //load xml file
                    xmlDoc.Load(filename);

                    XmlElement session = xmlDoc.DocumentElement;
                    XmlNodeList sceneNodes = session.GetElementsByTagName("Scene");

                    //begin playback
                    playback = true;

                    //load scenes listed in xml file
                    foreach (XmlNode currScene in sceneNodes)
                    {
                        XmlElement sceneNode = currScene as XmlElement;
                        String scenePath = currScene.Attributes.GetNamedItem("FilePath").Value;
                        StreamReader mysr = new StreamReader(scenePath);

                        LoadXAML(scenePath);

                        //InkCanvas sessionScene = LogicalTreeHelper.FindLogicalNode(rootObject, "scene") as InkCanvas;
                        
                        //perform events on scene
                        XmlNode eventNode = sceneNode.GetElementsByTagName("Events").Item(0);

                        XmlNodeList events;

                        if (eventNode.HasChildNodes)
                        {
                            events = eventNode.ChildNodes;
                        }
                        else
                        {
                            continue;
                        }

                        foreach (XmlNode mtEvent in events)
                        {
                            String mtAction = mtEvent.Name;

                            if (mtAction == "InkStroke")
                            {
                                //get points
                                XmlNodeList mtInkPoints = mtEvent.ChildNodes;
                                StylusPoint defaultPoint;
                                StylusPointCollection defaultPoints = new StylusPointCollection();
                                Stroke mtStroke;

                                XmlElement inkPoint = mtInkPoints[0] as XmlElement;

                                String xVal = inkPoint.Attributes.GetNamedItem("X").Value;
                                String yVal = inkPoint.Attributes.GetNamedItem("Y").Value;

                                Double X = Convert.ToDouble(xVal);
                                Double Y = Convert.ToDouble(yVal);

                                defaultPoint = new StylusPoint(X, Y);
                                defaultPoints.Add(defaultPoint);
                                mtStroke = new Stroke(defaultPoints);

                                scene.Strokes.Add(mtStroke);
                                
                                for (int i = 1; i < mtInkPoints.Count; i++)
                                {
                                    inkPoint = mtInkPoints[i] as XmlElement;

                                    xVal = inkPoint.Attributes.GetNamedItem("X").Value;
                                    yVal = inkPoint.Attributes.GetNamedItem("Y").Value;

                                    X = Convert.ToDouble(xVal);
                                    Y = Convert.ToDouble(yVal);

                                    //draw ink stroke one section at a time
                                    mtStroke.StylusPoints.Add(new StylusPoint(X, Y));

                                    //scene.Strokes.Remove(mtStroke);
                                    //scene.Strokes.Add(mtStroke);

                                    Refresh(scene);
                                }
                            }
                            else
                            {
                                XmlAttributeCollection attributes = mtEvent.Attributes;
                                Double X, Y, CenterX, CenterY, Rotation;
                                String elementName = attributes.GetNamedItem("Element").Value;

                                // objects = LogicalTreeHelper.GetChildren(scene);
                                Object mtElement = LogicalTreeHelper.FindLogicalNode(mtViewbox, elementName);
                                String objectType = mtElement.GetType().ToString();
                                UIElement currControl = new UIElement();

                                switch (objectType)
                                {
                                    case "System.Windows.Controls.Image":
                                        currControl = mtElement as Image;
                                        break;
                                    case "System.Windows.Controls.StackPanel":
                                        currControl = mtElement as StackPanel;
                                        break;
                                    case "System.Windows.Controls.MediaElement":
                                        currControl = mtElement as MediaElement;
                                        break;
                                    case "System.Windows.Controls.TextBlock":
                                        currControl = mtElement as TextBlock;
                                        break;
                                    case "System.Windows.Shapes.Ellipse":
                                        currControl = mtElement as Ellipse;
                                        break;
                                    case "System.Windows.Shapes.Rectangle":
                                        currControl = mtElement as Rectangle;
                                        break;
                                }

                                Matrix matrix = ((MatrixTransform)currControl.RenderTransform).Matrix;

                                switch (mtAction)
                                {
                                    case "Rotate":
                                        Rotation = Convert.ToDouble(attributes.GetNamedItem("Rotation").Value);
                                        CenterX = Convert.ToDouble(attributes.GetNamedItem("CenterX").Value);
                                        CenterY = Convert.ToDouble(attributes.GetNamedItem("CenterY").Value);

                                        matrix.RotateAt(Rotation, CenterX, CenterY);
                                        break;
                                    case "Scale":
                                        CenterX = Convert.ToDouble(attributes.GetNamedItem("CenterX").Value);
                                        CenterY = Convert.ToDouble(attributes.GetNamedItem("CenterY").Value);
                                        X = Convert.ToDouble(attributes.GetNamedItem("X").Value);
                                        Y = Convert.ToDouble(attributes.GetNamedItem("Y").Value);

                                        matrix.ScaleAt(X, Y, CenterX, CenterY);
                                        break;
                                    case "Translate":
                                        X = Convert.ToDouble(attributes.GetNamedItem("X").Value);
                                        Y = Convert.ToDouble(attributes.GetNamedItem("Y").Value);

                                        matrix.Translate(X, Y);
                                        break;
                                }
                                currControl.RenderTransform = new MatrixTransform(matrix);
                                bringElementToFront(currControl);
                                //currControl

                                Refresh(currControl);
                            }

                            System.Threading.Thread.Sleep(50);

                        }

                    }

                    //apply each action to the scene
                }
            }
        }
 public static Point FromStylusPointToPoint(StylusPoint stylusPoint)
 {
     return new Point(stylusPoint.X, stylusPoint.Y);
 }
Esempio n. 25
0
 private void AddSingleStrokeBasedNote(IdeationUnit strokeBasedIdea)
 {
     try
     {
         StrokeData ideaData = (StrokeData)(strokeBasedIdea.Content);
         List<System.Windows.Point> strokePoints = ideaData.StrokePoints;
         StylusPointCollection stylusPoints = new StylusPointCollection();
         foreach (System.Windows.Point p in strokePoints)
         {
             StylusPoint stylusP = new StylusPoint(p.X, p.Y);
             stylusPoints.Add(stylusP);
         }
         Stroke newStroke = new Stroke(stylusPoints);
         if (!ideaData.IsErasingStroke)
         {
             newStroke.DrawingAttributes = DrawingCanvasModeSwitcher.normalDrawingAttribute.Clone();
             newStroke.DrawingAttributes.Color = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(ideaData.StrokeColorCode);
         }
         else
         {
             newStroke.DrawingAttributes = new DrawingAttributes();
             newStroke.DrawingAttributes.Color = System.Windows.Media.Color.FromRgb(0, 0, 0);
             newStroke.DrawingAttributes.Width = newStroke.DrawingAttributes.Height = 30;
         }
         drawingCanvas.Strokes.Add(newStroke);
     }
     catch (Exception ex)
     {
         Utilities.UtilitiesLib.LogError(ex);
     }
 }
        protected void Update( object sender, EventArgs e )
        {
            paintCanvas.Strokes.Clear();
            windowWidth = (float)this.Width;
            windowHeight = (float)this.Height;

            Frame frame = leap.Frame();
            InteractionBox interactionBox = leap.Frame().InteractionBox;

            foreach ( Pointable pointable in leap.Frame().Pointables ) {
                // InteractionBox を利用した座標変換
                Leap.Vector normalizedPosition = interactionBox.NormalizePoint( pointable.StabilizedTipPosition );

                // Intersect Point を利用した座標変換
                //Leap.Vector normalizedPosition = locatedScreen.Intersect( pointable, true );

                // Projection Point を利用した座標変換
                //Leap.Vector normalizedPosition = locatedScreen.Project( pointable.TipPosition, false );

                float tx = normalizedPosition.x * windowWidth;
                float ty = windowHeight - normalizedPosition.y * windowHeight;

                int alpha = 255;
                // ホバー状態
                if ( pointable.TouchDistance > 0 && pointable.TouchZone != Pointable.Zone.ZONENONE ) {
                    alpha = 255 - (int)(255 * pointable.TouchDistance);
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0x0, 0xff, 0x0 );
                }
                // タッチ状態
                else if ( pointable.TouchDistance <= 0 ) {
                    alpha = -(int)(255 * pointable.TouchDistance);
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0xff, 0x0, 0x0 );
                }
                // タッチ対象外
                else {
                    alpha = 50;
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0x0, 0x0, 0xff );
                }

                StylusPoint touchPoint = new StylusPoint( tx, ty );
                StylusPointCollection tips = new StylusPointCollection( new StylusPoint[] { touchPoint } );
                Stroke touchStroke = new Stroke( tips, touchIndicator );
                paintCanvas.Strokes.Add( touchStroke );
            }
        }
Esempio n. 27
0
		WriteableBitmap GetImage (Color strokeColor, Color fillColor, Size size, float scale, bool shouldCrop = true, bool keepAspectRatio = true)
		{
			if (size.Width == 0 || size.Height == 0 || scale <= 0 || strokeColor == null ||
			    fillColor == null)
				return null;

			float uncroppedScale;
            Rect croppedRectangle = new Rect();

			Point [] cachedPoints;

			if (shouldCrop && (cachedPoints = Points).Any ()) {
			
				croppedRectangle = getCroppedRectangle (cachedPoints);

                if (croppedRectangle.X >= 5)
                {
                    croppedRectangle.X -= 5;
                    croppedRectangle.Width += 5;
                }
                if (croppedRectangle.Y >= 5)
                {
                    croppedRectangle.Y -= 5;
                    croppedRectangle.Height += 5;
                }
                if (croppedRectangle.X + croppedRectangle.Width <= size.Width - 5)
                    croppedRectangle.Width += 5;
                if (croppedRectangle.Y + croppedRectangle.Height <= size.Height - 5)
                    croppedRectangle.Height += 5;

				double scaleX = croppedRectangle.Width / size.Width;
				double scaleY = croppedRectangle.Height / size.Height;
				uncroppedScale = (float) (1 / Math.Max (scaleX, scaleY));
			} else {
				uncroppedScale = scale;
			}

            InkPresenter presenter;

            if (shouldCrop)
            {
                presenter = new InkPresenter()
                {
                    Width = keepAspectRatio ? size.Width / uncroppedScale : croppedRectangle.Width,
                    Height = keepAspectRatio ? size.Height / uncroppedScale : croppedRectangle.Height,
                    Strokes = new StrokeCollection(),
                    Background = new SolidColorBrush(fillColor)
                };
            }
            else
            {
                presenter = new InkPresenter()
                {
                    Width = size.Width,
                    Height = size.Height,
                    Strokes = new StrokeCollection(),
                    Background = new SolidColorBrush(fillColor)
                };
            }

			foreach (Stroke stroke in strokes) {
                var collection = new StylusPointCollection();

                var tempStroke = new Stroke ();
               
                if (shouldCrop)
                {
                    var newCollection = new StylusPointCollection ();
                    foreach (var point in stroke.StylusPoints)
                    {
                        var newPoint = new StylusPoint { X = point.X - croppedRectangle.X, Y = point.Y - croppedRectangle.Y };
                        newCollection.Add(newPoint);
                    }

                    tempStroke = new Stroke(newCollection);
                }
                
				tempStroke.DrawingAttributes.Color = strokeColor;
				presenter.Strokes.Add (shouldCrop ? tempStroke : stroke);
                tempStroke = null;
			}

            WriteableBitmap bitmap = new WriteableBitmap(presenter, new ScaleTransform() { ScaleX = uncroppedScale, ScaleY = uncroppedScale });

			return bitmap;
		}
Esempio n. 28
0
        /// <summary>
        /// Private helper for adding a StylusPoint to the BezierStylusPoints
        /// </summary> 
        private void AddInterpolatedBezierPoint(StylusPointCollection bezierStylusPoints,
                                                Point bezierPoint, 
                                                int[] additionalData, 
                                                float pressure)
        { 
            double xVal = bezierPoint.X > StylusPoint.MaxXY ?
                        StylusPoint.MaxXY :
                        (bezierPoint.X < StylusPoint.MinXY ? StylusPoint.MinXY : bezierPoint.X);
 
            double yVal = bezierPoint.Y > StylusPoint.MaxXY ?
                        StylusPoint.MaxXY : 
                        (bezierPoint.Y < StylusPoint.MinXY ? StylusPoint.MinXY : bezierPoint.Y); 

 
            StylusPoint newBezierPoint =
                new StylusPoint(xVal, yVal, pressure, bezierStylusPoints.Description, additionalData, false, false);

 
            bezierStylusPoints.Add(newBezierPoint);
        } 
 public double GetDistanceOf2Points(StylusPoint a, StylusPoint b)
 {
     return Distance(FromStylusPointToPoint(a), FromStylusPointToPoint(b));
 }
        private void AddNewPointToStroke(Point curCursorPosition)
        {
            if (_Stroke == null)  //setfirst point
            {
                StylusPointCollection stylusPointCollection = new StylusPointCollection();
                stylusPointCollection.Add(new StylusPoint(curCursorPosition.X, curCursorPosition.Y));
                _Stroke = new Stroke(stylusPointCollection);
                _currentInkCanvas.Strokes.Add(_Stroke);

                _curPointIndex = 0;

            }
            else //add next point to current stroke
            {
                StylusPoint stylusPoint = new StylusPoint(curCursorPosition.X, curCursorPosition.Y);
                _curPointIndex++;
                _Stroke.StylusPoints.Insert(_curPointIndex, stylusPoint);
            }
        }
Esempio n. 31
0
 private Stroke StringToStroke(string strokestring)
 {
     var PointCollection = new StylusPointCollection();
     var strokeDrawingAttributes = new DrawingAttributes();
     var reader = XmlReader.Create(new StringReader(strokestring));
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             switch (reader.Name)
             {
                 case "points":
                     reader.Read();
                     if (reader.NodeType == XmlNodeType.Text)
                     {
                         if (reader.HasValue)
                         {
                             var pointCollectionString = reader.Value.Trim();
                             string[] points = pointCollectionString.Split(' ');
                             foreach (string point in points)
                             {
                                 string[] members = point.Split(',');
                                 var sp = new StylusPoint { X = double.Parse(members[0]), Y = double.Parse(members[1]), PressureFactor = float.Parse(members[2]) };
                                 PointCollection.Add(sp);
                             }
                         }
                     }
                     break;
                 case "creator":
                     break;
                 case "size":
                     reader.Read();
                     if (reader.NodeType == XmlNodeType.Text)
                     {
                         if (reader.HasValue)
                         {
                             var sizeValue = reader.Value;
                             var size = double.Parse(sizeValue);
                             strokeDrawingAttributes.Height = size;
                             strokeDrawingAttributes.Width = size;
                         }
                     } break;
                 case "color":
                     reader.Read();
                     if (reader.NodeType == XmlNodeType.Text)
                     {
                         if (reader.HasValue)
                         {
                             var colorValue = reader.Value;
                             var color = new Color
                             {
                                 A = (byte)(Convert.ToUInt32(colorValue.Substring(1, 2), 16)),
                                 R = (byte)(Convert.ToUInt32(colorValue.Substring(3, 2), 16)),
                                 G = (byte)(Convert.ToUInt32(colorValue.Substring(5, 2), 16)),
                                 B = (byte)(Convert.ToUInt32(colorValue.Substring(7, 2), 16))
                             };
                             strokeDrawingAttributes.Color = color;
                         }
                     }
                     break;
                 case "stroke":
                     break;
             }
         }
     }
     var stroke = new Stroke(PointCollection);
     stroke.DrawingAttributes = strokeDrawingAttributes;
     return stroke;
 }
        public void SetDataInControl4CurCanvas()
        {
            try
            {
                _currentInkCanvas.Strokes.Clear();

                //Set start locations of terrorists and counterterrorist
                /*InkCanvas.SetLeft(_counterTerroristStartPos, _mapDatabase.CounterTerroristStartPos.X);
                InkCanvas.SetTop(_counterTerroristStartPos, _mapDatabase.CounterTerroristStartPos.Y);
                InkCanvas.SetLeft(_terroristStartPos, _mapDatabase.TerroristStartPos.X);
                InkCanvas.SetTop(_terroristStartPos, _mapDatabase.TerroristStartPos.Y);*/

                for (int i = 0; i < _mapDatabase.Layers.Count; i++)
                {
                    MapDatabase.Layer layer = _mapDatabase.Layers[i];
                    InkCanvas inkCanvas = (InkCanvas)_canvasList.Children[i];
                   // _currentInkCanvas = inkCanvas;
                    foreach (MapDatabase.Image image in layer.Images)
                    {
                        Image img = new Image();
                        img.Stretch = Stretch.Fill;
                        if (!File.Exists(image.Path))
                            throw new FileNotFoundException(image.Path);

                        BitmapImage bitmapImage = new BitmapImage();
                        bitmapImage.BeginInit();
                        bitmapImage.UriSource = new Uri(image.Path, UriKind.Absolute);
                        bitmapImage.EndInit();
                        img.Source = bitmapImage;

                        img.Width = image.Width;
                        img.Height = image.Height;
                        InkCanvas.SetLeft(img, image.X);
                        InkCanvas.SetTop(img, image.Y);
                        inkCanvas.Children.Add(img);
                    }

                    foreach (MapDatabase.Polygon polygon in layer.Polygons)
                    {
                        //Create a collection of points of the current polygon
                        StylusPointCollection stylusPointCollection = new StylusPointCollection();
                        foreach (Point point in polygon.Points)
                        {
                            StylusPoint stylusPoint = new StylusPoint(point.X, point.Y);
                            stylusPointCollection.Add(stylusPoint);
                        }

                        //Add polygon as a new stroke
                        Stroke stroke = new Stroke(stylusPointCollection);
                        stroke.DrawingAttributes.Color = polygon.Color;
                        inkCanvas.Strokes.Add(stroke);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMessageBox.Show(ex);
            }
        }
Esempio n. 33
0
        void _strokeStream_OnNormalEvent(TEventEntry aEvent, TByteBuffer aPayload)
        {
            rsv.Dispatcher.Invoke(
                delegate
                {   
                    string strokesStr = aPayload.ReadString();
                    if (String.IsNullOrEmpty(strokesStr))
                        return;
                    if (strokesStr == "clear")
                    {
                        _strokes = new Dictionary<string, Stroke>();
                        rsv.inkStrokes.Strokes.Clear();
                        rsv.inkStrokes.InvalidateVisual();
                        rsv.gMain.InvalidateVisual();
                        return;
                    }
                    string[] strokesArr = strokesStr.Split(';');
                    _strokes = new Dictionary<string, Stroke>();
                    rsv.inkStrokes.Strokes.Clear();
                    foreach (string strokeStr in strokesArr)
                    {
                        string[] strokeDef = strokeStr.Split('/');
                        if (strokeDef.Length != 2)
                            break;
                        string guid = strokeDef[0];
                        if (_strokes.ContainsKey(guid))
                            continue;
                            
                        string[] pointsArr = strokeDef[1].Split('|');
                        StylusPointCollection points = new StylusPointCollection();
                        try
                        {
                            foreach (string pointStr in pointsArr)
                            {

                                string[] pointParts = pointStr.Split(',');

                                if (pointParts.Length == 2 && wb != null)
                                {
                                    StylusPoint point = new StylusPoint(wb.Width / 640d * double.Parse(pointParts[1]), wb.Height - (wb.Height / 480d * double.Parse(pointParts[0])));
                                    //StylusPoint point = new StylusPoint(double.Parse(pointParts[1]), wb.Height - double.Parse(pointParts[0]));
                                    points.Add(point);
                                }
                            }
                        }
                        catch (Exception err)
                        {
                            string errMsg = err.Message;
                        }
                        try
                        {
                            Stroke stroke = new Stroke(points);
                            stroke.DrawingAttributes.Color = Colors.Red;
                            stroke.DrawingAttributes.Height = 3;
                            stroke.DrawingAttributes.Width = 3;
                            //rsv.inkStrokes.Width = rsv.bs.ActualWidth;
                            rsv.inkStrokes.Strokes.Add(stroke);
                                
                            _strokes.Add(guid, stroke);
                               
                        }
                        catch { }
                    }
                    rsv.inkStrokes.InvalidateVisual();
                    rsv.gMain.InvalidateVisual();
                });
        }
Esempio n. 34
0
        private static void placeInkBackToOriginalInkPresenter(InkPresenter inkCanvas, int i, StylusPointCollection spcTemp, Stroke newStroke)
        {
            for (int j = 0; j < ipToMove.Strokes[i].StylusPoints.Count; j++)
            {
                StylusPoint spTemp = new StylusPoint(ipToMove.Strokes[i].StylusPoints[j].X + ipToMove.Margin.Left, ipToMove.Strokes[i].StylusPoints[j].Y + ipToMove.Margin.Top);
                spcTemp.Add(spTemp);
            }

            newStroke.DrawingAttributes.Color = colorTemp;
            newStroke.DrawingAttributes.Height = 5;
            newStroke.DrawingAttributes.Width = 5;

            newStroke.StylusPoints.Add(spcTemp);
            inkCanvas.Strokes.Insert(layerIndex, newStroke);
        }
Esempio n. 35
0
 protected abstract double GetStylusPointWidthOrHeight(StylusPoint stylusPoint, bool isWidth);
 private void resizeSelectedObjects(Rect oldSelection, Rect newSelection)
 {
     var removingStrokes = new StrokeCollection();
     replacementStrokes.Clear();
     double WidthFactor = 1;
     double HeightFactor = 1;
     if (oldSelection.Width != newSelection.Width)
         WidthFactor = newSelection.Width / oldSelection.Width;
     if (oldSelection.Height != newSelection.Height)
         HeightFactor = newSelection.Height / oldSelection.Height;
     removeStylingFromStrokes();
     foreach (Stroke stroke in referencedStrokes)
     {
         var newSpc = new StylusPointCollection();
         foreach (StylusPoint sp in stroke.StylusPoints)
         {
             var newSp = new StylusPoint();
             newSp.X = ((sp.X - oldSelection.X) * WidthFactor) + newSelection.X;
             newSp.Y = ((sp.Y - oldSelection.Y) * HeightFactor) + newSelection.Y;
             newSp.PressureFactor = sp.PressureFactor;
             newSpc.Add(newSp);
         }
         var newStroke = new Stroke(newSpc);
         newStroke.DrawingAttributes.Color = stroke.DrawingAttributes.Color;
         newStroke.DrawingAttributes.OutlineColor = stroke.DrawingAttributes.OutlineColor;
         newStroke.DrawingAttributes.Height = stroke.DrawingAttributes.Height;
         newStroke.DrawingAttributes.Width = stroke.DrawingAttributes.Width;
         removingStrokes.Add(stroke);
         replacementStrokes.Add(newStroke);
         referencedCanvas.Strokes.Remove(stroke);
         referencedCanvas.Strokes.Add(newStroke);
     }
     referencedCanvas.eventHandler_ReplaceStrokes(removingStrokes, replacementStrokes);
     referencedCanvas.eventHandler_ReplaceSelectedStrokes(removingStrokes, replacementStrokes);
     referencedStrokes.Clear();
     foreach (Stroke stroke in replacementStrokes)
         referencedStrokes.Add(stroke);
     setupSelectionAdorner();
 }