51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
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.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using libplaza;
|
|
|
|
namespace WinPlaza {
|
|
public partial class MainWindow : Window {
|
|
string LastArtwork="";
|
|
Nightwave plaza=new Nightwave();
|
|
System.Timers.Timer tRefresh;
|
|
public MainWindow() {
|
|
InitializeComponent();
|
|
tRefresh = new System.Timers.Timer(500) { AutoReset = true };
|
|
tRefresh.Elapsed += evtRefresh;
|
|
tRefresh.Start();
|
|
}
|
|
|
|
private void evtRefresh(object sender, System.Timers.ElapsedEventArgs e) =>
|
|
_ = Dispatcher.BeginInvoke(new dgtInvokeRefresh(dgtRefresh));
|
|
private delegate void dgtInvokeRefresh();
|
|
private async void dgtRefresh() {
|
|
Nightwave.Status s=await plaza.Broadcast();
|
|
lbArtist.Content = s.Artist;
|
|
lbTitle.Content = s.Title;
|
|
lbAlbum.Content = s.Album;
|
|
slDuration.Maximum = s.Duration;
|
|
slDuration.Value = s.CalculatedElapsed;
|
|
sbListeners.Text = $"{s.Listeners} listeners";
|
|
lbLikeCt.Content = s.Likes;
|
|
lbDislikeCt.Content = s.Dislikes;
|
|
lbElapsed.Content = $"{(s.CalculatedElapsed / 60).ToString("D")}:{(s.CalculatedElapsed % 60).ToString("D2")}";
|
|
lbTime.Content = $"{(s.Duration / 60).ToString("D")}:{(s.Duration % 60).ToString("D2")}";
|
|
if(LastArtwork != s.ArtworkUri) {
|
|
art.Source = new BitmapImage(new Uri(s.ArtworkUri));
|
|
LastArtwork = s.ArtworkUri;
|
|
}
|
|
}
|
|
}
|
|
}
|