-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStartPage.xaml.cs
More file actions
107 lines (90 loc) · 3.57 KB
/
Copy pathStartPage.xaml.cs
File metadata and controls
107 lines (90 loc) · 3.57 KB
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
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Xabe.FFmpeg.Downloader;
namespace FeralCode
{
public partial class StartPage : Page
{
private static string _lastFocusedButtonName = "";
public StartPage()
{
InitializeComponent();
this.Loaded += Page_Loaded;
}
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
await EnsureFfmpegIsInstalledAsync();
if (!string.IsNullOrEmpty(_lastFocusedButtonName))
{
if (this.FindName(_lastFocusedButtonName) as Button is Button targetButton)
{
targetButton.Focus();
return;
}
}
BtnLiveTV.Focus();
}
private async Task EnsureFfmpegIsInstalledAsync()
{
string appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string ffmpegFolder = Path.Combine(appData, "FeralHTPC", "ffmpeg");
if (!Directory.Exists(ffmpegFolder)) Directory.CreateDirectory(ffmpegFolder);
string ffmpegPath = Path.Combine(ffmpegFolder, "ffmpeg.exe");
if (!File.Exists(ffmpegPath))
{
try
{
await FFmpegDownloader.GetLatestVersion(FFmpegVersion.Official, ffmpegFolder);
}
catch { }
}
}
private void LiveTv_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn) _lastFocusedButtonName = btn.Name;
NavigationService.Navigate(new GuidePage());
}
// --- NEW: Wires up the Recently Added button ---
private void Dashboard_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn) _lastFocusedButtonName = btn.Name;
NavigationService.Navigate(new DashboardPage());
}
private void Movies_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn) _lastFocusedButtonName = btn.Name;
NavigationService.Navigate(new MoviesPage());
}
private void Shows_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn) _lastFocusedButtonName = btn.Name;
NavigationService.Navigate(new ShowsPage());
}
// --- FIXED: Wires up the Videos button ---
private void Videos_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn) _lastFocusedButtonName = btn.Name;
NavigationService.Navigate(new VideosPage());
}
private void Apps_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn) _lastFocusedButtonName = btn.Name;
NavigationService.Navigate(new ExternalStreamsPage());
}
private void Multiview_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn) _lastFocusedButtonName = btn.Name;
NavigationService.Navigate(new MultiviewSetupPage());
}
private void Settings_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn) _lastFocusedButtonName = btn.Name;
NavigationService.Navigate(new SettingsPage());
}
}
}