@@ -5,13 +5,13 @@ namespace SmartContextMenu.Forms
55{
66 partial class SizeForm : Form
77 {
8- public int WindowLeft { get ; private set ; }
8+ public int ? WindowLeft { get ; private set ; }
99
10- public int WindowTop { get ; private set ; }
10+ public int ? WindowTop { get ; private set ; }
1111
12- public int WindowWidth { get ; private set ; }
12+ public int ? WindowWidth { get ; private set ; }
1313
14- public int WindowHeight { get ; private set ; }
14+ public int ? WindowHeight { get ; private set ; }
1515
1616 public SizeForm ( LanguageManager manager , Window window )
1717 {
@@ -28,59 +28,27 @@ private void InitializeControls(LanguageManager manager, Window window)
2828 btnApply . Text = manager . GetString ( "size_btn_apply" ) ;
2929 Text = manager . GetString ( "size_form" ) ;
3030
31- var left = window . Size . Left ;
32- var top = window . Size . Top ;
33- var width = window . Size . Width ;
34- var height = window . Size . Height ;
31+ var size = window . Size ;
3532
36- WindowLeft = left ;
37- WindowTop = top ;
38- WindowWidth = width ;
39- WindowHeight = height ;
33+ WindowLeft = size . Left ;
34+ WindowTop = size . Top ;
35+ WindowWidth = size . Width ;
36+ WindowHeight = size . Height ;
4037
41- txtLeft . Text = left . ToString ( ) ;
42- txtTop . Text = top . ToString ( ) ;
43- txtWidth . Text = width . ToString ( ) ;
44- txtHeight . Text = height . ToString ( ) ;
38+ txtLeft . Text = size . Left . ToString ( ) ;
39+ txtTop . Text = size . Top . ToString ( ) ;
40+ txtWidth . Text = size . Width . ToString ( ) ;
41+ txtHeight . Text = size . Height . ToString ( ) ;
4542
4643 DialogResult = DialogResult . Cancel ;
4744 }
4845
4946 private void ButtonApplyClick ( object sender , EventArgs e )
5047 {
51- if ( ! int . TryParse ( txtLeft . Text , out var left ) )
52- {
53- txtLeft . SelectAll ( ) ;
54- txtLeft . Focus ( ) ;
55- return ;
56- }
57-
58- if ( ! int . TryParse ( txtTop . Text , out var top ) )
59- {
60- txtTop . SelectAll ( ) ;
61- txtTop . Focus ( ) ;
62- return ;
63- }
64-
65- if ( ! int . TryParse ( txtWidth . Text , out var width ) )
66- {
67- txtWidth . SelectAll ( ) ;
68- txtWidth . Focus ( ) ;
69- return ;
70- }
71-
72- if ( ! int . TryParse ( txtHeight . Text , out var height ) )
73- {
74- txtHeight . SelectAll ( ) ;
75- txtHeight . Focus ( ) ;
76- return ;
77- }
78-
79- WindowLeft = left ;
80- WindowTop = top ;
81- WindowWidth = width ;
82- WindowHeight = height ;
83-
48+ WindowLeft = int . TryParse ( txtLeft . Text , out var left ) ? left : null ;
49+ WindowTop = int . TryParse ( txtTop . Text , out var top ) ? top : null ;
50+ WindowWidth = int . TryParse ( txtWidth . Text , out var width ) ? width : null ;
51+ WindowHeight = int . TryParse ( txtHeight . Text , out var height ) ? height : null ;
8452 DialogResult = DialogResult . OK ;
8553 Close ( ) ;
8654 }
0 commit comments