@@ -9,6 +9,7 @@ public sealed partial class DevToolsViewModel : ObservableObject
99 {
1010 protected readonly IFileTagsSettingsService FileTagsSettingsService = Ioc . Default . GetRequiredService < IFileTagsSettingsService > ( ) ;
1111 protected readonly IDevToolsSettingsService DevToolsSettingsService = Ioc . Default . GetRequiredService < IDevToolsSettingsService > ( ) ;
12+ private readonly ICommonDialogService CommonDialogService = Ioc . Default . GetRequiredService < ICommonDialogService > ( ) ;
1213
1314 public Dictionary < OpenInIDEOption , string > OpenInIDEOptions { get ; private set ; } = [ ] ;
1415 public ICommand RemoveCredentialsCommand { get ; }
@@ -37,21 +38,42 @@ public bool IsEditingIDEConfig
3738 public bool CanSaveIDEChanges
3839 {
3940 get => _CanSaveIDEChanges ;
40- set => SetProperty ( ref _CanSaveIDEChanges , value ) ;
41+ set => SetProperty ( ref _CanSaveIDEChanges , value ) ;
42+ }
43+
44+ private bool _IsFriendlyNameValid ;
45+ public bool IsFriendlyNameValid
46+ {
47+ get => _IsFriendlyNameValid ;
48+ set => SetProperty ( ref _IsFriendlyNameValid , value ) ;
4149 }
4250
4351 private string _IDEPath ;
4452 public string IDEPath
4553 {
4654 get => _IDEPath ;
47- set => SetProperty ( ref _IDEPath , value ) ;
55+ set
56+ {
57+ if ( SetProperty ( ref _IDEPath , value ) )
58+ CanSaveIDEChanges = IsFriendlyNameValid && ! string . IsNullOrWhiteSpace ( IDEPath ) ;
59+ }
4860 }
4961
5062 private string _IDEFriendlyName ;
5163 public string IDEFriendlyName
5264 {
5365 get => _IDEFriendlyName ;
54- set => SetProperty ( ref _IDEFriendlyName , value ) ;
66+ set
67+ {
68+ if ( SetProperty ( ref _IDEFriendlyName , value ) )
69+ {
70+ IsFriendlyNameValid =
71+ ! string . IsNullOrEmpty ( value ) &&
72+ ! value . Contains ( '\" ' ) &&
73+ ! value . Contains ( '\' ' ) ;
74+ CanSaveIDEChanges = IsFriendlyNameValid && ! string . IsNullOrWhiteSpace ( IDEPath ) ;
75+ }
76+ }
5577 }
5678
5779 public DevToolsViewModel ( )
@@ -63,6 +85,8 @@ public DevToolsViewModel()
6385
6486 IDEPath = DevToolsSettingsService . IDEPath ;
6587 IDEFriendlyName = DevToolsSettingsService . FriendlyIDEName ;
88+ IsFriendlyNameValid = true ;
89+ CanSaveIDEChanges = false ;
6690
6791 IsLogoutEnabled = GitHelpers . GetSavedCredentials ( ) != string . Empty ;
6892
@@ -112,6 +136,8 @@ private void DoCancelIDEChanges()
112136 private void DoSaveIDEChanges ( )
113137 {
114138 IsEditingIDEConfig = false ;
139+ IsFriendlyNameValid = true ;
140+ CanSaveIDEChanges = false ;
115141 DevToolsSettingsService . IDEPath = IDEPath ;
116142 DevToolsSettingsService . FriendlyIDEName = IDEFriendlyName ;
117143 }
@@ -123,7 +149,15 @@ private void DoStartEditingIDE()
123149
124150 private void DoOpenFilePickerForIDE ( )
125151 {
126-
152+ var result = CommonDialogService . Open_FileOpenDialog (
153+ MainWindow . Instance . WindowHandle ,
154+ false ,
155+ [ "*.exe;*.bat;*.cmd;*.ahk" ] ,
156+ Environment . SpecialFolder . ProgramFiles ,
157+ out var filePath
158+ ) ;
159+
160+ IDEPath = filePath ;
127161 }
128162 }
129163}
0 commit comments