99 Name =" UI"
1010 Title =" Crop Image"
1111 SizeToContent =" WidthAndHeight"
12- WindowStartupLocation =" CenterOwner "
13- MinHeight =" 500 " MinWidth =" 500 " >
12+ WindowStartupLocation =" CenterScreen "
13+ MinHeight =" 620 " MinWidth =" 400 " >
1414 <DockPanel DataContext =" {Binding ElementName=UI}" Margin =" 15" >
15+ <DockPanel .Resources>
16+ <SolidColorBrush x : Key =" CropFrameBrush" Color =" WhiteSmoke" />
17+ </DockPanel .Resources>
1518 <StackPanel DockPanel.Dock=" Bottom" >
16-
1719 <DockPanel VerticalAlignment =" Bottom" >
1820 <StackPanel DockPanel.Dock=" Right" VerticalAlignment =" Bottom" >
19- <Button Command =" {Binding CropCommand}" Content =" Crop" Width =" 100" Height =" 25" ></Button >
21+ <Button Content =" Crop" Command =" {Binding CropCommand}" Visibility =" {Binding IsCropped, Converter={StaticResource InverseBooleanToVisibilityConverter}}" Width =" 100" Height =" 25" ></Button >
22+ <Button Content =" Reset" Command =" {Binding ResetCommand}" Visibility =" {Binding IsCropped, Converter={StaticResource BooleanToVisibilityConverter}}" Width =" 100" Height =" 25" ></Button >
2023 </StackPanel >
21-
2224 <StackPanel >
2325 <TextBlock Text =" Image File" />
2426 <userControls : FilePickerTextBox FileName =" {Binding ImageFile, Mode=TwoWay}" IsRequired =" True" />
2527 </StackPanel >
26-
2728 </DockPanel >
28-
2929 <UniformGrid Columns =" 4" Margin =" 0,25,0,0" >
3030 <TextBlock />
3131 <TextBlock />
3232 <Button IsCancel =" True" Command =" {Binding CancelCommand}" MinWidth =" 100" Height =" 30" >_Cancel</Button >
33- <Button IsDefault =" True" Command =" {Binding OkCommand }" MinWidth =" 100" Height =" 30" >_Ok </Button >
33+ <Button IsDefault =" True" Command =" {Binding DoneCommand }" MinWidth =" 100" Height =" 30" >_Done </Button >
3434 </UniformGrid >
3535 </StackPanel >
36-
37- <StackPanel >
38- <Canvas Width =" {Binding ImageWidth}" Height =" {Binding ImageHeight}" MouseWheel =" Canvas_MouseWheel" >
39- <Image Source =" {Binding SourceImage}" Width =" {Binding ImageWidth}" Height =" {Binding ImageHeight}" />
40- <Rectangle x : Name =" CropFrame" Stroke =" Gainsboro" StrokeThickness =" 2" Width =" {Binding ZoomWidth}" Height =" {Binding ZoomHeight}" Fill =" Transparent" MouseLeftButtonUp =" Canvas_MouseLeftButtonUp" MouseLeftButtonDown =" Canvas_MouseLeftButtonDown" MouseMove =" Canvas_MouseMove" />
36+ <Border BorderThickness =" 2" BorderBrush =" Gainsboro" >
37+ <Canvas Width =" {Binding ImageWidth}" Height =" {Binding ImageHeight}" MouseWheel =" CropFrame_MouseWheel" >
38+ <Image Source =" {Binding SourceImage, FallbackValue={StaticResource PlaceholderImage}, TargetNullValue={StaticResource PlaceholderImage}}" Width =" {Binding ImageWidth}" Height =" {Binding ImageHeight}" />
39+ <Canvas x : Name =" CropFrame" Width =" {Binding ZoomWidth}" Height =" {Binding ZoomHeight}" Visibility =" {Binding IsCropped, Converter={StaticResource InverseBooleanToVisibilityConverter}}" MouseLeftButtonUp =" CropFrame_MouseLeftButtonUp" MouseLeftButtonDown =" CropFrame_MouseLeftButtonDown" MouseMove =" CropFrame_MouseMove" >
40+ <Grid >
41+ <Rectangle Width =" {Binding Width, ElementName=CropFrame}" Height =" {Binding Height, ElementName=CropFrame}" Stroke =" {StaticResource CropFrameBrush}" StrokeThickness =" 2" Fill =" Transparent" />
42+ <Grid Background =" Transparent" >
43+ <StackPanel VerticalAlignment =" Center" HorizontalAlignment =" Center" >
44+ <userControls : FontAwesome Icon ="  " IconStyle =" Light" Size =" 40" Color =" {StaticResource CropFrameBrush}" />
45+ <TextBlock Text =" Drag to move" Foreground =" {StaticResource CropFrameBrush}" HorizontalAlignment =" Center" />
46+ <TextBlock Text =" Mouse wheel to zoom" Foreground =" {StaticResource CropFrameBrush}" HorizontalAlignment =" Center" />
47+ </StackPanel >
48+ <Grid .Style>
49+ <Style TargetType =" {x:Type Grid}" >
50+ <Setter Property =" Opacity" Value =" 0" />
51+ <Style .Triggers>
52+ <Trigger Property =" IsMouseOver" Value =" True" >
53+ <Trigger .EnterActions>
54+ <BeginStoryboard >
55+ <Storyboard >
56+ <DoubleAnimation Storyboard.TargetProperty=" Opacity" To =" .7" Duration =" 0:0:0.3" />
57+ </Storyboard >
58+ </BeginStoryboard >
59+ </Trigger .EnterActions>
60+ <Trigger .ExitActions>
61+ <BeginStoryboard >
62+ <Storyboard >
63+ <DoubleAnimation Storyboard.TargetProperty=" Opacity" To =" 0" Duration =" 0:0:0.3" />
64+ </Storyboard >
65+ </BeginStoryboard >
66+ </Trigger .ExitActions>
67+ </Trigger >
68+ </Style .Triggers>
69+ </Style >
70+ </Grid .Style>
71+ </Grid >
72+ </Grid >
73+ </Canvas >
4174 </Canvas >
42- </StackPanel >
75+ </Border >
4376 </DockPanel >
4477</Window >
0 commit comments