void DisableDictionary() { AnalysisHintNode hint = inkAnalyzer.CreateAnalysisHint(); hint.Factoid = "NONE"; hint.Location.MakeInfinite(); }
protected override void OnContentRendered(EventArgs e) { base.OnContentRendered(e); // Initialize the Analyzer. analyzer = new InkAnalyzer(); analyzer.ResultsUpdated += new ResultsUpdatedEventHandler(analyzer_ResultsUpdated); // Add analysis hints for each form area. // Use the absolute Width and Height of the Grid's // RowDefinition and ColumnDefinition properties defined in XAML, // to calculate the bounds of the AnalysisHintNode objects. hintNodeTitle = analyzer.CreateAnalysisHint( new Rect(100, 0, 740, 100)); hintNodeDirector = analyzer.CreateAnalysisHint( new Rect(100, 100, 740, 100)); hintNodeStarring = analyzer.CreateAnalysisHint( new Rect(100, 200, 740, 100)); hintNodeRating = analyzer.CreateAnalysisHint( new Rect(100, 300, 320, 100)); hintNodeYear = analyzer.CreateAnalysisHint( new Rect(520, 300, 320, 100)); hintNodeGenre = analyzer.CreateAnalysisHint( new Rect(100, 400, 740, 100)); //Set the factoids on the hints. hintNodeTitle.Factoid = "(!IS_DEFAULT)"; hintNodeDirector.Factoid = "(!IS_PERSONALNAME_FULLNAME)"; hintNodeStarring.Factoid = "(!IS_PERSONALNAME_FULLNAME)"; hintNodeRating.Factoid = "(!IS_DEFAULT)"; hintNodeYear.Factoid = "(!IS_DATE_YEAR)"; hintNodeGenre.Factoid = "(!IS_DEFAULT)"; }
void onLoaded(object sender, RoutedEventArgs e) { m_analyzer = new InkAnalyzer(); m_analyzer.AnalysisModes = AnalysisModes.AutomaticReconciliationEnabled; m_analyzer.ResultsUpdated += new ResultsUpdatedEventHandler(m_analyzer_ResultsUpdated); string[] wordListArray = { "+", "-", "x", "/", "=", }; //00D7 = Multiplication X //2217 = Multiplication * //00F7 = Divide Sign //00B2 = ^2 hint = m_analyzer.CreateAnalysisHint(); hint.Location.MakeInfinite(); hint.Factoid = "(NUMBER)"; hint.SetWordlist(wordListArray); hint.Name = "Wordlist"; }
public void Populate(ICollection <Recognition> recogs, StroqCollection stroqs) { alternateRec = recogs.Count == 1 ? recogs.Single() : null; if (alternateRec != null && !stroqs.All((s) => alternateRec.strokes.Contains(_mrec.Sim[s]))) { alternateRec = null; } altstroqsRec = stroqs; altrecogsRec = recogs; _menuShell.Items.Clear(); MenuItem mi; bool needseparator = false; if (recogs.Count == 1) { /* regular alternates*/ Recognition rr = recogs.Single(); for (int i = 0; i < rr.alts.Length; i++) { string label; char c = rr.alts[i].Character; if (c != 0) { label = c.ToString(); } else { label = rr.alts[i].Word; if (label == null) { label = rr.alts[i].ToString(); label = label.Substring(1, label.Length - 2); } } mi = new MenuItem(); mi.Header = label; if (c != 0) { mi.ToolTip = Unicode.NameOf(c); mi.FontFamily = new FontFamily(starPadSDK.MathExpr.ExprWPF.EDrawingContext.FontFamilyURIBase, starPadSDK.MathExpr.ExprWPF.EDrawingContext.FontFamilyURIRel); if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= 'α' && c <= 'ω') || c == Unicode.G.GREEK_PHI_SYMBOL) { mi.FontStyle = FontStyles.Italic; } } else { mi.ToolTip = label; } mi.Tag = i; mi.Click += ChooseAlternate; mi.PreviewMouseDown += mi_MouseDown; mi.PreviewMouseUp += mi_MouseUp; if (i == 0) { mi.AllowDrop = true; mi.DragEnter += mi_DragCheck; mi.DragOver += mi_DragCheck; mi.Drop += mi_Drop; } if (rr.curalt == i) { mi.IsChecked = true; } _menuShell.Items.Add(mi); } needseparator = true; } if (stroqs.Count > 1 && stroqs.Count != recogs.Count /* FIXME: if a stroke has no recog, this won't work */) { /* option to split apart and recognize each stroke separately */ if (needseparator) { _menuShell.Items.Add(new Separator()); needseparator = false; } string label = ""; foreach (Stroq s1 in stroqs) { Recognition r = _mrec.Charreco.Classify(_mrec.Sim[s1], true); if (r == null) { continue; } string l; char c = r.alt.Character; if (c != 0) { l = c.ToString(); } else { l = r.alt.Word; if (l == null) { l = r.alt.ToString(); l = l.Substring(1, l.Length - 2); } } label += l; } mi = new MenuItem(); mi.Header = label; mi.ToolTip = "split combined symbol into separate symbols"; mi.Tag = -1; mi.Click += ChooseAlternate; _menuShell.Items.Add(mi); needseparator = true; } if (stroqs.Count > 0) { /* Interpret everything as a single word */ if (needseparator) { _menuShell.Items.Add(new Separator()); needseparator = false; } InkAnalyzer ia = new InkAnalyzer(); AnalysisHintNode ahn = ia.CreateAnalysisHint(); ahn.WordMode = true; ahn.Location.MakeInfinite(); foreach (Stroq s in stroqs) { ia.AddStroke(s.BackingStroke); } AnalysisStatus stat = ia.Analyze(); if (stat.Successful) { AnalysisAlternateCollection aac = ia.GetAlternates(); for (int i = 0; i < aac.Count; i++) { if (aac[i].AlternateNodes.Count > 1 || !(aac[i].AlternateNodes[0] is InkWordNode)) { continue; } mi = new MenuItem(); mi.Header = aac[i].RecognizedString; mi.ToolTip = "interpret all selected strokes as a single character or word: alternate " + (i + 1); mi.Tag = aac[i]; mi.Click += ChooseAlternate; if (alternateRec != null) { mi.PreviewMouseDown += mi_MouseDown; mi.PreviewMouseUp += mi_MouseUp; } if (aac[i].RecognizedString.Length == 1) { char c = aac[i].RecognizedString[0]; if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= 'α' && c <= 'ω')) { mi.FontStyle = FontStyles.Italic; } mi.ToolTip = (string)mi.ToolTip + " (" + Unicode.NameOf(c) + ")"; } _menuShell.Items.Add(mi); } } } _menuShell.InvalidateMeasure(); // odd that I need this }