private static Tuple <RecognitionRoot, List <InkRecognitionUnit> > _parseRecognitionUnits(JsonElement recoUnitsJson)
        {
            try
            {
                List <InkRecognitionUnit> recoUnits = new List <InkRecognitionUnit>();
                RecognitionRoot           root      = null;

                foreach (var recoUnitJson in recoUnitsJson.EnumerateArray())
                {
                    var category = recoUnitJson.GetProperty("category").GetString();
                    switch (category)
                    {
                    case "unknown":
                        var unclassifiedInk = new Unclassified(recoUnitJson);
                        recoUnits.Add(unclassifiedInk);
                        break;

                    case "writingRegion":
                        var recognizedWritingRegion = new RecognizedWritingRegion(recoUnitJson);
                        recoUnits.Add(recognizedWritingRegion);
                        break;

                    case "paragraph":
                        var recognizedParagraph = new RecognizedParagraph(recoUnitJson);
                        recoUnits.Add(recognizedParagraph);
                        break;

                    case "line":
                        var recognizedLine = new RecognizedLine(recoUnitJson);
                        recoUnits.Add(recognizedLine);
                        break;

                    case "inkWord":
                        var inkWord = new InkWord(recoUnitJson);
                        recoUnits.Add(inkWord);
                        break;

                    case "inkBullet":
                        var inkBullet = new InkBullet(recoUnitJson);
                        recoUnits.Add(inkBullet);
                        break;

                    case "inkDrawing":
                        var inkDrawing = new InkDrawing(recoUnitJson);
                        recoUnits.Add(inkDrawing);
                        break;

                    case "listItem":
                        var inkList = new RecognizedListItem(recoUnitJson);
                        recoUnits.Add(inkList);
                        break;
                    }
                }
                return(Tuple.Create(root, recoUnits));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        private void TestInkDrawing(InkDrawing drawing, RecognitionRoot root)
        {
            Assert.IsNotNull(drawing);
            Assert.IsTrue(drawing.Id == 1);
            Assert.IsTrue(drawing.Kind == InkRecognitionUnitKind.InkDrawing);
            //Assert.IsTrue(drawing.Parent == root);
            Assert.IsTrue(drawing.Children.Count() == 0);

            var point1 = new PointF(78.1f, 19.9f);
            var point2 = new PointF(103.8f, 66.5f);
            var point3 = new PointF(52.8f, 59.7f);
            var points = new List <PointF>()
            {
                point1, point2, point3
            };

            Assert.IsTrue(drawing.Points.SequenceEqual(points));

            Assert.IsTrue(drawing.RecognizedShape == RecognizedShape.Triangle);
            var center = new PointF(78.2f, 48.7f);

            Assert.IsTrue(drawing.Center.Equals(center));
            Assert.IsTrue(drawing.RotationAngle == 0.0f);

            var boundingRect = new RectangleF();

            boundingRect.Height = 47.6f;
            boundingRect.X      = 52.9f;
            boundingRect.Y      = 19.4f;
            boundingRect.Width  = 51.2f;
            Assert.IsTrue(drawing.BoundingBox.Equals(boundingRect));

            point1 = new PointF(79.5f, 18.7f);
            point2 = new PointF(103.5f, 67.0f);
            point3 = new PointF(64.3f, 86.4f);
            var point4 = new PointF(40.4f, 38.1f);
            var rotatedBoundingRect = new List <PointF> {
                point1, point2, point3, point4
            };

            Assert.IsTrue(drawing.RotatedBoundingBox.SequenceEqual(rotatedBoundingRect));
        }
 public void UpdateInkDrawing(InkDrawing inkDrawing)
 {
     _context.Entry(inkDrawing).State = EntityState.Modified;
 }
        public void DeleteInkDrawing(int inkDrawingID)
        {
            InkDrawing inkDrawing = _context.InkDrawings.Find(inkDrawingID);

            _context.InkDrawings.Remove(inkDrawing);
        }
 public void InsertInkDrawing(InkDrawing inkDrawing)
 {
     _context.InkDrawings.Add(inkDrawing);
 }