You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

771 lines
35 KiB

using CefSharp.Wpf;
using Container.Business;
using Container.ChildWindows;
using Container.Common;
using Container.Model;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Vlc.DotNet.Wpf;
namespace Container.Win
{
/// <summary>
/// ProgControl.xaml 的交互逻辑
/// </summary>
public partial class ProgControl : UserControl
{
string outLinePath;
App app = ((App)System.Windows.Application.Current);
DirectoryInfo vlcLibDirectory;
backgroundMaterialInfo backgroundMaterial;
string backgroundColor;
List<Component> components;
private Thread th1;//播放屏保的线程
bool isStop = false;
BrushConverter converter = new BrushConverter();
List<Task> tasks = new List<Task>();
List<MarqueeControlNew> marqueeControlNews = new List<MarqueeControlNew>();
List<ClockControl> clockControls = new List<ClockControl>();
List<WeatherControl> weatherControls = new List<WeatherControl>();
List<Image> imageControls = new List<Image>();
List<MediaPlayer> mediaControls = new List<MediaPlayer>();
List<ChromiumWebBrowser> chromiumWebBrowsers = new List<ChromiumWebBrowser>();
List<Canvas> canvasWebBrowsers = new List<Canvas>();
VlcControl vlcControl1 = new VlcControl();
VlcControl vlcControl2 = new VlcControl();
string vlcVideoPath = string.Empty;
string vlcVideo2Path = string.Empty;
List<CancellationTokenSource> cancellationTokens = new List<CancellationTokenSource>();
string[] options;
public ProgControl()
{
InitializeComponent();
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
// Default installation path of VideoLAN.LibVLC.Windows
vlcLibDirectory = new DirectoryInfo(currentDirectory);
//初始化配置,指定引用库
vlcControl1.SourceProvider.CreatePlayer(vlcLibDirectory);
//初始化配置,指定引用库
vlcControl2.SourceProvider.CreatePlayer(vlcLibDirectory);
// options = new string[]{
// "-I",
//"dummy",
//"--ignore-config",
//"--extraintf=logger",
//"--verbose=2",
//"--fullscreen",
//"--network-caching=300",
//"--live-caching=300",
//"--sout-mux-caching=300",
//"--file-caching=300",
//"--codec=mediacodec,iomx,all",
//"--quiet-synchro",
//" --clock-synchro=300",
//"--network-synchronisation",
//"--cr-average=10000"
// };
options = new string[] { "-I", "dummy", "--network-caching=<300", ":sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100" };
canvas.Children.Add(vlcControl1);
canvas.Children.Add(vlcControl2);
}
private void MediaPlayer_EndReached(object sender, Vlc.DotNet.Core.VlcMediaPlayerEndReachedEventArgs e)
{
Task.Factory.StartNew(() => {
//this.sourceProvider = null;
Application.Current.Dispatcher.BeginInvoke(new Action(() => {
vlcControl1.SourceProvider.MediaPlayer.Play(vlcVideoPath);
}));
});
}
private void MediaPlayer2_EndReached(object sender, Vlc.DotNet.Core.VlcMediaPlayerEndReachedEventArgs e)
{
Task.Factory.StartNew(() => {
//this.sourceProvider = null;
Application.Current.Dispatcher.BeginInvoke(new Action(() => {
vlcControl2.SourceProvider.MediaPlayer.Play(vlcVideo2Path);
}));
});
}
public void LoadProg(double width, double height, backgroundMaterialInfo backgroundmaterial, string backgroundcolor, List<Component> componentList)
{
backgroundMaterial = backgroundmaterial;
backgroundColor = backgroundcolor;
components = componentList;
this.Width = width;
this.Height = height;
canvas.Width = width;
canvas.Height = height;
try
{
outLinePath = AppDomain.CurrentDomain.BaseDirectory + "/OutlineFiles";
if (backgroundMaterial != null)
{
string fileExtension = string.Empty;
if (backgroundMaterial.filePath.Contains("?"))
{
fileExtension = backgroundMaterial.filePath.Substring(backgroundMaterial.filePath.LastIndexOf("."), backgroundMaterial.filePath.LastIndexOf("?") - backgroundMaterial.filePath.LastIndexOf(".")).ToLower();
}
else
{
fileExtension = backgroundMaterial.filePath.Substring(backgroundMaterial.filePath.LastIndexOf(".")).ToLower();
}
string url = outLinePath + "/Main/" + backgroundMaterial.fileHash + fileExtension;
if (File.Exists(url))
{
Image image = new Image();//新建图片对象
image.Source = new BitmapImage(new Uri(url));//读取图片
ImageBrush ib = new ImageBrush();//新建图片对象
ib.ImageSource = image.Source;//赋值为背景图片
canvas.Background = ib;//将图片对象赋值给Canvas的Background
}
}
else if (!string.IsNullOrEmpty(backgroundColor))
{
Color color = (Color)ColorConverter.ConvertFromString(backgroundColor);
canvas.Background = new SolidColorBrush(color);
}
int vlcCount = 0;
isStop = false;
foreach (var item in components)
{
if ((item.materials == null || item.materials.Count == 0) && (item.typeCode == "text" || item.typeCode == "image" || item.typeCode == "video"||item.typeCode== "audio" || item.typeCode == "html" || item.typeCode == "url"))
{
continue;
}
if (item.typeCode == "image")
{
Image image = new Image();
image.Width = item.width;
image.Height = item.height;
imageControls.Add(image);
canvas.Children.Add(image);
Canvas.SetLeft(image, item.offsetX);
Canvas.SetZIndex(image, item.zIndex);
Canvas.SetTop(image, item.offsetY);
image.Stretch = Stretch.Fill;
PlayImage(image, item.materials, item.config);
}
if (item.typeCode == "video")
{
vlcCount++;
if (vlcCount == 1)
{
vlcControl1.Width = item.width;
vlcControl1.Height = item.height;
Canvas.SetLeft(vlcControl1, item.offsetX);
Canvas.SetZIndex(vlcControl1, item.zIndex);
Canvas.SetTop(vlcControl1, item.offsetY);
PlayVideo(vlcControl1, item.materials, item.config, 1);
}
else
{
vlcControl2.Width = item.width;
vlcControl2.Height = item.height;
Canvas.SetLeft(vlcControl2, item.offsetX);
Canvas.SetZIndex(vlcControl2, item.zIndex);
Canvas.SetTop(vlcControl2, item.offsetY);
PlayVideo(vlcControl2, item.materials, item.config, 2);
}
}
if (item.typeCode == "text" && item.materials != null && item.materials.Count > 0)
{
var textBackgroundColor = item.config.Value<string>("backgroundColor");
var textBackgroundOpacity = item.config.Value<int?>("backgroundOpacity");
var textFontColor = item.config.Value<string>("fontColor");
var textFontSize = item.config.Value<string>("fontSize");
var textFontStyle = item.config.Value<string>("fontStyle");
var textAnimationSpeed = item.config.Value<string>("animationSpeed");
string fileExtension = string.Empty;
string url = string.Empty;
if (item.materials[0].fileUrl.Contains("?"))
{
fileExtension = item.materials[0].fileUrl.Substring(item.materials[0].fileUrl.LastIndexOf("."), item.materials[0].fileUrl.LastIndexOf("?") - item.materials[0].fileUrl.LastIndexOf(".")).ToLower();
}
else
{
fileExtension = item.materials[0].fileUrl.Substring(item.materials[0].fileUrl.LastIndexOf(".")).ToLower();
}
url = outLinePath + "/Main/" + item.materials[0].fileHash + fileExtension;
string textContent = DownLoadMethod.ReadContext(url);
textContent = textContent.Replace("\r\n", " ");
MarqueeControlNew marqueeControlNew = new MarqueeControlNew();
marqueeControlNew.Load(textContent, item.width, item.height, textFontSize, textBackgroundColor, textBackgroundOpacity, textFontColor, textFontStyle, textAnimationSpeed);
canvas.Children.Add(marqueeControlNew);
marqueeControlNews.Add(marqueeControlNew);
Canvas.SetLeft(marqueeControlNew, item.offsetX);
Canvas.SetZIndex(marqueeControlNew, item.zIndex);
Canvas.SetTop(marqueeControlNew, item.offsetY);
}
if (item.typeCode == "clock")
{
var backgroundColor = item.config.Value<string>("backgroundColor");
var fontColor = item.config.Value<string>("fontColor");
var style = item.config.Value<int?>("style");
ClockControl clock = new ClockControl();
clock.BindClock(style.Value, item.width, item.height, backgroundColor, fontColor);
canvas.Children.Add(clock);
clockControls.Add(clock);
Canvas.SetLeft(clock, item.offsetX);
Canvas.SetZIndex(clock, item.zIndex);
Canvas.SetTop(clock, item.offsetY);
}
if (item.typeCode == "weather")
{
var backgroundColor = item.config.Value<string>("backgroundColor");
var fontColor = item.config.Value<string>("fontColor");
var style = item.config.Value<int?>("style");
var city = item.config.Value<string>("cityName");
if (string.IsNullOrEmpty(city))
{
city = app.defaultCity;
}
if (!string.IsNullOrEmpty(city))
{
WeatherControl weather = new WeatherControl();
weather.LoadWeather(city, style.Value, item.width, item.height, backgroundColor, fontColor);
canvas.Children.Add(weather);
weatherControls.Add(weather);
Canvas.SetLeft(weather, item.offsetX);
Canvas.SetZIndex(weather, item.zIndex);
Canvas.SetTop(weather, item.offsetY);
}
}
if (item.typeCode == "audio" && item.materials != null && item.materials.Count > 0)
{
MediaPlayer media = new MediaPlayer();
string fileExtension = string.Empty;
string url = string.Empty;
if (item.materials[0].fileUrl.Contains("?"))
{
fileExtension = item.materials[0].fileUrl.Substring(item.materials[0].fileUrl.LastIndexOf("."), item.materials[0].fileUrl.LastIndexOf("?") - item.materials[0].fileUrl.LastIndexOf(".")).ToLower();
}
else
{
fileExtension = item.materials[0].fileUrl.Substring(item.materials[0].fileUrl.LastIndexOf(".")).ToLower();
}
url = outLinePath + "/Main/" + item.materials[0].fileHash + fileExtension;
media.Open(new Uri(url, UriKind.Relative));
media.MediaEnded += (sender, e) =>
{//播放结束后 又重新播放
media.Position = new TimeSpan(0);
};
media.Play();
mediaControls.Add(media);
}
if (item.typeCode == "html" && item.materials != null && item.materials.Count > 0)
{
string fileExtension = string.Empty;
string url = string.Empty;
if (item.materials[0].fileUrl.Contains("?"))
{
fileExtension = item.materials[0].fileUrl.Substring(item.materials[0].fileUrl.LastIndexOf("."), item.materials[0].fileUrl.LastIndexOf("?") - item.materials[0].fileUrl.LastIndexOf(".")).ToLower();
}
else
{
fileExtension = item.materials[0].fileUrl.Substring(item.materials[0].fileUrl.LastIndexOf(".")).ToLower();
}
url = outLinePath + "/Main/" + item.materials[0].fileHash + fileExtension;
ChromiumWebBrowser webBrowser = new ChromiumWebBrowser();
webBrowser.Width = item.width;
webBrowser.Height = item.height;
webBrowser.Address = url.Replace(@"/", @"\").Replace(@"\\",@"\") ;
//webBrowser.Address = "file:///D:/360MoveData/Users/jiaxl/Desktop/Websocket.html";
webBrowser.Background = Brushes.Black;
Canvas canvas1 = new Canvas();
canvas1.Width = item.width;
canvas1.Height = item.height;
canvas1.Background = Brushes.White;
canvas1.Children.Add(webBrowser);
//webBrowser.Load(url);
canvas.Children.Add(canvas1);
canvasWebBrowsers.Add(canvas1);
chromiumWebBrowsers.Add(webBrowser);
Canvas.SetLeft(canvas1, item.offsetX);
Canvas.SetZIndex(canvas1, item.zIndex);
Canvas.SetTop(canvas1, item.offsetY);
}
if (item.typeCode == "url" && item.materials != null && item.materials.Count > 0 && item.materials[0].mediaInfo != null && !string.IsNullOrEmpty(item.materials[0].mediaInfo.url))
{
ChromiumWebBrowser webBrowser = new ChromiumWebBrowser();
webBrowser.Width = item.width;
webBrowser.Height = item.height;
webBrowser.Address = item.materials[0].mediaInfo.url;
webBrowser.Background = Brushes.Black;
Canvas canvas1 = new Canvas();
canvas1.Width = item.width;
canvas1.Height = item.height;
canvas1.Background = Brushes.White;
canvas1.Children.Add(webBrowser);
//webBrowser.Load(url);
canvas.Children.Add(canvas1);
canvasWebBrowsers.Add(canvas1);
chromiumWebBrowsers.Add(webBrowser);
Canvas.SetLeft(canvas1, item.offsetX);
Canvas.SetZIndex(canvas1, item.zIndex);
Canvas.SetTop(canvas1, item.offsetY);
}
}
}
catch (Exception ex)
{
Class_Log _Log = new Class_Log();
_Log.WriteLogFile(ex.ToString());
}
}
//private void PlayImage(Image image, List<Material> materials, JObject config)
//{
// CancellationTokenSource source1 = new CancellationTokenSource();
// cancellationTokens.Add(source1);
// CancellationToken token = source1.Token;
// TaskFactory factory = new TaskFactory(token);
// Task tsk1 = factory.StartNew(() =>
// {
// var curPlayIndex = 0;
// var transitionPeriod = config.Value<int>("transitionPeriod");
// var transition = config.Value<string>("transition");
// string fileExtension = string.Empty;
// string url = string.Empty;
// DateTime? curDate = null;
// while (!isStop)
// {
// if (token.IsCancellationRequested)
// {
// //isStop = true;
// // 释放资源操作等等...
// break;
// }
// if (!curDate.HasValue||curDate.Value.AddMilliseconds(transitionPeriod * 1000) <= DateTime.Now)
// {
// if (materials[curPlayIndex].fileUrl.Contains("?"))
// {
// fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf("."), materials[curPlayIndex].fileUrl.LastIndexOf("?") - materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
// }
// else
// {
// fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
// }
// curDate = DateTime.Now;
// url = outLinePath + "/Main/" + materials[curPlayIndex].fileHash + fileExtension;
// BindImage(image, url, transition);
// curPlayIndex++;
// if (curPlayIndex >= materials.Count)
// {
// curPlayIndex = 0;
// }
// }
// else
// {
// Thread.Sleep(1);
// }
// }
// });
// //var thImage = new Thread(new ThreadStart(async () =>
// //{
// // var curPlayIndex = 0;
// // var transitionPeriod = config.Value<int>("transitionPeriod");
// // var transition = config.Value<string>("transition");
// // string fileExtension = string.Empty;
// // string url = string.Empty;
// // while (!isStop)
// // {
// // if (materials[curPlayIndex].fileUrl.Contains("?"))
// // {
// // fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf("."), materials[curPlayIndex].fileUrl.LastIndexOf("?") - materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
// // }
// // else
// // {
// // fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
// // }
// // url = outLinePath + "/Main/" + materials[curPlayIndex].fileHash + fileExtension;
// // BindImage(image, url, transition);
// // curPlayIndex++;
// // if (curPlayIndex >= materials.Count)
// // {
// // curPlayIndex = 0;
// // }
// // var taskProg = Task.Delay(transitionPeriod * 1000);
// // tasks.Add(taskProg);
// // await taskProg;
// // if (taskProg != null && taskProg.Status != TaskStatus.Canceled)
// // {
// // taskProg.Dispose();
// // tasks.Remove(taskProg);
// // }
// // }
// //}));
// //thImage.IsBackground = true;
// //thImage.Start();
//}
private void PlayImage(Image image, List<Material> materials, JObject config)
{
CancellationTokenSource source1 = new CancellationTokenSource();
cancellationTokens.Add(source1);
CancellationToken token = source1.Token;
TaskFactory factory = new TaskFactory(token);
Task tsk1 = factory.StartNew(async () =>
{
var curPlayIndex = 0;
var transitionPeriod = config.Value<int>("transitionPeriod");
var transition = config.Value<string>("transition");
string fileExtension = string.Empty;
string url = string.Empty;
DateTime? curDate = null;
while (!isStop)
{
if (token.IsCancellationRequested)
{
//isStop = true;
// 释放资源操作等等...
break;
}
//if (!curDate.HasValue || curDate.Value.AddMilliseconds(transitionPeriod * 1000) <= DateTime.Now)
//{
if (materials[curPlayIndex].fileUrl.Contains("?"))
{
fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf("."), materials[curPlayIndex].fileUrl.LastIndexOf("?") - materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
}
else
{
fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
}
curDate = DateTime.Now;
url = outLinePath + "/Main/" + materials[curPlayIndex].fileHash + fileExtension;
BindImage(image, url, transition);
curPlayIndex++;
if (curPlayIndex >= materials.Count)
{
curPlayIndex = 0;
}
if (token.IsCancellationRequested)
{
//isStop = true;
// 释放资源操作等等...
break;
}
else
{
await Task.Delay(transitionPeriod * 1000, token);
}
//}
//else
//{
// Thread.Sleep(1);
//}
}
});
}
private void BindImage(Image image, string img, string transition)
{
Action action = new Action(()=> {
image.Dispatcher.Invoke(new Action(() =>
{
if (img.ToLower().EndsWith(".gif"))
{
//FileStream stream = new FileStream(img, FileMode.Open, FileAccess.Read);
//XamlAnimatedGif.AnimationBehavior.SetSourceStream(image, stream);
//FileStream s = new FileStream(outLinePath + "/Main/" + ucList[app.currentIndex].sourceId + fileExtension, FileMode.Open, FileAccess.Read);
XamlAnimatedGif.AnimationBehavior.SetSourceUri(image, new Uri(img));
XamlAnimatedGif.AnimationBehavior.SetRepeatBehavior(image, RepeatBehavior.Forever);
XamlAnimatedGif.AnimationBehavior.SetAutoStart(image, true);
}
else
{
image.Source = new BitmapImage(new Uri(img));
}
}));
});
action.BeginInvoke(null,null);
}
private void PlayVideo(VlcControl vlcControl, List<Material> materials, JObject config,int type)
{
Action action = new Action(async delegate
{
try
{
Class_Log log = new Class_Log();
//if (th1 == null)
//{
CancellationTokenSource source1 = new CancellationTokenSource();
cancellationTokens.Add(source1);
CancellationToken token = source1.Token;
TaskFactory factory = new TaskFactory(token);
Task tsk1 = factory.StartNew(async () =>
{
var curPlayIndex = 0;
string fileExtension = string.Empty;
string url = string.Empty;
var curDate = DateTime.Now;
var duration = 0;
while (!isStop)
{
if (token.IsCancellationRequested)
{
//isStop = true;
// 释放资源操作等等...
break;
}
//log.WriteLogFile("-----curDate" + curDate.ToString("yyyy-MM-dd HH:mm:ss") + " url=" + url + " duration=" + duration);
//if (curDate.AddMilliseconds(duration) <= DateTime.Now)
//{
if (materials[curPlayIndex].fileUrl.Contains("?"))
{
fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf("."), materials[curPlayIndex].fileUrl.LastIndexOf("?") - materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
}
else
{
fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
}
url = outLinePath + "/Main/" + materials[curPlayIndex].fileHash + fileExtension;
duration = materials[curPlayIndex].duration;
//log.WriteLogFile("curDate" + curDate.ToString("yyyy-MM-dd HH:mm:ss") + " url=" + url + " duration=" + duration);
curDate = DateTime.Now;
if (type == 1)
{
vlcVideoPath = url;
}
else
{
vlcVideo2Path = url;
}
StopVideo(vlcControl);
StartVideo(vlcControl, url);
curPlayIndex++;
if (curPlayIndex >= materials.Count)
{
curPlayIndex = 0;
}
//var taskProg = Task.Delay(duration);
//tasks.Add(taskProg);
//await taskProg;
//if (taskProg != null && taskProg.Status != TaskStatus.Canceled)
//{
// taskProg.Dispose();
// tasks.Remove(taskProg);
//}
if (token.IsCancellationRequested)
{
//isStop = true;
// 释放资源操作等等...
break;
}
else
{
await Task.Delay(duration, token);
}
//}
//else
//{
// Thread.Sleep(1);
//}
//Thread.Sleep(duration);
}
});
//var thVideo = new Thread(new ThreadStart(async () =>
// {
// var curPlayIndex = 0;
// string fileExtension = string.Empty;
// string url = string.Empty;
// while (!isStop)
// {
// if (materials[curPlayIndex].fileUrl.Contains("?"))
// {
// fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf("."), materials[curPlayIndex].fileUrl.LastIndexOf("?") - materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
// }
// else
// {
// fileExtension = materials[curPlayIndex].fileUrl.Substring(materials[curPlayIndex].fileUrl.LastIndexOf(".")).ToLower();
// }
// url = outLinePath + "/Main/" + materials[curPlayIndex].fileHash + fileExtension;
// int duration = materials[curPlayIndex].duration;
// StartVideo(vlcControl, url);
// curPlayIndex++;
// if (curPlayIndex >= materials.Count)
// {
// curPlayIndex = 0;
// }
// var taskProg = Task.Delay(duration);
// tasks.Add(taskProg);
// await taskProg;
// if (taskProg != null && taskProg.Status != TaskStatus.Canceled)
// {
// taskProg.Dispose();
// tasks.Remove(taskProg);
// }
// //Thread.Sleep(duration);
// }
// }));
//thVideo.IsBackground = true;
//thVideo.Start();
//}
}
catch (Exception ex)
{
Class_Log log = new Class_Log();
log.WriteLogFile(ex.ToString(), "WindowViewErrorlog");
}
});
action.BeginInvoke(null, null);
}
private void StartVideo(VlcControl vlcControl, string videoPath)
{
try
{
vlcControl.SourceProvider.MediaPlayer.Play(new Uri(videoPath));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void StopVideo(VlcControl vlcControl)
{
try
{
if (vlcControl.SourceProvider.MediaPlayer.IsPlaying())
{
vlcControl.SourceProvider.MediaPlayer.Pause();
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
private async void UserControl_Loaded(object sender, RoutedEventArgs e)
{
}
public void Dispose()
{
try
{
vlcControl1.Width = 0;
vlcControl1.Height = 0;
vlcControl2.Width = 0;
vlcControl2.Height = 0;
isStop = true;
foreach (var item in tasks)
{
if (item != null && (item.IsCanceled || item.IsCompleted || item.IsFaulted))
{
item.Dispose();
}
}
tasks.Clear();
foreach (var item in marqueeControlNews)
{
item.Dispose();
canvas.Children.Remove(item);
}
marqueeControlNews.Clear();
foreach (var item in clockControls)
{
item.Dispose();
canvas.Children.Remove(item);
}
clockControls.Clear();
foreach (var item in weatherControls)
{
item.Dispose();
canvas.Children.Remove(item);
}
weatherControls.Clear();
foreach (var item in cancellationTokens)
{
item.Cancel();
}
cancellationTokens.Clear();
foreach (var item in imageControls)
{
canvas.Children.Remove(item);
}
imageControls.Clear();
foreach (var item in mediaControls)
{
item.Stop();
item.Close();
}
mediaControls.Clear();
foreach (var item in chromiumWebBrowsers)
{
item.Dispose();
canvas.Children.Remove(item);
}
chromiumWebBrowsers.Clear();
foreach (var item in canvasWebBrowsers)
{
canvas.Children.Remove(item);
}
canvasWebBrowsers.Clear();
StopVideo(vlcControl1);
StopVideo(vlcControl2);
}
catch (Exception e)
{
Class_Log _Log = new Class_Log();
_Log.WriteLogFile(e.ToString(), "prog");
}
}
}
}