protected virtual void OnSubCanvasGenerated(SubCanvasEventArgs e) { if (_subInkCanvasGenerated != null) { _subInkCanvasGenerated(this, e); } }
private void CheckOutputValue(StrokeCollection myStrokes, String recognizedCharacter) { Rect rect = myStrokes.GetBounds(); SubCanvasEventArgs args; switch(recognizedCharacter) { case "T": args = new SubCanvasEventArgs(LogicCanvasType.TruthTable, rect, myStrokes); OnSubCanvasGenerated(args); break; case "e": args = new SubCanvasEventArgs(LogicCanvasType.Expression, rect, myStrokes); OnSubCanvasGenerated(args); break; case "D": args = new SubCanvasEventArgs(LogicCanvasType.Diagram, rect, myStrokes); OnSubCanvasGenerated(args); break; case "d": args = new SubCanvasEventArgs(LogicCanvasType.Diagram, rect, myStrokes); OnSubCanvasGenerated(args); break; case "=": args = new SubCanvasEventArgs(LogicCanvasType.EqualSign, rect, myStrokes); OnSubCanvasGenerated(args); break; case "?": args = new SubCanvasEventArgs(LogicCanvasType.Question, rect, myStrokes); OnSubCanvasGenerated(args); break; default: break; } }
public void GenerateSubInkCanvas(object sender, SubCanvasEventArgs args) { switch (args.LogicCanvasType) { case LogicCanvasType.Diagram: Diagram.UserControl1 diagramUserControl1 = new Diagram.UserControl1(); diagramUserControl1.UserControlX = args.Central.X; diagramUserControl1.UserControlY = args.Central.Y; this.Children.Add(diagramUserControl1); //Ad-hoc diagramUserControl1.disableInkHandler += new DisableInkHandler(diagramUserControl1_disableInkCanvasInkHandler); if(args.MyStrokes != null) DeleteRecognizedStrokesOnInkCanvas(args.MyStrokes); break; case LogicCanvasType.Expression: Expression.UserControl1 expressionUserControl = new Expression.UserControl1(); expressionUserControl.UserControlX = args.Central.X - expressionUserControl.UserControlWidth / 2; expressionUserControl.UserControlY = args.Central.Y - expressionUserControl.UserControlHeight / 2; this.Children.Add(expressionUserControl); if(args.MyStrokes != null) DeleteRecognizedStrokesOnInkCanvas(args.MyStrokes); break; case LogicCanvasType.TruthTable: TruthTable.UserControl1 truthTableUserControl = new TruthTable.UserControl1(); truthTableUserControl.UserControlX = args.Central.X - truthTableUserControl.UserControlWidth / 2; truthTableUserControl.UserControlY = args.Central.Y - truthTableUserControl.UserControlHeight / 2; this.Children.Add(truthTableUserControl); if(args.MyStrokes != null) DeleteRecognizedStrokesOnInkCanvas(args.MyStrokes); break; case LogicCanvasType.EqualSign: if (!HasEqualSignInkRegionAdded(args.MyStrokes)) { InkQueryRegionStruct equalRegion = new InkQueryRegionStruct(args.MyStrokes); if (!HasControlInLeftRegion(ref equalRegion)) { equalRegion.GenerateLeftSideRegion(); } if (!HasControlInRightRegion(ref equalRegion)) { equalRegion.GenerateRightSideRegion(); } //Check Parsing Current InkQueryRegionStruct if (equalRegion.LeftSideUserControl != null && equalRegion.RightSideUserControl != null) { if (LogicParser1.Instance.MatchTwoUserControl(equalRegion.LeftSideUserControl, equalRegion.RightSideUserControl)) { this.Dispatcher.BeginInvoke((Action)(() => { MessageBox.Show("Match On Two Representations"); })); } else { this.Dispatcher.BeginInvoke((Action)(() => { MessageBox.Show("Not Match on Two Representations"); })); } this.Strokes.Remove(equalRegion.EqualStrokes); } else { this.Children.Add(equalRegion); } } _inkAnalyzer.RemoveStrokes(args.MyStrokes); ShowInkAnalysisFeedback = false; break; case LogicCanvasType.Question: this.Dispatcher.BeginInvoke((Action)(() => { MessageBox.Show("Basic User Manual"); })); break; } }