diff --git a/MHFZ_Overlay/Assets/Themes/CatppuccinMocha.xaml b/MHFZ_Overlay/Assets/Themes/CatppuccinMocha.xaml index e667e670..b8aee7cd 100644 --- a/MHFZ_Overlay/Assets/Themes/CatppuccinMocha.xaml +++ b/MHFZ_Overlay/Assets/Themes/CatppuccinMocha.xaml @@ -1,4 +1,4 @@ - - + + + + + + + + + - + @@ -703,9 +720,9 @@ - + - + @@ -720,9 +737,9 @@ - + - + @@ -734,29 +751,29 @@ - + - + - + - + - + - + - + @@ -768,12 +785,12 @@ - + - + - + @@ -785,12 +802,12 @@ - + - + - + @@ -802,17 +819,17 @@ - + - + - + - + diff --git a/MHFZ_Overlay/MHFZ_Overlay.csproj b/MHFZ_Overlay/MHFZ_Overlay.csproj index c9cdac89..bf99a640 100644 --- a/MHFZ_Overlay/MHFZ_Overlay.csproj +++ b/MHFZ_Overlay/MHFZ_Overlay.csproj @@ -818,7 +818,7 @@ - + diff --git a/MHFZ_Overlay/Models/Achievement.cs b/MHFZ_Overlay/Models/Achievement.cs index 9dd65dc7..c229bb99 100644 --- a/MHFZ_Overlay/Models/Achievement.cs +++ b/MHFZ_Overlay/Models/Achievement.cs @@ -14,7 +14,6 @@ namespace MHFZ_Overlay.Models; using MHFZ_Overlay.Views.Windows; using Wpf.Ui.Common; using Wpf.Ui.Controls; -using Wpf.Ui.Controls.IconElements; /// /// The achievements of the player. @@ -30,7 +29,7 @@ public async Task Show(Snackbar snackbar) } snackbar.Title = this.Title; - snackbar.Message = this.Objective; + snackbar.Content = this.Objective; snackbar.Icon = new SymbolIcon() { Symbol = SymbolRegular.Trophy32, @@ -41,12 +40,13 @@ public async Task Show(Snackbar snackbar) { MainWindow.MainWindowSoundPlayer.Play(); } - - await snackbar.ShowAsync(); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); await Task.Delay(TimeSpan.FromSeconds(1)); // Delay for a certain duration - snackbar.Hide(); // Hide the snackbar } + public TimeSpan SnackbarTimeOut { get; set; } = TimeSpan.FromSeconds(5); + /// /// Gets the color for title and icon from rank. /// diff --git a/MHFZ_Overlay/Services/AchievementService.cs b/MHFZ_Overlay/Services/AchievementService.cs index 023a1e7a..c86bc565 100644 --- a/MHFZ_Overlay/Services/AchievementService.cs +++ b/MHFZ_Overlay/Services/AchievementService.cs @@ -21,7 +21,6 @@ namespace MHFZ_Overlay.Services; using NLog; using Wpf.Ui.Common; using Wpf.Ui.Controls; -using Wpf.Ui.Controls.IconElements; public sealed class AchievementService : IAchievementService { @@ -68,21 +67,23 @@ public static async Task ShowMany(Snackbar snackbar, List achievementsID) } } + public static TimeSpan SnackbarTimeOut { get; set; } = TimeSpan.FromSeconds(5); + public static async Task ShowAchievementsTabInfo(Snackbar snackbar, int remainingAchievements) { var brushConverter = new BrushConverter(); var brushColor = (Brush?)brushConverter.ConvertFromString(CatppuccinMochaColors.NameHex["Crust"]); snackbar.Title = "Too many achievements!"; - snackbar.Message = $"To see the rest of the achievements unlocked ({remainingAchievements} left), see the Achievements tab in the Quests Logs section."; + snackbar.Content = $"To see the rest of the achievements unlocked ({remainingAchievements} left), see the Achievements tab in the Quests Logs section."; snackbar.Icon = new SymbolIcon() { Symbol = SymbolRegular.Info28, }; snackbar.Icon.Foreground = brushColor ?? Brushes.Black; snackbar.Appearance = ControlAppearance.Info; - await snackbar.ShowAsync(); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); await Task.Delay(TimeSpan.FromSeconds(1)); // Delay for a certain duration - snackbar.Hide(); // Hide the snackbar } public static AchievementService GetInstance() diff --git a/MHFZ_Overlay/Services/DatabaseService.cs b/MHFZ_Overlay/Services/DatabaseService.cs index 9b62a1e8..a485072d 100644 --- a/MHFZ_Overlay/Services/DatabaseService.cs +++ b/MHFZ_Overlay/Services/DatabaseService.cs @@ -33,9 +33,11 @@ namespace MHFZ_Overlay.Services; using Octokit; using Wpf.Ui.Common; using Wpf.Ui.Controls; -using Wpf.Ui.Controls.IconElements; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; using Formatting = Newtonsoft.Json.Formatting; using MessageBox = System.Windows.MessageBox; +using MessageBoxButton = System.Windows.MessageBoxButton; +using MessageBoxResult = System.Windows.MessageBoxResult; using Quest = Models.Quest; /// @@ -69,6 +71,8 @@ public sealed class DatabaseService public HashSet AllPlayerInventories { get; set; } + public TimeSpan SnackbarTimeOut { get; set; } = TimeSpan.FromSeconds(5); + private static DatabaseService? instance; private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); @@ -10139,7 +10143,14 @@ INNER JOIN if (!reader.HasRows) { var message = string.Format(CultureInfo.InvariantCulture, "Quest ID not found. Please use the Quest ID option in Settings and go into a quest in order to view the ID needed to search. You may also not have completed any runs for the selected Quest ID or for the selected category.\n\nQuest ID: {0}\nOverlay Mode: {1}\n{2}", questID, selectedOverlayMode, reader.ToString()); - configWindow.ConfigWindowSnackBar.ShowAsync(Messages.ErrorTitle, message, new SymbolIcon(SymbolRegular.ErrorCircle24), ControlAppearance.Danger); + var snackbar = new Snackbar(configWindow.ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)configWindow.FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = message; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle24); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); return; } else @@ -10181,7 +10192,14 @@ GROUP BY if (!reader.HasRows) { var message = string.Format(CultureInfo.InvariantCulture, "Quest ID not found. Please use the Quest ID option in Settings and go into a quest in order to view the ID needed to search. You may also not have completed any runs for the selected Quest ID or for the selected category.\n\nQuest ID: {0}\nOverlay Mode: {1}\n{2}", questID, selectedOverlayMode, reader.ToString()); - configWindow.ConfigWindowSnackBar.ShowAsync(Messages.ErrorTitle, message, new SymbolIcon(SymbolRegular.ErrorCircle24), ControlAppearance.Danger); + var snackbar = new Snackbar(configWindow.ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)configWindow.FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = message; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle24); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); return; } diff --git a/MHFZ_Overlay/Services/FileService.cs b/MHFZ_Overlay/Services/FileService.cs index 261acf75..3b735ee6 100644 --- a/MHFZ_Overlay/Services/FileService.cs +++ b/MHFZ_Overlay/Services/FileService.cs @@ -12,6 +12,7 @@ namespace MHFZ_Overlay.Services; using System.Linq; using System.Windows; using System.Windows.Controls; +using System.Windows.Forms; using System.Windows.Media; using System.Windows.Media.Imaging; using CsvHelper; @@ -19,13 +20,16 @@ namespace MHFZ_Overlay.Services; using MHFZ_Overlay.Models.Constant; using MHFZ_Overlay.Views.Windows; using Newtonsoft.Json; +using Octokit; using Wpf.Ui.Common; using Wpf.Ui.Controls; -using Wpf.Ui.Controls.IconElements; using Xunit; +using Application = System.Windows.Application; using Clipboard = System.Windows.Clipboard; using MessageBox = System.Windows.MessageBox; +using MessageBoxButton = System.Windows.MessageBoxButton; using SaveFileDialog = Microsoft.Win32.SaveFileDialog; +using TextBlock = System.Windows.Controls.TextBlock; /// /// Handles file creation, copying and deletion. Also handles the clipboard (TODO: might want another class for this). @@ -62,12 +66,22 @@ public static string CopyTextToClipboard(object textObject, Snackbar snackbar, s // https://stackoverflow.com/questions/3546016/how-to-copy-data-to-clipboard-in-c-sharp Clipboard.SetText(textToSave); logger.Info(CultureInfo.InvariantCulture, "Copied text to clipboard"); - snackbar.Show(Messages.InfoTitle, "Copied text to clipboard", new SymbolIcon(SymbolRegular.Clipboard32), ControlAppearance.Success); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = "Copied text to clipboard"; + snackbar.Icon = new SymbolIcon(SymbolRegular.Clipboard32); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } else { logger.Error(CultureInfo.InvariantCulture, "Could not copy text to clipboard: text block not found"); - snackbar.Show(Messages.ErrorTitle, "Could not copy text to clipboard: text block not found", new SymbolIcon(SymbolRegular.ClipboardError24), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not copy text to clipboard: text block not found"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ClipboardError24); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } return textToSave; @@ -103,19 +117,34 @@ public static string SaveTextFile(Snackbar snackbar, FrameworkElement element, s { File.WriteAllText(savefile.FileName, textToSave); logger.Info(CultureInfo.InvariantCulture, "Saved text {0}", savefile.FileName); - snackbar.Show(Messages.InfoTitle, "Saved text", new SymbolIcon(SymbolRegular.CheckmarkCircle20), ControlAppearance.Success); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = "Saved text"; + snackbar.Icon = new SymbolIcon(SymbolRegular.CheckmarkCircle20); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } catch (Exception ex) { logger.Error(ex, "Could not save text file"); - snackbar.Show(Messages.ErrorTitle, "Could not save text file", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not save text file"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } else { logger.Error("Could not save text file"); - snackbar.Show(Messages.ErrorTitle, "Could not save text file", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not save text file"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } return textToSave; @@ -148,26 +177,47 @@ public static void SaveElementAsImageFile(Snackbar snackbar, FrameworkElement el { CreateBitmapFromVisual(tb, savefile.FileName); logger.Info(CultureInfo.InvariantCulture, "Saved image {0}", savefile.FileName); - snackbar.Show(Messages.InfoTitle, $"Saved image {savefile.FileName}", new SymbolIcon(SymbolRegular.CheckmarkCircle20), ControlAppearance.Success); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = $"Saved image {savefile.FileName}"; + snackbar.Icon = new SymbolIcon(SymbolRegular.CheckmarkCircle20); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } else if (element is Grid g) { CreateBitmapFromVisual(g, savefile.FileName); logger.Info(CultureInfo.InvariantCulture, "Saved image {0}", savefile.FileName); - snackbar.Show(Messages.InfoTitle, $"Saved image {savefile.FileName}", new SymbolIcon(SymbolRegular.CheckmarkCircle20), ControlAppearance.Success); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = $"Saved image {savefile.FileName}"; + snackbar.Icon = new SymbolIcon(SymbolRegular.CheckmarkCircle20); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } } catch (Exception ex) { logger.Error(ex, "Could not save image file"); - snackbar.Show(Messages.ErrorTitle, "Could not save image file", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not save image file"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } else { logger.Error("Could not save image file"); - snackbar.Show(Messages.ErrorTitle, "Could not save image file", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not save image file"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } @@ -198,13 +248,23 @@ public static void SaveTextFile(Snackbar snackbar, string textToSave, string fil { File.WriteAllText(saveFileDialog.FileName, textToSave); logger.Info(CultureInfo.InvariantCulture, "Saved text {0}", saveFileDialog.FileName); - snackbar.Show(Messages.InfoTitle, "Saved text", new SymbolIcon(SymbolRegular.CheckmarkCircle20), ControlAppearance.Success); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = "Saved text"; + snackbar.Icon = new SymbolIcon(SymbolRegular.CheckmarkCircle20); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } catch (Exception ex) { logger.Error(ex, "Could not save text file"); - snackbar.Show(Messages.ErrorTitle, "Could not save text file", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not save text file"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } @@ -239,16 +299,28 @@ public static void SaveElementAsImageFile(Grid gridToSave, string fileName, Snac gridToSave.Background = previousBackground; logger.Info(CultureInfo.InvariantCulture, "Saved image {0}", savefile.FileName); - snackbar.Show(Messages.InfoTitle, $"Saved image {savefile.FileName}", new SymbolIcon(SymbolRegular.CheckmarkCircle20), ControlAppearance.Success); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = $"Saved image {savefile.FileName}"; + snackbar.Icon = new SymbolIcon(SymbolRegular.CheckmarkCircle20); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } catch (Exception ex) { logger.Error(ex, "Could not save image file"); - snackbar.Show(Messages.ErrorTitle, "Could not save image file", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not save image file"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } + public static TimeSpan SnackbarTimeOut { get; set; } = TimeSpan.FromSeconds(5); + /// /// Copies a UI element to the clipboard as an image. /// @@ -277,12 +349,22 @@ public static void CopyUIElementToClipboard(FrameworkElement element, Snackbar s bmpCopied.Render(dv); Clipboard.SetImage(bmpCopied); logger.Info(CultureInfo.InvariantCulture, "Copied image to clipboard"); - snackbar.Show(Messages.InfoTitle, "Copied image to clipboard", new SymbolIcon(SymbolRegular.Clipboard32), ControlAppearance.Success); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = "Copied image to clipboard"; + snackbar.Icon = new SymbolIcon(SymbolRegular.Clipboard32); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } catch (Exception ex) { logger.Error(ex, "Could not copy UI element to clipboard"); - snackbar.Show(Messages.ErrorTitle, "Could not copy UI element to clipboard", new SymbolIcon(SymbolRegular.ClipboardError24), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not copy UI element to clipboard"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ClipboardError24); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } @@ -369,13 +451,23 @@ public static void SaveRecordsAsCSVFile(T[] records, Snackbar snackbar, strin } logger.Info(CultureInfo.InvariantCulture, "Saved csv file {0}", savefile.FileName); - snackbar.Show(Messages.InfoTitle, "Saved csv file", new SymbolIcon(SymbolRegular.CheckmarkCircle20), ControlAppearance.Success); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = "Saved csv file"; + snackbar.Icon = new SymbolIcon(SymbolRegular.CheckmarkCircle20); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } catch (Exception ex) { logger.Error(ex, "Could not save class records as CSV file"); - snackbar.Show(Messages.ErrorTitle, "Could not save class records as CSV file", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not save class records as CSV file"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } diff --git a/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml b/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml index 8c6912be..c856a3de 100644 --- a/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml +++ b/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml @@ -4031,6 +4031,6 @@ Thunder Clad, Vigorous" Text="{Binding GetActiveSkillsForImage,Mode=OneTime}" Fo - + diff --git a/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml.cs b/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml.cs index 4541efde..e74204c1 100644 --- a/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml.cs +++ b/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml.cs @@ -19,6 +19,7 @@ namespace MHFZ_Overlay.Views.Windows; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; @@ -45,9 +46,6 @@ namespace MHFZ_Overlay.Views.Windows; using Wpf.Ui.Common; using Wpf.Ui.Contracts; using Wpf.Ui.Controls; -using Wpf.Ui.Controls.AutoSuggestBoxControl; -using Wpf.Ui.Controls.IconElements; -using Wpf.Ui.Controls.Window; using Wpf.Ui.Services; using Application = System.Windows.Application; using Clipboard = System.Windows.Clipboard; @@ -56,6 +54,9 @@ namespace MHFZ_Overlay.Views.Windows; using ListView = System.Windows.Controls.ListView; using MenuItem = Wpf.Ui.Controls.MenuItem; using MessageBox = System.Windows.MessageBox; +using MessageBoxButton = System.Windows.MessageBoxButton; +using MessageBoxResult = System.Windows.MessageBoxResult; +using TextBlock = System.Windows.Controls.TextBlock; using TextBox = System.Windows.Controls.TextBox; /// @@ -735,7 +736,7 @@ public ConfigWindow(MainWindow mainWindow) ISnackbarService snackbarService = new SnackbarService(); // Replace 'snackbarControl' with your actual snackbar control instance - snackbarService.SetSnackbarControl(ConfigWindowSnackBar); + snackbarService.SetSnackbarPresenter(ConfigWindowSnackBarPresenter); // Stop the stopwatch stopwatch.Stop(); @@ -1133,7 +1134,8 @@ private void BtnSaveFile_Click(object sender, RoutedEventArgs e) textToSave = MainWindow.dataLoader.model.MarkdownSavedGearStats; } - FileService.SaveTextFile(ConfigWindowSnackBar, textToSave, "GearStats"); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + FileService.SaveTextFile(snackbar, textToSave, "GearStats"); } /// @@ -1157,16 +1159,27 @@ private void BtnCopyFile_Click(object sender, RoutedEventArgs e) { var previousBackground = GearTextGrid.Background; GearTextGrid.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(GearTextGrid, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(GearTextGrid, snackbar); GearTextGrid.Background = previousBackground; return; } // https://stackoverflow.com/questions/3546016/how-to-copy-data-to-clipboard-in-c-sharp Clipboard.SetText(textToSave); - ConfigWindowSnackBar.Show(Messages.InfoTitle, "Copied text to clipboard", new SymbolIcon(SymbolRegular.Clipboard32), ControlAppearance.Success); + var snackbarSuccess = new Snackbar(ConfigWindowSnackBarPresenter); + snackbarSuccess.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + snackbarSuccess.Title = Messages.InfoTitle; + snackbarSuccess.Content = "Copied text to clipboard"; + snackbarSuccess.Appearance = ControlAppearance.Success; + snackbarSuccess.Icon = new SymbolIcon(SymbolRegular.Clipboard32); + snackbarSuccess.Timeout = SnackbarTimeOut; + snackbarSuccess.Show(); } + public TimeSpan SnackbarTimeOut { get; set; } = TimeSpan.FromSeconds(5); + private void FilterBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { HuntLogDataGrid.Items.Filter = GetFilter(); @@ -1383,7 +1396,14 @@ private void OpenSettingsFolder_Click(object sender, RoutedEventArgs e) if (!Directory.Exists(settingsFileDirectoryName)) { logger.Error(CultureInfo.InvariantCulture, "Could not open settings folder"); - ConfigWindowSnackBar.ShowAsync(Messages.ErrorTitle, "Could not open settings folder", new SymbolIcon(SymbolRegular.ErrorCircle24), ControlAppearance.Danger); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not open settings folder"; + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle24); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); return; } @@ -1395,7 +1415,14 @@ private void OpenSettingsFolder_Click(object sender, RoutedEventArgs e) catch (Exception ex) { logger.Error(ex); - ConfigWindowSnackBar.ShowAsync(Messages.ErrorTitle, "Could not open settings folder", new SymbolIcon(SymbolRegular.ErrorCircle24), ControlAppearance.Danger); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not open settings folder"; + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle24); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } @@ -1732,11 +1759,25 @@ private void UpdateYoutubeLink_ButtonClick(object sender, RoutedEventArgs e) string youtubeLink = youtubeLinkTextBox.Text.Trim(); if (databaseManager.UpdateYoutubeLink(sender, e, runID, youtubeLink)) { - ConfigWindowSnackBar.ShowAsync(Messages.InfoTitle, string.Format(CultureInfo.InvariantCulture, "Updated run {0} with link https://youtube.com/watch?v={1}", runID, youtubeLink), new SymbolIcon(SymbolRegular.Video32), ControlAppearance.Success); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.InfoTitle; + snackbar.Content = string.Format(CultureInfo.InvariantCulture, "Updated run {0} with link https://youtube.com/watch?v={1}", runID, youtubeLink); + snackbar.Appearance = ControlAppearance.Success; + snackbar.Icon = new SymbolIcon(SymbolRegular.Video32); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } else { - ConfigWindowSnackBar.ShowAsync(Messages.ErrorTitle, string.Format(CultureInfo.InvariantCulture, "Could not update run {0} with link https://youtube.com/watch?v={1}. The link may have already been set to the same value, or the run ID and link input are invalid.", runID, youtubeLink), new SymbolIcon(SymbolRegular.Video32), ControlAppearance.Danger); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = string.Format(CultureInfo.InvariantCulture, "Could not update run {0} with link https://youtube.com/watch?v={1}. The link may have already been set to the same value, or the run ID and link input are invalid.", runID, youtubeLink); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Icon = new SymbolIcon(SymbolRegular.Video32); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } @@ -1839,7 +1880,9 @@ private void QuestLogGearBtnSaveFile_Click(object sender, RoutedEventArgs e) var fileName = "Set"; var beginningFileName = "Run"; var beginningText = RunIDTextBox.Text.Trim(); - FileService.SaveTextFile(ConfigWindowSnackBar, textToSave, fileName, beginningFileName, beginningText); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.SaveTextFile(snackbar, textToSave, fileName, beginningFileName, beginningText); } private void QuestLogGearBtnCopyFile_Click(object sender, RoutedEventArgs e) @@ -1851,7 +1894,9 @@ private void QuestLogGearBtnCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = questLogGearStatsTextBlock.Background; questLogGearStatsTextBlock.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(questLogGearStatsTextBlock, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(questLogGearStatsTextBlock, snackbar); questLogGearStatsTextBlock.Background = previousBackground; } @@ -1876,8 +1921,9 @@ private void CompendiumBtnSaveFile_Click(object sender, RoutedEventArgs e) string textToSave = compendiumTextBlock.Text; textToSave = string.Format(CultureInfo.InvariantCulture, "```text\n{0}\n```", textToSave); - - FileService.SaveTextFile(ConfigWindowSnackBar, textToSave, "Compendium"); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.SaveTextFile(snackbar, textToSave, "Compendium"); } private void CompendiumBtnCopyFile_Click(object sender, RoutedEventArgs e) @@ -1889,7 +1935,9 @@ private void CompendiumBtnCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = compendiumInformationStackPanel.Background; compendiumInformationStackPanel.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(compendiumInformationStackPanel, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(compendiumInformationStackPanel, snackbar); compendiumInformationStackPanel.Background = previousBackground; } @@ -2014,7 +2062,9 @@ private void CalendarButtonCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = calendarDataGrid.Background; calendarDataGrid.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(calendarDataGrid, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(calendarDataGrid, snackbar); calendarDataGrid.Background = previousBackground; } @@ -2026,7 +2076,9 @@ private void PersonalBestButtonSaveFile_Click(object sender, RoutedEventArgs e) } var fileName = $"PersonalBest-Quest_{QuestIDTextBox.Text}-{OverlayModeComboBox.Text}-{personalBestSelectedType}-{personalBestSelectedWeapon}".Trim().Replace(" ", "_"); - FileService.SaveElementAsImageFile(personalBestMainGrid, fileName, ConfigWindowSnackBar, false); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.SaveElementAsImageFile(personalBestMainGrid, fileName, snackbar, false); } private void PersonalBestButtonCopyFile_Click(object sender, RoutedEventArgs e) @@ -2038,7 +2090,9 @@ private void PersonalBestButtonCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = personalBestMainGrid.Background; personalBestMainGrid.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(personalBestMainGrid, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(personalBestMainGrid, snackbar); personalBestMainGrid.Background = previousBackground; } @@ -2084,7 +2138,9 @@ private void Top20ButtonCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = top20MainGrid.Background; top20MainGrid.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(top20MainGrid, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(top20MainGrid, snackbar); top20MainGrid.Background = previousBackground; } @@ -2135,7 +2191,9 @@ private void WeaponStatsButtonCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = weaponStatsMainGrid.Background; weaponStatsMainGrid.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(weaponStatsMainGrid, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(weaponStatsMainGrid, snackbar); weaponStatsMainGrid.Background = previousBackground; } @@ -2181,7 +2239,9 @@ private void MostRecentButtonCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = mostRecentRunsDataGrid.Background; mostRecentRunsDataGrid.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(mostRecentRunsDataGrid, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(mostRecentRunsDataGrid, snackbar); mostRecentRunsDataGrid.Background = previousBackground; } @@ -2193,7 +2253,9 @@ private void StatsGraphsButtonSaveFile_Click(object sender, RoutedEventArgs e) } var fileName = $"StatsGraphs-{statsGraphsSelectedOption}"; - FileService.SaveElementAsImageFile(statsGraphsMainGrid, fileName, ConfigWindowSnackBar, false); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.SaveElementAsImageFile(statsGraphsMainGrid, fileName, snackbar, false); } private void StatsGraphsButtonCopyFile_Click(object sender, RoutedEventArgs e) @@ -2205,7 +2267,9 @@ private void StatsGraphsButtonCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = statsGraphsMainGrid.Background; statsGraphsMainGrid.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(statsGraphsMainGrid, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(statsGraphsMainGrid, snackbar); statsGraphsMainGrid.Background = previousBackground; } @@ -2218,7 +2282,9 @@ private void StatsTextButtonSaveFile_Click(object sender, RoutedEventArgs e) string textToSave = statsTextTextBlock.Text; textToSave = string.Format(CultureInfo.InvariantCulture, "```text\n{0}\n```", textToSave); - FileService.SaveTextFile(ConfigWindowSnackBar, textToSave, $"StatsText-Run_{RunIDTextBox.Text}-{statsTextSelectedOption}"); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.SaveTextFile(snackbar, textToSave, $"StatsText-Run_{RunIDTextBox.Text}-{statsTextSelectedOption}"); } private void StatsTextButtonCopyFile_Click(object sender, RoutedEventArgs e) @@ -2230,7 +2296,9 @@ private void StatsTextButtonCopyFile_Click(object sender, RoutedEventArgs e) var previousBackground = statsTextTextBlock.Background; statsTextTextBlock.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(statsTextTextBlock, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(statsTextTextBlock, snackbar); statsTextTextBlock.Background = previousBackground; } @@ -2242,7 +2310,9 @@ private void PersonalBestsOverviewButtonSaveFile_Click(object sender, RoutedEven } var fileName = $"PersonalBestsOverview-Quest_{QuestIDTextBox.Text}-{DateTime.UtcNow.ToString("yy/MM/dd", CultureInfo.InvariantCulture).Replace("/", "-")}"; - FileService.SaveElementAsImageFile(DiscordEmbedWeaponPersonalBest, fileName, ConfigWindowSnackBar, false); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.SaveElementAsImageFile(DiscordEmbedWeaponPersonalBest, fileName, snackbar, false); } private void PersonalBestsOverviewButtonCopyFile_Click(object sender, RoutedEventArgs e) @@ -2254,7 +2324,9 @@ private void PersonalBestsOverviewButtonCopyFile_Click(object sender, RoutedEven var previousBackground = DiscordEmbedWeaponPersonalBest.Background; DiscordEmbedWeaponPersonalBest.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1E, 0x1E, 0x2E)); - FileService.CopyUIElementToClipboard(DiscordEmbedWeaponPersonalBest, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + FileService.CopyUIElementToClipboard(DiscordEmbedWeaponPersonalBest, snackbar); DiscordEmbedWeaponPersonalBest.Background = previousBackground; } @@ -4018,7 +4090,9 @@ private void StatsTextMainGrid_Loaded(object sender, RoutedEventArgs e) private async void FumoImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { - await achievementManager.RewardAchievement(225, ConfigWindowSnackBar); + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + await achievementManager.RewardAchievement(225, snackbar); } private void Achievements3DPreviewGrid_Loaded(object sender, RoutedEventArgs e) @@ -4184,80 +4258,103 @@ private void HunterNotesGridMenuItem_Click(object sender, RoutedEventArgs e) { if (sender is MenuItem menuItem && menuItem.Parent is ContextMenu contextMenu && contextMenu.PlacementTarget is FrameworkElement element) { + var snackbar = new Snackbar(ConfigWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + // Check the Tag property of the ContextMenu to decide which menu items to handle if (contextMenu.Name == "HunterNotesContextMenu") { if (menuItem.Name == "HunterNotesCopyTextMenuItem") { - FileService.CopyTextToClipboard(element, ConfigWindowSnackBar); + FileService.CopyTextToClipboard(element, snackbar); } else if (menuItem.Name == "HunterNotesSaveTextMenuItem") { - FileService.SaveTextFile(ConfigWindowSnackBar, element, element.Name); + FileService.SaveTextFile(snackbar, element, element.Name); } else if (menuItem.Name == "HunterNotesSaveImageMenuItem") { - FileService.SaveElementAsImageFile(ConfigWindowSnackBar, element, element.Name); + FileService.SaveElementAsImageFile(snackbar, element, element.Name); } else if (menuItem.Name == "HunterNotesCopyImageMenuItem") { - FileService.CopyUIElementToClipboard(element, ConfigWindowSnackBar); + FileService.CopyUIElementToClipboard(element, snackbar); } else { logger.Error("Invalid Menu Item option: {0}", menuItem); - ConfigWindowSnackBar.Show(Messages.ErrorTitle, $"Invalid Menu Item option: {menuItem}", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = $"Invalid Menu Item option: {menuItem}"; + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } else if (contextMenu.Name == "HunterNotesContextMenuImageOnly") { if (menuItem.Name == "HunterNotesSaveImageMenuItem2") { - FileService.SaveElementAsImageFile(ConfigWindowSnackBar, element, element.Name); + FileService.SaveElementAsImageFile(snackbar, element, element.Name); } else if (menuItem.Name == "HunterNotesCopyImageMenuItem2") { - FileService.CopyUIElementToClipboard(element, ConfigWindowSnackBar); + FileService.CopyUIElementToClipboard(element, snackbar); } else { logger.Error("Invalid Menu Item option: {0}", menuItem); - ConfigWindowSnackBar.Show(Messages.ErrorTitle, $"Invalid Menu Item option: {menuItem}", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = $"Invalid Menu Item option: {menuItem}"; + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } else if (contextMenu.Name == "HunterNotesContextMenuImageCSV") { if (menuItem.Name == "HunterNotesSaveImageMenuItem3") { - FileService.SaveElementAsImageFile(ConfigWindowSnackBar, element, element.Name); + FileService.SaveElementAsImageFile(snackbar, element, element.Name); } else if (menuItem.Name == "HunterNotesCopyImageMenuItem3") { - FileService.CopyUIElementToClipboard(element, ConfigWindowSnackBar); + FileService.CopyUIElementToClipboard(element, snackbar); } else if (menuItem.Name == "HunterNotesSaveCSVMenuItem") { if (element.Name == "HuntedLogGrid") { - FileService.SaveRecordsAsCSVFile(Monsters, ConfigWindowSnackBar, "HuntedLog"); + FileService.SaveRecordsAsCSVFile(Monsters, snackbar, "HuntedLog"); } else if (element.Name == "AchievementsGrid") { FileService.SaveRecordsAsCSVFile( AchievementService.FilterAchievementsToCompletedOnly( MainWindow.dataLoader.model.PlayerAchievements - ).ToArray(), ConfigWindowSnackBar, "Achievements"); + ).ToArray(), snackbar, "Achievements"); } else { logger.Error("Unhandled csv class records: {0}", element.Name); - ConfigWindowSnackBar.Show(Messages.ErrorTitle, "Could not save class records as CSV file: unhandled element", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not save class records as CSV file: unhandled element"; + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } else { logger.Error("Invalid Menu Item option: {0}", menuItem); - ConfigWindowSnackBar.Show(Messages.ErrorTitle, $"Invalid Menu Item option: {menuItem}", new SymbolIcon(SymbolRegular.ErrorCircle20), ControlAppearance.Danger); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = $"Invalid Menu Item option: {menuItem}"; + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle20); + snackbar.Timeout = SnackbarTimeOut; + snackbar.Show(); } } else diff --git a/MHFZ_Overlay/Views/Windows/MainWindow.xaml b/MHFZ_Overlay/Views/Windows/MainWindow.xaml index fb045f82..12602c70 100644 --- a/MHFZ_Overlay/Views/Windows/MainWindow.xaml +++ b/MHFZ_Overlay/Views/Windows/MainWindow.xaml @@ -715,7 +715,7 @@ - + diff --git a/MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs b/MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs index 87eed5ad..c1568cf4 100644 --- a/MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs +++ b/MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs @@ -48,7 +48,6 @@ namespace MHFZ_Overlay.Views.Windows; using Wpf.Ui.Common; using Wpf.Ui.Contracts; using Wpf.Ui.Controls; -using Wpf.Ui.Controls.IconElements; using Wpf.Ui.Services; using XInputium; using XInputium.XInput; @@ -63,6 +62,8 @@ namespace MHFZ_Overlay.Views.Windows; using DragEventArgs = System.Windows.DragEventArgs; using Image = System.Windows.Controls.Image; using Label = System.Windows.Controls.Label; +using MessageBoxButton = System.Windows.MessageBoxButton; +using MessageBoxResult = System.Windows.MessageBoxResult; using MouseEventArgs = System.Windows.Input.MouseEventArgs; using NotifyIcon = Wpf.Ui.Controls.NotifyIcon; using Point = System.Windows.Point; @@ -137,6 +138,8 @@ private void OptionChangelog_Click(object sender, RoutedEventArgs e) OpenLink("https://github.com/DorielRivalet/mhfz-overlay/blob/main/CHANGELOG.md"); } + public TimeSpan MainWindowSnackbarTimeOut { get; set; } = TimeSpan.FromSeconds(5); + private void OptionSettingsFolder_Click(object sender, RoutedEventArgs e) { try @@ -146,7 +149,14 @@ private void OptionSettingsFolder_Click(object sender, RoutedEventArgs e) if (!Directory.Exists(settingsFileDirectoryName)) { LoggerInstance.Error(CultureInfo.InvariantCulture, "Could not open settings folder"); - this.MainWindowSnackBar.ShowAsync(Messages.ErrorTitle, "Could not open settings folder", new SymbolIcon(SymbolRegular.ErrorCircle24), ControlAppearance.Danger); + var snackbar = new Snackbar(MainWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not open settings folder"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle24); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = MainWindowSnackbarTimeOut; + snackbar.Show(); return; } @@ -158,7 +168,14 @@ private void OptionSettingsFolder_Click(object sender, RoutedEventArgs e) catch (Exception ex) { LoggerInstance.Error(ex); - this.MainWindowSnackBar.ShowAsync(Messages.ErrorTitle, "Could not open settings folder", new SymbolIcon(SymbolRegular.ErrorCircle24), ControlAppearance.Danger); + var snackbar = new Snackbar(MainWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.ErrorTitle; + snackbar.Content = "Could not open settings folder"; + snackbar.Icon = new SymbolIcon(SymbolRegular.ErrorCircle24); + snackbar.Appearance = ControlAppearance.Danger; + snackbar.Timeout = MainWindowSnackbarTimeOut; + snackbar.Show(); } } @@ -414,7 +431,7 @@ public MainWindow() ISnackbarService snackbarService = new SnackbarService(); // Replace 'snackbarControl' with your actual snackbar control instance - snackbarService.SetSnackbarControl(this.MainWindowSnackBar); + snackbarService.SetSnackbarPresenter(this.MainWindowSnackBarPresenter); splashScreen.Close(TimeSpan.FromSeconds(0.1)); @@ -765,7 +782,7 @@ private void AnimateOutlinedTextBlock(OutlinedTextBlock outlinedTextBlock, Brush Storyboard fadeInStoryboard = new Storyboard(); Storyboard.SetTarget(fadeIn, outlinedTextBlock); - Storyboard.SetTargetProperty(fadeIn, new PropertyPath(TextBlock.OpacityProperty)); + Storyboard.SetTargetProperty(fadeIn, new PropertyPath(OutlinedTextBlock.OpacityProperty)); Storyboard.SetTarget(colorInAnimation, outlinedTextBlock); Storyboard.SetTargetProperty(colorInAnimation, new PropertyPath(OutlinedTextBlock.FillProperty)); fadeInStoryboard.Children.Add(fadeIn); @@ -773,7 +790,7 @@ private void AnimateOutlinedTextBlock(OutlinedTextBlock outlinedTextBlock, Brush Storyboard fadeOutStoryboard = new Storyboard(); Storyboard.SetTarget(fadeOut, outlinedTextBlock); - Storyboard.SetTargetProperty(fadeOut, new PropertyPath(TextBlock.OpacityProperty)); + Storyboard.SetTargetProperty(fadeOut, new PropertyPath(OutlinedTextBlock.OpacityProperty)); Storyboard.SetTarget(colorOutAnimation, outlinedTextBlock); Storyboard.SetTargetProperty(colorOutAnimation, new PropertyPath(OutlinedTextBlock.FillProperty)); fadeOutStoryboard.Children.Add(fadeOut); @@ -2033,7 +2050,9 @@ private async Task CheckQuestStateForDatabaseLogging() // TODO: add logging check requirement in case the user needs the hash sets. // We await since we are dealing with database - await AchievementManagerInstance.CheckForAchievementsAsync(MainWindowSnackBar, dataLoader, DatabaseManagerInstance, s); + var snackbar = new Snackbar(MainWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + await AchievementManagerInstance.CheckForAchievementsAsync(snackbar, dataLoader, DatabaseManagerInstance, s); } } @@ -2666,7 +2685,14 @@ private void Window_Loaded(object sender, RoutedEventArgs e) if (dataLoader.loadedOutsideMezeporta) { - MainWindowSnackBar.ShowAsync(Messages.WarningTitle, "It is not recommended to load the overlay outside of Mezeporta", new SymbolIcon(SymbolRegular.Warning28), ControlAppearance.Caution); + var snackbar = new Snackbar(MainWindowSnackBarPresenter); + snackbar.Style = (Style)FindResource("CatppuccinMochaSnackBar"); + snackbar.Title = Messages.WarningTitle; + snackbar.Content = "It is not recommended to load the overlay outside of Mezeporta"; + snackbar.Icon = new SymbolIcon(SymbolRegular.Warning28); + snackbar.Appearance = ControlAppearance.Caution; + snackbar.Timeout = MainWindowSnackbarTimeOut; + snackbar.Show(); } DatabaseManagerInstance.LoadDatabaseDataIntoHashSets(SaveIconGrid, dataLoader); diff --git a/MHFZ_Overlay/Views/Windows/SettingsForm.xaml.cs b/MHFZ_Overlay/Views/Windows/SettingsForm.xaml.cs index 2bd52a3c..db0af240 100644 --- a/MHFZ_Overlay/Views/Windows/SettingsForm.xaml.cs +++ b/MHFZ_Overlay/Views/Windows/SettingsForm.xaml.cs @@ -6,7 +6,7 @@ namespace MHFZ_Overlay.Views.Windows; using System.Windows; using System.Windows.Controls; -using Wpf.Ui.Controls.Window; +using Wpf.Ui.Controls; /// /// Interaction logic for SettingsForm.xaml