-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
333a406
commit 451db25
Showing
18 changed files
with
295 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Avalonia; | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Vocup.Settings.Core; | ||
|
||
public class RectJsonConverter : JsonConverter<Rect> | ||
{ | ||
public override Rect Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
if (reader.TokenType != JsonTokenType.StartObject) | ||
throw new JsonException(); | ||
|
||
double x = 0, y = 0, width = 0, height = 0; | ||
|
||
while (reader.Read()) | ||
{ | ||
if (reader.TokenType == JsonTokenType.PropertyName) | ||
{ | ||
var propertyName = reader.GetString(); | ||
|
||
if (propertyName == "X") | ||
{ | ||
reader.Read(); | ||
x = reader.GetDouble(); | ||
} | ||
else if (propertyName == "Y") | ||
{ | ||
reader.Read(); | ||
y = reader.GetDouble(); | ||
} | ||
else if (propertyName == "Width") | ||
{ | ||
reader.Read(); | ||
width = reader.GetDouble(); | ||
} | ||
else if (propertyName == "Height") | ||
{ | ||
reader.Read(); | ||
height = reader.GetDouble(); | ||
} | ||
else | ||
{ | ||
reader.Skip(); | ||
} | ||
} | ||
else if (reader.TokenType == JsonTokenType.EndObject) | ||
{ | ||
return new Rect(x, y, width, height); | ||
} | ||
} | ||
|
||
throw new JsonException(); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, Rect value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStartObject(); | ||
|
||
writer.WritePropertyName("X"); | ||
writer.WriteNumberValue(value.X); | ||
|
||
writer.WritePropertyName("Y"); | ||
writer.WriteNumberValue(value.Y); | ||
|
||
writer.WritePropertyName("Width"); | ||
writer.WriteNumberValue(value.Width); | ||
|
||
writer.WritePropertyName("Height"); | ||
writer.WriteNumberValue(value.Height); | ||
|
||
writer.WriteEndObject(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Avalonia; | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Vocup.Settings.Core; | ||
|
||
public class SizeJsonConverter : JsonConverter<Size> | ||
{ | ||
public override Size Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
if (reader.TokenType != JsonTokenType.StartObject) | ||
throw new JsonException(); | ||
|
||
double width = 0, height = 0; | ||
|
||
while (reader.Read()) | ||
{ | ||
if (reader.TokenType == JsonTokenType.PropertyName) | ||
{ | ||
var propertyName = reader.GetString(); | ||
|
||
if (propertyName == "Width") | ||
{ | ||
reader.Read(); | ||
width = reader.GetDouble(); | ||
} | ||
else if (propertyName == "Height") | ||
{ | ||
reader.Read(); | ||
height = reader.GetDouble(); | ||
} | ||
else | ||
{ | ||
reader.Skip(); | ||
} | ||
} | ||
else if (reader.TokenType == JsonTokenType.EndObject) | ||
{ | ||
return new Size(width, height); | ||
} | ||
} | ||
|
||
throw new JsonException(); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, Size value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WritePropertyName("Width"); | ||
writer.WriteNumberValue(value.Width); | ||
writer.WritePropertyName("Height"); | ||
writer.WriteNumberValue(value.Height); | ||
writer.WriteEndObject(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using Vocup.Settings.Core; | ||
|
||
namespace Vocup.Settings.Model; | ||
|
||
public class RecentFile : SettingsBase | ||
{ | ||
public RecentFile(string fileName, DateTime lastAccess, DateTime lastAvailable) | ||
{ | ||
FileName = fileName; | ||
LastAccess = lastAccess; | ||
LastAvalailable = lastAvailable; | ||
} | ||
|
||
public string FileName { get; } | ||
|
||
private DateTime _lastAccess; | ||
public DateTime LastAccess | ||
{ | ||
get => _lastAccess; | ||
set => RaiseAndSetIfChanged(ref _lastAccess, value); | ||
} | ||
|
||
private DateTime _lastAvailable; | ||
/// <summary> | ||
/// Gets or sets the last time the file was available on the file system. | ||
/// </summary> | ||
public DateTime LastAvalailable | ||
{ | ||
get => _lastAvailable; | ||
set => RaiseAndSetIfChanged(ref _lastAvailable, value); | ||
} | ||
} |
Oops, something went wrong.