dragon-iso/src/TeamsISO.App/OnboardingWindow.xaml.cs

57 lines
2 KiB
C#

using System.IO;
using System.Windows;
namespace TeamsISO.App;
/// <summary>
/// First-launch welcome dialog. Walks the user through the once-per-machine
/// setup that's not derivable from the UI alone (NDI runtime install, Teams
/// admin permission, transcoder topology) and points them at where logs and
/// presets live for later self-service.
///
/// Suppression is governed by a marker file at
/// <c>%LOCALAPPDATA%\TeamsISO\onboarding.flag</c>. The presence of the file —
/// regardless of contents — means "don't show again." The user can restore
/// the dialog by deleting that file.
/// </summary>
public partial class OnboardingWindow : Window
{
private static string FlagPath =>
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"TeamsISO", "onboarding.flag");
public OnboardingWindow() => InitializeComponent();
/// <summary>
/// Returns true on first launch (and on launches where the user previously
/// unchecked "Don't show this again" so the marker file was never created).
/// </summary>
public static bool ShouldShow()
{
try { return !File.Exists(FlagPath); }
catch { return false; } // permission errors → assume already shown
}
private void OnDismiss(object sender, RoutedEventArgs e)
{
if (SuppressBox.IsChecked == true)
{
try
{
var dir = Path.GetDirectoryName(FlagPath);
if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir);
File.WriteAllText(FlagPath,
"Onboarding dialog dismissed at " + DateTimeOffset.UtcNow.ToString("o") + ". " +
"Delete this file to see the welcome dialog again on next launch.");
}
catch
{
// Disk full / permission denied — show the dialog again next launch
// rather than fail noisily.
}
}
DialogResult = true;
Close();
}
}