-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
667 lines (629 loc) · 30.3 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
using Microsoft.Win32;
using System.ComponentModel;
using System.IO;
using System.Text;
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 System.CodeDom.Compiler;
using System.Configuration.Internal;
using Microsoft.Extensions.Configuration;
using System.Runtime.InteropServices;
using System.Windows.Controls.Primitives;
using System.Text.RegularExpressions;
using SngParser;
using System.Drawing;
using System.Windows.Interop;
using System.Drawing.Imaging;
using System.IO.Pipes;
using System.Drawing.Drawing2D;
using Microsoft.VisualBasic;
using SysConfig = System.Configuration;
using System.Collections.Specialized;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using System.Reflection;
namespace FGH3ChartBrowser
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public string scanFolder;
public List<SongEntry> songList;
public int totalSongs;
public int scannedSongs;
public int scanProgress;
public int scanErrors;
public BackgroundWorker ScanBgWorker;
public BackgroundWorker AlbumLoadBgWorker;
public string currentLoadingPhrase;
public SysConfig.Configuration config;
public BitmapSource bmpSrc;
public Bitmap bmp;
public MainWindow()
{
scanFolder = "";
songList = new List<SongEntry>() { };
InitializeComponent();
// TO DO: Figure out dark mode theme?
MainWin.Title += $" v{Assembly.GetExecutingAssembly().GetName().Version?.ToString(3)}";
ScanProgressBar.Value = 0;
RefreshSongInfo();
totalSongs = 0;
scannedSongs = 0;
scanErrors = 0;
SongsDataGrid.ItemsSource = songList;
ScanBgWorker = new BackgroundWorker();
ScanBgWorker.WorkerReportsProgress = true;
ScanBgWorker.DoWork += ScanSongs;
ScanBgWorker.ProgressChanged += UpdateScanProgress;
ScanBgWorker.RunWorkerCompleted += FinishedScanning;
AlbumLoadBgWorker = new BackgroundWorker(); // soon?
currentLoadingPhrase = "";
config = SysConfig.ConfigurationManager.OpenExeConfiguration(SysConfig.ConfigurationUserLevel.None);
bmpSrc = new BitmapImage();
bmp = new Bitmap(4,4);
LoadConfig();
}
private void RefreshSongInfo(SongEntry song)
{
LoadingPhraseTxt.Text = song.LoadingPhrase;
SongTitleTxt.Content = song.Title;
ArtistTxt.Text = song.Artist;
AlbumTxt.Text = "Album: " + song.Album;
GenreTxt.Text = "Genre: " + song.Genre;
string yearStr = "";
if (song.Year > 0) yearStr = int.Clamp(song.Year, 0, 99999).ToString();
YearTxt.Content = $"Year: {yearStr}";
CharterTxt.Text = $"Charter: {song.Charter}";
LeadDiffTxt.Content = $"Lead Intensity: {int.Clamp(song.IntensityLead, 0, 99)}";
BassDiffTxt.Content = $"Bass Intensity: {int.Clamp(song.IntensityBass, 0, 99)}";
if (song.IntensityLead > 99) LeadDiffTxt.Content += "+";
if (song.IntensityBass > 99) BassDiffTxt.Content += "+";
string starsLead = "";
string starsBass = "";
if (song.IntensityLead >= 0)
{
int i = 1;
for (i = 1; i <= 9; i++)
{
if (i <= song.IntensityLead) starsLead += "★";
else if (i <= 6) starsLead += "☆";
}
if (song.IntensityLead > 9) starsLead += "+";
}
if (song.IntensityBass >= 0)
{
int i = 1;
for (i = 1; i <= 9; i++)
{
if (i <= song.IntensityBass) starsBass += "★";
else if (i <= 6) starsBass += "☆";
}
if (song.IntensityBass > 9) starsBass += "+";
}
LeadStarsTxt.Content = starsLead;
BassStarsTxt.Content = starsBass;
}
private void RefreshSongInfo()
{
LoadingPhraseTxt.Text = "";
SongTitleTxt.Content = "";
ArtistTxt.Text = "";
AlbumTxt.Text = "Album: ";
GenreTxt.Text = "Genre: ";
YearTxt.Content = "Year: ";
CharterTxt.Text = "Charter: ";
LeadDiffTxt.Content = "Lead Intensity: ";
BassDiffTxt.Content = "Bass Intensity: ";
LeadStarsTxt.Content = "☆☆☆☆☆☆";
BassStarsTxt.Content = "☆☆☆☆☆☆";
}
private void LoadConfig()
{
FGH3_Path_TxtBox.Text = config.AppSettings.Settings["fastgh3_exe_location"].Value;
if (String.IsNullOrEmpty(FGH3_Path_TxtBox.Text))
{
FGH3_Path_TxtBox.Text = @"C:\Program Files (x86)\FastGH3\FastGH3.exe";
config.AppSettings.Settings["fastgh3_exe_location"].Value = @"C:\Program Files (x86)\FastGH3\FastGH3.exe";
config.Save();
}
if (!config.AppSettings.Settings.AllKeys.Contains("ui_theme"))
{
config.AppSettings.Settings.Add("ui_theme", "0");
}
int.TryParse(config.AppSettings.Settings["ui_theme"].Value, out int theme);
ThemeSwitcher.SelectedIndex = theme;
scanFolder = config.AppSettings.Settings["charts_folder"].Value;
Chart_Folder_TxtBox.Text = scanFolder;
config.Save();
}
private void GH3PathBrowseBtn_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog
{
DefaultExt = ".exe",
Filter = "The game (FastGH3.exe)|FastGH3.exe",
DefaultDirectory = "C:\\Program Files (x86)\\FastGH3"
};
Nullable<bool> result = dlg.ShowDialog();
if (result.HasValue && result.Value)
{
string filename = dlg.FileName;
FGH3_Path_TxtBox.Text = filename;
config.AppSettings.Settings["fastgh3_exe_location"].Value = filename;
config.Save();
}
}
private async void ScanSongs(object? sender, DoWorkEventArgs e)
{
string searchPath = scanFolder;
BackgroundWorker bw = sender as BackgroundWorker;
if (!String.IsNullOrWhiteSpace(searchPath) && System.IO.Path.Exists(searchPath))
{
IEnumerable<string> charts = Directory.EnumerateFiles(searchPath, "notes.chart", SearchOption.AllDirectories);
IEnumerable<string> midis = Directory.EnumerateFiles(searchPath, "notes.mid", SearchOption.AllDirectories);
IEnumerable<string> sngs = Directory.EnumerateFiles(searchPath, "*.sng", SearchOption.AllDirectories);
// TO DO: implement a better way of counting songs?
totalSongs = charts.Count<string>() + midis.Count<string>() + sngs.Count<string>();
if (totalSongs > 0)
{
songList.Clear();
scannedSongs = 0;
scanErrors = 0;
foreach (string chart in charts)
{
FileInfo fileInfo = new FileInfo(chart);
string chartDir = "" + fileInfo.Directory?.FullName;
string[] songIniFiles = Directory.GetFiles(chartDir, "song.ini", SearchOption.TopDirectoryOnly);
if (songIniFiles != null)
{
if (songIniFiles.Length > 0)
{
SongEntry songEntry = new SongEntry(chart);
IConfiguration songIniConfig = null;
string artist = "Unknown Artist";
string title = "Unknown Title";
string album = "Unknown Album";
string charter = "Unknown Charter";
string genre = "";
string loadingPhrase = "";
int year = 0;
try
{
songIniConfig = new ConfigurationBuilder().AddIniFile(songIniFiles[0]).Build();
IConfigurationSection songSect = songIniConfig.GetSection("song");
artist = RemoveHtml(songSect["artist"] + "");
title = RemoveHtml(songSect["name"] + "");
album = RemoveHtml(songSect["album"] + "");
charter = RemoveHtml(songSect["charter"] + "");
genre = RemoveHtml(songSect["genre"] + "");
loadingPhrase += RemoveHtml((songSect["loading_phrase"] + "").Replace("<br>", "\n"));
int.TryParse(songIniConfig.GetSection("song")["year"], out year);
int diffLead = 0;
int diffBass = 0;
int.TryParse(songIniConfig.GetSection("song")["diff_guitar"], out diffLead);
if (!int.TryParse(songIniConfig.GetSection("song")["diff_bass"], out diffBass))
{
int.TryParse(songIniConfig.GetSection("song")["diff_rhythm"], out diffBass);
}
songEntry.IntensityLead = int.Clamp(diffLead, 0, 100);
songEntry.IntensityBass = int.Clamp(diffBass, 0, 100);
}
catch { scanErrors++; }
songEntry.Artist = "" + artist;
songEntry.Title = "" + title;
songEntry.Album = "" + album;
songEntry.Charter = "" + charter;
songEntry.Genre = genre;
songEntry.Year = year;
songEntry.Path = chart;
songEntry.LoadingPhrase = loadingPhrase;
songList.Add(songEntry);
scannedSongs++;
}
}
else
{
totalSongs -= 1;
scanErrors++;
}
scanProgress = 100 * scannedSongs / totalSongs;
bw.ReportProgress(scanProgress);
}
foreach (string midi in midis)
{
FileInfo fileInfo = new FileInfo(midi);
string chartDir = "" + fileInfo.Directory?.FullName;
string[] songIniFiles = Directory.GetFiles(chartDir, "song.ini", SearchOption.TopDirectoryOnly);
if (songIniFiles != null)
{
if (songIniFiles.Length > 0)
{
SongEntry songEntry = new SongEntry(midi);
IConfiguration songIniConfig = null;
string artist = "Unknown Artist";
string title = "Unknown Title";
string album = "Unknown Album";
string charter = "Unknown Charter";
string genre = "";
string loadingPhrase = "";
int year = 0;
try
{
songIniConfig = new ConfigurationBuilder().AddIniFile(songIniFiles[0]).Build();
IConfigurationSection songSect = songIniConfig.GetSection("song");
artist = RemoveHtml(songSect["artist"] + "");
title = RemoveHtml(songSect["name"] + "");
album = RemoveHtml(songSect["album"] + "");
charter = RemoveHtml(songSect["charter"] + "");
genre = RemoveHtml(songSect["genre"] + "");
loadingPhrase += RemoveHtml((songSect["loading_phrase"] + "").Replace("<br>","\n"));
int.TryParse(songIniConfig.GetSection("song")["year"], out year);
int diffLead = 0;
int diffBass = 0;
int.TryParse(songIniConfig.GetSection("song")["diff_guitar"], out diffLead); if (!int.TryParse(songIniConfig.GetSection("song")["diff_bass"], out diffBass))
{
int.TryParse(songIniConfig.GetSection("song")["diff_rhythm"], out diffBass);
}
songEntry.IntensityLead = int.Clamp(diffLead, 0, 100);
songEntry.IntensityBass = int.Clamp(diffBass, 0, 100);
}
catch { scanErrors++; }
songEntry.Artist = "" + artist;
songEntry.Title = "" + title;
songEntry.Album = "" + album;
songEntry.Charter = "" + charter;
songEntry.Genre = genre;
songEntry.Year = year;
songEntry.Path = midi;
songEntry.LoadingPhrase = loadingPhrase;
songList.Add(songEntry);
scannedSongs++;
}
}
else
{
totalSongs -= 1;
scanErrors++;
}
scanProgress = 100 * scannedSongs / totalSongs;
bw.ReportProgress(scanProgress);
}
foreach (string sngPath in sngs)
{
FileInfo fileInfo = new FileInfo(sngPath);
SongEntry songEntry = new SongEntry(sngPath);
songEntry.Genre = "";
songEntry.LoadingPhrase = "";
songEntry.Year = 0;
try
{
Sng sngData = Sng.Load(sngPath);
string artist = "";
string title = "";
string album = "";
string charter = "";
string genre = "";
string loadingPhrase = "";
string diffLeadStr = "";
string diffBassStr = "";
int diffLead = 0;
int diffBass = 0;
sngData.meta.TryGetValue("artist", out artist);
sngData.meta.TryGetValue("name", out title);
sngData.meta.TryGetValue("album", out album);
sngData.meta.TryGetValue("genre", out genre);
sngData.meta.TryGetValue("charter", out charter);
sngData.meta.TryGetValue("loading_phrase", out loadingPhrase);
sngData.meta.TryGetValue("diff_guitar", out diffLeadStr);
sngData.meta.TryGetValue("diff_rhythm", out diffBassStr);
int.TryParse(diffLeadStr, out diffLead);
int.TryParse(diffBassStr, out diffBass);
songEntry.IntensityLead = int.Clamp(diffLead, 0, 100);
songEntry.IntensityBass = int.Clamp(diffBass, 0, 100);
songEntry.Title = "" + RemoveHtml(title);
songEntry.Artist = "" + RemoveHtml(artist);
songEntry.Album = "" + RemoveHtml(album);
songEntry.Genre = "" + RemoveHtml(genre);
songEntry.Charter = "" + RemoveHtml(charter);
songEntry.LoadingPhrase = "" + RemoveHtml(("" + loadingPhrase).Replace("<br>","\n"));
int year = 0;
int.TryParse(sngData.meta["year"], out year);
songEntry.Year = year;
}
catch
{
songEntry.Artist = "Unknown Artist";
songEntry.Title = "Unknown Title";
songEntry.Album = "Unknown Album";
songEntry.Charter = "Unknown Charter";
scanErrors++;
}
songEntry.Path = sngPath;
songList.Add(songEntry);
scannedSongs++;
scanProgress = 100 * scannedSongs / totalSongs;
bw.ReportProgress(scanProgress);
}
}
}
}
private void UpdateScanProgress(object? sender, ProgressChangedEventArgs e)
{
ScanProgressBar.Value = e.ProgressPercentage;
ScanProgressTxt.Text = $"{scannedSongs} / {totalSongs}";
}
private void FinishedScanning(object? sender, RunWorkerCompletedEventArgs e)
{
SongsDataGrid.ItemsSource = songList;
CollectionViewSource.GetDefaultView(SongsDataGrid.ItemsSource).Filter = this.SongFilter;
ScanProgressBar.Value = 100;
ScanProgressTxt.Text = $"{songList.Count} songs found";
if (scanErrors > 0) ScanProgressTxt.Text += $" ({scanErrors} errors)";
ChartsPathBrowseBtn.IsEnabled = true;
Chart_Folder_TxtBox.IsEnabled = true;
ScanChartsBtn.Content = "Scan Songs";
ScanChartsBtn.IsEnabled = true;
}
private void AlbumClick(object sender, RoutedEventArgs e)
{
// TO DO: figure out making a popup with album image
}
private void ScanChartsBtn_Click(object sender, RoutedEventArgs e)
{
ScanChartsBtn.IsEnabled = false;
ScanChartsBtn.Content = "Scanning...";
ChartsPathBrowseBtn.IsEnabled = false;
Chart_Folder_TxtBox.IsEnabled = false;
scanFolder = Chart_Folder_TxtBox.Text;
ScanBgWorker.RunWorkerAsync();
}
public static string RemoveHtml(string input)
{
return Regex.Replace(input, "<[a-zA-Z/].*?>", String.Empty);
}
private void ChartsPathBrowseBtn_Click(object sender, RoutedEventArgs e)
{
var dlg = new OpenFolderDialog();
Nullable<bool> result = dlg.ShowDialog();
if (result.HasValue && result.Value)
{
Chart_Folder_TxtBox.Text = dlg.FolderName;
config.AppSettings.Settings["charts_folder"].Value = dlg.FolderName;
config.Save();
}
}
private void PlaySongBtn_Click(object sender, RoutedEventArgs e)
{
PlaySong();
}
private bool SongFilter(object item)
{
if (String.IsNullOrEmpty(SearchTxtBox.Text))
{
return true;
}
else if (item != null)
{
if (item.GetType() == typeof(SongEntry))
{
string search = SearchTxtBox.Text.Replace(" ", "").Replace("-", "");
SongEntry entry = (SongEntry)item;
string results = "";
if (entry.Artist != null) results += entry.Artist;
if (entry.Title != null) results += entry.Title;
if (entry.Artist != null) results += entry.Artist; // in case someone switches artist and title
if (entry.Album != null) results += entry.Album;
if (entry.Genre != null) results += entry.Genre;
if (entry.Charter != null) results += entry.Charter;
if (entry.Path != null) results += entry.Path;
results = results.Replace(" ", "").Replace("-", "");
return (results.Contains(search, StringComparison.OrdinalIgnoreCase));
}
else { return true; }
}
else return false;
}
private void SearchTxtBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (!SongFilter(SongsDataGrid.SelectedItem)) SongsDataGrid.SelectedItem = null;
SongsDataGrid.Items.Filter = SongFilter;
SongsDataGrid.Items.Refresh();
}
private void PlaySong()
{
int index = SongsDataGrid.SelectedIndex;
if (index >= 0)
{
var entry = SongsDataGrid.SelectedItems[0];
if (entry != null)
{
if (entry.GetType() == typeof(SongEntry))
{
string shart = (entry as SongEntry)?.Path + "";
if (System.IO.Path.Exists(FGH3_Path_TxtBox.Text))
System.Diagnostics.Process.Start(FGH3_Path_TxtBox.Text, "\"" + shart + "\"");
}
}
}
}
private void FGH3SettingsBtn_Click(object sender, RoutedEventArgs e)
{
if (System.IO.Path.Exists(FGH3_Path_TxtBox.Text))
System.Diagnostics.Process.Start(FGH3_Path_TxtBox.Text, "-settings");
}
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
public async void LoadAlbumArtFromBitmap(string filepath)
{
BitmapImage bi = new BitmapImage(new Uri(filepath, UriKind.Absolute));
bmpSrc = bi;
AlbumRect.Fill = new ImageBrush(bi);
AlbumRect.Visibility = Visibility.Visible;
}
public async void LoadAlbumArtFromBitmap(Bitmap bitmap)
{
IntPtr hBitmap = bitmap.GetHbitmap();
BitmapSource bi;
try
{
bi = Imaging.CreateBitmapSourceFromHBitmap(
hBitmap,
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
bmpSrc = bi;
AlbumRect.Fill = new ImageBrush(bi);
AlbumRect.Visibility = Visibility.Visible;
}
finally
{
DeleteObject(hBitmap);
}
}
public async void LoadAlbumArt(object? sender, DoWorkEventArgs e)
{
LoadAlbumArtFromBitmap(bmp);
}
private void SetAlbumArt(object? sender, RunWorkerCompletedEventArgs? e)
{
AlbumRect.Fill = new ImageBrush(bmpSrc);
AlbumRect.Visibility = Visibility.Visible;
}
private void SongsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (SongsDataGrid.SelectedItem != null)
{
var entry = SongsDataGrid.SelectedItem;
if (entry.GetType() == typeof(SongEntry))
{
SongEntry song = (SongEntry)entry;
currentLoadingPhrase = song.LoadingPhrase;
RefreshSongInfo(song);
if (song.Path.ToLower().EndsWith(".chart") || song.Path.ToLower().EndsWith(".mid"))
{
string? folder = new FileInfo(song.Path).DirectoryName;
string[] albumCandidates = Directory.GetFiles(folder + "", "album.*", SearchOption.TopDirectoryOnly);
if (albumCandidates.Length > 0)
{
LoadAlbumArtFromBitmap(albumCandidates[0]);
SetAlbumArt(null, null);
}
else AlbumRect.Visibility = Visibility.Hidden;
}
if (song.Path.EndsWith(".sng"))
{
try
{
Sng sng = Sng.Load(song.Path);
bool foundAlbumArt = false;
foreach (var file in sng.files)
{
if (file.name.ToLower().StartsWith("album"))
{
foundAlbumArt = true;
// bmp = new Bitmap(new MemoryStream(file.data));
LoadAlbumArtFromBitmap(new Bitmap(new MemoryStream(file.data)));
SetAlbumArt(null, null);
// AlbumLoadBgWorker.DoWork += LoadAlbumArt;
// AlbumLoadBgWorker.WorkerReportsProgress = false;
// AlbumLoadBgWorker.RunWorkerCompleted += SetAlbumArt;
// AlbumLoadBgWorker.RunWorkerAsync();
break;
}
}
if (!foundAlbumArt)
{
AlbumRect.Visibility = Visibility.Hidden;
}
}
catch { }
}
}
}
else AlbumRect.Visibility = Visibility.Hidden;
}
private void SongsDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
// PlaySong(); // TO DO: Find a better way to implement quickly selecting a song to play?
}
private void OpenInExplorerBtn_Click(object sender, RoutedEventArgs e)
{
if (SongsDataGrid.SelectedItem != null)
{
var entry = SongsDataGrid.SelectedItem;
if (entry.GetType() == typeof(SongEntry))
{
SongEntry song = (SongEntry)entry;
FileInfo fileInfo = new FileInfo(song.Path);
string songDir = "" + fileInfo.Directory?.FullName;
if (File.Exists(song.Path))
System.Diagnostics.Process.Start("explorer.exe", $"/select, \"{song.Path}\"");
else
System.Diagnostics.Process.Start("explorer.exe", songDir);
}
}
}
private void ThemeSwitcher_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ThemeSwitcher.SelectedIndex >= 0)
{
switch (ThemeSwitcher.SelectedIndex)
{
case 0:
MainWin.ThemeMode = ThemeMode.System;
break;
case 1:
MainWin.ThemeMode = ThemeMode.Dark;
break;
case 2:
MainWin.ThemeMode = ThemeMode.Light;
break;
}
if (config != null)
{
if (config.AppSettings.Settings.AllKeys.Contains("ui_theme"))
{
config.AppSettings.Settings["ui_theme"].Value = ThemeSwitcher.SelectedIndex.ToString();
config.Save();
}
}
}
}
}
public class SongEntry
{
public string Artist { get; set; }
public string Title { get; set; }
public string Album { get; set; }
public string Charter { get; set; }
public int Year { get; set; }
public string Genre { get; set; }
public string Path { get; set; }
public string LoadingPhrase { get; set; }
public int IntensityLead { get; set; }
public int IntensityBass { get; set; }
public SongEntry(string path = "", string artist = "Unknown Artist", string title = "Unknown Title", string album = "Unknown Album", string charter = "", int year = 0, string genre = "", string loadingPhrase = "", int intensityLead = 0, int intensityBass = 0)
{
Artist = artist;
Title = title;
Album = album;
Charter = charter;
Year = year;
Genre = genre;
Path = path;
LoadingPhrase = loadingPhrase;
IntensityLead = intensityLead;
IntensityBass = intensityBass;
}
}
}