From bb768ca2a9274d07ef4618e527452dcdd6cd430d Mon Sep 17 00:00:00 2001
From: Sam Wilkins <samwilkins333@gmail.com>
Date: Mon, 27 Jan 2020 13:19:50 -0500
Subject: fallback behavior for non-downloaded images and restored ink
 recognition

---
 src/client/views/InkingStroke.tsx | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

(limited to 'src/client/views/InkingStroke.tsx')

diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx
index aca507147..f315ce12a 100644
--- a/src/client/views/InkingStroke.tsx
+++ b/src/client/views/InkingStroke.tsx
@@ -11,6 +11,12 @@ import { FieldView, FieldViewProps } from "./nodes/FieldView";
 import React = require("react");
 import { TraceMobx } from "../../new_fields/util";
 import { InteractionUtils } from "../util/InteractionUtils";
+import { ContextMenu } from "./ContextMenu";
+import { CognitiveServices } from "../cognitive_services/CognitiveServices";
+import { faPaintBrush } from "@fortawesome/free-solid-svg-icons";
+import { library } from "@fortawesome/fontawesome-svg-core";
+
+library.add(faPaintBrush);
 
 type InkDocument = makeInterface<[typeof documentSchema]>;
 const InkDocument = makeInterface(documentSchema);
@@ -22,6 +28,11 @@ export class InkingStroke extends DocExtendableComponent<FieldViewProps, InkDocu
     @computed get PanelWidth() { return this.props.PanelWidth(); }
     @computed get PanelHeight() { return this.props.PanelHeight(); }
 
+    private analyzeStrokes = () => {
+        const data: InkData = Cast(this.Document.data, InkField)?.inkData ?? [];
+        CognitiveServices.Inking.Appliers.ConcatenateHandwriting(this.Document, ["inkAnalysis", "handwriting"], [data]);
+    }
+
     render() {
         TraceMobx();
         const data: InkData = Cast(this.Document.data, InkField)?.inkData ?? [];
@@ -37,12 +48,23 @@ export class InkingStroke extends DocExtendableComponent<FieldViewProps, InkDocu
         const scaleX = this.PanelWidth / width;
         const scaleY = this.PanelHeight / height;
         return (
-            <svg width={width} height={height} style={{
-                transformOrigin: "top left",
-                transform: `scale(${scaleX}, ${scaleY})`,
-                mixBlendMode: this.Document.tool === InkTool.Highlighter ? "multiply" : "unset",
-                pointerEvents: "all"
-            }}>
+            <svg
+                width={width}
+                height={height}
+                style={{
+                    transformOrigin: "top left",
+                    transform: `scale(${scaleX}, ${scaleY})`,
+                    mixBlendMode: this.Document.tool === InkTool.Highlighter ? "multiply" : "unset",
+                    pointerEvents: "all"
+                }}
+                onContextMenu={() => {
+                    ContextMenu.Instance.addItem({
+                        description: "Analyze Stroke",
+                        event: this.analyzeStrokes,
+                        icon: "paint-brush"
+                    });
+                }}
+            >
                 {points}
             </svg>
         );
-- 
cgit v1.2.3-70-g09d2

