Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
 private bool ShowVideoWin(DragInfo info, VideoPanelItem vpi)
 {
     if (_topWin != null)
     {
         string        videoID = (string)info.Data;
         PopupWinModel model   = new PopupWinModel(videoID);
         PopupWin      popup   = new PopupWin();
         popup.IsTopmost   = true;
         popup.DataContext = model;
         Point startPos = info.GetPosition(vpi);
         startPos = vpi.PointToScreen(startPos);
         startPos = new Point(startPos.X - vpi.ActualWidth / 2, startPos.Y - vpi.ActualHeight / 2);
         if (startPos.X < 0)
         {
             startPos.X = 0;
         }
         if (startPos.Y < 0)
         {
             startPos.Y = 0;
         }
         popup.Left = startPos.X;
         popup.Top  = startPos.Y;
         if (vpi.ActualWidth < AppConstants.VideoControlMinWidth)
         {
             popup.Width = AppConstants.VideoControlMinWidth;
             if (vpi.ActualHeight == 0)
             {
                 popup.Height = AppConstants.VideoControlMinWidth * 0.75;
             }
             else
             {
                 popup.Height = vpi.ActualHeight * (AppConstants.VideoControlMinWidth / vpi.ActualWidth);
             }
         }
         else
         {
             popup.Width  = vpi.ActualWidth;
             popup.Height = vpi.ActualHeight;
         }
         popup.Show();
         return(true);
     }
     return(false);
 }