Beispiel #1
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.truthTableUserControl = ((LogicPad2.TruthTable.UserControl1)(target));
     return;
     case 2:
     this.UserControlScaleXY = ((System.Windows.Media.ScaleTransform)(target));
     return;
     case 3:
     this.UserControlXY = ((System.Windows.Media.TranslateTransform)(target));
     return;
     case 4:
     this.controlBorder = ((System.Windows.Controls.Border)(target));
     return;
     case 5:
     this.Grid0 = ((System.Windows.Controls.Grid)(target));
     return;
     case 6:
     this.truthTableInkCanvas = ((LogicPad2.TruthTable.MSInkAnalysisCanvas)(target));
     return;
     case 7:
     this.controlRegion = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 8:
     this.TermLabel = ((System.Windows.Controls.Label)(target));
     return;
     case 9:
     this.DeleteTerm = ((System.Windows.Controls.Button)(target));
     return;
     case 10:
     this.myTerm = ((System.Windows.Controls.Label)(target));
     return;
     case 11:
     this.AddTerm = ((System.Windows.Controls.Button)(target));
     return;
     case 12:
     this.btnSave = ((System.Windows.Controls.Button)(target));
     return;
     case 13:
     this.btnCancel = ((System.Windows.Controls.Button)(target));
     return;
     case 14:
     this.btnTransform = ((System.Windows.Controls.Button)(target));
     return;
     case 15:
     this.btnScale = ((System.Windows.Controls.Button)(target));
     return;
     }
     this._contentLoaded = true;
 }
        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;
            }
        }