/* * 3.4插入视频 Video */ public void insertVideoToPage(DControl ctl) { //获取视频所在的集合 StorageVideo storageVideo = storageVideoBll.get(ctl.storageId); if (storageVideo == null) { storageVideo = new StorageVideo(); storageVideo.url = "/myfile/sysimg/notExists/video.mp4"; storageVideo.origFilename = "演示视频.mp4"; } StorageVideoDto dto = StorageVideoUtil.convert(storageVideo); StorageImage storageImage = storageImageBll.get(dto.storageImageId); dto.storageImageUrl = storageImage?.url; Cfg pageCfg = PageWidthUtil.getPageCfg(pageTemplate.dPage, App.localStorage.cfg); CVideo cVideo = NewControlUtil.newCVideo(ctl, dto, pageCfg, pageTemplate.mqServer, true); System.Windows.Style myStyle = (System.Windows.Style)pageTemplate.container.FindResource("DefaultCVideoStyle"); cVideo.Style = myStyle; cVideo.PreviewMouseLeftButtonDown += control_MouseDown; cVideo.PreviewMouseMove += control_MouseMove; cVideo.PreviewMouseLeftButtonUp += control_MouseUp; //控件上右击显示菜单 cVideo.MouseRightButtonUp += control_MouseRightButtonUp; pageTemplate.container.Children.Add(cVideo); }
/* * 保存视频 */ private void Submit_Button_Click(object sender, RoutedEventArgs e) { DControl currDControl = (DControl)currElement.Tag; StorageVideo storageVideo = storageVideoBll.get(this.currDControl.storageId); if (storageVideo == null) { MessageBox.Show("视频不存在"); return; } //更新到数据库 DControl dControl = dControlBll.get(currDControl.id); dControl.storageId = this.currDControl.storageId; dControlBll.update(dControl); currElement.Tag = dControl; //更新页面控件信息 //获取视频所在的集合 //StorageVideo storageVideo = storageVideoBll.get(ctl.storageId); //获取视频列表 StorageVideoDto dto = StorageVideoUtil.convert(storageVideo); StorageImage storageImage = storageImageBll.get(dto.storageImageId); dto.storageImageUrl = storageImage?.url; CVideo cVideo = (CVideo)currElement; cVideo.updateElement(dControl, true, dto); Close(); }
/* * 插入视频背景 * * @param storageVideo 视频信息 * * @param pageWidth 页面宽度 * * @param pageHeight 页面高度 * */ private void insertCVideoBackground(StorageVideo storageVideo, int pageWidth, int pageHeight) { DControl ctl = new DControl(); ctl.name = "CVideoBackground"; ctl.width = pageWidth; ctl.height = pageHeight; ctl.left = 0; ctl.top = 0; ctl.storageId = storageVideo.id; StorageVideoDto dto = StorageVideoUtil.convert(storageVideo); StorageImage storageImage = storageImageBll.get(dto.storageImageId); dto.storageImageUrl = storageImage?.url; CVideoBackground cVideoBackground1 = new CVideoBackground(dto, true); cVideoBackground1.Name = "CVideoBackground"; cVideoBackground1.HorizontalAlignment = HorizontalAlignment.Left; cVideoBackground1.VerticalAlignment = VerticalAlignment.Top; cVideoBackground1.Margin = new Thickness(ctl.left, ctl.top, 0, 0); cVideoBackground1.Width = ctl.width; cVideoBackground1.Height = ctl.height; backgroundVideo.Children.Add(cVideoBackground1); }
/* * 3.4插入视频 Video */ public void insertVideoToPage(DControl ctl) { //获取视频所在的集合 StorageVideo storageVideo = storageVideoBll.get(ctl.storageId); if (storageVideo == null) { storageVideo = new StorageVideo(); storageVideo.url = "/myfile/sysimg/notExists/video.mp4"; storageVideo.origFilename = "演示视频.mp4"; } StorageVideoDto dto = StorageVideoUtil.convert(storageVideo); StorageImage storageImage = storageImageBll.get(dto.storageImageId); dto.storageImageUrl = storageImage?.url; //foreach (Window win in App.appWindowList) //{ // string type = win.GetType().Name; // Console.WriteLine("窗口类型:" + type); //} Cfg pageCfg = PageWidthUtil.getPageCfg(dPage, App.localStorage.cfg); CVideo cVideo = NewControlUtil.newCVideo(ctl, dto, pageCfg, pageTemplate1.mqServer, false); loadAllAnimation(cVideo, ctl); mainContainer.Children.Add(cVideo); }
private void insertCVideoBackground(StorageVideo storageVideo) { Cfg cfg = new Cfg(); cfg.screenWidth = Convert.ToInt32(pageTemplate.ActualWidth); cfg.screenHeight = Convert.ToInt32(pageTemplate.ActualHeight); DControl ctl = new DControl(); ctl.name = "CVideoBackground"; ctl.width = cfg.screenWidth; ctl.height = cfg.screenHeight; ctl.left = 0; ctl.top = 0; ctl.storageId = storageVideo.id; StorageVideoDto dto = StorageVideoUtil.convert(storageVideo); StorageImage storageImage = storageImageBll.get(dto.storageImageId); dto.storageImageUrl = storageImage?.url; CVideoBackground cVideoBackground1 = new CVideoBackground(dto, true); cVideoBackground1.Name = "CVideoBackground"; cVideoBackground1.HorizontalAlignment = HorizontalAlignment.Left; cVideoBackground1.VerticalAlignment = VerticalAlignment.Top; cVideoBackground1.Margin = new Thickness(ctl.left, ctl.top, 0, 0); cVideoBackground1.Width = ctl.width; cVideoBackground1.Height = ctl.height; pageTemplate.backgroundVideo.Children.Add(cVideoBackground1); }
/* * 1.4 链接到全屏视频 */ public void insertFullVideoToPage(DControlDto dControlDto) { StorageVideo storageVideo = storageVideoBll.get(dControlDto.linkToVideoId); int frameWidth = App.localStorage.cfg.screenWidth; int frameHeight = App.localStorage.cfg.screenHeight; if (dPage.width > 0) { frameWidth = dPage.width; } if (dPage.height > 0) { frameHeight = dPage.height; } Cfg cfg = new Cfg(); cfg.screenWidth = frameWidth; cfg.screenHeight = frameHeight; if (storageVideo == null) { storageVideo = new StorageVideo(); storageVideo.url = "/myfile/sysimg/notExists/video.mp4"; storageVideo.origFilename = "演示视频.mp4"; } StorageVideoDto dto = StorageVideoUtil.convert(storageVideo); StorageImage storageImage = storageImageBll.get(dto.storageImageId); dto.storageImageUrl = storageImage?.url; DControl ctl = new DControl(); ctl.id = 10003; ctl.pageId = 0; ctl.name = "cVideo"; ctl.width = cfg.screenWidth; ctl.height = cfg.screenHeight; ctl.left = 0; ctl.top = 0; ctl.type = "Video"; ctl.content = FileUtil.getFilenameTitle(storageVideo?.origFilename); ctl.idx = 0; ///// ctl.linkToPageId = 0; ctl.isClickShow = false; ctl.linkToVideoId = 0; ctl.autoplay = true; ctl.loop = false; ctl.turnPictureSpeed = 0; ctl.storageId = storageVideo.id; Canvas fullVideoCanvas = new Canvas(); fullVideoCanvas.Name = "fullVideoCanvas"; fullVideoCanvas.Width = ctl.width; fullVideoCanvas.Height = ctl.height; fullVideoCanvas.HorizontalAlignment = HorizontalAlignment.Left; fullVideoCanvas.VerticalAlignment = VerticalAlignment.Top; TransformGroup group = new TransformGroup(); double scaleX = dControlDto.width / Convert.ToDouble(ctl.width); double scaleY = dControlDto.height / Convert.ToDouble(ctl.height); ScaleTransform scaleTransform = new ScaleTransform(); scaleTransform.ScaleX = scaleX; scaleTransform.ScaleY = scaleY; group.Children.Add(scaleTransform); fullVideoCanvas.RenderTransform = group; double left = dControlDto.left; double top = dControlDto.top; fullVideoCanvas.Margin = new Thickness(left, top, 0, 0); Panel.SetZIndex(fullVideoCanvas, 10003); CVideo cVideo = new CVideo(ctl, true, cfg, dto, pageTemplate1.mqServer, true); cVideo.Name = "cVideo"; cVideo.HorizontalAlignment = HorizontalAlignment.Left; cVideo.VerticalAlignment = VerticalAlignment.Top; cVideo.Width = ctl.width; cVideo.Height = ctl.height; cVideo.Background = null; cVideo.Tag = ctl; //动画,平移到指定位置 double toTranslateTransformX = 0 - dControlDto.left; double toTranslateTransformY = 0 - dControlDto.top; fullVideoCanvas.Children.Add(cVideo); AnimationUtil.loadFullVideo(fullVideoCanvas, toTranslateTransformX, toTranslateTransformY); pageTemplate1.container.Children.Add(fullVideoCanvas); //是否显示关闭按钮 Button closebtn = cVideo.GetClosebtn(); closebtn.Visibility = Visibility.Visible; closebtn.Tag = true; closebtn.Click += (object sender, RoutedEventArgs e) => closeVideoAnimation(fullVideoCanvas, dControlDto, cVideo); }