Files
Chronos/src/Chronos.App/Editor/CropCommit.cs
T
Alby96andClaude Opus 5.5 188b2c2e55
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) (#26)
Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.

Closes #19
Closes #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-11-05 01:09:09 +01:00

32 lines
1.3 KiB
C#

using System.Windows;
using System.Windows.Input;
using Chronos.Ui.Visuals;
namespace Chronos.App.Editor;
/// <summary>
/// Runs a command after every finished edit of the crop box on a <see cref="PreviewViewport"/> (a drag released, a key
/// press), with the <see cref="CropEditEventArgs"/> as its parameter (owner review 1, R5).
/// </summary>
public static class CropCommit
{
public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached(
"Command", typeof(ICommand), typeof(CropCommit), new PropertyMetadata(null, OnCommandChanged));
public static ICommand? GetCommand(DependencyObject d) => (ICommand?)d.GetValue(CommandProperty);
public static void SetCommand(DependencyObject d, ICommand? value) => d.SetValue(CommandProperty, value);
private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not PreviewViewport viewport) return;
viewport.CropEditCompleted -= OnEditCompleted;
if (e.NewValue is not null) viewport.CropEditCompleted += OnEditCompleted;
}
private static void OnEditCompleted(object sender, CropEditEventArgs e)
{
if (GetCommand((DependencyObject)sender) is { } command && command.CanExecute(e)) command.Execute(e);
}
}