/* * 插入视频背景 * * @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); }
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); }
/* * 保存数据 */ private void Submit_Button_Click(object sender, RoutedEventArgs e) { StorageVideo storageVideo = null; object tag = backgroundVideoId.Tag; if (tag != null) { storageVideo = (StorageVideo)tag; } //更新到数据库 DPage dPage = dPageBll.get(currDPage.id); dPage.backgroundVideoId = storageVideo == null ? 0 : storageVideo.id; dPageBll.update(dPage); currDPage = dPage; pageTemplate.dPage = dPage; //更新页面控件信息 //1.清空视频背景 foreach (FrameworkElement ele in pageTemplate.backgroundVideo.Children) { if (ele.Name == "CVideoBackground") { CVideoBackground cVideoBackground = (CVideoBackground)ele; cVideoBackground = null; } } pageTemplate.backgroundVideo.Children.Clear(); if (storageVideo != null) { insertCVideoBackground(storageVideo); } Close(); }
private void PageTemplate_UnLoaded(object sender, RoutedEventArgs e) { foreach (UIElement element in container.Children) { if (element is Button) { Button btn = element as Button; btn.Background = null; btn = null; } else if (element is DocumentViewer) { DocumentViewer documentViewer = element as DocumentViewer; documentViewer.Style = null; documentViewer.PreviewMouseLeftButtonDown -= editing.control_MouseDown; documentViewer.PreviewMouseMove -= editing.control_MouseMove; documentViewer.PreviewMouseLeftButtonUp -= editing.control_MouseUp; //控件上右击显示菜单 documentViewer.MouseRightButtonUp -= editing.control_MouseRightButtonUp; documentViewer.SizeChanged -= WordUtil.Word_SizeChanged; documentViewer.Document = null; documentViewer = null; } else if (element is TurnPicture) { TurnPicture turnPicture = element as TurnPicture; turnPicture = null; } else if (element is CVideo) { CVideo cVideo = element as CVideo; cVideo = null; } else if (element is CFrame) { CFrame cFrame = element as CFrame; cFrame.Content = null; cFrame = null; } else if (element is Gif) { Gif gif = element as Gif; gif = null; } else { FrameworkElement fe = element as FrameworkElement; fe = null; } } //释放视频背景 foreach (FrameworkElement ele in backgroundVideo.Children) { if (ele.Name == "CVideoBackground") { CVideoBackground cVideoBackground = (CVideoBackground)ele; cVideoBackground = null; } } backgroundVideo.Children.Clear(); Background = null; editing = null; Content = null; container.Children.Clear(); GC.Collect(); //GC.WaitForPendingFinalizers(); //GC.Collect(); }
public void PageTemplate_UnLoaded(object sender, RoutedEventArgs e) { Unloaded -= PageTemplate_UnLoaded; foreach (FrameworkElement element in container.Children) { if (element is Button) { Button btn = element as Button; if (btn.Name == "Image") { btn.Click -= insertToPage.imageButtonClick; } else if (btn.Name == "BackButton") { btn.Click -= insertToPage.backButtonClick; } else if (btn.Name == "HomeButton") { btn.Click -= insertToPage.homeButtonClick; } btn.Background = null; btn = null; } else if (element is DocumentViewer) { DocumentViewer documentViewer = element as DocumentViewer; documentViewer.Document = null; documentViewer = null; } else if (element is TurnPicture) { TurnPicture turnPicture = element as TurnPicture; turnPicture = null; } else if (element is Marque) { Marque marque = element as Marque; marque = null; } else if (element is MarqueLayer) { MarqueLayer marqueLayer = element as MarqueLayer; marqueLayer = null; } else if (element is CVideo) { CVideo cVideo = element as CVideo; cVideo = null; } else if (element is CFrame) { CFrame cFrame = element as CFrame; cFrame.Content = null; cFrame = null; } else if (element is TextBlock) { TextBlock textBlock = element as TextBlock; textBlock.PreviewMouseUp -= insertToPage.textBlock_PreviewMouseUp; textBlock.PreviewTouchUp -= insertToPage.textBlock_PreviewTouchUp; textBlock = null; } else if (element is Gif) { Gif gif = element as Gif; gif.PreviewMouseUp -= insertToPage.gif_PreviewMouseUp; gif.PreviewTouchUp -= insertToPage.gif_PreviewTouchUp; gif = null; } else if (element is CAudio) { CAudio cAudio = element as CAudio; cAudio.PreviewMouseUp += insertToPage.cAudio_PreviewMouseUp; cAudio.PreviewTouchUp += insertToPage.cAudio_PreviewTouchUp; cAudio = null; } else if (element is CCalendar) { CCalendar cCalendar = element as CCalendar; cCalendar = null; } else if (element is Canvas && element.Name == "frameDialogCanvas") { releaseFrameDialogCanvas(element); } else { FrameworkElement fe = element as FrameworkElement; fe = null; } } //释放视频背景 foreach (FrameworkElement ele in backgroundVideo.Children) { if (ele.Name == "CVideoBackground") { CVideoBackground cVideoBackground = (CVideoBackground)ele; cVideoBackground = null; } } backgroundVideo.Children.Clear(); Background = null; insertToPage = null; Content = null; container.Children.Clear(); GC.Collect(); }