示例#1
0
        //public void initializeAllVariable()
        //{
        //    startInsert = 0;
        //    endInsert = 0;
        //    preSelectedCount = 0;
        //    afterSelectedCount = 0;
        //    distanceOfTrueTime = 0;

        //}

        private void drawLine()
        {
            if (0 != keyFrames.Count)
            {
                int line = (keyFrames.Count - 1) / countInrow + 1;
                for (int i = 1; i <= line; i++)
                {
                    Point startPoint = new Point(Center.X, Center.Y + i * showHeight + 2);
                    Point endPoint   = new Point(Center.X + (showWidth - fusePixel) * countInrow + fusePixel, Center.Y + i * showHeight + 2);
                    InkTool.getInstance().DrawLine(startPoint.X, startPoint.Y, endPoint.X, endPoint.Y, InkCanvas, Colors.Black);
                }
            }
        }
 public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (videoSummarization != null && _startPoint != null && _inkCanvas.Strokes.Count > 0)
     {
         _currPoint = e.GetPosition(_inkCanvas);
         Stroke lastStroke = _inkCanvas.Strokes.Last();
         _inkCanvas.Strokes.Remove(lastStroke);
         if (_inkCollector.KeyFramesAnnotation.relatedKeyFrameIndexes.IndexOf(startIndex) == -1 &&
             startIndex != int.MinValue && isInAnnotationBox(_currPoint))
         {
             Stroke linkLine;
             if (_inkCollector.KeyFrameAnnotation.HorizontalAlignment == HorizontalAlignment.Left)
             {
                 linkLine = InkTool.getInstance().DrawLine(selectKeyFrameCenterPoint.X + inkCanvasSpiralSummarizationMargin.Left,
                                                           selectKeyFrameCenterPoint.Y + inkCanvasSpiralSummarizationMargin.Top,
                                                           _inkCollector.KeyFrameAnnotation.Margin.Left + _inkCollector.KeyFrameAnnotation.Width / 2,
                                                           _inkCollector.KeyFrameAnnotation.Margin.Top + _inkCollector.KeyFrameAnnotation.Height / 2,
                                                           _inkCanvas, Color.FromArgb(180, 0, 255, 0));
             }
             else
             {
                 linkLine = InkTool.getInstance().DrawLine(selectKeyFrameCenterPoint.X + inkCanvasSpiralSummarizationMargin.Left,
                                                           selectKeyFrameCenterPoint.Y + inkCanvasSpiralSummarizationMargin.Top,
                                                           _inkCanvas.ActualWidth - _inkCollector.KeyFrameAnnotation.Width / 2,
                                                           _inkCollector.KeyFrameAnnotation.Margin.Top + _inkCollector.KeyFrameAnnotation.Height / 2,
                                                           _inkCanvas, Color.FromArgb(180, 0, 255, 0));
             }
             _inkCollector.KeyFramesAnnotation.relatedKeyFrameIndexes.Add(startIndex);
             selectKeyFrame.Annotations.Add(linkLine, _inkCollector.KeyFramesAnnotation);
             //videoSummarization.AddPoint2Track(startIndex, Colors.Red, 0);
             ((SpiralSummarization)videoSummarization).AddPoints2ShowSpiral(startIndex, Colors.Red, 0);
         }
         _startPoint.X = 0;
         _startPoint.Y = 0;
     }
 }
        public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Stroke lastStroke = _inkCanvas.Strokes.Last();

            if (!(_startPoint.X == 0 && _startPoint.Y == 0))
            {
                //先清空原来选中的关键帧序列
                //clearPreMessage();
                _currPoint = e.GetPosition(_inkCanvas);
                if (_currPoint.Y < TableGrid.ActualHeight / 2)
                {
                    if (_currPoint.X < TableGrid.ActualWidth / 2)
                    {
                        _currPoint.X -= ((InkCanvas)_inkCanvas.Children[0]).Margin.Left;
                        _currPoint.Y -= ((InkCanvas)_inkCanvas.Children[0]).Margin.Top;
                        endIndex      = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft.getSelectedKeyFrameIndex(_currPoint);
                        if (startIndex != int.MinValue && endIndex != int.MinValue)
                        {
                            endKeyFrame            = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft.KeyFrames[endIndex];
                            endSpiralSummarization = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft;
                        }
                        _currPoint.X += ((InkCanvas)_inkCanvas.Children[0]).Margin.Left;
                        _currPoint.Y += ((InkCanvas)_inkCanvas.Children[0]).Margin.Top;
                    }
                    //右边的螺旋摘要
                    else
                    {
                        Point endPointRight = e.GetPosition((InkCanvas)_inkCanvas.Children[1]);
                        endIndex = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationRight.getSelectedKeyFrameIndex(endPointRight);
                        if (startIndex != int.MinValue && endIndex != int.MinValue)
                        {
                            endKeyFrame            = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationRight.KeyFrames[endIndex];
                            endSpiralSummarization = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationRight;
                        }
                    }
                }
                else
                {
                    Point endPointBottom = e.GetPosition((InkCanvas)_inkCanvas.Children[2]);
                    endIndex = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationBottom.getSelectedKeyFrameIndex(endPointBottom);
                    if (startIndex != int.MinValue && endIndex != int.MinValue)
                    {
                        endKeyFrame            = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationBottom.KeyFrames[endIndex];
                        endSpiralSummarization = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationBottom;
                    }
                }
                if (startKeyFrame != null && endKeyFrame != null && startKeyFrame != endKeyFrame)
                {
                    startKeyFrame.HyperLink = endKeyFrame;
                    _inkCollector.HyperLinkKeyFrames.Add(startKeyFrame);
                    startKeyFrame.HyperLinkSpiralSummarization = endSpiralSummarization;
                    _inkCanvas.Strokes.Remove(_inkCanvas.Strokes.Last());
                    InkTool.getInstance().DrawLine(_startPoint.X, _startPoint.Y, _currPoint.X, _currPoint.Y, _inkCanvas, Colors.Red);
                    InkTool.getInstance().drawPoint(_startPoint.X, _startPoint.Y, 8, Colors.Blue, _inkCanvas);
                }
                else
                {
                    mouseGesture.StopCapture();
                    _inkCanvas.Strokes.Remove(lastStroke);
                }
                _startPoint.X = 0;
                _startPoint.Y = 0;
            }
        }
        /// <summary>
        /// 将stroke以点迹的模式擦除,拆分成两个stroke
        /// </summary>
        /// <param name="stroke">被擦除的stroke</param>
        /// <param name="pointErasePoints">擦除的点</param>
        void ProcessPointErase(Stroke stroke, Point pointErasePoint)
        {
            if (stroke.StylusPoints.Count > 1)
            {
                Stroke hitTestStroke;
                StylusPointCollection splitStrokePoints1 = new StylusPointCollection();
                StylusPointCollection splitStrokePoints2 = new StylusPointCollection();

                StylusPointCollection spc = new StylusPointCollection();
                foreach (StylusPoint point in stroke.StylusPoints)
                {
                    spc.Add(point);
                }
                hitTestStroke = new Stroke(spc);
                hitTestStroke.DrawingAttributes = stroke.DrawingAttributes;

                while (true)
                {
                    if (hitTestStroke.StylusPoints.Count > 0)
                    {
                        if (hitTestStroke.StylusPoints.Count > 1)
                        {
                            StylusPoint sp = hitTestStroke.StylusPoints[hitTestStroke.StylusPoints.Count - 1];
                            hitTestStroke.StylusPoints.RemoveAt(hitTestStroke.StylusPoints.Count - 1);
                            if (!hitTestStroke.HitTest(pointErasePoint, 3))
                            {
                                break;
                            }
                            splitStrokePoints2.Add(sp);
                        }
                        else
                        {
                            break;
                        }
                    }
                }


                StylusPointCollection spc2 = new StylusPointCollection();
                foreach (StylusPoint point in stroke.StylusPoints)
                {
                    spc2.Add(point);
                }
                hitTestStroke = new Stroke(spc2);
                hitTestStroke.DrawingAttributes = stroke.DrawingAttributes;
                //从下标为0的位置开始遍历点迹,直到第一个被擦除的点
                while (true)
                {
                    if (hitTestStroke.StylusPoints.Count > 0)
                    {
                        if (hitTestStroke.StylusPoints.Count > 1)
                        {
                            StylusPoint sp = hitTestStroke.StylusPoints[0];
                            hitTestStroke.StylusPoints.RemoveAt(0);
                            if (!hitTestStroke.HitTest(pointErasePoint, 3))
                            {
                                break;
                            }
                            splitStrokePoints1.Add(sp);
                        }
                        else
                        {
                            break;
                        }
                    }
                }


                // 将原来的stroke删除掉,然后添加两个新的stroke
                if (splitStrokePoints1.Count > 1)
                {
                    Stroke splitStroke1 = new Stroke(splitStrokePoints1);
                    splitStroke1.DrawingAttributes = InkTool.getInstance().DrawingAttributesCopy(stroke.DrawingAttributes);
                    MyStroke         mystroke = new MyStroke(splitStroke1);
                    AddStrokeCommand cmd      = new AddStrokeCommand(_inkCollector, mystroke);
                    _inkCollector.CommandStack.Push(cmd);
                    cmd.execute();
                }


                if (splitStrokePoints2.Count > 1)
                {
                    Stroke splitStroke2 = new Stroke(splitStrokePoints2);
                    splitStroke2.DrawingAttributes = InkTool.getInstance().DrawingAttributesCopy(stroke.DrawingAttributes);
                    MyStroke         mystroke = new MyStroke(splitStroke2);
                    AddStrokeCommand cmd      = new AddStrokeCommand(_inkCollector, mystroke);
                    _inkCollector.CommandStack.Push(cmd);
                    cmd.execute();
                }
            }
            DeleteStrokeCommand dsc = new DeleteStrokeCommand(_inkCollector, stroke);

            _inkCollector.CommandStack.Push(dsc);
            dsc.execute();
        }
        /// <summary>
        /// 方向和笔序识别结果匹配和处理
        /// </summary>
        /// <param name="args"></param>
        void gesture_GestureMatchEvent(MouseGestureEventArgs args)
        {
            //记录操作事件与持续时间
            recordOperateEvent(args.Present);
            switch (args.Present)
            {
            case "keyFrameAnnotation":
                if (startIndex != int.MinValue && startIndex == endIndex && _inkCollector.IsShowUnbrokenKeyFrame)
                {
                    _keyFrameAnnotation = new KeyFrameAnnotation();
                    KeyFrame selectKeyFrame = videoSummarization.ShowKeyFrames[startIndex];
                    _inkCollector.SelectKeyFrames.Add(videoSummarization.ShowKeyFrames[startIndex]);
                    Dictionary <Stroke, KeyFramesAnnotation> s = selectKeyFrame.Annotations;
                    //在已经有注释的情况下显示已有的注释
                    if (selectKeyFrame.Annotations.Count > 0)
                    {
                        KeyValuePair <Stroke, KeyFramesAnnotation> currPair = (from KeyValuePair <Stroke, KeyFramesAnnotation> anno in selectKeyFrame.Annotations
                                                                               //where anno.Value == _keyFramesAnnotation
                                                                               select anno).First();
                        keyFramesAnnotation = (KeyFramesAnnotation)(currPair.Value);
                        foreach (int index in keyFramesAnnotation.relatedKeyFrameIndexes)
                        {
                            currPair = (from KeyValuePair <Stroke, KeyFramesAnnotation> anno in videoSummarization.ShowKeyFrames[index].Annotations
                                        where anno.Value == keyFramesAnnotation
                                        select anno).First();
                            Stroke stroke = (Stroke)(currPair.Key);
                            _inkCanvas.Strokes.Add(stroke);
                        }
                        _keyFrameAnnotation.InkCanvasAnnotation.Strokes.Add(keyFramesAnnotation.Strokes);
                    }
                    else
                    {
                        keyFramesAnnotation = new KeyFramesAnnotation();
                    }
                    _inkCollector.KeyFramesAnnotation = keyFramesAnnotation;
                    _inkCollector.KeyFrameAnnotation  = _keyFrameAnnotation;
                    _keyFrameAnnotation.setInkCollector(_inkCollector);
                    _keyFrameAnnotation.setKeyFramesAnnotation(keyFramesAnnotation, true);
                    //显示关键帧注释
                    _keyFrameAnnotation.Width             = keyFramesAnnotation.Width;
                    _keyFrameAnnotation.Height            = keyFramesAnnotation.Height;
                    _keyFrameAnnotation.VerticalAlignment = VerticalAlignment.Top;
                    Stroke linkLine;
                    if (videoSummarization.ShowKeyFrameCenterPoints[startIndex].X < videoSummarization.Center.X)
                    {
                        _keyFrameAnnotation.HorizontalAlignment = HorizontalAlignment.Left;
                        if (selectKeyFrame.Annotations.Count == 0)
                        {    //画关键帧到注释框的连线
                            linkLine = InkTool.getInstance().DrawLine(videoSummarization.ShowKeyFrameCenterPoints[startIndex].X + inkCanvasSpiralSummarizationMargin.Left,
                                                                      videoSummarization.ShowKeyFrameCenterPoints[startIndex].Y + inkCanvasSpiralSummarizationMargin.Top,
                                                                      _keyFrameAnnotation.Margin.Left + _keyFrameAnnotation.Width / 2,
                                                                      _keyFrameAnnotation.Margin.Top + _keyFrameAnnotation.Height / 2,
                                                                      _inkCanvas, Color.FromArgb(180, 0, 255, 0));
                            selectKeyFrame.Annotations.Add(linkLine, keyFramesAnnotation);
                            keyFramesAnnotation.relatedKeyFrameIndexes.Add(startIndex);
                            MoveTimer.Stop();
                        }
                    }
                    else
                    {
                        _keyFrameAnnotation.HorizontalAlignment = HorizontalAlignment.Right;
                        if (selectKeyFrame.Annotations.Count == 0)
                        {
                            linkLine = InkTool.getInstance().DrawLine(videoSummarization.ShowKeyFrameCenterPoints[startIndex].X + inkCanvasSpiralSummarizationMargin.Left,
                                                                      videoSummarization.ShowKeyFrameCenterPoints[startIndex].Y + inkCanvasSpiralSummarizationMargin.Top,
                                                                      _inkCanvas.ActualWidth - _keyFrameAnnotation.Width / 2,
                                                                      _keyFrameAnnotation.Margin.Top + _keyFrameAnnotation.Height / 2,
                                                                      _inkCanvas, Color.FromArgb(180, 0, 255, 0));
                            selectKeyFrame.Annotations.Add(linkLine, keyFramesAnnotation);
                            keyFramesAnnotation.relatedKeyFrameIndexes.Add(startIndex);
                            MoveTimer.Stop();
                        }
                    }
                    _keyFrameAnnotation.Visibility = Visibility.Visible;
                    _inkCollector._mainPage.LayoutRoot.Children.Add(_keyFrameAnnotation);
                    _inkCollector.Mode = InkMode.AddKeyFrameAnnotation;
                }
                else
                {
                    //VideoSummarizationControl.TableGrid.ColumnDefinitions[0].Width = new GridLength(VideoSummarizationControl.TableGrid.ActualWidth * 0.25);
                }
                break;

            case "SpiralFullScreen":
                //VideoSummarizationControl.TableGrid.ColumnDefinitions[0].Width = new GridLength(0);
                break;

            default:
                //Console.WriteLine("default");
                break;
            }
        }
示例#6
0
        //Inertia is completed, we can reuse the object
        public void Completed(PictureTracker pictureTracker)
        {
            Console.WriteLine("zoomState:" + zoomState);
            if (zoomState != 0)
            {
                if (indexes[0] != int.MinValue && indexes[1] != int.MinValue &&
                    indexes[0] != indexes[1])
                {
                    if (indexes[0] > indexes[1])
                    {
                        int tem = indexes[1];
                        indexes[1] = indexes[0];
                        indexes[0] = tem;
                    }
                    if (zoomState == 1)
                    {
                        if (isFocus)
                        {
                            if (!SpiralSummarization.IsZoomOut)
                            {
                                SpiralSummarization.ZoomInOut();
                            }
                        }
                        else
                        {
                            SpiralSummarization.InsertKeyFrames(indexes[0], indexes[1]);
                        }
                    }
                    else if (zoomState == 2)
                    {
                        if (isFocus)
                        {
                            if (SpiralSummarization.IsZoomOut)
                            {
                                SpiralSummarization.ZoomInOut();
                            }
                        }
                        else
                        {
                            SpiralSummarization.HiddenKeyFrames(indexes[0], indexes[1]);
                        }
                    }
                }
                else if (indexes[0] == int.MinValue && indexes[1] == int.MinValue)
                {
                    if (zoomState == 1)
                    {
                        InkTool.getInstance().InkCanvasZoom(InkCanvas, zoomRate, zoomRate + 0.1 <= 3 ? zoomRate = zoomRate + 0.1 : zoomRate, 0.5, 0.5);
                        _videoSummarizationControl.InkCanvasShowRate.Content = (zoomRate * 100).ToString() + "%";
                    }
                    else if (zoomState == 2)
                    {
                        InkTool.getInstance().InkCanvasZoom(InkCanvas, zoomRate, zoomRate > 0.15 ? zoomRate = zoomRate - 0.1 : zoomRate, 0.5, 0.5);
                        _videoSummarizationControl.InkCanvasShowRate.Content = (zoomRate * 100).ToString() + "%";
                    }
                }
            }

            else if (indexes[0] != int.MinValue && indexes[1] == int.MinValue)
            {
                VideoSummarizationTool.locateMediaPlayer(
                    _spiralSummarization.InkCollector._mainPage.VideoSummarizationControl.mediaPlayer,
                    _spiralSummarization.KeyFrames[indexes[0]]);
            }
            pictureTracker.index = int.MinValue;
            indexes[0]           = int.MinValue;
            indexes[1]           = int.MinValue;
            zoomState            = 0;
            _pictureTrackers.Push(pictureTracker);
        }