mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 20:54:59 +00:00
feature: remember window size and layout information (#165)
This commit is contained in:
parent
7f2e22def6
commit
f977e76ea7
8 changed files with 94 additions and 5 deletions
80
src/ViewModels/LayoutInfo.cs
Normal file
80
src/ViewModels/LayoutInfo.cs
Normal file
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json;
|
||||
|
||||
using Avalonia.Controls;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class LayoutInfo : ObservableObject
|
||||
{
|
||||
public double LauncherWidth
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = 1280;
|
||||
|
||||
public double LauncherHeight
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = 720;
|
||||
|
||||
[JsonConverter(typeof(GridLengthConverter))]
|
||||
public GridLength RepositorySidebarWidth
|
||||
{
|
||||
get => _repositorySidebarWidth;
|
||||
set => SetProperty(ref _repositorySidebarWidth, value);
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(GridLengthConverter))]
|
||||
public GridLength WorkingCopyLeftWidth
|
||||
{
|
||||
get => _workingCopyLeftWidth;
|
||||
set => SetProperty(ref _workingCopyLeftWidth, value);
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(GridLengthConverter))]
|
||||
public GridLength StashesLeftWidth
|
||||
{
|
||||
get => _stashesLeftWidth;
|
||||
set => SetProperty(ref _stashesLeftWidth, value);
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(GridLengthConverter))]
|
||||
public GridLength CommitDetailChangesLeftWidth
|
||||
{
|
||||
get => _commitDetailChangesLeftWidth;
|
||||
set => SetProperty(ref _commitDetailChangesLeftWidth, value);
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(GridLengthConverter))]
|
||||
public GridLength CommitDetailFilesLeftWidth
|
||||
{
|
||||
get => _commitDetailFilesLeftWidth;
|
||||
set => SetProperty(ref _commitDetailFilesLeftWidth, value);
|
||||
}
|
||||
|
||||
private GridLength _repositorySidebarWidth = new GridLength(250, GridUnitType.Pixel);
|
||||
private GridLength _workingCopyLeftWidth = new GridLength(300, GridUnitType.Pixel);
|
||||
private GridLength _stashesLeftWidth = new GridLength(300, GridUnitType.Pixel);
|
||||
private GridLength _commitDetailChangesLeftWidth = new GridLength(256, GridUnitType.Pixel);
|
||||
private GridLength _commitDetailFilesLeftWidth = new GridLength(256, GridUnitType.Pixel);
|
||||
}
|
||||
|
||||
public class GridLengthConverter : JsonConverter<GridLength>
|
||||
{
|
||||
public override GridLength Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var size = reader.GetDouble();
|
||||
return new GridLength(size, GridUnitType.Pixel);
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, GridLength value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteNumberValue(value.Value);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue