-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.axaml.cs
86 lines (76 loc) · 2.92 KB
/
Settings.axaml.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
using Avalonia.Controls;
using Avalonia.Interactivity;
using MangaDex_Library;
using MsBox.Avalonia;
using MsBox.Avalonia.Enums;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using static Manga_Manager.Globals;
namespace Manga_Manager;
public partial class Settings : Window
{
private bool isFirstTrigger;
public Settings()
{
InitializeComponent();
LanguageComboBox.ItemsSource = languageDictionary.Keys;
LanguageComboBox.SelectedItem = languageDictionary.FirstOrDefault(language => language.Value == selectedLanguage).Key;
UpdatesCheckBox.IsChecked = checkUpdates;
isFirstTrigger = hideJsonFile;
HideJsonCheckBox.IsChecked = hideJsonFile;
WarningCheckBox.IsChecked = !noWarning;
}
private void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
selectedLanguage = languageDictionary[LanguageComboBox.SelectedItem.ToString()];
MDLParameters.Language = selectedLanguage;
MDLGetData.ForceReset();
}
private void UpdatesCheckBox_Checked(object sender, RoutedEventArgs e)
{
checkUpdates = (bool)UpdatesCheckBox.IsChecked;
}
private async void HideJsonCheckBox_Checked(object sender, RoutedEventArgs e)
{
hideJsonFile = (bool)HideJsonCheckBox.IsChecked;
if (isFirstTrigger == true)
{
isFirstTrigger = false;
return;
}
try
{
if (hideJsonFile == true)
{
File.Move("Manga Library Manager.json", ".Manga Library Manager.json");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
File.SetAttributes(".Manga Library Manager.json", File.GetAttributes(".Manga Library Manager.json") | FileAttributes.Hidden);
}
else
{
File.Move(".Manga Library Manager.json", "Manga Library Manager.json");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
File.SetAttributes("Manga Library Manager.json", File.GetAttributes("Manga Library Manager.json") & ~FileAttributes.Hidden);
}
}
catch
{
await MessageBoxManager.GetMessageBoxStandard("Write error", "Could not complete the operation!", ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error).ShowAsync();
isFirstTrigger = true;
HideJsonCheckBox.IsChecked = !HideJsonCheckBox.IsChecked;
}
}
private void WarningCheckBox_Checked(object sender, RoutedEventArgs e)
{
noWarning = !(bool)WarningCheckBox.IsChecked;
}
private void IssueButton_Clicked(object sender, RoutedEventArgs args)
{
OpenLink("https://github.com/ErisLoona/Manga-Library-Manager/issues");
}
private void DonateButton_Clicked(object sender, RoutedEventArgs args)
{
OpenLink("https://ko-fi.com/erisloona");
}
}