diff --git a/zstio-tv/Config.cs b/zstio-tv/Config.cs
index 4bfc2c6..2d35c77 100644
--- a/zstio-tv/Config.cs
+++ b/zstio-tv/Config.cs
@@ -4,7 +4,8 @@ internal class Config
{
#region Application
public static string Version = "0.24";
- public static bool Developer = false;
+ public static bool Developer = true;
+ public static string[] ImageExtensions = { ".png", ".jpg", ".jpeg" };
public static string Warning = "Przypominamy, że obowiązuje całkowity zakaz opuszczania terenu szkoły podczas zajęć i przerw międzylekcyjnych.";
#endregion
diff --git a/zstio-tv/Display/MediaWindow.xaml b/zstio-tv/Display/MediaWindow.xaml
index c657f40..a18b3e8 100644
--- a/zstio-tv/Display/MediaWindow.xaml
+++ b/zstio-tv/Display/MediaWindow.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:zstio_tv"
mc:Ignorable="d"
- Title="ConfigWindow" Loaded="Window_Loaded" Height="270" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" Background="#FF101010">
+ Title="MediaWindow" Loaded="WindowLoaded" Height="600" Width="500" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" Background="#FF101010">
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/zstio-tv/Display/MediaWindow.xaml.cs b/zstio-tv/Display/MediaWindow.xaml.cs
index cf9a96a..7ad8d7e 100644
--- a/zstio-tv/Display/MediaWindow.xaml.cs
+++ b/zstio-tv/Display/MediaWindow.xaml.cs
@@ -1,11 +1,11 @@
using System;
+using System.Data;
+using System.IO;
+using System.Linq;
using System.Windows;
-using System.Drawing;
+using System.Windows.Forms;
using System.Windows.Media.Imaging;
-using System.IO;
-using System.Windows.Media;
-using System.Runtime.InteropServices;
-using System.Windows.Interop;
+using System.Windows.Threading;
namespace zstio_tv
{
@@ -16,40 +16,63 @@ public MediaWindow()
InitializeComponent();
}
- private const int GWL_STYLE = -16;
- private const int WS_SYSMENU = 0x80000;
- [DllImport("user32.dll", SetLastError = true)]
- private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
- [DllImport("user32.dll")]
- private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
+ int SlideBackup = 0;
+
+ DispatcherTimer BannerTimer = new DispatcherTimer();
+ DispatcherTimer SlideTimer = new DispatcherTimer();
+ private void WindowLoaded(object sender, RoutedEventArgs e)
+ {
+ SlideBackup = MainWindow.Pages;
+
+ BannerTimer.Interval = TimeSpan.FromSeconds((int)bannerslider.Value);
+ BannerTimer.Tick += BannerTimer_Tick;
+
+ SlideTimer.Interval = TimeSpan.FromSeconds((int)slideslider.Value);
+ SlideTimer.Tick += SlideTimer_Tick;
+ }
- private void Rectangle_Drop(object sender, DragEventArgs e)
+ int BannerSlide = 0;
+ private void BannerTimer_Tick(object sender, EventArgs e)
{
+ BannerSlide++;
+ if (BannerSlide == BannerFileCount)
+ {
+ BannerSlide = 0;
+ }
try
{
- var DropData = e.Data.GetData(DataFormats.FileDrop);
- if (DropData != null)
- {
- var DropDataFilenames = DropData as string[];
- if (DropDataFilenames.Length > 0)
- {
- Image image = Image.FromFile(DropDataFilenames[0]);
+ string ImagePath = Path.Combine(BannerDirectory, BannerFiles[BannerSlide]);
- using (MemoryStream stream = new MemoryStream())
- {
- image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
- stream.Seek(0, SeekOrigin.Begin);
+ BitmapImage bitmapImage = new BitmapImage();
+ bitmapImage.BeginInit();
+ bitmapImage.UriSource = new Uri(ImagePath, UriKind.RelativeOrAbsolute);
+ bitmapImage.EndInit();
- BitmapImage bitmapImage = new BitmapImage();
- bitmapImage.BeginInit();
- bitmapImage.StreamSource = stream;
- bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
- bitmapImage.EndInit();
+ MainWindow._Instance.handler_bar_banner_panel_image.ImageSource = bitmapImage;
+ } catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
+ }
- previewsource.ImageSource = bitmapImage;
- }
- }
- }
+ int SlideSlide = 0;
+ private void SlideTimer_Tick(object sender, EventArgs e)
+ {
+ SlideSlide++;
+ if (SlideSlide == SlideFileCount)
+ {
+ SlideSlide = 0;
+ }
+ try
+ {
+ string ImagePath = Path.Combine(SlideDirectory, SlideFiles[SlideSlide]);
+
+ BitmapImage bitmapImage = new BitmapImage();
+ bitmapImage.BeginInit();
+ bitmapImage.UriSource = new Uri(ImagePath, UriKind.RelativeOrAbsolute);
+ bitmapImage.EndInit();
+
+ MainWindow._Instance.customslideimages_image.ImageSource = bitmapImage;
}
catch (Exception ex)
{
@@ -57,32 +80,115 @@ private void Rectangle_Drop(object sender, DragEventArgs e)
}
}
- ImageSource NoImage;
- private void Window_Loaded(object sender, RoutedEventArgs e)
+ private void slidevisibility_Click(object sender, RoutedEventArgs e)
{
- var hwnd = new WindowInteropHelper(this).Handle;
- SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
+ if (slidevisibility.IsChecked == true)
+ {
+ MainWindow.Pages = SlideBackup + 1;
+ SlideTimer.Interval = TimeSpan.FromSeconds((int)slideslider.Value);
+ SlideTimer.Start();
+ } else
+ {
+ MainWindow.Pages = SlideBackup;
+ SlideTimer.Interval = TimeSpan.FromSeconds((int)slideslider.Value);
+ SlideTimer.Stop();
+ }
+ }
- NoImage = previewsource.ImageSource;
+ private void bannervisibility_Click(object sender, RoutedEventArgs e)
+ {
+ if (bannervisibility.IsChecked == true)
+ {
+ MainWindow._Instance.handler_bar_banner.Visibility = Visibility.Visible;
+ BannerTimer.Interval = TimeSpan.FromSeconds((int)bannerslider.Value);
+ BannerTimer.Start();
+ } else
+ {
+ MainWindow._Instance.handler_bar_banner.Visibility = Visibility.Collapsed;
+ BannerTimer.Interval = TimeSpan.FromSeconds((int)bannerslider.Value);
+ BannerTimer.Stop();
+ }
+ }
+
+ int BannerFileCount = 0; string BannerDirectory; string[] BannerFiles;
+ private void BannerSelectFolderClick(object sender, RoutedEventArgs e)
+ {
+ using (var FolderDialog = new FolderBrowserDialog())
+ {
+ DialogResult DialogResult = FolderDialog.ShowDialog();
+
+ if (DialogResult == DialogResult.OK && !string.IsNullOrWhiteSpace(FolderDialog.SelectedPath))
+ {
+ BannerDirectory = FolderDialog.SelectedPath;
+
+ BannerFiles = Directory.GetFiles(FolderDialog.SelectedPath)
+ .Where(file => Config.ImageExtensions.Contains(Path.GetExtension(file), StringComparer.OrdinalIgnoreCase))
+ .ToArray();
+
+ DataTable FilesDataTable = new DataTable();
+ FilesDataTable.Columns.Add("FileCount", typeof(int));
+ FilesDataTable.Columns.Add("FileName", typeof(string));
+
+ foreach (string FileName in BannerFiles)
+ {
+ BannerFileCount++;
+ DataRow FilesRow = FilesDataTable.NewRow();
+ FilesRow["FileCount"] = BannerFileCount;
+ FilesRow["FileName"] = Path.GetFileName(FileName);
+ FilesDataTable.Rows.Add(FilesRow);
+ bannerdata.ItemsSource = FilesDataTable.DefaultView;
+ }
+ }
+ }
}
- private void ApplyButton(object sender, RoutedEventArgs e)
+ int SlideFileCount = 0; string SlideDirectory; string[] SlideFiles;
+ private void SlideSelectFolderClick(object sender, RoutedEventArgs e)
{
- if (previewsource.ImageSource == NoImage)
+ using (var FolderDialog = new FolderBrowserDialog())
{
- MessageBox.Show("Prosze wrzucic obrazek.");
- return;
+ DialogResult DialogResult = FolderDialog.ShowDialog();
+
+ if (DialogResult == DialogResult.OK && !string.IsNullOrWhiteSpace(FolderDialog.SelectedPath))
+ {
+ SlideDirectory = FolderDialog.SelectedPath;
+
+ SlideFiles = Directory.GetFiles(FolderDialog.SelectedPath)
+ .Where(file => Config.ImageExtensions.Contains(Path.GetExtension(file), StringComparer.OrdinalIgnoreCase))
+ .ToArray();
+
+ DataTable FilesDataTable = new DataTable();
+ FilesDataTable.Columns.Add("FileCount", typeof(int));
+ FilesDataTable.Columns.Add("FileName", typeof(string));
+
+ foreach (string FileName in SlideFiles)
+ {
+ SlideFileCount++;
+ DataRow FilesRow = FilesDataTable.NewRow();
+ FilesRow["FileCount"] = SlideFileCount;
+ FilesRow["FileName"] = Path.GetFileName(FileName);
+ FilesDataTable.Rows.Add(FilesRow);
+ slidedata.ItemsSource = FilesDataTable.DefaultView;
+ }
+ }
}
+ }
- MainWindow._Instance.handler_bar_banner_panel_image.ImageSource = previewsource.ImageSource;
- MainWindow._Instance.handler_bar_banner.Visibility = Visibility.Visible;
- this.Hide();
+ private void BannerSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (bannerslider != null && bannerslidertext != null)
+ bannerslidertext.Content = $"{(int)bannerslider.Value}s";
+ }
+ private void SlideSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (slideslider != null && slideslidertext != null)
+ slideslidertext.Content = $"{(int)slideslider.Value}s";
}
- private void HideButton(object sender, RoutedEventArgs e)
+ private void Apply(object sender, RoutedEventArgs e)
{
- this.Hide();
- MainWindow._Instance.handler_bar_banner.Visibility = Visibility.Collapsed;
+ BannerTimer.Interval = TimeSpan.FromSeconds((int)bannerslider.Value);
+ SlideTimer.Interval = TimeSpan.FromSeconds((int)slideslider.Value);
}
}
}
diff --git a/zstio-tv/Helpers/ILesson.cs b/zstio-tv/Helpers/ILesson.cs
index a9fec16..c44f4d5 100644
--- a/zstio-tv/Helpers/ILesson.cs
+++ b/zstio-tv/Helpers/ILesson.cs
@@ -46,8 +46,10 @@ public static string[] GetLessons()
}
}
+ int TemponaryState = 0;
if (NextLessonOrBreakStartTime == DateTime.MaxValue)
{
+ TemponaryState = 1;
return new string[] { "Brak lekcji na dziś", "" };
}
@@ -55,9 +57,14 @@ public static string[] GetLessons()
if (TimeToNextLessonOrBreak.TotalMinutes <= 0)
{
+ TemponaryState = 0;
return new string[] { "Przerwa", "00:00:00" };
}
+ // replace the api after lessons
+ if (TemponaryState == 1)
+ MainWindow.ReplacementsGETAPI_Tick(null, null);
+
return new string[] { "Przerwa", $"{TimeToNextLessonOrBreak.ToString(@"hh\:mm\:ss")}" };
}
}
diff --git a/zstio-tv/MainWindow.xaml b/zstio-tv/MainWindow.xaml
index 7ce73ac..206cf7f 100644
--- a/zstio-tv/MainWindow.xaml
+++ b/zstio-tv/MainWindow.xaml
@@ -159,11 +159,12 @@
+
+
@@ -189,9 +190,9 @@
-
+ -->
-
+
@@ -240,7 +241,11 @@
-
+
+
+
+
+
@@ -283,6 +288,9 @@
+
+
+
diff --git a/zstio-tv/MainWindow.xaml.cs b/zstio-tv/MainWindow.xaml.cs
index acbcb16..b3b0e27 100644
--- a/zstio-tv/MainWindow.xaml.cs
+++ b/zstio-tv/MainWindow.xaml.cs
@@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
-using System.Net.NetworkInformation;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Animation;
@@ -25,24 +24,6 @@ public MainWindow()
_Instance = this;
}
- public static bool CheckForInternetConnection(int timeoutMs = 10000, string url = null)
- {
- try
- {
- Ping myPing = new Ping();
- String host = "google.com";
- byte[] buffer = new byte[32];
- int timeout = 1000;
- PingOptions pingOptions = new PingOptions();
- PingReply reply = myPing.Send(host, timeout, buffer, pingOptions);
- return (reply.Status == IPStatus.Success);
- }
- catch (Exception)
- {
- return false;
- }
- }
-
private void WindowLoaded(object sender, RoutedEventArgs e)
{
string ServerVersion = IVersion.GetVersion(); if (ServerVersion == Config.Version)
@@ -103,10 +84,6 @@ private void WindowLoaded(object sender, RoutedEventArgs e)
TabTimer.Interval = TimeSpan.FromSeconds(1);
TabTimer.Tick += TabTimerTick;
TabTimer.Start();
- DispatcherTimer ReplacementsGETAPI = new DispatcherTimer();
- ReplacementsGETAPI.Interval = TimeSpan.FromHours(16);
- ReplacementsGETAPI.Tick += ReplacementsGETAPI_Tick;
- ReplacementsGETAPI.Start();
DispatcherTimer ReplacementsCALC = new DispatcherTimer();
ReplacementsCALC.Interval = TimeSpan.FromSeconds(10);
ReplacementsCALC.Tick += ReplacementsCALC_Tick;
@@ -265,9 +242,14 @@ public static void ReplacementsGETAPI_Tick(object sender, EventArgs e)
}
}
- int PageTime = 0; int PageIndex = 0; public static int PageLength = 30;
+ int PageTime = 0; int PageIndex = 0; public static int PageLength = 30, Pages = 2;
private void TabTimerTick(object sender, EventArgs e)
{
+ for (int i = 0; i < handler_content_description_pages_display.Children.Count; i++)
+ {
+ ((Ellipse)handler_content_description_pages_display.Children[i]).Visibility = (i < Pages) ? Visibility.Visible : Visibility.Collapsed;
+ }
+
if (!LocalMemory.SongPlaying)
{
handler_spotifyqr_title.Text = "Ostatnio grane";
@@ -285,7 +267,7 @@ private void TabTimerTick(object sender, EventArgs e)
if (PageTime == PageLength)
{
PageIndex++;
- if (PageIndex == 2)
+ if (PageIndex == Pages)
{
PageIndex = 0;
}