示例#1
0
 private void thumbVideoPlayer_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (startIndex == int.MinValue)
     {
         VideoSummarizationTool.locateMediaPlayer(VideoSummarizationControl.mediaPlayer, videoSummarization.ShowKeyFrames[currIndex]);
     }
     else
     {
         VideoSummarizationTool.locateMediaPlayer(VideoSummarizationControl.mediaPlayer, videoSummarization.ShowKeyFrames[startIndex]);
     }
 }
示例#2
0
 /// <summary>
 /// 单击超链接图片,视频进行跳转
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void hyperLinkPlayer_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     VideoSummarizationTool.locateMediaPlayer(VideoSummarizationControl.mediaPlayer, hyperLink);
     videoSummarization.hideSummarization();
     hyperLinkSpiralSummarization.showSpiralSummarization();
     _inkCollector.VideoSummarization = hyperLinkSpiralSummarization;
     videoSummarization = hyperLinkSpiralSummarization;
     //_inkCollector.KeyFrames = _inkCollector.VideoSummarization.KeyFrames;
     _inkCollector.VideoSummarization.InkCanvas.Margin = new Thickness(0, 0, 0, 0);
     videoSummarization = hyperLinkSpiralSummarization;
     VideoSummarizationControl.hyperLinkPlayer.Visibility = Visibility.Collapsed;
 }
示例#3
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 (_startPoint.X < (TableGrid.ActualWidth - 300) * 0.5)
                {
                    _currPoint.X -= ((InkCanvas)_inkCanvas.Children[0]).Margin.Left;
                    _currPoint.Y -= ((InkCanvas)_inkCanvas.Children[0]).Margin.Top;
                    endIndex      = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft.getSelectedKeyFrameIndex(_currPoint);
                }
                //右边的螺旋摘要
                else
                {
                    Point endPointRight = e.GetPosition((InkCanvas)_inkCanvas.Children[1]);
                    endIndex = _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationRight.getSelectedKeyFrameIndex(endPointRight);
                }
                if (startIndex != int.MinValue && endIndex != int.MinValue && startIndex != endIndex)
                {
                    if (startIndex > endIndex)
                    {
                        int temp = startIndex;
                        startIndex = endIndex;
                        endIndex   = temp;
                    }
                    if (_startPoint.X < TableGrid.ActualWidth / 2)
                    {
                        for (int i = startIndex; i <= endIndex; i++)
                        {
                            if (i < _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft.KeyFrames.Count)
                            {
                                Image image = VideoSummarizationTool.KeyFrameToImage(_inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft.KeyFrames[i]);

                                image.Margin = new Thickness(2, _inkCollector._mainPage.VideoSummarizationControl.keyFrameList._inkCanvas.Children.Count * 84, 0, 0);
                                _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft.KeyFrames[i].Image =
                                    VideoSummarizationTool.KeyFrameToImage(_inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft.KeyFrames[i]);
                                selectKeyFrames.Add(_inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationLeft.KeyFrames[i].convertToNewKeyFrame());
                                _inkCollector._mainPage.VideoSummarizationControl.keyFrameList._inkCanvas.Children.Add(image);
                            }
                        }
                    }
                    //右边的螺旋摘要
                    else
                    {
                        for (int i = startIndex; i <= endIndex; i++)
                        {
                            Image image = VideoSummarizationTool.KeyFrameToImage(_inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationRight.KeyFrames[i]);
                            image.Margin = new Thickness(2, _inkCollector._mainPage.VideoSummarizationControl.keyFrameList2._inkCanvas.Children.Count * 84, 0, 0);
                            _inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationRight.KeyFrames[i].Image =
                                VideoSummarizationTool.KeyFrameToImage(_inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationRight.KeyFrames[i]);
                            selectKeyFrames.Add(_inkCollector._mainPage.VideoSummarizationControl.SpiralSummarizationRight.KeyFrames[i].convertToNewKeyFrame());
                            _inkCollector._mainPage.VideoSummarizationControl.keyFrameList2._inkCanvas.Children.Add(image);
                        }
                    }
                }
                else
                {
                    mouseGesture.StopCapture();
                }
                _startPoint.X = 0;
                _startPoint.Y = 0;
                _inkCanvas.Strokes.Remove(lastStroke);
            }
        }
示例#4
0
        public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (videoSummarization != null && _startPoint != null && _inkCanvas.Strokes.Count > 0)
            {
                Stroke lastStroke = _inkCanvas.Strokes.Last();
                //先清空原来选中的关键帧序列
                clearPreMessage();
                _currPoint    = e.GetPosition(_inkCanvas);
                _currPoint.X -= inkCanvasSpiralSummarizationMargin.Left;
                _currPoint.Y -= inkCanvasSpiralSummarizationMargin.Top;
                endIndex      = videoSummarization.getSelectedKeyFrameIndex(_currPoint);
                //记录操作类型与持续时间
                recordOperateTrace("UP````````````````````````````````````````````````````Up");
                upTime = System.DateTime.Now;

                if (lastStroke.StylusPoints.Count == 1)
                {
                    if (startIndex != int.MinValue && startIndex == endIndex && _inkCollector.IsShowUnbrokenKeyFrame)
                    {
                        if (_inkCollector.DefaultSummarizationNum == 0)
                        {
                            mouseGesture.Points.Clear();
                        }
                        if (GlobalValues.locationQuestions.Count > 0)
                        {
                            if (GlobalValues.CurrLocationId + 1 < GlobalValues.locationQuestions.Count)
                            {
                                if (GlobalValues.locationAnswers[GlobalValues.CurrLocationId].IndexOf(videoSummarization.KeyFrames.IndexOf(videoSummarization.ShowKeyFrames[startIndex]) + 1) != -1)
                                {
                                    GlobalValues.CurrLocationId++;
                                    GlobalValues.LocationQuestion.setQuestion(GlobalValues.locationQuestions[GlobalValues.CurrLocationId]);
                                    VideoSummarizationControl.RecordCurrOperationAndTime("第" + (GlobalValues.CurrLocationId - 1).ToString() +
                                                                                         "次定位正确");
                                    GlobalValues.LocationQuestion.TBQuestion.Background = new SolidColorBrush(GlobalValues.LocationQuestionBackGrouds[GlobalValues.CurrLocationId]);
                                }
                            }
                            else
                            {
                                VideoSummarizationControl.RecordCurrOperationAndTime("最后一次定位正确");
                                switch (GlobalValues.summarizationTypeNo)
                                {
                                case 0:
                                    VideoSummarizationControl.Record("Spiral");
                                    break;

                                case 1:
                                    VideoSummarizationControl.Record("Tile");
                                    break;

                                case 2:
                                    VideoSummarizationControl.Record("Tapestry");
                                    break;
                                }
                                MessageBox.Show("恭喜你完成此项任务!");
                                VideoSummarizationControl.sWriter.Close();
                                VideoSummarizationControl.myStream.Close();
                                Environment.Exit(1);
                            }
                        }
                        //定位视频
                        if (0 <= startIndex && startIndex < videoSummarization.ShowKeyFrames.Count && VideoSummarizationControl != null)
                        {
                            //定位视频,position的单位是秒
                            videoSource = videoSummarization.ShowKeyFrames[startIndex].VideoName;
                            VideoSummarizationTool.locateMediaPlayer(VideoSummarizationControl.mediaPlayer, videoSummarization.ShowKeyFrames[startIndex]);
                            //显示超链接
                            if (hyperLink != null)
                            {
                                VideoSummarizationControl.TableGrid.Children.Remove(hyperLink.Image);
                            }
                            hyperLink = videoSummarization.ShowKeyFrames[startIndex].HyperLink;
                            if (hyperLink != null)
                            {
                                VideoSummarizationControl.hyperLinkPlayer.Visibility = Visibility.Visible;
                                VideoSummarizationTool.locateMediaPlayer(VideoSummarizationControl.hyperLinkPlayer, hyperLink);
                                hyperLinkSpiralSummarization = videoSummarization.ShowKeyFrames[startIndex].HyperLinkSpiralSummarization;
                                VideoSummarizationControl.hyperLinkPlayer.MouseLeftButtonUp += new MouseButtonEventHandler(hyperLinkPlayer_MouseLeftButtonUp);
                            }
                            //记录操作事件与持续时间
                            recordOperateEvent("locate::::::::::::::::::::::::::::::::::::::Locate");
                        }
                    }
                }
                else
                {
                    if (_inkCollector.DefaultSummarizationNum == 0)
                    {
                        mouseGesture.StopCapture();
                    }
                }
                _startPoint.X = 0;
                _startPoint.Y = 0;
                _inkCanvas.Strokes.Remove(lastStroke);
            }
        }
示例#5
0
        public void VideoPlayTimer_Tick(object sender, EventArgs e)
        {
            int videoTimeNow = (int)VideoSummarizationControl.mediaPlayer.Position.TotalMilliseconds;

            //修改时间轴和播放时间
            VideoSummarizationControl._timeBar.Value = videoTimeNow;

            //修改显示播放进度的值的textbox
            List <string> timeCurr = new List <string>();

            timeCurr = ConvertClass.getInstance().MsToHMS(videoTimeNow);
            VideoSummarizationControl.VideoProgressText.Text = timeCurr[0] + ":" + timeCurr[1] + ":" + timeCurr[2] + "/" + timeTotalString;

            //显示超链接关键帧
            foreach (KeyFrame keyFrame in _inkCollector.HyperLinkKeyFrames)
            {
                if (keyFrame.VideoName == videoSource && (int)(keyFrame.Time / 1000) == (int)(videoTimeNow / 1000))
                {
                    if (hyperLink != null)
                    {
                        VideoSummarizationControl.TableGrid.Children.Remove(hyperLink.Image);
                    }
                    hyperLink = keyFrame.HyperLink;
                    VideoSummarizationControl.hyperLinkPlayer.Visibility = Visibility.Visible;
                    VideoSummarizationTool.locateMediaPlayer(VideoSummarizationControl.hyperLinkPlayer, hyperLink);
                    hyperLinkPlayTimer          = new System.Windows.Forms.Timer();
                    hyperLinkPlayTimer.Interval = 8000;
                    hyperLinkPlayTimer.Tick    += new System.EventHandler(hyperLinkPlayTimer_Tick);
                    hyperLinkPlayTimer.Start();
                    hyperLinkSpiralSummarization = keyFrame.HyperLinkSpiralSummarization;
                    VideoSummarizationControl.hyperLinkPlayer.MouseLeftButtonUp += new MouseButtonEventHandler(hyperLinkPlayer_MouseLeftButtonUp);
                    break;
                }
            }

            bool isHasAnnotation = false;
            bool isHasKeyFrame   = false;

            foreach (KeyFrame keyFrame in videoSummarization.KeyFrames)
            {
                if ((int)(keyFrame.Time / 1000) == (int)(videoTimeNow / 1000))
                {
                    if (_inkCollector.DefaultSummarizationNum == 0 && _inkCollector.IsShowRedPoint)
                    {
                        //在螺旋摘要中修改螺旋线表明播放到当前帧了
                        int currIndex = videoSummarization.KeyFrames.IndexOf(keyFrame);
                        if (currPlayKeyFrameStroke != null)
                        {
                            _inkCollector.VideoSummarization.InkCanvas.Strokes.Remove(currPlayKeyFrameStroke);
                        }
                        currPlayKeyFrameStroke = _inkCollector.VideoSummarization.AddPoint2Track(currIndex, Colors.Red, 8);
                    }
                    //显示草图注释
                    isHasKeyFrame = true;
                    Dictionary <Stroke, KeyFramesAnnotation> s = keyFrame.Annotations;
                    if (s.Count > 0)
                    {
                        KeyValuePair <Stroke, KeyFramesAnnotation> currPair;
                        if (_keyFrameAnnotation != null && keyFramesAnnotation != null)
                        {
                            _keyFrameAnnotation.Visibility = Visibility.Collapsed;
                            _inkCollector._mainPage.LayoutRoot.Children.Remove(_keyFrameAnnotation);
                            _keyFrameAnnotation = null;
                            foreach (int index in keyFramesAnnotation.relatedKeyFrameIndexes)
                            {
                                currPair = (from KeyValuePair <Stroke, KeyFramesAnnotation> anno in _inkCollector.VideoSummarization.ShowKeyFrames[index].Annotations
                                            where anno.Value == keyFramesAnnotation
                                            select anno).First();
                                Stroke linkline = (Stroke)(currPair.Key);
                                _inkCollector._mainPage._inkCanvas.Strokes.Remove(linkline);
                            }
                        }
                        _keyFrameAnnotation = new KeyFrameAnnotation();
                        currPair            = (from KeyValuePair <Stroke, KeyFramesAnnotation> anno in keyFrame.Annotations
                                               //where anno.Value == _keyFramesAnnotation
                                               select anno).First();
                        keyFramesAnnotation = (KeyFramesAnnotation)(currPair.Value);
                        int firstIndex = 0;
                        int count      = 0;
                        foreach (int index in keyFramesAnnotation.relatedKeyFrameIndexes)
                        {
                            if (count == 0)
                            {
                                firstIndex = index;
                            }
                            count++;
                            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[firstIndex].X < videoSummarization.Center.X)
                        {
                            _keyFrameAnnotation.HorizontalAlignment = HorizontalAlignment.Left;
                        }
                        else
                        {
                            _keyFrameAnnotation.HorizontalAlignment = HorizontalAlignment.Right;
                        }
                        _keyFrameAnnotation.Visibility = Visibility.Visible;
                        _inkCollector._mainPage.LayoutRoot.Children.Add(_keyFrameAnnotation);

                        //VideoSummarizationControl.BtnSpiralScreenBack.Visibility = Visibility.Collapsed;
                        //VideoSummarizationControl.BtnSpiralScreen.Visibility = Visibility.Collapsed;
                        isHasAnnotation = true;
                    }
                    break;
                }
            }
            if (isHasKeyFrame && !isHasAnnotation && _inkCollector.Mode != InkMode.AddKeyFrameAnnotationDouble)
            {
                KeyValuePair <Stroke, KeyFramesAnnotation> currPair;
                if (_keyFrameAnnotation != null && keyFramesAnnotation != null)
                {
                    _keyFrameAnnotation.Visibility = Visibility.Collapsed;
                    foreach (int index in keyFramesAnnotation.relatedKeyFrameIndexes)
                    {
                        currPair = (from KeyValuePair <Stroke, KeyFramesAnnotation> anno in _inkCollector.VideoSummarization.ShowKeyFrames[index].Annotations
                                    where anno.Value == keyFramesAnnotation
                                    select anno).First();
                        Stroke linkline = (Stroke)(currPair.Key);
                        _inkCollector._mainPage._inkCanvas.Strokes.Remove(linkline);
                    }
                }
            }
        }
示例#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);
        }