11using System ;
22using System . Drawing ;
33using System . Windows . Input ;
4+ using Reactive . Bindings ;
45
56// ReSharper disable MemberCanBePrivate.Global
67
@@ -21,25 +22,31 @@ public class RegionSelectorViewModel : NotifyPropertyChanged
2122
2223 public RegionSelectorViewModel ( )
2324 {
24- MoveLeftCommand = new DelegateCommand ( ( ) => Left -= KeyMoveDelta ) ;
25- MoveRightCommand = new DelegateCommand ( ( ) => Left += KeyMoveDelta ) ;
26- MoveUpCommand = new DelegateCommand ( ( ) => Top -= KeyMoveDelta ) ;
27- MoveDownCommand = new DelegateCommand ( ( ) => Top += KeyMoveDelta ) ;
28-
29- IncreaseWidthCommand = new DelegateCommand ( ( ) => Width += KeyMoveDelta ) ;
30- DecreaseWidthCommand = new DelegateCommand ( ( ) => Width -= KeyMoveDelta ) ;
31- IncreaseHeightCommand = new DelegateCommand ( ( ) => Height += KeyMoveDelta ) ;
32- DecreaseHeightCommand = new DelegateCommand ( ( ) => Height -= KeyMoveDelta ) ;
25+ MoveLeftCommand = new ReactiveCommand ( )
26+ . WithSubscribe ( ( ) => Left -= KeyMoveDelta ) ;
27+ MoveRightCommand = new ReactiveCommand ( )
28+ . WithSubscribe ( ( ) => Left += KeyMoveDelta ) ;
29+ MoveUpCommand = new ReactiveCommand ( )
30+ . WithSubscribe ( ( ) => Top -= KeyMoveDelta ) ;
31+ MoveDownCommand = new ReactiveCommand ( )
32+ . WithSubscribe ( ( ) => Top += KeyMoveDelta ) ;
33+
34+ IncreaseWidthCommand = new ReactiveCommand ( )
35+ . WithSubscribe ( ( ) => Width += KeyMoveDelta ) ;
36+ DecreaseWidthCommand = new ReactiveCommand ( )
37+ . WithSubscribe ( ( ) => Width -= KeyMoveDelta ) ;
38+ IncreaseHeightCommand = new ReactiveCommand ( )
39+ . WithSubscribe ( ( ) => Height += KeyMoveDelta ) ;
40+ DecreaseHeightCommand = new ReactiveCommand ( )
41+ . WithSubscribe ( ( ) => Height -= KeyMoveDelta ) ;
3342 }
3443
3544 public int Left
3645 {
3746 get => _left ;
3847 set
3948 {
40- _left = value ;
41-
42- OnPropertyChanged ( ) ;
49+ Set ( ref _left , value ) ;
4350 RaisePropertyChanged ( nameof ( LeftDip ) ) ;
4451 }
4552 }
@@ -55,9 +62,7 @@ public int Top
5562 get => _top ;
5663 set
5764 {
58- _top = value ;
59-
60- OnPropertyChanged ( ) ;
65+ Set ( ref _top , value ) ;
6166 RaisePropertyChanged ( nameof ( TopDip ) ) ;
6267 }
6368 }
@@ -73,9 +78,7 @@ public int Width
7378 get => _width ;
7479 set
7580 {
76- _width = Math . Max ( value , MinWidth ) ;
77-
78- OnPropertyChanged ( ) ;
81+ Set ( ref _width , Math . Max ( value , MinWidth ) ) ;
7982 RaisePropertyChanged ( nameof ( WidthDip ) ) ;
8083 }
8184 }
@@ -91,9 +94,7 @@ public int Height
9194 get => _height ;
9295 set
9396 {
94- _height = Math . Max ( value , MinHeight ) ;
95-
96- OnPropertyChanged ( ) ;
97+ Set ( ref _height , Math . Max ( value , MinHeight ) ) ;
9798 RaisePropertyChanged ( nameof ( HeightDip ) ) ;
9899 }
99100 }
0 commit comments