//为草图缩略图加上时间段 public static void AddTextBoxTime(MyButton myButton) { List <string> hmsStart = ConvertClass.getInstance().MsToHMS(myButton.TimeStart); List <string> hmsEnd = ConvertClass.getInstance().MsToHMS(myButton.TimeEnd); string TimeString = hmsStart[0] + ":" + hmsStart[1] + ":" + hmsStart[2] + "-" + hmsEnd[0] + ":" + hmsEnd[1] + ":" + hmsEnd[2]; TextBox textBoxTime = new TextBox(); textBoxTime.Margin = new System.Windows.Thickness(myButton.Left, myButton.Top - 15, 0, 0); textBoxTime.Width = 110; textBoxTime.FontSize = 10; textBoxTime.Height = 15; textBoxTime.Background = null; textBoxTime.Text = TimeString; textBoxTime.BorderThickness = new System.Windows.Thickness(0); if (myButton.TextBoxTime != null) { textBoxTime.RenderTransform = myButton.TextBoxTime.RenderTransform; if (myButton.TextBoxTime.Background != null) { textBoxTime.Background = myButton.TextBoxTime.Background; } } myButton.TextBoxTime = textBoxTime; }
public void InkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e) { ReadOnlyCollection<GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults(); Rect bound = e.Strokes.GetBounds(); System.Drawing.Rectangle rectangleBound = ConvertClass.getInstance().RectToRectangle(bound); if (gestureResults[0].RecognitionConfidence == RecognitionConfidence.Strong) { switch (gestureResults[0].ApplicationGesture) { case ApplicationGesture.ScratchOut: foreach (MyButton myButton in _inkFrame.InkCollector.Sketch.MyButtons) { Rect rectMyButton=new Rect(new Point(myButton.Left,myButton.Top),new Point(myButton.Left+myButton.Width,myButton.Top+myButton.Height)); if (MathTool.getInstance().isHitRects(e.Strokes.GetBounds(), rectMyButton) == true) { DeleteButtonCommand dbc = new DeleteButtonCommand(_inkFrame.InkCollector, myButton,_videoList); dbc.execute(); InkCollector.CommandStack.Push(dbc); } } foreach (MyArrow myArrow in _inkFrame.InkCollector.Sketch.MyArrows) { Rect rectMyButton = new Rect(myArrow.StartPoint,myArrow.EndPoint); if (MathTool.getInstance().isHitRects(e.Strokes.GetBounds(), rectMyButton) == true) { Command dac = new DeleteArrowCommand(_inkFrame.InkCollector, myArrow); dac.execute(); InkCollector.CommandStack.Push(dac); } } break; case ApplicationGesture.Down: if (downcount == 1) { getKeyFramesInGivenVideoClip(_inkFrame.InkCollector.Sketch.MyButtons[0].VideoPath.Substring(8), (int)_inkFrame.InkCollector.Sketch.MyButtons[0].TimeEnd, (int)_inkFrame.InkCollector.Sketch.MyButtons[1].TimeStart); } else if (downcount == 0) { getKeyFramesInGivenVideoClip(_inkFrame.InkCollector.Sketch.MyButtons[0].VideoPath.Substring(8), (int)_inkFrame.InkCollector.Sketch.MyButtons[5].TimeEnd, (int)_inkFrame.InkCollector.Sketch.MyButtons[6].TimeStart); } else if (downcount == 2) { getKeyFramesInGivenVideoClip(_inkFrame.InkCollector.Sketch.MyButtons[0].VideoPath.Substring(8), (int)_inkFrame.InkCollector.Sketch.MyButtons[6].TimeEnd, (int)_inkFrame.InkCollector.Sketch.MyButtons[7].TimeStart); InkCollector.Mode = InkMode.VideoPlay; } //else if (downcount == 3) //{ // getKeyFramesInGivenVideoClip(_inkFrame.InkCollector.Sketch.MyButtons[0].VideoPath.Substring(8), // (int)_inkFrame.InkCollector.Sketch.MyButtons[8].TimeEnd, // (int)_inkFrame.InkCollector.Sketch.MyButtons[9].TimeStart); //} downcount++; //getKeyFramesInGivenVideoClip(GlobalValues.FilesPath + "/麋鹿王.avi", 0, // 1069000); break; } } }
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); } } } }
//为草图缩略图加上时间段 public static void AddTextBoxTime2(MyButton myButton) { //colon是冒号的意思 List <MaskedTextBox> maskedTextBoxList = new List <MaskedTextBox>(); List <string> hmsStart = ConvertClass.getInstance().MsToHMS(myButton.TimeStart); List <string> hmsEnd = ConvertClass.getInstance().MsToHMS(myButton.TimeEnd); string TimeString = hmsStart[0] + ":" + hmsStart[1] + ":" + hmsStart[2] + " - " + hmsEnd[0] + ":" + hmsEnd[1] + ":" + hmsEnd[2]; MaskedTextBox shMaskedTextBoxTime = new MaskedTextBox(); shMaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left, myButton.Top - 40, 0, 0); shMaskedTextBoxTime.Width = 20; shMaskedTextBoxTime.Height = 20; shMaskedTextBoxTime.Background = null; shMaskedTextBoxTime.Text = hmsStart[0]; shMaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); shMaskedTextBoxTime.InputMask = "II"; maskedTextBoxList.Add(shMaskedTextBoxTime); MaskedTextBox colon1MaskedTextBoxTime = new MaskedTextBox(); colon1MaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 15, myButton.Top - 40, 0, 0); colon1MaskedTextBoxTime.Width = 10; colon1MaskedTextBoxTime.Height = 20; colon1MaskedTextBoxTime.Background = null; //colon1MaskedTextBoxTime.Text = hmsStart[0]; colon1MaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); colon1MaskedTextBoxTime.InputMask = ":"; maskedTextBoxList.Add(colon1MaskedTextBoxTime); MaskedTextBox smMaskedTextBoxTime = new MaskedTextBox(); smMaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 30, myButton.Top - 40, 0, 0); smMaskedTextBoxTime.Width = 20; smMaskedTextBoxTime.Height = 20; smMaskedTextBoxTime.Background = null; smMaskedTextBoxTime.Text = hmsStart[1]; smMaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); smMaskedTextBoxTime.InputMask = "II"; maskedTextBoxList.Add(smMaskedTextBoxTime); MaskedTextBox colon2MaskedTextBoxTime = new MaskedTextBox(); colon2MaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 50, myButton.Top - 40, 0, 0); colon2MaskedTextBoxTime.Width = 5; colon2MaskedTextBoxTime.Height = 20; colon2MaskedTextBoxTime.Background = null; //colon1MaskedTextBoxTime.Text = hmsStart[0]; colon2MaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); colon2MaskedTextBoxTime.InputMask = ":"; maskedTextBoxList.Add(colon2MaskedTextBoxTime); MaskedTextBox ssMaskedTextBoxTime = new MaskedTextBox(); ssMaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 47, myButton.Top - 40, 0, 0); ssMaskedTextBoxTime.Width = 20; ssMaskedTextBoxTime.Height = 20; ssMaskedTextBoxTime.Background = null; ssMaskedTextBoxTime.Text = hmsStart[2]; ssMaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); ssMaskedTextBoxTime.InputMask = "II"; maskedTextBoxList.Add(ssMaskedTextBoxTime); MaskedTextBox intervalMaskedTextBoxTime = new MaskedTextBox(); intervalMaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 62, myButton.Top - 40, 0, 0); intervalMaskedTextBoxTime.Width = 20; intervalMaskedTextBoxTime.Height = 20; intervalMaskedTextBoxTime.Background = null; //colon1MaskedTextBoxTime.Text = hmsStart[0]; intervalMaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); intervalMaskedTextBoxTime.InputMask = " - "; maskedTextBoxList.Add(intervalMaskedTextBoxTime); MaskedTextBox ehMaskedTextBoxTime = new MaskedTextBox(); ehMaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 82, myButton.Top - 40, 0, 0); ehMaskedTextBoxTime.Width = 20; ehMaskedTextBoxTime.Height = 20; ehMaskedTextBoxTime.Background = null; ehMaskedTextBoxTime.Text = hmsEnd[0]; ehMaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); ehMaskedTextBoxTime.InputMask = "II"; maskedTextBoxList.Add(ehMaskedTextBoxTime); MaskedTextBox colon3MaskedTextBoxTime = new MaskedTextBox(); colon3MaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 102, myButton.Top - 40, 0, 0); colon3MaskedTextBoxTime.Width = 5; colon3MaskedTextBoxTime.Height = 20; colon3MaskedTextBoxTime.Background = null; //colon1MaskedTextBoxTime.Text = hmsStart[0]; colon3MaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); colon3MaskedTextBoxTime.InputMask = ":"; maskedTextBoxList.Add(colon3MaskedTextBoxTime); MaskedTextBox emMaskedTextBoxTime = new MaskedTextBox(); emMaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 104, myButton.Top - 40, 0, 0); emMaskedTextBoxTime.Width = 20; emMaskedTextBoxTime.Height = 20; emMaskedTextBoxTime.Background = null; emMaskedTextBoxTime.Text = hmsEnd[1]; emMaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); emMaskedTextBoxTime.InputMask = "II"; maskedTextBoxList.Add(emMaskedTextBoxTime); MaskedTextBox colon4MaskedTextBoxTime = new MaskedTextBox(); colon4MaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 124, myButton.Top - 40, 0, 0); colon4MaskedTextBoxTime.Width = 5; colon4MaskedTextBoxTime.Height = 20; colon4MaskedTextBoxTime.Background = null; //colon1MaskedTextBoxTime.Text = hmsStart[0]; colon4MaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); colon4MaskedTextBoxTime.InputMask = ":"; maskedTextBoxList.Add(colon4MaskedTextBoxTime); MaskedTextBox esMaskedTextBoxTime = new MaskedTextBox(); esMaskedTextBoxTime.Margin = new System.Windows.Thickness(myButton.Left + 126, myButton.Top - 40, 0, 0); esMaskedTextBoxTime.Width = 20; esMaskedTextBoxTime.Height = 20; esMaskedTextBoxTime.Background = null; esMaskedTextBoxTime.Text = hmsEnd[2]; esMaskedTextBoxTime.BorderThickness = new System.Windows.Thickness(0); esMaskedTextBoxTime.InputMask = "II"; maskedTextBoxList.Add(esMaskedTextBoxTime); //myButton.MaskedTextBoxList = maskedTextBoxList; }