Beispiel #1
0
        void MoveTimer_Tick(object sender, EventArgs e)
        {
            if (_startPoint.X == 0 && _startPoint.Y == 0)// && _inkCollector.KeyFrameAnnotation.Visibility == Visibility.Collapsed)
            {
                moveTimerSecond += 1;
                if (moveTimerSecond >= 3 && currIndex != int.MinValue && currIndex < videoSummarization.ShowKeyFrames.Count &&
                    _inkCollector.IsShowUnbrokenKeyFrame)
                {
                    if (preImage != null)
                    {
                        _inkCanvas.Children.Remove(preImage);
                    }
                    if (_keyFrameAnnotation != null)
                    {
                        _inkCollector._mainPage.LayoutRoot.Children.Remove(_keyFrameAnnotation);
                        _keyFrameAnnotation = null;
                    }
                    left  = videoSummarization.ShowKeyFrames[currIndex].Image.Margin.Left; // +videoSummarization.ShowKeyFrames[currIndex].Image.Width / 2 - 60;
                    top   = videoSummarization.ShowKeyFrames[currIndex].Image.Margin.Top;  // +videoSummarization.ShowKeyFrames[currIndex].Image.Height / 2 - 40;
                    left += inkCanvasSpiralSummarizationMargin.Left;
                    top  += inkCanvasSpiralSummarizationMargin.Top;
                    if (_inkCollector.DefaultSummarizationNum == 1)
                    {
                        top += videoSummarization.InkCanvas.Margin.Top;
                    }
                    _inkCollector.SelectKeyFrames.Add(videoSummarization.KeyFrames[currIndex]);
                    int videoTime = videoSummarization.ShowKeyFrames[currIndex].Time;
                    //在关键帧上画圆,显示小视频
                    _inkCollector._mainPage._thumbVideoPlayer.Margin     = new Thickness(left, top - 40, 0, 0);
                    _inkCollector._mainPage._thumbVideoPlayer.Visibility = Visibility.Visible;
                    _inkCollector._mainPage._thumbVideoPlayer.InitVideoPlayer(videoSummarization.ShowKeyFrames[currIndex].VideoName, videoTime, 5000, true);
                    _inkCollector._mainPage._thumbVideoPlayer.videoPlayer.MouseLeftButtonUp += new MouseButtonEventHandler(thumbVideoPlayer_MouseLeftButtonUp);

                    //显示关键帧注释
                    KeyFrame selectKeyFrame = videoSummarization.ShowKeyFrames[currIndex];
                    Dictionary <Stroke, KeyFramesAnnotation> s = selectKeyFrame.Annotations;
                    if (s.Count > 0)
                    {
                        _keyFrameAnnotation = new KeyFrameAnnotation();
                        _keyFrameAnnotation.setInkCollector(_inkCollector);
                        _keyFrameAnnotation.setKeyFramesAnnotation(keyFramesAnnotation, false);
                        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);
                            if (_inkCanvas.Strokes.IndexOf(stroke) == -1)
                            {
                                _inkCanvas.Strokes.Add(stroke);
                            }
                        }
                        _keyFrameAnnotation.InkCanvasAnnotation.Strokes.Add(keyFramesAnnotation.Strokes);
                        //显示关键帧注释
                        _keyFrameAnnotation.Width             = keyFramesAnnotation.Width;
                        _keyFrameAnnotation.Height            = keyFramesAnnotation.Height;
                        _keyFrameAnnotation.VerticalAlignment = VerticalAlignment.Top;
                        if (videoSummarization.ShowKeyFrameCenterPoints[startIndex].X < videoSummarization.Center.X)
                        {
                            _keyFrameAnnotation.HorizontalAlignment = HorizontalAlignment.Left;
                        }
                        else
                        {
                            _keyFrameAnnotation.HorizontalAlignment = HorizontalAlignment.Right;
                        }
                        _keyFrameAnnotation.Visibility = Visibility.Visible;
                        _inkCollector._mainPage.LayoutRoot.Children.Add(_keyFrameAnnotation);
                    }

                    moveTimerSecond = 0;
                }
            }
        }
        /// <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;
            }
        }