//选中所有
 private void SelectAllFun()
 {
     foreach (Canvas video in storageListWrap.Children)
     {
         VideoListTag tag = (VideoListTag)video.Tag;
         if (!tag.isSelected)
         {
             selectThisImage(video);
         }
     }
 }
        //勾选视频
        private void selectButton(Canvas videoCanvas)
        {
            //移除所有
            unselectedAllVideo();

            //选中当前
            selectCurrVideo(videoCanvas);

            //更新当前控件数据
            VideoListTag tag = (VideoListTag)videoCanvas.Tag;

            storageVideoId = tag.storageVideo.id;
        }
        /*
         * 切换选中状态
         */
        private void toggleSelectStatus(Canvas video)
        {
            VideoListTag tag = (VideoListTag)video.Tag;

            if (tag.isSelected)
            {
                unSelectThisImage(video);
            }
            else
            {
                selectThisImage(video);
            }
        }
        //鼠标离开视频
        private void videoCanvasMouseLeave(object sender, MouseEventArgs e)
        {
            Canvas       videoCanvas = (Canvas)sender;
            VideoListTag tag         = (VideoListTag)videoCanvas.Tag;

            if (videoCanvas != null && !tag.isSelected)
            {
                FrameworkElement selectButton = FrameworkElementUtil.getByName(videoCanvas, "selectButton");
                if (selectButton != null)
                {
                    selectButton.Visibility = Visibility.Hidden;
                }
            }
        }
        /*
         * 取消选中当前图片
         */
        private void unSelectThisImage(Canvas video)
        {
            VideoListTag tag          = (VideoListTag)video.Tag;
            Button       selectButton = (Button)FrameworkElementUtil.getByName(video, "selectButton");

            if (selectButton != null)
            {
                selectButton.Visibility = Visibility.Hidden;
                selectButton.Background = new ImageBrush
                {
                    ImageSource = new BitmapImage(new Uri(@"Resources/ico_media_select.png", UriKind.Relative)),
                    Stretch     = Stretch.UniformToFill
                };
            }
            tag.isSelected = false;
            video.Tag      = tag;
        }
        //点击勾选视频
        private void selectButtonClick(object sender, RoutedEventArgs e)
        {
            Canvas           videoCanvas = null;
            FrameworkElement fe          = (FrameworkElement)sender;

            if (fe.Name == "videoCanvas")
            {
                videoCanvas = (Canvas)fe;
            }
            else if (fe.Name == "selectButton")
            {
                videoCanvas = (Canvas)VisualTreeHelper.GetParent(fe);
            }
            VideoListTag tag = (VideoListTag)videoCanvas.Tag;

            toggleSelectStatus(videoCanvas);
        }
        //选中当前视频
        private void selectCurrVideo(Canvas videoCanvas)
        {
            Button selectButton = (Button)FrameworkElementUtil.getByName(videoCanvas, "selectButton");

            if (selectButton != null)
            {
                selectButton.Visibility = Visibility.Visible;
                selectButton.Background = new ImageBrush
                {
                    ImageSource = new BitmapImage(new Uri(@"Resources/ico_media_select_active.png", UriKind.Relative)),
                    Stretch     = Stretch.UniformToFill
                };
            }
            VideoListTag tag = (VideoListTag)videoCanvas.Tag;

            tag.isSelected  = true;
            videoCanvas.Tag = tag;
        }
        //勾选视频
        private void selectButton(Canvas videoCanvas)
        {
            //移除所有
            unselectedAllVideo();

            //选中当前
            selectCurrVideo(videoCanvas);

            //更新当前控件数据
            VideoListTag tag = (VideoListTag)videoCanvas.Tag;

            // this.currDControl.url = tag.storageVideo.url;
            //  this.currDControl.imgs = tag.storageVideo.img;

            //显示选中的控件
            showSelectedVideo(tag.storageVideo);
            currDControl.linkToVideoId = tag.storageVideo.id;
        }
        /*
         * 移动到
         */
        private void Batch_Move_To_Click(object sender, RoutedEventArgs e)
        {
            List <StorageVideo> list       = new List <StorageVideo>();//创建了一个空列表
            List <Canvas>       canvasList = new List <Canvas>();
            UIElementCollection children   = storageListWrap.Children;

            //1.获取所有勾选图片,同时移除选中
            for (int i = 0; i < children.Count; i++)
            {
                Canvas       canvas = (Canvas)children[i];
                VideoListTag tag    = (VideoListTag)canvas.Tag;
                if (tag.isSelected)
                {
                    list.Add(tag.storageVideo);
                    canvasList.Add(canvas);
                }
            }
            StorageVideoMoveToFolderWindow win = new StorageVideoMoveToFolderWindow(storageListWrap, list, canvasList);

            win.ShowDialog();
        }
        /*
         * 初始化一个图片控件
         */
        private Canvas initOneVideo(StorageVideo storageVideo)
        {
            VideoListTag tag = new VideoListTag();

            tag.isSelected   = false;
            tag.storageVideo = storageVideo;
            Canvas videoCanvas = new Canvas();

            videoCanvas.Name   = "videoCanvas";
            videoCanvas.Width  = 100;
            videoCanvas.Height = 100;
            videoCanvas.Margin = new Thickness(10);
            videoCanvas.Tag    = tag;

            //1.按钮
            StorageImage storageImage = storageImageBll.get(storageVideo.storageImageId);
            string       imgFullPath  = FileUtil.notExistsShowDefault(storageImage?.url, Params.ImageNotExists);

            imgFullPath = AppDomain.CurrentDomain.BaseDirectory + imgFullPath;

            Image videoImage = new Image();

            videoImage.Name    = "videoImage1";
            videoImage.Width   = 100;
            videoImage.Height  = 75;
            videoImage.Source  = FileUtil.readImage2(imgFullPath, 200);
            videoImage.Stretch = Stretch.UniformToFill;

            //2.按钮行
            Canvas bg = new Canvas();

            bg.Name       = "bg";
            bg.Background = Brushes.Black;
            bg.Width      = 100;
            bg.Height     = 24;
            bg.Opacity    = 0.6;
            bg.SetValue(Canvas.BottomProperty, 25.0);
            bg.SetValue(Canvas.LeftProperty, 0.0);

            //时长
            string mmss   = VideoUtil.duration2mmss(storageVideo.duration);
            Label  lLabel = new Label();

            lLabel.Width      = 50;
            lLabel.Height     = 24;
            lLabel.Content    = mmss;
            lLabel.Foreground = Brushes.White;
            lLabel.SetValue(Canvas.LeftProperty, 0.0);
            lLabel.SetValue(Canvas.TopProperty, 0.0);
            bg.Children.Add(lLabel);

            //删除按钮
            Button rbtn = new Button();

            rbtn.Width           = 16;
            rbtn.Height          = 16;
            rbtn.BorderThickness = new Thickness(0);
            rbtn.Background      = new ImageBrush
            {
                ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + "/myfile/sysimg/ico-image-remove.png")
                ,
                Stretch = Stretch.UniformToFill
            };
            rbtn.SetValue(Canvas.RightProperty, -8.0);
            rbtn.SetValue(Canvas.TopProperty, -8.0);
            // bg.Children.Add(rbtn);
            // rbtn.Click += rbtnClick;


            //标题
            Label titleLabel = new Label();

            titleLabel.Width   = 100;
            titleLabel.Height  = 25;
            titleLabel.Content = storageVideo.origFilename;
            titleLabel.SetValue(Canvas.LeftProperty, 0.0);
            titleLabel.SetValue(Canvas.BottomProperty, 0.0);
            titleLabel.ToolTip = storageVideo.origFilename;

            //勾选
            Button selectButton = new Button();

            selectButton.Name            = "selectButton";
            selectButton.Tag             = storageVideo.id;
            selectButton.Width           = 24;
            selectButton.Height          = 24;
            selectButton.BorderThickness = new Thickness(0);
            selectButton.SetValue(Canvas.LeftProperty, 7.0);
            selectButton.SetValue(Canvas.TopProperty, 7.0);
            selectButton.Background = new ImageBrush
            {
                ImageSource = new BitmapImage(new Uri(@"Resources/ico_media_select.png", UriKind.Relative)),
                Stretch     = Stretch.UniformToFill
            };
            selectButton.Visibility = Visibility.Hidden;


            videoCanvas.MouseEnter          += videoCanvasMouseEnter;
            videoCanvas.MouseLeave          += videoCanvasMouseLeave;
            videoCanvas.MouseLeftButtonDown += selectButtonClick;
            selectButton.Click += selectButtonClick;



            videoCanvas.Children.Add(videoImage);
            videoCanvas.Children.Add(bg);
            videoCanvas.Children.Add(titleLabel);
            videoCanvas.Children.Add(selectButton);
            // videoCanvas.Children.Add(rbtn);

            return(videoCanvas);
        }
        /*
         * 添加已选择的视频
         */
        private Canvas initSelectedVideo(StorageVideo video)
        {
            VideoListTag tag = new VideoListTag();

            tag.isSelected   = false;
            tag.storageVideo = video;
            Canvas selectedVideoCanvas = new Canvas();

            selectedVideoCanvas.Name   = "selectedVideoCanvas";
            selectedVideoCanvas.Width  = 100;
            selectedVideoCanvas.Height = 100;
            selectedVideoCanvas.Margin = new Thickness(10);
            selectedVideoCanvas.Tag    = tag;

            //1.按钮
            StorageImage storageImage = storageImageBll.get(video.storageImageId);
            string       imgFullPath  = FileUtil.notExistsShowDefault(storageImage?.url, Params.ImageNotExists);

            imgFullPath = AppDomain.CurrentDomain.BaseDirectory + imgFullPath;
            Image videoImage = new Image();

            videoImage.Name    = "videoImage1";
            videoImage.Width   = 100;
            videoImage.Height  = 75;
            videoImage.Source  = FileUtil.readImage2(imgFullPath, 200);
            videoImage.Stretch = Stretch.UniformToFill;

            //2.按钮行
            Canvas bg = new Canvas();

            bg.Name       = "bg";
            bg.Background = Brushes.Black;
            bg.Width      = 100;
            bg.Height     = 24;
            bg.Opacity    = 0.6;
            bg.SetValue(Canvas.BottomProperty, 25.0);
            bg.SetValue(Canvas.LeftProperty, 0.0);

            //时长
            string mmss   = VideoUtil.duration2mmss(video.duration);
            Label  lLabel = new Label();

            lLabel.Width      = 50;
            lLabel.Height     = 24;
            lLabel.Content    = mmss;
            lLabel.Foreground = Brushes.White;
            lLabel.SetValue(Canvas.LeftProperty, 0.0);
            lLabel.SetValue(Canvas.TopProperty, 0.0);
            bg.Children.Add(lLabel);

            //删除按钮
            Button rbtn = new Button();

            rbtn.Width           = 16;
            rbtn.Height          = 16;
            rbtn.BorderThickness = new Thickness(0);
            rbtn.Background      = new ImageBrush
            {
                ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + App.localStorage.icoRemove)
                ,
                Stretch = Stretch.UniformToFill
            };
            rbtn.SetValue(Canvas.RightProperty, -8.0);
            rbtn.SetValue(Canvas.TopProperty, -8.0);
            rbtn.Click += rbtnRemoveSelectedVideoClick;


            //标题
            string videoFullPath = FileUtil.notExistsShowDefault(video?.url, Params.VideoNotExists);
            string fullFolder    = FileUtil.getDirectory(AppDomain.CurrentDomain.BaseDirectory + videoFullPath);

            Label titleLabel = new Label();

            titleLabel.Width   = 100;
            titleLabel.Height  = 25;
            titleLabel.Content = video.origFilename;
            titleLabel.Tag     = fullFolder;
            titleLabel.SetValue(Canvas.LeftProperty, 0.0);
            titleLabel.SetValue(Canvas.BottomProperty, 0.0);
            titleLabel.ToolTip = video.origFilename;
            titleLabel.PreviewMouseLeftButtonUp += titleLabel_PreviewMouseLeftButtonUp;

            selectedVideoCanvas.Children.Add(videoImage);
            selectedVideoCanvas.Children.Add(bg);
            selectedVideoCanvas.Children.Add(titleLabel);
            selectedVideoCanvas.Children.Add(rbtn);
            return(selectedVideoCanvas);
        }