Files
Wino-Mail/Wino.Mail.WinUI/Dialogs/WhatIsNewDialog.xaml.cs
T

55 lines
1.6 KiB
C#
Raw Normal View History

2026-03-02 00:44:29 +01:00
using System.Collections.Generic;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Updates;
namespace Wino.Dialogs;
public sealed partial class WhatIsNewDialog : ContentDialog
{
private readonly IUpdateManager _updateManager;
public List<UpdateNoteSection> Sections { get; }
2026-03-05 10:12:03 +01:00
private bool _canClose = false;
2026-03-02 00:44:29 +01:00
public WhatIsNewDialog(UpdateNotes notes, IUpdateManager updateManager)
{
InitializeComponent();
_updateManager = updateManager;
Sections = notes.Sections;
// Show the Get Started button immediately when there is only one page.
2026-03-05 10:12:03 +01:00
UpdateNotesControl.SelectedIndexChanged += OnUpdateSectionChanged;
UpdateGetStartedButtonVisibility(UpdateNotesControl.SelectedIndex);
Closing += OnDialogClosing;
2026-03-02 00:44:29 +01:00
}
2026-03-05 10:12:03 +01:00
private void OnUpdateSectionChanged(object? sender, int selectedIndex)
=> UpdateGetStartedButtonVisibility(selectedIndex);
2026-03-02 00:44:29 +01:00
2026-03-05 10:12:03 +01:00
private void UpdateGetStartedButtonVisibility(int selectedIndex)
{
2026-03-02 00:44:29 +01:00
GetStartedButton.Visibility = selectedIndex == Sections.Count - 1
? Visibility.Visible
: Visibility.Collapsed;
}
2026-03-05 10:12:03 +01:00
private void OnDialogClosing(ContentDialog sender, ContentDialogClosingEventArgs args)
2026-03-02 00:44:29 +01:00
{
2026-03-05 10:12:03 +01:00
// Only allow closing when Get Started button was clicked.
if (!_canClose)
args.Cancel = true;
2026-03-02 00:44:29 +01:00
}
private void OnGetStartedClicked(object sender, RoutedEventArgs e)
2026-03-02 00:44:29 +01:00
{
GetStartedButton.IsEnabled = false;
2026-03-05 10:12:03 +01:00
_updateManager.MarkUpdateNotesAsSeen();
_canClose = true;
2026-03-02 00:44:29 +01:00
Hide();
}
}