diff --git a/Emerald/App.xaml.cs b/Emerald/App.xaml.cs index d643e6a3..68e0a213 100644 --- a/Emerald/App.xaml.cs +++ b/Emerald/App.xaml.cs @@ -9,11 +9,20 @@ using System; using Emerald.Helpers; -namespace Emerald; +namespace Emerald; public partial class App : Application { + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: private Helpers.Settings.SettingsSystem SS; /// +After: + private SettingsSystem SS; + /// +*/ + private Services.SettingsService SS; + /// /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// @@ -41,7 +50,14 @@ private void ConfigureServices(IServiceCollection services) services.AddTransient(provider => new ModpackStore(typeof(ModpackStore).Log())); //Settings + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: services.AddSingleton(); +After: + services.AddSingleton(); +*/ + services.AddSingleton(); } @@ -49,8 +65,7 @@ private void ConfigureServices(IServiceCollection services) protected override async void OnLaunched(LaunchActivatedEventArgs args) { var logPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - "Emerald", + DirectResoucres.LocalDataPath, "logs", "app_.log"); @@ -86,8 +101,20 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args) //Help me. ServiceLocator.SetLocatorProvider(() => new Emerald.Services.ServiceProviderLocator(Host!.Services)); + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: SS = ServiceLocator.Current.GetInstance(); this.Log().LogInformation("New Instance was created. Logs are being saved at: {logPath}",logPath); +After: + SS = ServiceLocator.Current.GetInstance(); + this.Log().LogInformation("New Instance was created. Logs are being saved at: {logPath}",logPath); +*/ + SS = ServiceLocator.Current.GetInstance(); + this.Log().LogInformation("New Instance was created. Logs are being saved at: {logPath}",logPath); + + //load settings, + SS.LoadData(); // Do not repeat app initialization when the Window already has content, // just ensure that the window is active @@ -96,9 +123,6 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args) // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); - //load settings, - SS.LoadData(); - // Place the frame in the current Window MainWindow.Content = rootFrame; } @@ -130,31 +154,22 @@ private void MainWindow_Closed(object sender, WindowEventArgs args) #region UnhandledExceptions private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) { - var logPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - "Emerald"); e.Handled = true; LogUnhandledException(e.Exception, "UI UnhandledException"); - ShowPlatformErrorDialog($"An unexpected error occurred. The application needs to be closed.\n see logs at {logPath} for more details"); + ShowPlatformErrorDialog($"An unexpected error occurred. The application needs to be closed.\nSee crash details at {DirectResoucres.LocalDataPath} for more details"); } private void CurrentDomain_UnhandledException(object sender, System.UnhandledExceptionEventArgs e) { - var logPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - "Emerald"); LogUnhandledException((Exception)e.ExceptionObject, "AppDomain UnhandledException"); - ShowPlatformErrorDialog($"A critical error occurred. The application needs to be closed.\n see logs at {logPath} for more details"); + ShowPlatformErrorDialog($"A critical error occurred. The application needs to be closed.\nSee crash details at {DirectResoucres.LocalDataPath} for more details"); } private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - var logPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - "Emerald"); e.SetObserved(); LogUnhandledException(e.Exception, "Task UnobservedException"); - ShowPlatformErrorDialog($"A unobserved error occurred. The application needs to be closed.\n see logs at {logPath} for more details"); + ShowPlatformErrorDialog($"A unobserved error occurred. The application needs to be closed.\nSee crash details at {DirectResoucres.LocalDataPath} for more details"); } private void LogUnhandledException(Exception exception, string source) @@ -169,12 +184,7 @@ private void LogUnhandledException(Exception exception, string source) // Save to crash file (platform-specific path) var crashPath = Path.Combine( -#if WINDOWS - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), -#else - Environment.GetFolderPath(Environment.SpecialFolder.Personal), -#endif - "Emerald", + DirectResoucres.LocalDataPath, "crashes", $"crash_{DateTime.Now:yyyyMMdd_HHmmss}.txt" ); diff --git a/Emerald/Assets/NavigationViewIcons/home.png b/Emerald/Assets/NavigationViewIcons/home.png new file mode 100644 index 00000000..e2885c46 Binary files /dev/null and b/Emerald/Assets/NavigationViewIcons/home.png differ diff --git a/Emerald/Assets/NavigationViewIcons/logs.png b/Emerald/Assets/NavigationViewIcons/logs.png new file mode 100644 index 00000000..4de089af Binary files /dev/null and b/Emerald/Assets/NavigationViewIcons/logs.png differ diff --git a/Emerald/Assets/NavigationViewIcons/news.png b/Emerald/Assets/NavigationViewIcons/news.png new file mode 100644 index 00000000..3209faf4 Binary files /dev/null and b/Emerald/Assets/NavigationViewIcons/news.png differ diff --git a/Emerald/Assets/NavigationViewIcons/settings.png b/Emerald/Assets/NavigationViewIcons/settings.png new file mode 100644 index 00000000..050340b7 Binary files /dev/null and b/Emerald/Assets/NavigationViewIcons/settings.png differ diff --git a/Emerald/Assets/NavigationViewIcons/store.png b/Emerald/Assets/NavigationViewIcons/store.png new file mode 100644 index 00000000..031b8379 Binary files /dev/null and b/Emerald/Assets/NavigationViewIcons/store.png differ diff --git a/Emerald/Assets/NavigationViewIcons/tasks.png b/Emerald/Assets/NavigationViewIcons/tasks.png new file mode 100644 index 00000000..02fbb08c Binary files /dev/null and b/Emerald/Assets/NavigationViewIcons/tasks.png differ diff --git a/Emerald/DirectResources.cs b/Emerald/DirectResources.cs index 240d3162..ed885ede 100644 --- a/Emerald/DirectResources.cs +++ b/Emerald/DirectResources.cs @@ -30,6 +30,17 @@ public static string Platform return "Skia"; #else return "Unknown"; +#endif + } + } + public static string LocalDataPath + { + get + { +#if WINDOWS + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Emerald"); +#else + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Emerald"); #endif } } diff --git a/Emerald/Emerald.csproj b/Emerald/Emerald.csproj index 59731572..eee377e3 100644 --- a/Emerald/Emerald.csproj +++ b/Emerald/Emerald.csproj @@ -49,6 +49,12 @@ + + + + + + diff --git a/Emerald/Helpers/Extensions.cs b/Emerald/Helpers/Extensions.cs index d231f0b9..5899eebb 100644 --- a/Emerald/Helpers/Extensions.cs +++ b/Emerald/Helpers/Extensions.cs @@ -79,8 +79,17 @@ public static ContentDialog ToContentDialog(this UIElement content, string title Content = content, Padding = new(12) } : content, + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: RequestedTheme = (ElementTheme)ServiceLocator.Current.GetInstance< Helpers.Settings.SettingsSystem>().Settings.App.Appearance.Theme }; +After: + RequestedTheme = (ElementTheme)ServiceLocator.Current.GetInstance< SettingsSystem>().Settings.App.Appearance.Theme + }; +*/ + RequestedTheme = (ElementTheme)ServiceLocator.Current.GetInstance< Services.SettingsService>().Settings.App.Appearance.Theme + }; App.Current.Log().LogInformation("Created ContentDialog with title: {title}", title); return dialog; } @@ -140,9 +149,9 @@ public static string Localize(this string resourceKey) { try { - string s = Windows.ApplicationModel.Resources.ResourceLoader - .GetForViewIndependentUse() - .GetString(resourceKey); + string s = Windows.ApplicationModel.Resources.ResourceLoader + .GetForViewIndependentUse() + .GetString(resourceKey); return string.IsNullOrEmpty(s) ? resourceKey : s; } diff --git a/Emerald/Helpers/MessageBox.cs b/Emerald/Helpers/MessageBox.cs index 7b1010c6..8dc0f21d 100644 --- a/Emerald/Helpers/MessageBox.cs +++ b/Emerald/Helpers/MessageBox.cs @@ -129,8 +129,17 @@ private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDia public static async Task Show(string title, string caption, MessageBoxButtons buttons, string customResult1 = null, string customResult2 = null, bool waitUntilOpens = true) { var theme = ServiceLocator.IsLocationProviderSet ? + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: (ElementTheme)ServiceLocator.Current.GetInstance().Settings.App.Appearance.Theme : ElementTheme.Default; +After: + (ElementTheme)ServiceLocator.Current.GetInstance().Settings.App.Appearance.Theme : + ElementTheme.Default; +*/ + (ElementTheme)ServiceLocator.Current.GetInstance().Settings.App.Appearance.Theme : + ElementTheme.Default; var d = new MessageBox(title, caption, buttons, customResult1, customResult2) { XamlRoot = App.Current.MainWindow.Content.XamlRoot, @@ -171,8 +180,17 @@ public static async Task Show(string title, string caption, M public static async Task Show(string text) { var theme = ServiceLocator.IsLocationProviderSet ? + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: (ElementTheme)ServiceLocator.Current.GetInstance().Settings.App.Appearance.Theme : ElementTheme.Default; +After: + (ElementTheme)ServiceLocator.Current.GetInstance().Settings.App.Appearance.Theme : + ElementTheme.Default; +*/ + (ElementTheme)ServiceLocator.Current.GetInstance().Settings.App.Appearance.Theme : + ElementTheme.Default; var d = new MessageBox("Information".Localize(), text, MessageBoxButtons.Ok) { XamlRoot = App.Current.MainWindow.Content.XamlRoot, diff --git a/Emerald/Helpers/Settings/JSON.cs b/Emerald/Helpers/Settings/JSON.cs index 7370ba61..5b98be1f 100644 --- a/Emerald/Helpers/Settings/JSON.cs +++ b/Emerald/Helpers/Settings/JSON.cs @@ -351,7 +351,7 @@ public partial class Appearance : JSON private int _MicaType = 0; [ObservableProperty] - private (int A, int R, int G, int B)? _CustomMicaTintColor; + private Color? _CustomMicaTintColor; [ObservableProperty] diff --git a/Emerald/MainPage.xaml b/Emerald/MainPage.xaml index ad12e865..ba80ddac 100644 --- a/Emerald/MainPage.xaml +++ b/Emerald/MainPage.xaml @@ -65,6 +65,7 @@ @@ -89,20 +90,17 @@ VerticalAlignment="Top" Content="{x:Bind InfoBadge}" /> (); + SS = ServiceLocator.Current.GetInstance(); this.InitializeComponent(); this.Loaded += MainPage_Loaded; NavView.ItemInvoked += MainNavigationView_ItemInvoked; @@ -52,16 +52,17 @@ void TintColor() break; case Helpers.Settings.Enums.MicaTintColor.CustomColor: var c = SS.Settings.App.Appearance.CustomMicaTintColor; - MainGrid.Background = new SolidColorBrush() - { - Color = c == null ? Color.FromArgb(255, 234, 0, 94) : Color.FromArgb((byte)c.Value.A, (byte)c.Value.R, (byte)c.Value.G, (byte)c.Value.B), + MainGrid.Background = new SolidColorBrush() + { + Color = c ?? Color.FromArgb(255, 234, 0, 94), Opacity = (double)SS.Settings.App.Appearance.TintOpacity / 100 }; break; } } TintColor(); - + this.GetThemeService().SetThemeAsync((AppTheme)SS.Settings.App.Appearance.Theme); + //Mica (Windows 11) var mica = WindowManager.IntializeWindow(App.Current.MainWindow); #if WINDOWS @@ -78,52 +79,52 @@ void InitializeNavView() NavView.MenuItems.Add(new SquareNavigationViewItem("Home".Localize()) { + Thumbnail = "ms-appx:///Assets/NavigationViewIcons/home.png", FontIconGlyph = "\xE80F", Tag = "Home", SolidFontIconGlyph = "\xEA8A", - IsSelected = true, - ShowFontIcons = true + IsSelected = true }); NavView.MenuItems.Add(new SquareNavigationViewItem("Store".Localize()) { + Thumbnail = "ms-appx:///Assets/NavigationViewIcons/store.png", Tag = "Store", FontIconGlyph = "\xE7BF", SolidFontIconGlyph = "\xE7BF", - IsSelected = false, - ShowFontIcons = true + IsSelected = false }); NavView.MenuItems.Add(new SquareNavigationViewItem("News".Localize()) { + Thumbnail = "ms-appx:///Assets/NavigationViewIcons/news.png", Tag = "News", FontIconGlyph = "\xF57E", SolidFontIconGlyph = "\xF57E", - IsSelected = false, - ShowFontIcons = true + IsSelected = false }); NavView.FooterMenuItems.Add(new SquareNavigationViewItem("Tasks".Localize()) { + Thumbnail = "ms-appx:///Assets/NavigationViewIcons/tasks.png", Tag = "Tasks", FontIconGlyph = "\xE9D5", SolidFontIconGlyph = "\xE9D5", - IsSelected = false, - ShowFontIcons = true + IsSelected = false }); NavView.FooterMenuItems.Add(new SquareNavigationViewItem("Logs".Localize()) { + Thumbnail = "ms-appx:///Assets/NavigationViewIcons/logs.png", Tag = "Logs", FontIconGlyph = "\xE756", SolidFontIconGlyph = "\xE756", - IsSelected = false, - ShowFontIcons = true + IsSelected = false }); NavView.FooterMenuItems.Add(new SquareNavigationViewItem("Settings".Localize()) { + Thumbnail = "ms-appx:///Assets/NavigationViewIcons/settings.png", Tag = "Settings", FontIconGlyph = "\xE713", SolidFontIconGlyph = "\xE713", - IsSelected = false, - ShowFontIcons = true + IsSelected = false }); NavView.SelectedItem = NavView.MenuItems[0]; @@ -139,8 +140,8 @@ private void MainPage_Loaded(object sender, RoutedEventArgs e) #if WINDOWS Emerald.Helpers.WindowManager.SetTitleBar(App.Current.MainWindow, AppTitleBar); #endif - InitializeNavView(); InitializeAppearance(); + InitializeNavView(); } private Thickness GetNavViewHeaderMargin() diff --git a/Emerald/Models/SquareNavigationViewItem.cs b/Emerald/Models/SquareNavigationViewItem.cs index bc2ea821..aa5d33d5 100644 --- a/Emerald/Models/SquareNavigationViewItem.cs +++ b/Emerald/Models/SquareNavigationViewItem.cs @@ -6,31 +6,45 @@ namespace Emerald.Models; public partial class SquareNavigationViewItem : Model { - public Helpers.Settings.SettingsSystem SS { get; private set; } + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: + private readonly Helpers.Settings.SettingsSystem SS; + public SquareNavigationViewItem() +After: + private readonly SettingsSystem SS; + public SquareNavigationViewItem() +*/ + private readonly Services.SettingsService SS; public SquareNavigationViewItem() { + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: SS = ServiceLocator.Current.GetInstance(); PropertyChanged += (_, e) => +After: + SS = ServiceLocator.Current.GetInstance(); + PropertyChanged += (_, e) => +*/ + SS = ServiceLocator.Current.GetInstance(); + PropertyChanged += (_, e) => { + //idk why I did this if (e.PropertyName == nameof(IsSelected) || e.PropertyName == nameof(ShowFontIcons)) { InvokePropertyChanged(null); } }; + + SS.Settings.App.Appearance.PropertyChanged += (_, e) => + { + InvokePropertyChanged(null); + }; } - public SquareNavigationViewItem(string name, bool isSelected = false, ImageSource image = null, InfoBadge infoBadge = null) + public SquareNavigationViewItem(string name) : this() { Name = name; - IsSelected = isSelected; - Thumbnail = image; - InfoBadge = infoBadge; - PropertyChanged += (_, e) => - { - if (e.PropertyName == nameof(IsSelected) || e.PropertyName == nameof(ShowFontIcons)) - { - InvokePropertyChanged(null); - } - }; } public string Tag { get; set; } @@ -50,17 +64,18 @@ public SquareNavigationViewItem(string name, bool isSelected = false, ImageSourc private bool _IsEnabled = true; [ObservableProperty] - private ImageSource _Thumbnail; + private string _Thumbnail; [ObservableProperty] private InfoBadge _InfoBadge; - [ObservableProperty] - private bool _ShowFontIcons; + private bool ShowFontIcons => SS.Settings.App.Appearance.ShowFontIcons; + + //Using Converters is a pain in uno. public Visibility FontIconVisibility => ShowFontIcons && !IsSelected ? Visibility.Visible : Visibility.Collapsed; public Visibility SolidFontIconVisibility => ShowFontIcons && IsSelected ? Visibility.Visible : Visibility.Collapsed; public Visibility SelectionVisibility => IsSelected ? Visibility.Collapsed : Visibility.Visible; + public Visibility ImageVisibility => ShowFontIcons ? Visibility.Collapsed : Visibility.Visible; - public bool ShowThumbnail => !ShowFontIcons; } diff --git a/Emerald/Helpers/Settings/SettingsSystem.cs b/Emerald/Services/SettingsService.cs similarity index 76% rename from Emerald/Helpers/Settings/SettingsSystem.cs rename to Emerald/Services/SettingsService.cs index 4d4ac25a..e3b39e2a 100644 --- a/Emerald/Helpers/Settings/SettingsSystem.cs +++ b/Emerald/Services/SettingsService.cs @@ -1,4 +1,4 @@ -using Emerald.Helpers.Settings.JSON; +using Emerald.Helpers.Settings; using Microsoft.Extensions.Logging; using System.Text.Json; using System; @@ -7,17 +7,17 @@ using System.Threading.Tasks; using Windows.Storage; -namespace Emerald.Helpers.Settings; -public class SettingsSystem +namespace Emerald.Services; +public class SettingsService { - private readonly ILogger _logger; + private readonly ILogger _logger; - public JSON.Settings Settings { get; private set; } - public Account[] Accounts { get; set; } + public Helpers.Settings.JSON.Settings Settings { get; private set; } + public Helpers.Settings.JSON.Account[] Accounts { get; set; } public event EventHandler? APINoMatch; - public SettingsSystem(ILogger logger) + public SettingsService(ILogger logger) { _logger = logger; } @@ -56,15 +56,15 @@ public void LoadData() try { _logger.LogInformation("Loading settings and accounts."); - Settings = GetSerializedFromSettings("Settings", JSON.Settings.CreateNew()); - Accounts = GetSerializedFromSettings("Accounts", Array.Empty()); + Settings = GetSerializedFromSettings("Settings", Helpers.Settings.JSON.Settings.CreateNew()); + Accounts = GetSerializedFromSettings("Accounts", Array.Empty()); if (Settings.APIVersion != DirectResoucres.SettingsAPIVersion) { _logger.LogWarning("API version mismatch. Triggering APINoMatch event."); APINoMatch?.Invoke(this, ApplicationData.Current.LocalSettings.Values["Settings"] as string); - ApplicationData.Current.LocalSettings.Values["Settings"] = JSON.Settings.CreateNew().Serialize(); - Settings = JsonSerializer.Deserialize(ApplicationData.Current.LocalSettings.Values["Settings"] as string); + ApplicationData.Current.LocalSettings.Values["Settings"] = Helpers.Settings.JSON.Settings.CreateNew().Serialize(); + Settings = JsonSerializer.Deserialize(ApplicationData.Current.LocalSettings.Values["Settings"] as string); } } catch (Exception ex) @@ -78,10 +78,10 @@ public async Task CreateBackup(string system) try { string json = await FileIO.ReadTextAsync(await ApplicationData.Current.LocalFolder.CreateFileAsync("backups.json", CreationCollisionOption.OpenIfExists)); - var backups = string.IsNullOrWhiteSpace(json) ? new Backups() : JsonSerializer.Deserialize(json); + var backups = string.IsNullOrWhiteSpace(json) ? new Helpers.Settings.JSON.Backups() : JsonSerializer.Deserialize(json); - backups.AllBackups ??= Array.Empty(); - backups.AllBackups = backups.AllBackups.Append(new SettingsBackup { Time = DateTime.Now, Backup = system }).ToArray(); + backups.AllBackups ??= Array.Empty(); + backups.AllBackups = backups.AllBackups.Append(new Helpers.Settings.JSON.SettingsBackup { Time = DateTime.Now, Backup = system }).ToArray(); json = backups.Serialize(); await FileIO.WriteTextAsync(await ApplicationData.Current.LocalFolder.CreateFileAsync("backups.json", CreationCollisionOption.OpenIfExists), json); @@ -99,7 +99,7 @@ public async Task DeleteBackup(int index) try { string json = await FileIO.ReadTextAsync(await ApplicationData.Current.LocalFolder.CreateFileAsync("backups.json", CreationCollisionOption.OpenIfExists)); - var backups = string.IsNullOrWhiteSpace(json) ? new Backups() : JsonSerializer.Deserialize(json); + var backups = string.IsNullOrWhiteSpace(json) ? new Helpers.Settings.JSON.Backups() : JsonSerializer.Deserialize(json); backups.AllBackups?.ToList().RemoveAt(index); json = backups.Serialize(); @@ -114,12 +114,12 @@ public async Task DeleteBackup(int index) } } - public async Task> GetBackups() + public async Task> GetBackups() { try { string json = await FileIO.ReadTextAsync(await ApplicationData.Current.LocalFolder.CreateFileAsync("backups.json", CreationCollisionOption.OpenIfExists)); - var backups = string.IsNullOrWhiteSpace(json) ? new Backups() : JsonSerializer.Deserialize(json); + var backups = string.IsNullOrWhiteSpace(json) ? new Helpers.Settings.JSON.Backups() : JsonSerializer.Deserialize(json); _logger.LogInformation("Backups retrieved successfully."); return backups.AllBackups?.ToList() ?? []; diff --git a/Emerald/UserControls/ArgumentsListView.xaml.cs b/Emerald/UserControls/ArgumentsListView.xaml.cs index a0c6fb8c..5916ab2f 100644 --- a/Emerald/UserControls/ArgumentsListView.xaml.cs +++ b/Emerald/UserControls/ArgumentsListView.xaml.cs @@ -19,76 +19,77 @@ namespace Emerald.UserControls; - //Copied from Emerald.UWP - public sealed partial class ArgumentsListView : UserControl +//Copied from Emerald.UWP +public sealed partial class ArgumentsListView : UserControl +{ + private int count = 0; + + private readonly Services.SettingsService SS; + public ArgumentsListView() { - private int count = 0; - private readonly Helpers.Settings.SettingsSystem SS; - public ArgumentsListView() - { - SS = ServiceLocator.Current.GetInstance(); - InitializeComponent(); - view.ItemsSource = Source; - UpdateSource(); - } + SS = ServiceLocator.Current.GetInstance(); + InitializeComponent(); + view.ItemsSource = Source; + UpdateSource(); + } - private ObservableCollection Source = new(); - private void btnAdd_Click(object sender, RoutedEventArgs e) - { - count++; - var r = new ArgTemplate { Arg = "", Count = count }; - Source.Add(r); - UpdateMainSource(); - view.SelectedItem = r; - } - public void UpdateSource() + private ObservableCollection Source = new(); + private void btnAdd_Click(object sender, RoutedEventArgs e) + { + count++; + var r = new ArgTemplate { Arg = "", Count = count }; + Source.Add(r); + UpdateMainSource(); + view.SelectedItem = r; + } + public void UpdateSource() + { + Source.Clear(); + if (SS.Settings.Minecraft.JVM.Arguments != null) { - Source.Clear(); - if (SS.Settings.Minecraft.JVM.Arguments != null) + foreach (var item in SS.Settings.Minecraft.JVM.Arguments) { - foreach (var item in SS.Settings.Minecraft.JVM.Arguments) + count++; + var r = new ArgTemplate { Arg = item, Count = count }; + r.PropertyChanged += (_, _) => { - count++; - var r = new ArgTemplate { Arg = item, Count = count }; - r.PropertyChanged += (_, _) => - { - UpdateMainSource(); - }; - Source.Add(r); - } + UpdateMainSource(); + }; + Source.Add(r); } - btnRemove.IsEnabled = Source.Any(); } - private void UpdateMainSource() => - SS.Settings.Minecraft.JVM.Arguments = Source.Select(x => x.Arg).ToArray(); + btnRemove.IsEnabled = Source.Any(); + } + private void UpdateMainSource() => + SS.Settings.Minecraft.JVM.Arguments = Source.Select(x => x.Arg).ToArray(); - private void btnRemove_Click(object sender, RoutedEventArgs e) + private void btnRemove_Click(object sender, RoutedEventArgs e) + { + foreach (var item in view.SelectedItems) { - foreach (var item in view.SelectedItems) - { - Source.Remove((ArgTemplate)item); - } - UpdateMainSource(); + Source.Remove((ArgTemplate)item); } + UpdateMainSource(); + } - private void TextBox_PointerPressed(object sender, PointerRoutedEventArgs e) - { - view.SelectedIndex = Source.IndexOf(Source.FirstOrDefault(x => x.Count == ((sender as FrameworkElement).DataContext as ArgTemplate).Count)); - } + private void TextBox_PointerPressed(object sender, PointerRoutedEventArgs e) + { + view.SelectedIndex = Source.IndexOf(Source.FirstOrDefault(x => x.Count == ((sender as FrameworkElement).DataContext as ArgTemplate).Count)); + } - private void TextBox_TextChanged(object sender, TextChangedEventArgs e) - { - view.SelectedIndex = Source.IndexOf(Source.FirstOrDefault(x => x.Count == ((sender as FrameworkElement).DataContext as ArgTemplate).Count)); - UpdateMainSource(); - } + private void TextBox_TextChanged(object sender, TextChangedEventArgs e) + { + view.SelectedIndex = Source.IndexOf(Source.FirstOrDefault(x => x.Count == ((sender as FrameworkElement).DataContext as ArgTemplate).Count)); + UpdateMainSource(); + } - private void TextBox_GotFocus(object sender, RoutedEventArgs e) - { - view.SelectedIndex = Source.IndexOf(Source.FirstOrDefault(x => x.Count == ((sender as FrameworkElement).DataContext as ArgTemplate).Count)); - } + private void TextBox_GotFocus(object sender, RoutedEventArgs e) + { + view.SelectedIndex = Source.IndexOf(Source.FirstOrDefault(x => x.Count == ((sender as FrameworkElement).DataContext as ArgTemplate).Count)); + } - private void view_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - btnRemove.IsEnabled = view.SelectedItems.Any(); - } + private void view_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + btnRemove.IsEnabled = view.SelectedItems.Any(); } +} diff --git a/Emerald/Views/Settings/AppearancePage.xaml.cs b/Emerald/Views/Settings/AppearancePage.xaml.cs index 69d064f0..4a8b5492 100644 --- a/Emerald/Views/Settings/AppearancePage.xaml.cs +++ b/Emerald/Views/Settings/AppearancePage.xaml.cs @@ -75,13 +75,14 @@ public sealed partial class AppearancePage : Page Color.FromArgb(255, 126, 115, 95) }; - private readonly Helpers.Settings.SettingsSystem SS; + + private readonly Services.SettingsService SS; public AppearancePage() { InitializeComponent(); this.Log().Info("Initializing AppearancePage..."); - SS = ServiceLocator.Current.GetInstance(); + SS = ServiceLocator.Current.GetInstance(); if (SS.Settings.App.Appearance.MicaTintColor == (int)Helpers.Settings.Enums.MicaTintColor.CustomColor) { @@ -110,7 +111,7 @@ private void GVColorList_SelectionChanged(object sender, SelectionChangedEventAr { var c = TintColorsList[GVColorList.SelectedIndex]; SS.Settings.App.Appearance.MicaTintColor = (int)Helpers.Settings.Enums.MicaTintColor.CustomColor; - SS.Settings.App.Appearance.CustomMicaTintColor = (c.A, c.R, c.G, c.B); + SS.Settings.App.Appearance.CustomMicaTintColor = c; this.Log().Info($"Selected tint color changed to: {c}"); diff --git a/Emerald/Views/Settings/GeneralPage.xaml.cs b/Emerald/Views/Settings/GeneralPage.xaml.cs index 985067c6..e82a5737 100644 --- a/Emerald/Views/Settings/GeneralPage.xaml.cs +++ b/Emerald/Views/Settings/GeneralPage.xaml.cs @@ -18,7 +18,7 @@ using Windows.Foundation.Collections; using Windows.Storage.Pickers; -using SS = Emerald.Helpers.Settings.SettingsSystem; +using SS = Emerald.Services.SettingsService; // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 namespace Emerald.Views.Settings; @@ -27,11 +27,29 @@ namespace Emerald.Views.Settings; /// public sealed partial class GeneralPage : Page { + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: private readonly Helpers.Settings.SettingsSystem SS; public GeneralPage() +After: + private readonly SS SS; + public GeneralPage() +*/ + private readonly Services.SettingsService SS; + public GeneralPage() { + +/* Unmerged change from project 'Emerald (net8.0-windows10.0.22621)' +Before: SS = ServiceLocator.Current.GetInstance(); this.InitializeComponent(); +After: + SS = ServiceLocator.Current.GetInstance(); + this.InitializeComponent(); +*/ + SS = ServiceLocator.Current.GetInstance(); + this.InitializeComponent(); } private async void btnChangeMPath_Click(object sender, RoutedEventArgs e) { diff --git a/Emerald/Views/Settings/SettingsPage.xaml.cs b/Emerald/Views/Settings/SettingsPage.xaml.cs index ea4933df..856dfd3c 100644 --- a/Emerald/Views/Settings/SettingsPage.xaml.cs +++ b/Emerald/Views/Settings/SettingsPage.xaml.cs @@ -28,7 +28,6 @@ private void Navigate(NavigationViewItem itm) break; case "About": throw new NotImplementedException(); - break; default: NavigateOnce(typeof(GeneralPage)); break;