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

Autosaving and upgraded to .NET 8 #582

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5239405
Upgraded to .NET 8.0
CPKreu Nov 24, 2023
4b96289
Implemented autosaving
CPKreu Nov 28, 2023
9e7911f
Put autosaves in extra temp directory
CPKreu Nov 28, 2023
f3fd30e
Added autosave period setting
CPKreu Nov 28, 2023
2bf506a
Implemented disabling autosave
CPKreu Nov 28, 2023
e19c7e5
Fixed wrong error being passed when PixiEditor has no right to write …
CPKreu Nov 28, 2023
f02f8a5
Fixed crash report and integrated temp autosave files
CPKreu Nov 28, 2023
1a41f55
Made CodeFactor happy
CPKreu Nov 28, 2023
9095b14
Added autosave icons and ability to pause autosaving for document ses…
CPKreu Nov 29, 2023
a8710fe
Fixed #581 "Open from clipboard" causes a crash
CPKreu Nov 29, 2023
c4bc98f
Fixed textTimer being called before UpdateMainMenuTextSave being called
CPKreu Nov 29, 2023
16705ea
Enhanced crash reports
CPKreu Nov 29, 2023
2073f58
Made Codefactor happy again
CPKreu Nov 29, 2023
7c8b750
Removed settings button for now
CPKreu Nov 29, 2023
3e13ff3
Toggle between pause and play icon in autosave control
CPKreu Nov 29, 2023
5a02a7d
Added Paths.PathToUnsavedFilesFolder
CPKreu Dec 1, 2023
1afefa4
Use separate message when all changes are already saved
CPKreu Dec 1, 2023
f1d4aac
Autosave unsaved files on close
CPKreu Dec 1, 2023
e049fab
Save all files on close when autosaving is enabled
CPKreu Dec 2, 2023
653c0a9
Added lots of new report state info
CPKreu Dec 3, 2023
f3fea6d
Fix main canvas not updating on launch
Equbuxu Dec 3, 2023
cd4c9a7
Merge branch 'master' into autosave
CPKreu Dec 5, 2023
391bafb
Added deadlock detector
CPKreu Dec 5, 2023
15e4b13
Always save files to temp and auto reopen on deadlock
CPKreu Dec 7, 2023
5c9322b
Better panic autosaving
CPKreu Dec 7, 2023
12d8b2e
Include autosaved file in crash report and added rounded corners to t…
CPKreu Dec 7, 2023
4076fb8
3
CPKreu Dec 7, 2023
1cc24ae
Fixed "Do you wanna save" dialog being shown even though the document…
CPKreu Dec 8, 2023
86ef86d
Added settings for restoring last session and saving user files
CPKreu Dec 8, 2023
81bf41c
Fix session ending window not being fully localized and save session …
CPKreu Dec 9, 2023
5fd6c02
Detect deadlock fast if mainThread is sleeping
CPKreu Dec 9, 2023
b0dba62
Fixed LocalizedString not updating if only parameters changed
CPKreu Dec 9, 2023
f0bf934
Added Debug commands for backing up and loading preferences
CPKreu Dec 9, 2023
3ccf4d5
Use DispatcherTimer instead of System.Timers.Timer in AutosaveDocumen…
CPKreu Dec 10, 2023
8b88985
Report PropertyChanged call from non UI thread and fixed fatal error …
CPKreu Dec 10, 2023
5edd7e2
Improved localization key show modes
CPKreu Dec 10, 2023
8bd5015
Merge branch 'master' into autosave
CPKreu Dec 10, 2023
3eb1cb7
Fixed text being cut off from autosave control
CPKreu Dec 10, 2023
7f15b17
Only stopwatch the time in a debug build
CPKreu Dec 11, 2023
2aac3ed
Fix deadlock detector detecting deadlock on shutdown
CPKreu Dec 11, 2023
9144948
Delete helper process for collecting deadlock exception
CPKreu Dec 11, 2023
755ff0b
Added deadlock detection debug window
CPKreu Dec 11, 2023
0a4cd2d
Remove deadlock detection helper
CPKreu Dec 11, 2023
13145d8
Crashes fixes and autosavecontrol look
flabbet Dec 12, 2023
56de69b
Update incompatible.json
flabbet Dec 12, 2023
a699958
Small refactorings
Equbuxu Dec 12, 2023
d4daa55
Change palettes folder name back to Palettes
Equbuxu Dec 12, 2023
0fe207a
Copy global-ish variable to avoid closing over it (tbh that task.run …
Equbuxu Dec 12, 2023
2c2ee12
Merge branch 'master' into autosave
flabbet Jan 13, 2024
e035514
Merge fixes
flabbet Jan 13, 2024
2141eba
Autosave all on crash
flabbet Jan 13, 2024
d138826
Updated installer to install .NET 8
flabbet Jan 13, 2024
4fd89f8
Don't autosave all files on crash
CPKreu Jan 21, 2024
3c62ff4
Added preference constants attribute
CPKreu Jan 21, 2024
e6739c5
Fix AutosaveAllForNextSession writing UnsavedNextSessionFiles to remo…
CPKreu Jan 21, 2024
78e2859
Renamed RemotePreferenceConstant to to SyncedPreferenceConstant
CPKreu Jan 21, 2024
cb17bcc
If we got the default value use the defaultValue
CPKreu Jan 21, 2024
559a8a7
Keep showing text as a text block instead of tooltip but only on hove…
CPKreu Jan 21, 2024
46fc262
Fixed CodeFactor
CPKreu Jan 21, 2024
bf70dc8
Improved PreferencesDiagnostics
CPKreu Jan 21, 2024
b9dddac
Make 'Mark as saved' a passthrough action, now the * works correctly
Equbuxu Feb 11, 2024
fb28d43
Separated out autosave control updates from autosave logic, I don't r…
Equbuxu Feb 14, 2024
a66cf20
Autosave progress
Equbuxu Mar 14, 2024
1970872
FIxed compilation errors
flabbet May 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ChunkyImageLib/ChunkyImageLib.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
Expand Down
2 changes: 1 addition & 1 deletion src/ChunkyImageLibTest/ChunkyImageLibTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion src/ChunkyImageLibVis/ChunkyImageLibVis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<Configurations>Debug;Release;Steam;DevRelease</Configurations>
Expand Down
2 changes: 1 addition & 1 deletion src/PixiEditor.Builder/build/PixiEditor.Builder.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<AssemblyName>PixiEditor.Builder</AssemblyName>
<RootNamespace>PixiEditor.Builder</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ public enum LocalizationKeyShowMode
/// <summary>
/// Shows a long string ensuring responsive layout
/// </summary>
LALALA,
LAGLAGLAG,

/// <summary>
/// Shows a short string ensuring responsive layout
/// </summary>
Short
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ public string Key
#else
Value = OverridenKeyFlowMode switch
{
LocalizationKeyShowMode.Value => GetValue(value),
LocalizationKeyShowMode.Key => Key,
LocalizationKeyShowMode.ValueKey => $"{GetValue(value)} ({Key})",
LocalizationKeyShowMode.LALALA => $"#~{GetLongString(GetValue(value).Count(x => x == ' ') + 1)}{Math.Abs(Key.GetHashCode()).ToString()[..2]}~#",
LocalizationKeyShowMode.LAGLAGLAG => $"#~{GetLongString(GetValue(value).Count(x => x == ' ') + 1)}{Math.Abs(Key.GetHashCode()).ToString()[..2]}~#",
LocalizationKeyShowMode.Short => "L",
_ => GetValue(value)
};
#endif
}
}
public string Value { get; private set; }

public object[] Parameters { get; set; }
public object[]? Parameters { get; set; }

public LocalizedString(string key)
{
Expand Down Expand Up @@ -73,7 +75,7 @@ private string GetValue(string localizationKey)
return ApplyParameters(ILocalizationProvider.Current.CurrentLanguage.Locale[localizationKey]);
}

private string GetLongString(int length) => string.Join(' ', Enumerable.Repeat("LaLaLaLaLa", length));
private string GetLongString(int length) => string.Join(' ', Enumerable.Repeat("LagLagLaag", length));

private string ApplyParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public interface IPreferences
{
public static IPreferences Current { get; private set; }
public static IPreferences? Current { get; private set; }

/// <summary>
/// Saves the preferences to be stored permanently.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@

public static class PreferencesConstants
{
public const string FavouritePalettes = "FavouritePalettes";
public const string RecentlyOpened = "RecentlyOpened";
public const string FavouritePalettes = nameof(FavouritePalettes);

public const string RecentlyOpened = nameof(RecentlyOpened);

public const string MaxOpenedRecently = "MaxOpenedRecently";
public const string MaxOpenedRecently = nameof(MaxOpenedRecently);
public const int MaxOpenedRecentlyDefault = 8;
public const string DisableNewsPanel = "DisableNewsPanel";
public const string LastCheckedNewsIds = "LastCheckedNewsIds";
public const string NewsPanelCollapsed = "NewsPanelCollapsed";

public const string DisableNewsPanel = nameof(DisableNewsPanel);

public const string LastCheckedNewsIds = nameof(LastCheckedNewsIds);

public const string NewsPanelCollapsed = nameof(NewsPanelCollapsed);

public const string AutosavePeriodMinutes = nameof(AutosavePeriodMinutes);
public const double AutosavePeriodDefault = 3;

public const string UnsavedNextSessionFiles = nameof(UnsavedNextSessionFiles);

public const string AutosaveToDocumentPath = nameof(AutosaveToDocumentPath);
public const bool AutosaveToDocumentPathDefault = false;

public const string SaveSessionStateEnabled = nameof(SaveSessionStateEnabled);
public const bool SaveSessionStateDefault = true;
}
2 changes: 1 addition & 1 deletion src/PixiEditor.Extensions/PixiEditor.Extensions.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
Expand Down
4 changes: 3 additions & 1 deletion src/PixiEditor.Extensions/UI/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ private static void KeyPropertyChangedCallback(DependencyObject d, DependencyPro

private static void LocalizedStringPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.SetValue(KeyProperty, ((LocalizedString)e.NewValue).Key);
var key = ((LocalizedString)e.NewValue).Key;
d.SetValue(KeyProperty, key);
UpdateKey(d, key);
}

private static void EnumPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/PixiEditor.Platform/PixiEditor.Platform.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>AnyCPU;x64;x86</Platforms>
Expand Down
2 changes: 1 addition & 1 deletion src/PixiEditor.UpdateModule/PixiEditor.UpdateModule.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Platforms>AnyCPU;x64;x86</Platforms>
<Configurations>Debug;Release;Steam;DevRelease</Configurations>
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
2 changes: 1 addition & 1 deletion src/PixiEditor.Zoombox/PixiEditor.Zoombox.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<WarningsAsErrors>Nullable</WarningsAsErrors>
Expand Down
94 changes: 64 additions & 30 deletions src/PixiEditor/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Threading;
using PixiEditor.Extensions.Common.Localization;
using PixiEditor.Extensions.Common.UserPreferences;
using PixiEditor.Helpers;
using PixiEditor.Models.AppExtensions;
using PixiEditor.Helpers.UI;
using PixiEditor.Models.Controllers;
Expand All @@ -15,7 +14,6 @@
using PixiEditor.Platform;
using PixiEditor.Views;
using PixiEditor.Views.Dialogs;
using Timer = System.Timers.Timer;

namespace PixiEditor;

Expand All @@ -42,34 +40,47 @@ protected override void OnStartup(StartupEventArgs e)

if (ParseArgument("--crash (\"?)([A-z0-9:\\/\\ -_.]+)\\1", arguments, out Group[] groups))
{
CrashReport report = CrashReport.Parse(groups[2].Value);
MainWindow = new CrashReportDialog(report);
MainWindow.Show();
try
{
CrashReport report = CrashReport.Parse(groups[2].Value);
MainWindow = new CrashReportDialog(report);
MainWindow.Show();
}
catch (Exception exception)
{
Task sendReport = null;

try
{
sendReport = CrashHelper.SendExceptionInfoToWebhook(exception);
}
finally
{
MessageBox.Show($"Fatal error while trying to open crash report in App.OnStartup()\nPlease report this https://pixieditor.net/help\n{exception}", "Fatal error");
if (sendReport != null && sendReport.Status != TaskStatus.RanToCompletion)
sendReport.Wait(8000);
Shutdown();
}
}

return;
}

#if !STEAM
if (!HandleNewInstance())
if (ParseArgument("--wait-before-init ([0-9]+)", arguments, out Group[] waitBeforeInitGroups))
{
return;
Task.Delay(int.Parse(waitBeforeInitGroups[1].ValueSpan)).Wait();
}
#endif

LoadingWindow.ShowInNewThread();

AddNativeAssets();

InitPlatform();

ExtensionLoader extensionLoader = new ExtensionLoader();
extensionLoader.LoadExtensions();

MainWindow = new MainWindow(extensionLoader);
MainWindow.ContentRendered += (_, _) =>
#if !STEAM
if (!HandleNewInstance() && !arguments.Contains("--force-new-instance"))
{
LoadingWindow.Instance.SafeClose();
MainWindow.Activate();
};
return;
}
#endif

var extensionLoader = InitApp();

MainWindow = new MainWindow(extensionLoader);
MainWindow.Show();
}

Expand All @@ -80,6 +91,20 @@ private void InitPlatform()
platform.PerformHandshake();
}

public ExtensionLoader InitApp()
{
LoadingWindow.ShowInNewThread();

AddNativeAssets();

InitPlatform();

ExtensionLoader extensionLoader = new ExtensionLoader();
extensionLoader.LoadExtensions();

return extensionLoader;
}

private IPlatform GetActivePlatform()
{
#if STEAM
Expand Down Expand Up @@ -183,14 +208,23 @@ protected override void OnSessionEnding(SessionEndingCancelEventArgs e)
var vm = ViewModelMain.Current;
if (vm is null)
return;

if (IPreferences.Current != null)
{
vm.AutosaveAllForNextSession();
}

if (vm.DocumentManagerSubViewModel.Documents.Any(x => !x.AllChangesSaved))
if (vm.DocumentManagerSubViewModel.Documents.All(x => x.AllChangesSaved || x.AllChangesAutosaved))
{
ConfirmationType confirmation = ConfirmationDialog.Show(
new LocalizedString("SESSION_UNSAVED_DATA", e.ReasonSessionEnding),
$"{e.ReasonSessionEnding}");
e.Cancel = confirmation != ConfirmationType.Yes;
return;
}

string reason = e.ReasonSessionEnding.ToString().ToUpperInvariant();

var confirmation = ConfirmationDialog.Show(
new LocalizedString(reason),
new LocalizedString($"{reason}_TITLE"));
e.Cancel = confirmation != ConfirmationType.Yes;
}

private bool ParseArgument(string pattern, string args, out Group[] groups)
Expand Down
Loading