Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RegPreview] Various improvements on how files are saved #37628

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
make spell check happy
  • Loading branch information
htcfreek committed Feb 25, 2025
commit 7dfadaf42283c8cb79e08cdd05a93fbe443cbe9c
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@ namespace RegistryPreviewUILib
{
public sealed partial class RegistryPreviewMainPage : Page
{
private static readonly string _usavedFileIndicator = "* ";
private static readonly char[] _usavedFileIndicatorChars = [' ', '*'];
private static readonly string _unsavedFileIndicator = "* ";
private static readonly char[] _unsavedFileIndicatorChars = [' ', '*'];

private static SemaphoreSlim _dialogSemaphore = new(1);
private string lastKeyPath;
@@ -940,19 +940,19 @@ public void ChangeCursor(UIElement uiElement, bool wait)
public void UpdateUnsavedFileIndicator(bool show)
{
// get and cut current title
string currentTitel = Regex.Replace(_mainWindow.Title, APPNAME + @"$|\s-\s" + APPNAME + @"$", string.Empty);
string currentTitle = Regex.Replace(_mainWindow.Title, APPNAME + @"$|\s-\s" + APPNAME + @"$", string.Empty);

// verify
bool titleContiansIndicator = currentTitel.StartsWith(_usavedFileIndicator, StringComparison.CurrentCultureIgnoreCase);
bool titleContainsIndicator = currentTitle.StartsWith(_unsavedFileIndicator, StringComparison.CurrentCultureIgnoreCase);

// update
if (!titleContiansIndicator && show)
if (!titleContainsIndicator && show)
{
_updateWindowTitleFunction(_usavedFileIndicator + currentTitel);
_updateWindowTitleFunction(_unsavedFileIndicator + currentTitle);
}
else if (titleContiansIndicator && !show)
else if (titleContainsIndicator && !show)
{
_updateWindowTitleFunction(currentTitel.TrimStart(_usavedFileIndicatorChars));
_updateWindowTitleFunction(currentTitle.TrimStart(_unsavedFileIndicatorChars));
}
}