Skip to content

Commit

Permalink
spotify qr code
Browse files Browse the repository at this point in the history
  • Loading branch information
meetox80 committed Oct 2, 2023
1 parent 3d667eb commit 93a7ffc
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 23 deletions.
2 changes: 1 addition & 1 deletion zstio-tv/Helpers/IDateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static string CalculateClock()

public static string CalculateDate()
{
string Day = DateTime.Now.ToString("dd");
string Day = DateTime.Now.ToString("%d");
string ProcessMonth = DateTime.Now.ToString("MM");
string ProcessWeekDay = DateTime.Now.DayOfWeek.ToString();

Expand Down
5 changes: 5 additions & 0 deletions zstio-tv/Helpers/IReplacements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public static void PlaceElement(string LessonNumber, string branch, string teach
TeacherSpacingRectangle.Width = SpacingWidth;
TeacherSpacingRectangle.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF202020"));
HandlerPanel.Children.Add(TeacherSpacingRectangle);
if (TeacherTextBlock.Text.Length > 23)
{
double TempSize = (TeacherTextBlock.Text.Length - 23) * 0.25;
TeacherTextBlock.FontSize = TeacherTextBlock.FontSize - TempSize;
}

Grid ReplacementGrid = new Grid();
ReplacementGrid.Width = 300 - SpacingWidth;
Expand Down
58 changes: 45 additions & 13 deletions zstio-tv/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@
</Path.Effect>
</Path>

<TextBlock x:Name="handler_bar_weatherwidget_header_title" VerticalAlignment="Top" TextAlignment="Center" Text="XXXXXXXXXX" Foreground="White" FontFamily="/Font/InterBold/#Inter" Margin="0,-1,0,0" FontSize="15" Height="15" Width="200"/>
<TextBlock Margin="0,-4,0,0" x:Name="handler_bar_weatherwidget_header_title" VerticalAlignment="Top" HorizontalAlignment="Center" TextAlignment="Center" Text="XXXXXXXXXX" Foreground="White" FontFamily="/Font/InterBold/#Inter" FontSize="20" Height="20" Width="200"/>
</StackPanel>
</Grid>

<Grid x:Name="handler_bar_happynumberwidget" Height="50" Width="250" Margin="0,15,0,0">
<Grid Visibility="Collapsed" x:Name="handler_bar_happynumberwidget" Height="50" Width="250" Margin="0,15,0,0">
<Rectangle RadiusX="10" RadiusY="10" Fill="#FF0A0505" Stroke="#FF272727">
<Rectangle.Effect>
<DropShadowEffect ShadowDepth="0" Direction="0" BlurRadius="15"/>
</Rectangle.Effect>
</Rectangle>

<StackPanel x:Name="handler_bar_happynumberwidget_header" Orientation="Horizontal" Margin="20,16,0,0">
<TextBlock Opacity="0.75" x:Name="handler_bar_happynumberwidget_header_title" VerticalAlignment="Top" TextAlignment="Center" Text="Szczesliwy numerek:" Foreground="White" FontFamily="/Font/InterBold/#Inter" Margin="0,-1,0,0" FontSize="15" Height="15"/>
<TextBlock x:Name="handler_bar_happynumberwidget_header_content" VerticalAlignment="Top" TextAlignment="Center" Text="0" Foreground="White" FontFamily="/Font/InterBold/#Inter" Margin="0,-5,0,0" Width="75" FontSize="25" Height="30"/>
<StackPanel x:Name="handler_bar_happynumberwidget_header" Orientation="Horizontal" Margin="20,0,0,0">
<TextBlock Opacity="0.75" x:Name="handler_bar_happynumberwidget_header_title" VerticalAlignment="Center" TextAlignment="Center" Text="Szczęśliwy numerek:" Foreground="White" FontFamily="/Font/InterBold/#Inter" Margin="0,1,0,0" FontSize="15" Height="20"/>
<TextBlock x:Name="handler_bar_happynumberwidget_header_content" TextAlignment="Center" Text="0" Foreground="White" FontFamily="/Font/InterBold/#Inter" Margin="0,-1,0,0" Width="75" FontSize="25" Height="30"/>
</StackPanel>
</Grid>
</StackPanel>
Expand Down Expand Up @@ -140,6 +140,7 @@
// Field example, to see in designer; uncomment and remove this.
// Made to port into raw c# from xaml
<Grid VerticalAlignment="Top" Margin="0,10,0,0">
<Rectangle Height="45" Width="1000" Fill="#FF0E0B0B" RadiusX="5" RadiusY="5"/>
<StackPanel Orientation="Horizontal">
Expand All @@ -152,7 +153,7 @@
</Grid>
<Rectangle Width="2" Fill="#FF202020"/>
<Grid Width="298">
<TextBlock Text="John Doe" Foreground="White" FontFamily="/Font/InterBold/#Inter" FontSize="16" TextAlignment="Center" VerticalAlignment="Center" Width="300"/>
<TextBlock Text="John Doeihdaf hids shfhdsfudsfhadf uuidf id" Margin="0,0,0,0" Foreground="White" FontFamily="/Font/InterBold/#Inter" FontSize="16" TextAlignment="Center" VerticalAlignment="Center" Width="300"/>
</Grid>
<Rectangle Width="2" Fill="#FF202020"/>
<Grid Width="298">
Expand All @@ -172,7 +173,42 @@

<TabItem Header="TabItem" Foreground="{x:Null}" BorderBrush="{x:Null}" Background="{x:Null}" Visibility="Collapsed">
<Grid>
<Label Content="tab2" Foreground="White"/>
<Grid x:Name="handler_spotifyqr" VerticalAlignment="Center" HorizontalAlignment="Center" Height="500" Width="375" Margin="0,0,0,75">
<TextBlock x:Name="handler_spotifyqr_title" Text="Aktualnie gramy" FontFamily="/Font/InterBold/#Inter" Foreground="White" TextAlignment="Center" FontSize="40"/>

<Grid Height="425" Margin="0,75,0,0">
<Rectangle RadiusX="20" RadiusY="20" Fill="#FF0D0A0A"/>

<Grid Height="325" Width="325" Margin="0,25,0,0" VerticalAlignment="Top">
<Rectangle RadiusX="10" RadiusY="10" Width="324" Height="324">
<Rectangle.Fill>
<ImageBrush x:Name="handler_spotifyqr_background" ImageSource="https://i.imgur.com/UsGvzra.png"/>
</Rectangle.Fill>
</Rectangle>

<Rectangle Height="200" Margin="0,0,0,50" VerticalAlignment="Bottom">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#00000000"/>
<GradientStop Color="Black" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>

<Rectangle RadiusX="10" RadiusY="10" Height="80" Width="325" VerticalAlignment="Bottom">
<Rectangle.Fill>
<ImageBrush x:Name="handler_spotifyqr_code" ImageSource="https://scannables.scdn.co/uri/plain/png/000000/white/640/spotify:playlist:56Ljg19fTjjP1cgO2WFtAT"/>
</Rectangle.Fill>
</Rectangle>
</Grid>

<Grid VerticalAlignment="Bottom" Margin="0,0,0,10">
<Rectangle Height="55" Width="250" RadiusX="10" RadiusY="10" Fill="#FF161111" Stroke="#FF221B1B"/>

<TextBlock FontFamily="/Font/InterBold/#Inter" Foreground="White" Text="Zeskanuj kod Spotify" FontSize="20" TextAlignment="Center" Margin="0,14,0,0"/>
</Grid>
</Grid>
</Grid>
</Grid>
</TabItem>

Expand All @@ -195,7 +231,7 @@
</TabItem>
</TabControl>

<Label x:Name="loadingmodules" FontSize="20" Foreground="White" FontFamily="/Font/InterBold/#Inter" Content="Ladowanie modułow, proszę czekać." HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Label Visibility="Collapsed" x:Name="loadingmodules" FontSize="20" Foreground="White" FontFamily="/Font/InterBold/#Inter" Content="Ladowanie modułow, proszę czekać." HorizontalAlignment="Center" VerticalAlignment="Center"/>

<Rectangle>
<!-- Fading Overlay -->
Expand Down Expand Up @@ -228,11 +264,7 @@
</Grid>

<Grid Height="5" VerticalAlignment="Bottom">
<Rectangle x:Name="handler_content_tabchangeprogress" Width="5" Fill="#FFCC4E4E" HorizontalAlignment="Left" RadiusX="2.5" RadiusY="2.5">
<Rectangle.Effect>
<DropShadowEffect Color="#FFCC4E4E" ShadowDepth="0" Direction="0" BlurRadius="20"/>
</Rectangle.Effect>
</Rectangle>
<Rectangle x:Name="handler_content_tabchangeprogress" Width="5" Fill="#FFCC4E4E" HorizontalAlignment="Left" RadiusX="2.5" RadiusY="2.5"/>
</Grid>
</Grid>

Expand Down
27 changes: 19 additions & 8 deletions zstio-tv/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Animation;
Expand Down Expand Up @@ -37,7 +35,6 @@ private void WindowLoaded(object sender, RoutedEventArgs e)
ConfigWindow ConfigWindow_Manager = new ConfigWindow();
ConfigWindow_Manager.Show();


Process[] processes = Process.GetProcessesByName("node");
foreach (Process process in processes)
{
Expand Down Expand Up @@ -107,14 +104,14 @@ private void WindowLoaded(object sender, RoutedEventArgs e)
private void GetWeatherTick(object sender, EventArgs e)
{
LocalMemory.WeatherAPIResponse = IWeather.GetWeatherData();

if (LocalMemory.WeatherAPIResponse != null || LocalMemory.WeatherAPIResponse != "")
Console.WriteLine(LocalMemory.WeatherAPIResponse);
if (LocalMemory.WeatherAPIResponse != null && LocalMemory.WeatherAPIResponse != "" && LocalMemory.WeatherAPIResponse != "{}")
{
JObject WeatherData = JObject.Parse(LocalMemory.WeatherAPIResponse);

if (WeatherData["current"] != null)
if (WeatherData["current"] != null && WeatherData["current"].ToString() != "")
{
handler_bar_weatherwidget_header_title.Text = $"{Config.WeatherCity} - {WeatherData["current"]["temp_c"].ToString()}°C";
handler_bar_weatherwidget_header_title.Text = $"{Config.WeatherCity}: {WeatherData["current"]["temp_c"].ToString()}°C";
}
}
}
Expand Down Expand Up @@ -157,6 +154,12 @@ private void SpotifyCurrentPlaying_Tick(object sender, EventArgs e)
handler_bar_zstiofm_image.Source = SongImageBitmap;

LocalMemory.SongPlaying = true;

// SpotifyQR Integration
string SpotifyQR = $"https://scannables.scdn.co/uri/plain/png/000000/white/640/{SongResponse["item"]["uri"].ToString()}";
BitmapImage SpotifyQR_Bitmap = new BitmapImage(new Uri(SpotifyQR));
handler_spotifyqr_code.ImageSource = SpotifyQR_Bitmap;
handler_spotifyqr_background.ImageSource = SongImageBitmap;
}
}

Expand Down Expand Up @@ -234,6 +237,14 @@ public static void ReplacementsGETAPI_Tick(object sender, EventArgs e)
int PageTime = 0; int PageIndex = 0; public static int PageLength = 30;
private void TabTimerTick(object sender, EventArgs e)
{
if (!LocalMemory.SongPlaying)
{
handler_spotifyqr_title.Text = "Ostatnio grane";
} else
{
handler_spotifyqr_title.Text = "Aktualnie gramy";
}

if (PageTime == 1)
TabTransition(0, 1);

Expand All @@ -243,7 +254,7 @@ private void TabTimerTick(object sender, EventArgs e)
if (PageTime == PageLength)
{
PageIndex++;
if (PageIndex == 4)
if (PageIndex == 2)
{
PageIndex = 0;
}
Expand Down
1 change: 0 additions & 1 deletion zstio-tv/Modules/Module_HappyNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Windows;
using System.Windows.Threading;

namespace zstio_tv.Modules
Expand Down
1 change: 1 addition & 0 deletions zstio-tv/ModulesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static void ExecuteModules(string[] Modules)
// Forward for selected modules
if (string.Join(",", GetModules()).Contains("happynumber"))
{
MainWindow._Instance.handler_bar_happynumberwidget.Visibility = Visibility.Visible;
Module_HappyNumber.RegisterModule(AddressInfo);
}
}
Expand Down

0 comments on commit 93a7ffc

Please sign in to comment.