Esempio n. 1
0
        /// <summary>
        /// This is to test the store functionlaity.
        /// </summary>
        //[TestMethod]
        public void TestInkStrokeStrore()
        {
            var inkStrokeStore = new InkStrokeStore();

            Assert.IsNotNull(inkStrokeStore);

            var stroke = TestUtils.CreateRandomStroke();

            Assert.IsNotNull(stroke);

            // Check default configurations of InkRecognizerStroke
            var strokeId1        = inkStrokeStore.AddStroke(stroke);
            var strokesFromStore = inkStrokeStore.GetStrokes();

            Assert.IsTrue(strokesFromStore.Count() == 1);

            var strokeFromStore = strokesFromStore.ElementAt(0);

            Assert.IsTrue(strokeFromStore.Id == strokeId1);
            Assert.IsTrue(strokeFromStore.Kind == InkStrokeKind.Unknown);

            // Change the configurations of InkRecognizerStroke
            var strokeId2 = inkStrokeStore.AddStroke(stroke, InkStrokeKind.InkDrawing, "en-GB");

            strokesFromStore = inkStrokeStore.GetStrokes();
            Assert.IsTrue(strokesFromStore.Count() == 2);

            strokeFromStore = strokesFromStore.ElementAt(1);
            Assert.IsTrue(strokeFromStore.Id == strokeId2);
            Assert.IsTrue(strokeFromStore.Kind == InkStrokeKind.InkDrawing);
            Assert.IsTrue(strokeFromStore.Language == "en-GB");

            // Check deletion of strokes from Stroke store
            inkStrokeStore.RemoveStroke(strokeId1);
            strokesFromStore = inkStrokeStore.GetStrokes();
            Assert.IsTrue(strokesFromStore.Count() == 1);
            Assert.IsTrue(strokeFromStore.Id == strokeId2);
            inkStrokeStore.RemoveStroke(strokeId2);
            strokesFromStore = inkStrokeStore.GetStrokes();
            Assert.IsTrue(strokesFromStore.Count() == 0);
        }
Esempio n. 2
0
        // <MainWindow>
        public MainWindow()
        {
            InitializeComponent();

            strokeToIdMap = new Dictionary <System.Windows.Ink.Stroke, long>();
            idToStrokeMap = new Dictionary <long, System.Windows.Ink.Stroke>();

            strokeStore = new InkStrokeStore();

            //Use Bezier smoothing while rendering the stroke
            var drawingAttributes = inkCanvas.DefaultDrawingAttributes;

            drawingAttributes.FitToCurve       = true;
            inkCanvas.DefaultDrawingAttributes = drawingAttributes;

            inkCanvas.StrokeCollected += InkCanvas_StrokeCollected;
            inkCanvas.StrokeErasing   += InkCanvas_StrokeErased;

            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(IDLE_WAITING_TIME);
        }
        // <MainPage>
        public MainPage()
        {
            this.InitializeComponent();

            strokeToIdMap = new Dictionary <Windows.UI.Input.Inking.InkStroke, long>();
            idToStrokeMap = new Dictionary <long, Windows.UI.Input.Inking.InkStroke>();

            strokeStore = new InkStrokeStore();

            // By default, enable inking only by Pen
            var inkPresenter = inkCanvas.InkPresenter;

            inkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen;

            inkPresenter.StrokeInput.StrokeStarted += InkPresenter_StrokeInputStarted;
            inkPresenter.StrokeInput.StrokeEnded   += InkPresenter_StrokeInputEnded;
            inkPresenter.StrokesCollected          += InkPresenter_StrokesCollected;
            inkPresenter.StrokesErased             += InkPresenter_StrokesErased;

            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(IDLE_WAITING_TIME);
        }