private int _delayTime = 300; //延时时间。 public void DragOver(DropInfo info) { _mouseOn = true; if (info.KeyStates.HasFlag(DragDropKeyStates.ControlKey)) { info.Effects = DragDropEffects.Copy; } else { info.Effects = DragDropEffects.Move; } if (!_accepted) { VideoPanelItem vpi = info.Target as VideoPanelItem; VideoPanelItem srcVpi = info.Source as VideoPanelItem; //延时拖动接收。 if (Environment.TickCount - _startTick < _delayTime) { return; } string videoId = info.Data as string; if (videoId == null && info.DataType.ToUpper().EndsWith(".STRING")) { videoId = info.GetDataFromJson <string>(); } if (videoId == null) { info.Effects = DragDropEffects.None; return; } if (vpi != null && videoId != null && !vpi.Equals(srcVpi)) { _videoMode = vpi.ViewModel.ControlViewModel; DropAdorner = CreateAdorner(vpi); DropAdorner.VisualCover.Visibility = Visibility.Hidden; // Point toPnt = new Point(0, 0); double scaleX = 1; double scaleY = 1; if (srcVpi != null && IsBrothers(srcVpi, vpi)) { //隐藏源的视频。 if (vpi.VideoControl != null && vpi.ViewModel.ControlViewModel.IsVisible) { _videoMode.Opacity = 0; DropAdorner.VisualCover.Visibility = Visibility.Visible; toPnt = vpi.PointFromScreen(srcVpi.PointToScreen(new Point(0, 0))); scaleX = srcVpi.ActualWidth / vpi.ActualWidth; scaleY = srcVpi.ActualHeight / vpi.ActualHeight; } } //启动动画。 Storyboard sb = CreateStoryboard(toPnt, scaleX, scaleY, 1); sb.Begin(DropAdorner, true); _accepted = true; } } }
VideoPanelDropAdorner CreateAdorner(VideoPanelItem vpi) { VideoPanelDropAdorner adorner = new VideoPanelDropAdorner(vpi, vpi.VideoControl?.videoDisp); return(adorner); }