/// <summary>
        /// 每条注释笔迹完成以后的操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InkCanvasAnnotation_StrokeCollected(object sender, System.Windows.Controls.InkCanvasStrokeCollectedEventArgs e)
        {
            if (null != _keyFramesAnnotation)
            {
                if (_keyFramesAnnotation.Strokes.Count == 0)
                {
                    if (_inkCollector.DefaultSummarizationNum == 0)
                    {
                        //关键帧索引
                        int index = _inkCollector.VideoSummarization.ShowKeyFrames.IndexOf(_inkCollector.SelectKeyFrames[0]);
                        ((SpiralSummarization)_inkCollector.VideoSummarization).AddPoints2ShowSpiral(index, Colors.Red, 0);
                    }
                    else if (_inkCollector.DefaultSummarizationNum == 1)
                    {
                        int         index   = _inkCollector.VideoSummarization.KeyFrames.IndexOf(_inkCollector.SelectKeyFrames[0]);
                        StylusPoint slPoint = _inkCollector.VideoSummarization.KeyPoints[index];

                        StylusPointCollection spc        = new StylusPointCollection();
                        StylusPoint           currPoint1 = new StylusPoint(slPoint.X - _inkCollector.VideoSummarization.ShowWidth / 2, slPoint.Y + _inkCollector.VideoSummarization.ShowHeight / 2 + 2);
                        StylusPoint           currPoint2 = new StylusPoint(slPoint.X + _inkCollector.VideoSummarization.ShowWidth / 2, slPoint.Y + _inkCollector.VideoSummarization.ShowHeight / 2 + 2);
                        spc.Add(currPoint1);
                        spc.Add(currPoint2);
                        Stroke s = new Stroke(spc);
                        s.DrawingAttributes.Color  = Colors.Red;
                        s.DrawingAttributes.Width  = 3;
                        s.DrawingAttributes.Height = 3;
                        ((InkCanvas)(_inkCollector._mainPage._inkCanvas.Children[1])).Strokes.Add(s);
                    }
                }
                Stroke lastStroke = InkCanvasAnnotation.Strokes[InkCanvasAnnotation.Strokes.Count - 1].Clone();
                _keyFramesAnnotation.Strokes.Add(lastStroke);
            }
        }
 private void InkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     InkAnalyzer analyser = new InkAnalyzer();
     analyser.AddStrokes(_inkCanvas.Strokes);
     analyser.Analyze();
     _inkResults.Text = analyser.GetRecognizedString();
     e.Handled = false;
 }
 protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
 {
     base.OnStrokeCollected(e);
     var handler = StampedStrokeCollected;
     if (handler != null)
     {
         handler(this, new StampedStrokeCollectedEventArgs { Stroke = e.Stroke, StampedStroke = Stamper.CurrentStroke });
     }
 }
Beispiel #4
0
        protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
        {
            Strokes.Remove(e.Stroke);
            var customStroke = new SmoothableStroke(e.Stroke.GetBezierStylusPoints());
            Strokes.Add(customStroke);

            InkCanvasStrokeCollectedEventArgs args =
                new InkCanvasStrokeCollectedEventArgs(customStroke);
            base.OnStrokeCollected(args);
        }
 private void InkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     var rounding = 1;
     File.AppendAllText(file, e.Stroke.StylusPoints.Aggregate<StylusPoint, string>("",
         (points,point)=>
             points+string.Format(" {0} {1} {2}", 
                 Math.Round(point.X,rounding), 
                 Math.Round(point.Y,rounding), 
                 Math.Round(point.PressureFactor,rounding))).Trim()+"\n");
 }
 private void singleStrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     e.Stroke.tag(new StrokeTag { author = Globals.me, privacy = Globals.privacy, isHighlighter = e.Stroke.DrawingAttributes.IsHighlighter });
     var privateAwareStroke = new PrivateAwareStroke(e.Stroke, target);
     Strokes.Remove(e.Stroke);
     privateAwareStroke.startingSum(privateAwareStroke.sum().checksum);
     Strokes.Add(privateAwareStroke);
     doMyStrokeAdded(privateAwareStroke);
     Commands.RequerySuggested(Commands.Undo);
 }
 private void StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     if (client != null)
     {
         var internalStroke = e.Stroke;
         var newStroke = new TargettedStroke(client.location.currentSlide, client.username, "presentationSpace", "public", internalStroke);
         client.SendStroke(newStroke);
     }
 }
 protected virtual new void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
 {
 }
        /**
         * This is called when the user finishes drawing a stroke.
         * */
        private void strokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            //Console.WriteLine("Stroke Collected");
            Stroke s = e.Stroke;
            if(s.StylusPoints.Count < 20){
                inkCanvas.Strokes.Remove(s);
            }
            Double firstX = s.StylusPoints[0].X;
            Double firstY = s.StylusPoints[0].Y;
            Point first = new Point(firstX,firstY);

            Double lastX= s.StylusPoints[s.StylusPoints.Count-1].X ;
            Double lastY = s.StylusPoints[s.StylusPoints.Count-1].Y ;
            Point last = new Point(lastX,lastY);

            Polyline p = new Polyline();
            p.Stroke = System.Windows.Media.Brushes.Cornsilk;
            p.StrokeThickness = 3.5;

            PointCollection pc = new PointCollection();
            pc.Add(first);
            pc.Add(last);

            p.Points = pc;
            inkCanvas.Strokes.Remove(s);
            myCanvas.Children.Add(p);
        }
 void canvasDeTinta_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     m_analyzer.AddStroke(e.Stroke);
     temp.Start();
 }
Beispiel #11
0
        public void StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            Matrix m = new Matrix();
            m.Translate(-UserControlX, -UserControlY);
            m.Scale(1 / UserControlScaleX, 1 / UserControlScaleY);
            e.Stroke.Transform(m, false);

            this.TruthTableInkCanvas.OnStrokesCollected(this, e);
        }
Beispiel #12
0
 private void strokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     if (OnInkChanged != null)
         OnInkChanged();
 }
Beispiel #13
0
 void onStrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     m_analyzer.AddStroke(e.Stroke);
     m_analyzer.BackgroundAnalyze();
 }
        private void OnStrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs args)
        {
            if (lastStrokes == null)
                lastStrokes = new StrokeCollection();
            lastStrokes.Add(args.Stroke);

            if (ActiveSessionManager.ActivePenMode == PenMode.Selection
                || ActiveSessionManager.ActivePenMode == PenMode.GestureArea)
                selectedStrokes = args.Stroke;
        }
        /*
        * Expression User Control: Yes
        * TruthTable User Control: Yes
        * Diagram User Control: Yes
        * 
        */
        protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
        {
            if (InputDevice == TabletDeviceType.Touch)
            {
                this.Strokes.Remove(e.Stroke);
                return;
            }

            base.OnStrokeCollected(e);

            foreach (UIElement child in Children)
            {
                if (child is IPassable)
                {
                    if (child is LogicPad2.Expression.UserControl1)
                    {
                        #region Expression User Control
                        LogicPad2.Expression.UserControl1 expressionUserControl = child as LogicPad2.Expression.UserControl1;

                        if (expressionUserControl.UserControlStatus == UserControlStatus.Scale)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }
                        else if (expressionUserControl.UserControlStatus == UserControlStatus.Transform)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        //HitTest
                        //Calculate center of stroke
                        Rect strokeRect = e.Stroke.GetBounds();
                        Point center = new Point(strokeRect.Left + strokeRect.Width / 2d,
                            strokeRect.Top + strokeRect.Height / 2d);

                        //Point transformPoint = child.RenderTransform.Inverse.Transform(center);
                        //HitTestResult result = VisualTreeHelper.HitTest(child, center);

                        HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(center));

                        if (result != null)
                        {
                            //Check HitTest Result on InkCanvas
                            result = VisualTreeHelper.HitTest(expressionUserControl.ExpressionInkCanvas, this.TransformToDescendant(expressionUserControl.ExpressionInkCanvas).Transform(center));
                            if (result != null)
                            {
                                (child as IPassable).StrokeCollected(this, e);
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Save Button
                            result = VisualTreeHelper.HitTest(expressionUserControl.SaveButton, this.TransformToDescendant(expressionUserControl.SaveButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                MessageBox.Show("Save Command!!!");
                                return;
                            }

                            //Check HitTest Result on Cancel Button
                            result = VisualTreeHelper.HitTest(expressionUserControl.CancelButton, this.TransformToDescendant(expressionUserControl.CancelButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                CheckDeletedControlOnInkQueryRegionStruct(expressionUserControl);
                                this.Children.Remove(expressionUserControl);
                                if(CurrentEditingUserControl != null && CurrentEditingUserControl == expressionUserControl)
                                {
                                    ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.Main));
                                }
                                return;
                            }

                            //Check HitTest Result on Scale Button
                            result = VisualTreeHelper.HitTest(expressionUserControl.ScaleButton, this.TransformToDescendant(expressionUserControl.ScaleButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Transform Region
                            result = VisualTreeHelper.HitTest(expressionUserControl.TransformButton, this.TransformToDescendant(expressionUserControl.TransformButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on StarPad Alternate MenuItems
                           
                            if (expressionUserControl.HitTestAltsMenuCreator(this, center))
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }
                           
                            //For control region part Ad-Hoc
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }
                        #endregion
                    }
                    else if (child is LogicPad2.TruthTable.UserControl1)
                    {
                        #region Truth Table User Control

                        LogicPad2.TruthTable.UserControl1 truthTableUserControl = child as LogicPad2.TruthTable.UserControl1;

                        if (truthTableUserControl.UserControlStatus == UserControlStatus.Scale)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }
                        else if (truthTableUserControl.UserControlStatus == UserControlStatus.Transform)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        //HitTest
                        //Calculate center of stroke
                        Rect strokeRect = e.Stroke.GetBounds();
                        Point center = new Point(strokeRect.Left + strokeRect.Width / 2d,
                            strokeRect.Top + strokeRect.Height / 2d);

                        //Point transformPoint = child.RenderTransform.Inverse.Transform(center);
                        //HitTestResult result = VisualTreeHelper.HitTest(child, center);

                        HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(center));

                        if (result != null)
                        {
                            //Check HitTest Result on InkCanvas
                            result = VisualTreeHelper.HitTest(truthTableUserControl.TruthTableInkCanvas, this.TransformToDescendant(truthTableUserControl.TruthTableInkCanvas).Transform(center));
                            if (result != null)
                            {
                                (child as IPassable).StrokeCollected(this, e);
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Increase Term Button 
                            result = VisualTreeHelper.HitTest(truthTableUserControl.IncreaseTermButton, this.TransformToDescendant(truthTableUserControl.IncreaseTermButton).Transform(center));
                            if (result != null)
                            {
                                truthTableUserControl.IncreaseTerm();
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Decrease Term Button
                            result = VisualTreeHelper.HitTest(truthTableUserControl.DecreaseTermButton, this.TransformToDescendant(truthTableUserControl.DecreaseTermButton).Transform(center));
                            if (result != null)
                            {
                                truthTableUserControl.DecreaseTerm();
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Save Button
                            result = VisualTreeHelper.HitTest(truthTableUserControl.SaveButton, this.TransformToDescendant(truthTableUserControl.SaveButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                MessageBox.Show("Save Command!!!");
                                return;
                            }

                            //Check HitTest Result on Cancel Button
                            result = VisualTreeHelper.HitTest(truthTableUserControl.CancelButton, this.TransformToDescendant(truthTableUserControl.CancelButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                CheckDeletedControlOnInkQueryRegionStruct(truthTableUserControl);
                                this.Children.Remove(truthTableUserControl);
                                if (CurrentEditingUserControl != null && CurrentEditingUserControl == truthTableUserControl)
                                {
                                    ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.Main));
                                }
                                
                                return;
                            }

                            //For control region part Ad-Hoc
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        #endregion
                    }
                    else if (child is LogicPad2.Diagram.UserControl1)
                    {
                        #region Diagram User Control

                        LogicPad2.Diagram.UserControl1 diagramUserControl = child as LogicPad2.Diagram.UserControl1;

                        if (diagramUserControl.UserControlStatus == UserControlStatus.Scale)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }
                        else if (diagramUserControl.UserControlStatus == UserControlStatus.Transform)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        //HitTest
                        //Calculate center of stroke
                        Rect strokeRect = e.Stroke.GetBounds();
                        Point center = new Point(strokeRect.Left + strokeRect.Width / 2d,
                            strokeRect.Top + strokeRect.Height / 2d);

                        //Point transformPoint = child.RenderTransform.Inverse.Transform(center);
                        //HitTestResult result = VisualTreeHelper.HitTest(child, center);

                    
                        HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(center));

                        if (result != null)
                        {
                            //Check HitTest Result on InkCanvas
                            result = VisualTreeHelper.HitTest(diagramUserControl.DiagramInkCanvas, this.TransformToDescendant(diagramUserControl.DiagramInkCanvas).Transform(center));
                            if (result != null)
                            {
                                Matrix m = new Matrix();
                                m.Translate(-diagramUserControl.UserControlX - 6, -diagramUserControl.UserControlY - 6);
                                //m.Translate(-UserControlX, -UserControlY);
                                m.Scale(1/diagramUserControl.UserControlScaleX, 1 / diagramUserControl.UserControlScaleY);
                                e.Stroke.Transform(m, false);
                                (child as IPassable).StrokeCollected(this, e);
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Save Button
                            result = VisualTreeHelper.HitTest(diagramUserControl.SaveButton, this.TransformToDescendant(diagramUserControl.SaveButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                MessageBox.Show("Save Command!!!");
                                return;
                            }

                            //Check HitTest Result on Cancel Button
                            result = VisualTreeHelper.HitTest(diagramUserControl.CancelButton, this.TransformToDescendant(diagramUserControl.CancelButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                CheckDeletedControlOnInkQueryRegionStruct(diagramUserControl);
                                this.Children.Remove(diagramUserControl);
                                if (CurrentEditingUserControl != null && CurrentEditingUserControl == diagramUserControl)
                                {
                                    ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.Main));
                                }
                                
                                return;
                            }

                            //For control region part Ad-Hoc
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        #endregion
                    }
                    else if (child is ExpressionWindow.ExpressionRepresentation)
                    {
                        #region Expression Representation

                        ExpressionWindow.ExpressionRepresentation expressionRepr = child as ExpressionWindow.ExpressionRepresentation;

                        if (expressionRepr.UserControlStatus == UserControlStatus.Scale)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }
                        else if (expressionRepr.UserControlStatus == UserControlStatus.Transform)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        //HitTest
                        //Calculate center of stroke
                        Rect strokeRect = e.Stroke.GetBounds();
                        Point center = new Point(strokeRect.Left + strokeRect.Width / 2d,
                            strokeRect.Top + strokeRect.Height / 2d);

                        //Point transformPoint = child.RenderTransform.Inverse.Transform(center);
                        //HitTestResult result = VisualTreeHelper.HitTest(child, center);

                        HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(center));

                        if (result != null)
                        {
                            //Check HitTest Result on Cancel Button
                            result = VisualTreeHelper.HitTest(expressionRepr.CancelButton, this.TransformToDescendant(expressionRepr.CancelButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                //CheckDeletedControlOnInkQueryRegionStruct(expressionRepr);
                                if (this.Children.Contains(expressionRepr.Owner))
                                {
                                    if (expressionRepr.Owner is LogicPad2.Diagram.UserControl1)
                                    {
                                        LogicPad2.Diagram.UserControl1 userControl1 = expressionRepr.Owner as LogicPad2.Diagram.UserControl1;
                                        userControl1.IsExpressionRepreVisible = false;
                                        ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.Diagram, userControl1));
                                    }
                                    else if (expressionRepr.Owner is LogicPad2.TruthTable.UserControl1)
                                    {
                                        LogicPad2.TruthTable.UserControl1 userControl2 = expressionRepr.Owner as LogicPad2.TruthTable.UserControl1;
                                        userControl2.IsExpressionRepreVisible = false;
                                        ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.TruthTable, userControl2));
                                    }
                                }
                                this.Children.Remove(expressionRepr);
                                return;
                            }

                            //Check HitTest Result on Scale Button
                            result = VisualTreeHelper.HitTest(expressionRepr.ScaleButton, this.TransformToDescendant(expressionRepr.ScaleButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Transform Region
                            result = VisualTreeHelper.HitTest(expressionRepr.TransformButton, this.TransformToDescendant(expressionRepr.TransformButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //For control region part Ad-Hoc
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        #endregion
                    }
                    else if (child is TruthTableWindow.TruthTableRepresentation)
                    {
                        #region TruthTable Representation

                        TruthTableWindow.TruthTableRepresentation truthTableRepr = child as TruthTableWindow.TruthTableRepresentation;

                        if (truthTableRepr.UserControlStatus == UserControlStatus.Scale)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }
                        else if (truthTableRepr.UserControlStatus == UserControlStatus.Transform)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        //HitTest
                        //Calculate center of stroke
                        Rect strokeRect = e.Stroke.GetBounds();
                        Point center = new Point(strokeRect.Left + strokeRect.Width / 2d,
                            strokeRect.Top + strokeRect.Height / 2d);

                        //Point transformPoint = child.RenderTransform.Inverse.Transform(center);
                        //HitTestResult result = VisualTreeHelper.HitTest(child, center);

                        HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(center));

                        if (result != null)
                        {
                            //Check HitTest Result on Cancel Button
                            result = VisualTreeHelper.HitTest(truthTableRepr.CancelButton, this.TransformToDescendant(truthTableRepr.CancelButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                //CheckDeletedControlOnInkQueryRegionStruct(truthTableRepr);
                                if (this.Children.Contains(truthTableRepr.Owner))
                                {
                                    if (truthTableRepr.Owner is LogicPad2.Diagram.UserControl1)
                                    {
                                        LogicPad2.Diagram.UserControl1 userControl1 = truthTableRepr.Owner as LogicPad2.Diagram.UserControl1;
                                        userControl1.IsTruthTableRepreVisible = false;
                                        ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.Diagram, userControl1));
                                    }
                                    else if (truthTableRepr.Owner is LogicPad2.Expression.UserControl1)
                                    {
                                        LogicPad2.Expression.UserControl1 userControl2 = truthTableRepr.Owner as LogicPad2.Expression.UserControl1;
                                        userControl2.IsTruthTableRepreVisible = false;
                                        ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.Expression, userControl2));
                                    }
                                }
                                this.Children.Remove(truthTableRepr);
                                return;
                            }

                            //Check HitTest Result on Scale Button
                            result = VisualTreeHelper.HitTest(truthTableRepr.ScaleButton, this.TransformToDescendant(truthTableRepr.ScaleButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Transform Region
                            result = VisualTreeHelper.HitTest(truthTableRepr.TransformButton, this.TransformToDescendant(truthTableRepr.TransformButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //For control region part Ad-Hoc
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        #endregion
                    }
                    else if (child is GatesWpf.DiagramRepresentation)
                    {
                        #region Diagram Representation

                        GatesWpf.DiagramRepresentation diagramRepr = child as GatesWpf.DiagramRepresentation;

                        if (diagramRepr.UserControlStatus == UserControlStatus.Scale)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }
                        else if (diagramRepr.UserControlStatus == UserControlStatus.Transform)
                        {
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        //HitTest
                        //Calculate center of stroke
                        Rect strokeRect = e.Stroke.GetBounds();
                        Point center = new Point(strokeRect.Left + strokeRect.Width / 2d,
                            strokeRect.Top + strokeRect.Height / 2d);

                        //Point transformPoint = child.RenderTransform.Inverse.Transform(center);
                        //HitTestResult result = VisualTreeHelper.HitTest(child, center);

                        HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(center));

                        if (result != null)
                        {
                            //Check HitTest Result on Cancel Button
                            result = VisualTreeHelper.HitTest(diagramRepr.CancelButton, this.TransformToDescendant(diagramRepr.CancelButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                //CheckDeletedControlOnInkQueryRegionStruct(truthTableRepr);
                                if (this.Children.Contains(diagramRepr.Owner))
                                {
                                    if (diagramRepr.Owner is LogicPad2.TruthTable.UserControl1)
                                    {
                                        LogicPad2.TruthTable.UserControl1 userControl1 = diagramRepr.Owner as LogicPad2.TruthTable.UserControl1;
                                        userControl1.IsDiagramRepreVisible = false;
                                        ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.TruthTable, userControl1));
                                    }
                                    else if (diagramRepr.Owner is LogicPad2.Expression.UserControl1)
                                    {
                                        LogicPad2.Expression.UserControl1 userControl2 = diagramRepr.Owner as LogicPad2.Expression.UserControl1;
                                        userControl2.IsDiagramRepreVisible = false;
                                        ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.Expression, userControl2));
                                    }
                                }
                                this.Children.Remove(diagramRepr);
                                return;
                            }

                            //Check HitTest Result on Scale Button
                            result = VisualTreeHelper.HitTest(diagramRepr.ScaleButton, this.TransformToDescendant(diagramRepr.ScaleButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //Check HitTest Result on Transform Region
                            result = VisualTreeHelper.HitTest(diagramRepr.TransformButton, this.TransformToDescendant(diagramRepr.TransformButton).Transform(center));
                            if (result != null)
                            {
                                this.Strokes.Remove(e.Stroke);
                                return;
                            }

                            //For control region part Ad-Hoc
                            this.Strokes.Remove(e.Stroke);
                            return;
                        }

                        #endregion
                    }
                }
            }

            Stroke currentStroke = e.Stroke;

            /* check for scribble delete */
            if (ScribbleDelete(currentStroke))
            {
                CheckInkEqualSignRegion();
                return;
            } 

            _inkAnalyzer.AddStroke(currentStroke);
            _inkAnalyzer.BackgroundAnalyze();

            this.ShowInkAnalysisFeedback = true;
        }
 void InkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     ConnectEndStylusPoints(e.Stroke);
 }
Beispiel #17
0
		protected virtual void EndStroke(Contact contact)
		{
			Stroke stroke = (Stroke)contact.GetUserData(key);
			if (stroke != null)
			{
				InkCanvasStrokeCollectedEventArgs args = new InkCanvasStrokeCollectedEventArgs(stroke);
				OnStrokeCollected(args);
			}
		}
Beispiel #18
0
		protected virtual void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
		{
			RaiseEvent(e);
		}
Beispiel #19
0
		protected virtual void OnCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
		{
			OnStrokeCollected(e);
		}
Beispiel #20
0
        private void drawingCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            try
            {
                sv_MainCanvas.IsHitTestVisible = true;
                Stroke latestStroke = e.Stroke;
                StylusPointCollection strokePoints = latestStroke.StylusPoints;
                if (!DrawingCanvasModeSwitcher.IsInErasingMode() && strokePoints.Count < 10)
                {
                    return;
                }
                List<System.Windows.Point> pathPoints = new List<System.Windows.Point>();
                foreach (StylusPoint stylusP in strokePoints)
                {
                    System.Windows.Point p = new System.Windows.Point();
                    p.X = stylusP.X;
                    p.Y = stylusP.Y;
                    pathPoints.Add(p);
                }
                /*if (Utilities.UtilitiesLib.CheckClosedPath(pathPoints))
                {
                    System.Windows.Point orginTopleft, orginBottomRight, orginCenter;
                    Utilities.UtilitiesLib.extractAnchorPointsOfPath(pathPoints,out orginTopleft,out orginBottomRight,out orginCenter);

                    IdeationUnitGroup idea = new IdeationUnitGroup();
                    IdeaGroupContentType ideaGroupContent = new IdeaGroupContentType();
                    ideaGroupContent.DisplayBoundaries = pathPoints;
                    idea.Content = ideaGroupContent;
                    idea.Id = IdeaIDGenerator.generateID();
                    idea.CenterX = (float)orginCenter.X;
                    idea.CenterY = (float)orginCenter.Y;

                    AddSingleIdeaGroup(idea);
                }*/
                //add corresponding idea object for this stroke
                IdeationUnit strokeIdea = new StrokeBasedIdea();
                strokeIdea.Id = IdeaIDGenerator.generateID();
                StrokeData strokeData = new StrokeData();
                strokeData.IsErasingStroke = DrawingCanvasModeSwitcher.IsInErasingMode();
                strokeData.StrokeColorCode = new System.Windows.Media.ColorConverter().ConvertToString(latestStroke.DrawingAttributes.Color);
                strokeData.StrokePoints = pathPoints;
                strokeIdea.Content = strokeData;
                brainstormManager.AddIdeaInBackground(strokeIdea);
                //get the current screenshot
                TakeASnapshot();
                timelineManager.AddADDChange(strokeIdea);
            }
            catch (Exception ex)
            {
                Utilities.UtilitiesLib.LogError(ex);
            }
        }
 private void InkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     if (ThisAddIn.instance.wire.isConnected && ThisAddIn.instance.wire.isInConversation)
         ThisAddIn.instance.wire.sendRawStroke(e.Stroke);
     InkCanvas source = (InkCanvas)sender;
     strokeCollectionsForSlides[lastSlide].Add(e.Stroke);
     foreach (InkCanvas canvas in ActiveCanvasses)
         if (canvas != source)
         {
             detachInkCanvasHandlers(canvas);
             if (canvas.Strokes.Count(s => s.sum().checksum.ToString().Equals(e.Stroke.sum().checksum.ToString())) == 0)
                 canvas.Strokes.Add(e.Stroke);
             attachInkCanvasHandlers(canvas);
         }
 }
Beispiel #22
0
        private void inkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(recordingFilename);

            XmlNodeList sceneNodes = xmlDoc.GetElementsByTagName("Scene");
            XmlNode currentSceneNode = sceneNodes.Item(0);

            foreach(XmlNode sceneNode in sceneNodes)
            {
                String sceneFile = sceneNode.Attributes.Item(0).Value.ToString();

                if (sceneFile == sceneDir + "//" + sceneName + ".xaml")
                {
                    currentSceneNode = sceneNode;
                    break;
                }
            }

            XmlNode eventsNode = currentSceneNode.ChildNodes.Item(0);
            XmlElement inkNode = xmlDoc.CreateElement("InkStroke");
            eventsNode.AppendChild(inkNode);
            
            foreach (StylusPoint point in e.Stroke.StylusPoints)
            {

                XmlElement pointNode = xmlDoc.CreateElement("Point");
                inkNode.AppendChild(pointNode);

                pointNode.SetAttribute("X", point.X.ToString());
                pointNode.SetAttribute("Y", point.Y.ToString());
            }

            xmlDoc.Save(recordingFilename);
        }
Beispiel #23
0
 void InkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     double dist = Distance(e.Stroke.StylusPoints.First(), e.Stroke.StylusPoints.Last());
     if (dist < 5)
     {
         e.Stroke.StylusPoints[e.Stroke.StylusPoints.Count - 1] = e.Stroke.StylusPoints.First();
     }
 }
        protected override void StylusInputEnd(bool commit)
        {
            // The follow code raises Gesture and/or StrokeCollected event
            // The out-side code could throw exception in the their handlers. We use try/finally block to protect our status.
            try
            {
                if ( commit )
                {
                    // NTRAID:WINDOWS#1613731-2006/04/27-WAYNEZEN,
                    // It's possible that the input may end up without any StylusPoint being collected since the behavior can be deactivated by
                    // the user code in the any event handler.
                    if ( _stylusPoints != null )
                    {
                        Debug.Assert(_strokeDrawingAttributes != null, "_strokeDrawingAttributes can not be null, did we not see a down?");

                        Stroke stroke =
                            new Stroke(_stylusPoints, _strokeDrawingAttributes);

                        //we don't add the stroke to the InkCanvas stroke collection until RaiseStrokeCollected
                        //since this might be a gesture and in some modes, gestures don't get added
                        InkCanvasStrokeCollectedEventArgs argsStroke = new InkCanvasStrokeCollectedEventArgs(stroke);
                        InkCanvas.RaiseGestureOrStrokeCollected(argsStroke, _userInitiated);
                    }
                }
            }
            finally
            {
                _stylusPoints = null;
                _strokeDrawingAttributes = null;
                _userInitiated = false;
                EditingCoordinator.InvalidateBehaviorCursor(this);
            }
        }
Beispiel #25
0
        void IPassable.StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            //Probably need to change the stroke to the coordinates of this canvas
            e.Stroke.DrawingAttributes.Color = Colors.Red;
            //inqCanvas.Stroqs.Add(e.Stroke);

            Matrix m = new Matrix();
            m.Translate(-UserControlX, -UserControlY);
            m.Scale(1 / UserControlScaleX, 1 / UserControlScaleY);
            e.Stroke.Transform(m, false);

            Stroq stroq = new Stroq(e.Stroke);
            inqCanvas.Stroqs.Add(stroq);

            /* If we get here, it's a real stroke (not movement), so deselect any selection */
            Deselect();

            /* check for scribble delete */
            if (ScribbleDelete(stroq)) return;

            /* check for lassos/circles around stuff */
            if (LassoSelect(stroq)) return;

            _mathStroqs.Add(stroq);
        }
 // Run when a stroke is placed on the canvas
 private void RoadCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     history.Push(e.Stroke);
 }
 private void inkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     Stroke s = e.Stroke;
     Console.WriteLine("inkCanvas_StrokeCollected Called");
     //Left for future work
     //You can implement the snapping feature here
     //Also note we have inkCanvas.DefaultDrawingAttributes.FitToCurve = true; inside constructor
     // You may not wanna use that
 }
 /// <summary>
 /// Handles the OnStrokeCollected event for SurfaceInkCanvas.
 /// </summary>
 /// <param name="sender">The SurfaceInkCanvas that raised the event.</param>
 /// <param name="args">The arguments for the event.</param>
 private void OnStrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs args)
 {
     mostRecentStroke = args.Stroke;
 }
 protected virtual new void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
 {
 }
 public void StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     
 }
Beispiel #31
0
 protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
 {
     this.Strokes.Remove(e.Stroke);
     this.Strokes.Add(new ChinesebrushStroke(e.Stroke.StylusPoints, imageSource));
 }
Beispiel #32
0
        public void circuitInkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            CurrentStroke = e.Stroke;

            if (!circuitInkCanvas.Strokes.Contains(e.Stroke))
            {
                circuitInkCanvas.Strokes.Add(e.Stroke);
            }

            #region Flick Detection

            //Flick Gesture
            TimeSpan timespan = DateTime.Now - _stylusDownTime;

            StrokeInfo stroke = new StrokeInfo(CurrentStroke, timespan);

            //Real Analysis
            if (StrokeAnalyzer.Instance.IsFlick(stroke) && 1 == 0)
            {
                FlickDirections direction = StrokeAnalyzer.Instance.DetectFlickDirection(stroke);
                StylusPoint PointA = stroke.StartPoint;
                StylusPoint PointB = stroke.EndPoint;
                AnimateArrowInFlickDirection(PointA.X, PointA.Y, PointB.X, PointB.Y);

                //Throw one gate xaml on the canvas
                Gate newGate = null;

                switch (direction)
                {
                    case FlickDirections.UpLeft:
                        newGate = new UserOutput();
                        break;
                    case FlickDirections.DownLeft:
                        newGate = new Xor();
                        //OR
                        break;
                    case FlickDirections.Down:
                        newGate = new And();
                        //AND
                        break;
                    case FlickDirections.DownRight:
                        //NOT
                        newGate = new Not();
                        break;
                    case FlickDirections.Up:
                        //INPUT
                        newGate = new Or();
                        break;
                    case FlickDirections.UpRight:
                        //OUTPUT
                        newGate = new UserInput();
                        break;
                }
                //GateLocation location = new GateLocation();
                //Heuristic
                //BO KANG??
                Point temp = new Point(PointA.X - 30, PointA.Y - 30);

                this.AddGate(newGate, new GateLocation(this.GetNearestSnapTo(this.TranslateScrolledPoint(temp))));
                //this.AddGate(newGate, location);
                this.circuitInkCanvas.UpdateLayout();
                this.circuitInkCanvas.Strokes.Remove(CurrentStroke);
            }

            #endregion

            /* check for drag Gate Stroke*/
            if (onGateStroke)
            {
                circuitInkCanvas.Strokes.Remove(e.Stroke);
                return;
            }

            /*check for draw wire stroke*/
            if(onWireStroke)
            {
                circuitInkCanvas.Strokes.Remove(e.Stroke);
                onWireStroke = false;
                return;
            }else
            {
                if(onWireMoveStroke)
                {
                    circuitInkCanvas.Strokes.Remove(e.Stroke);
                    onWireMoveStroke = false;
                    return;
                }
            }

            //Debug.WriteLine("Stroke Bound Percentage is " + stroke.BoundPercentage);
            /* Test if the current stroke is wire connect stroke */
            if (stroke.BoundPercentage > 10)
            {
                return;
            }

            //Debug.WriteLine("Stroke BoundPercentage is " + stroke.BoundPercentage.ToString());

            /* check for scribble delete */
            if (ScribbleDelete(e.Stroke)) return;
        }
Beispiel #33
0
 public void StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
 {
     //Matrix m = new Matrix();
     //m.Translate(-UserControlX, -UserControlY);
     //m.Scale(1 / UserControlScaleX, 1 / UserControlScaleY);
     //e.Stroke.Transform(m, false);
    
     this.inkCanvas.circuitInkCanvas_StrokeCollected(sender, e);
 }