mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:56:31 +00:00
rework autoupdate to script only
zoom fix
This commit is contained in:
@@ -126,9 +126,26 @@ public class CanvasEditor : Canvas
|
||||
|
||||
public void SetImageSource(ImageSource? source)
|
||||
{
|
||||
SetZoom();
|
||||
_backgroundImage.Source = source;
|
||||
}
|
||||
|
||||
private void SetZoom(Matrix? matrix = null)
|
||||
{
|
||||
if (matrix == null)
|
||||
{
|
||||
_matrixTransform.Matrix = Matrix.Identity;
|
||||
_isZoomedIn = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_matrixTransform.Matrix = matrix.Value;
|
||||
_isZoomedIn = true;
|
||||
}
|
||||
foreach (var detection in CurrentDetections)
|
||||
detection.UpdateAdornerScale(scale: _matrixTransform.Matrix.M11);
|
||||
}
|
||||
|
||||
private void CanvasWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (Keyboard.Modifiers != ModifierKeys.Control)
|
||||
@@ -139,19 +156,12 @@ public class CanvasEditor : Canvas
|
||||
|
||||
var matrix = _matrixTransform.Matrix;
|
||||
if (scale < 1 && matrix.M11 * scale < 1.0)
|
||||
{
|
||||
_matrixTransform.Matrix = Matrix.Identity;
|
||||
_isZoomedIn = false;
|
||||
}
|
||||
SetZoom();
|
||||
else
|
||||
{
|
||||
matrix.ScaleAt(scale, scale, mousePos.X, mousePos.Y);
|
||||
_matrixTransform.Matrix = matrix;
|
||||
_isZoomedIn = true;
|
||||
SetZoom(matrix);
|
||||
}
|
||||
|
||||
foreach (var detection in CurrentDetections)
|
||||
detection.UpdateAdornerScale(scale: _matrixTransform.Matrix.M11);
|
||||
}
|
||||
|
||||
private void Init(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -4,7 +4,8 @@ using MessagePack;
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
[MessagePackObject]
|
||||
public class ApiCredentials : EventArgs
|
||||
[Verb("credsManual", HelpText = "Manual Credentials")]
|
||||
public class ApiCredentials
|
||||
{
|
||||
[Key(nameof(Email))]
|
||||
[Option('e', "email", Required = true, HelpText = "User Email")]
|
||||
@@ -13,4 +14,11 @@ public class ApiCredentials : EventArgs
|
||||
[Key(nameof(Password))]
|
||||
[Option('p', "pass", Required = true, HelpText = "User Password")]
|
||||
public string Password { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
[Verb("credsEncrypted", isDefault: true, HelpText = "Encrypted Credentials")]
|
||||
public class ApiCredentialsEncrypted
|
||||
{
|
||||
[Option('c', "creds", Group = "auto", HelpText = "Encrypted Creds")]
|
||||
public string Creds { get; set; } = null!;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public class DirectoriesConfig
|
||||
|
||||
{
|
||||
public string ApiResourcesDirectory { get; set; } = null!;
|
||||
public string? ApiResourcesDirectory { get; set; } = null!;
|
||||
|
||||
public string VideosDirectory { get; set; } = null!;
|
||||
public string LabelsDirectory { get; set; } = null!;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Azaion.Common;
|
||||
|
||||
public class Security
|
||||
{
|
||||
private static string GenDefaultKey()
|
||||
{
|
||||
var date = DateTime.UtcNow;
|
||||
return $"sAzaion_default_dfvkjhg_{date:yyyy}-{date:MM}_{date:dd}_{date:HH}_key";
|
||||
}
|
||||
|
||||
public static string Encrypt<T>(T model, string? key = null) where T : class
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var inputBytes = Encoding.UTF8.GetBytes(json);
|
||||
|
||||
var keyBytes = SHA256.HashData(Encoding.UTF8.GetBytes(key ?? GenDefaultKey()));
|
||||
var iv = RandomNumberGenerator.GetBytes(16);
|
||||
|
||||
using var aes = Aes.Create();
|
||||
aes.Key = keyBytes;
|
||||
aes.IV = iv;
|
||||
aes.Mode = CipherMode.CFB;
|
||||
aes.Padding = PaddingMode.ISO10126;
|
||||
|
||||
using var encryptor = aes.CreateEncryptor();
|
||||
var ciphertext = encryptor.TransformFinalBlock(inputBytes, 0, inputBytes.Length);
|
||||
|
||||
var result = new byte[iv.Length + ciphertext.Length];
|
||||
iv.CopyTo(result, 0);
|
||||
ciphertext.CopyTo(result, iv.Length);
|
||||
|
||||
return Convert.ToBase64String(result);
|
||||
}
|
||||
|
||||
public static T Decrypt<T>(string encryptedData, string? key = null) where T : class
|
||||
{
|
||||
var ciphertextWithIv = Convert.FromBase64String(encryptedData);
|
||||
var keyBytes = SHA256.HashData(Encoding.UTF8.GetBytes(key ?? GenDefaultKey()));
|
||||
|
||||
var iv = ciphertextWithIv[..16];
|
||||
var ciphertext = ciphertextWithIv[16..];
|
||||
|
||||
using var aes = Aes.Create();
|
||||
aes.Key = keyBytes;
|
||||
aes.IV = iv;
|
||||
aes.Mode = CipherMode.CFB;
|
||||
aes.Padding = PaddingMode.ISO10126;
|
||||
|
||||
using var decryptor = aes.CreateDecryptor();
|
||||
var plaintext = decryptor.TransformFinalBlock(ciphertext, 0, ciphertext.Length);
|
||||
|
||||
var json = Encoding.UTF8.GetString(plaintext);
|
||||
return JsonConvert.DeserializeObject<T>(json)!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user