public InkMirror() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Enabled; inkRecognizer = new ServiceHelpers.InkRecognizer(subscriptionKey); recoTreeNodes = new Dictionary <int, InkRecognitionUnit>(); recoTreeParentNodes = new List <InkRecognitionUnit>(); recoText = new Dictionary <int, Tuple <string, Color> >(); redoStrokes = new Stack <InkStroke>(); clearedStrokes = new List <InkStroke>(); activeTool = ballpointPen; inkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Mouse; inkCanvas.InkPresenter.StrokeInput.StrokeStarted += InkPresenter_StrokeInputStarted; inkCanvas.InkPresenter.StrokesErased += InkPresenter_StrokesErased; var languages = new List <Language> { new Language("Chinese (Simplified)", "zh-CN"), new Language("Chinese (Traditional)", "zh-TW"), new Language("English (UK)", "en-GB"), new Language("English (US)", "en-US"), new Language("French", "fr-FR"), new Language("German", "de-DE"), new Language("Italian", "it-IT"), new Language("Korean", "ko-KR"), new Language("Portuguese", "pt-PT"), new Language("Spanish", "es-ES") }; languageDropdown.ItemsSource = languages; }
private void InkPresenter_StrokeInputStarted(InkStrokeInput sender, PointerEventArgs args) { clearedStrokes.Clear(); inkCleared = false; activeTool = inkToolbar.ActiveTool; }
public FormFiller() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Enabled; inkRecognizer = new ServiceHelpers.InkRecognizer(subscriptionKey); redoStacks = new Dictionary <string, Stack <InkStroke> >(); clearedStrokesLists = new Dictionary <string, List <InkStroke> >(); activeTool = ballpointPen; // Add event handlers and create redo stacks for each form field's ink canvases foreach (string prefix in prefixes) { var canvas = this.FindName($"{prefix}Canvas") as InkCanvas; canvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Mouse; canvas.InkPresenter.StrokeInput.StrokeStarted += InkPresenter_StrokeInputStarted; canvas.InkPresenter.StrokeInput.StrokeEnded += InkPresenter_StrokeInputEnded; canvas.InkPresenter.StrokesErased += InkPresenter_StrokeErased; redoStacks.Add(prefix, new Stack <InkStroke>()); clearedStrokesLists.Add(prefix, new List <InkStroke>()); } // Timer created for ink recognition to happen after a set time period once a stroke ends dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Interval = TimeSpan.FromMilliseconds(350); }
public InkMirror() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Enabled; inkRecognizer = new ServiceHelpers.InkRecognizer(subscriptionKey); recoTreeNodes = new Dictionary <int, InkRecognitionUnit>(); recoTreeParentNodes = new List <InkRecognitionUnit>(); recoText = new Dictionary <int, Tuple <string, Color> >(); redoStrokes = new Stack <InkStroke>(); clearedStrokes = new List <InkStroke>(); activeTool = ballpointPen; inkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Mouse; inkCanvas.InkPresenter.StrokeInput.StrokeStarted += InkPresenter_StrokeInputStarted; inkCanvas.InkPresenter.StrokesErased += InkPresenter_StrokesErased; resultNav.SelectedItem = resultNav.MenuItems[0]; // Set default ink color to blue ballpointPen.SelectedBrushIndex = 16; pencil.SelectedBrushIndex = 16; }
private void InkPresenter_StrokeInputStarted(InkStrokeInput sender, PointerEventArgs args) { ViewCanvasButton_Click(null, null); clearedStrokes.Clear(); inkCleared = false; activeTool = inkToolbar.ActiveTool; }
private void InkPresenter_StrokesErased(InkPresenter sender, InkStrokesErasedEventArgs args) { // When strokes are erased they are treated the same as an undo and are pushed onto a stack of strokes for the redo button foreach (var stroke in args.Strokes) { redoStrokes.Push(stroke); } activeTool = inkToolbar.ActiveTool; }
private void InkPresenter_StrokeInputStarted(InkStrokeInput sender, PointerEventArgs args) { inkRecoTimer.Stop(); textToggleTimer.Stop(); int index = currentCanvas.Name.IndexOf("Canvas"); string prefix = currentCanvas.Name.Substring(0, index); clearedStrokesLists[prefix].Clear(); inkCleared = false; activeTool = inkToolbar.ActiveTool; }
private void InkPresenter_StrokeInputStarted(InkStrokeInput sender, PointerEventArgs args) { dispatcherTimer.Stop(); int index = currentCanvas.Name.IndexOf("Canvas"); string prefix = currentCanvas.Name.Substring(0, index); var formField = this.FindName($"{prefix}") as Grid; if (formField.Tag.ToString() == "accepted") { formField.BorderBrush = new SolidColorBrush(Colors.Yellow); formField.Tag = "pending"; } clearedStrokesLists[prefix].Clear(); inkCleared = false; activeTool = inkToolbar.ActiveTool; }
public FormFiller() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Enabled; inkRecognizer = new ServiceHelpers.InkRecognizer(subscriptionKey); redoStacks = new Dictionary <string, Stack <InkStroke> >(); clearedStrokesLists = new Dictionary <string, List <InkStroke> >(); currentCanvas = yearCanvas; inkToolbar.TargetInkCanvas = currentCanvas; activeTool = ballpointPen; // Set default ink color to blue ballpointPen.SelectedBrushIndex = 16; pencil.SelectedBrushIndex = 16; // Add event handlers and create redo stacks for each form field's ink canvases foreach (string prefix in prefixes) { var canvas = this.FindName($"{prefix}Canvas") as InkCanvas; canvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Mouse; canvas.InkPresenter.StrokeInput.StrokeStarted += InkPresenter_StrokeInputStarted; canvas.InkPresenter.StrokeInput.StrokeEnded += InkPresenter_StrokeInputEnded; canvas.InkPresenter.StrokesErased += InkPresenter_StrokeErased; redoStacks.Add(prefix, new Stack <InkStroke>()); clearedStrokesLists.Add(prefix, new List <InkStroke>()); } // Timer created for ink recognition to happen after a set time period once a stroke ends inkRecoTimer = new DispatcherTimer(); inkRecoTimer.Tick += InkRecoTimer_Tick; inkRecoTimer.Interval = TimeSpan.FromMilliseconds(350); // Timer created to switch from ink to text when user is idle in form field after a set time textToggleTimer = new DispatcherTimer(); textToggleTimer.Tick += TextToggleTimer_Tick; textToggleTimer.Interval = TimeSpan.FromSeconds(3); }
// </SnippetInkToolbarMainPageCB> // <SnippetInkToolbarLoadedCB> /// <summary> /// Handle the Loaded event of the InkToolbar. /// By default, the active tool is set to the first tool on the toolbar. /// Here, we set the active tool to the pencil button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void inkToolbar_Loaded(object sender, RoutedEventArgs e) { InkToolbarToolButton pencilButton = inkToolbar.GetToolButton(InkToolbarTool.Pencil); inkToolbar.ActiveTool = pencilButton; }