Skip to content

Commit 51cc353

Browse files
committed
Add local area adjustment feature to image editor
Introduced a LocalAdjustmentRectangle for region selection and a checkbox to toggle local/global adjustments. Refactored image adjustment handlers to support applying effects to either the whole image or a selected area, improving editing flexibility. Added SetAppearance method for rectangle customization.
1 parent c4b012b commit 51cc353

File tree

3 files changed

+112
-220
lines changed

3 files changed

+112
-220
lines changed

MagickCrop/Controls/ResizableRectangle.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ public MagickGeometry CropShape
3232
(uint)rectangle.ActualHeight);
3333
}
3434

35+
/// <summary>
36+
/// Sets the stroke color and optionally hides the fill of the inner rectangle.
37+
/// </summary>
38+
public void SetAppearance(System.Windows.Media.Brush stroke, bool showFill)
39+
{
40+
rectangle.Stroke = stroke;
41+
rectangle.Fill = showFill
42+
? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue) { Opacity = 0.06 }
43+
: null;
44+
}
45+
3546
private void UserControl_MouseMove(object sender, MouseEventArgs e)
3647
{
3748
if (Mouse.LeftButton == MouseButtonState.Released

MagickCrop/MainWindow.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
Visibility="Collapsed" />
235235

236236
<local:ResizableRectangle x:Name="CroppingRectangle" Visibility="Collapsed" />
237+
<local:ResizableRectangle x:Name="LocalAdjustmentRectangle" Visibility="Collapsed" />
237238
</Canvas>
238239

239240
<!-- Pixel Precision Zoom Control - Outside ShapeCanvas to avoid being affected by canvas zoom -->
@@ -570,6 +571,14 @@
570571
<wpfui:SymbolIcon Symbol="ImageEdit24" ToolTip="Adjust image appearance" />
571572
</TabItem.Header>
572573
<StackPanel Orientation="Vertical">
574+
<CheckBox
575+
x:Name="LocalAdjustmentCheckBox"
576+
Margin="0,4"
577+
Checked="LocalAdjustmentCheckBox_Checked"
578+
Content="Local Area"
579+
IsChecked="False"
580+
ToolTip="When checked, adjustments apply only to the selected region"
581+
Unchecked="LocalAdjustmentCheckBox_Unchecked" />
573582
<MenuItem
574583
Name="AutoContrastMenuItem"
575584
Click="AutoContrastMenuItem_Click"

0 commit comments

Comments
 (0)