@@ -30,9 +30,7 @@ public static async Task ShowAddProfileDialog(IProfileManager viewModel, IDialog
30
30
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
31
31
viewModel . OnProfileDialogClose ( ) ;
32
32
33
- AddProfile ( instance ) ;
34
-
35
- viewModel . RefreshProfiles ( ) ;
33
+ ProfileManager . AddProfile ( ParseProfileInfo ( instance ) ) ;
36
34
} , async instance =>
37
35
{
38
36
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
@@ -62,10 +60,7 @@ public static async Task ShowEditProfileDialog(IProfileManager viewModel, IDialo
62
60
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
63
61
viewModel . OnProfileDialogClose ( ) ;
64
62
65
- RemoveProfile ( profile ) ;
66
- AddProfile ( instance ) ;
67
-
68
- viewModel . RefreshProfiles ( ) ;
63
+ ProfileManager . ReplaceProfile ( profile , ParseProfileInfo ( instance ) ) ;
69
64
} , async instance =>
70
65
{
71
66
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
@@ -94,9 +89,7 @@ public static async Task ShowCopyAsProfileDialog(IProfileManager viewModel, IDia
94
89
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
95
90
viewModel . OnProfileDialogClose ( ) ;
96
91
97
- AddProfile ( instance ) ;
98
-
99
- viewModel . RefreshProfiles ( ) ;
92
+ ProfileManager . AddProfile ( ParseProfileInfo ( instance ) ) ;
100
93
} , async instance =>
101
94
{
102
95
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
@@ -124,10 +117,8 @@ public static async Task ShowDeleteProfileDialog(IProfileManager viewModel, IDia
124
117
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
125
118
viewModel . OnProfileDialogClose ( ) ;
126
119
127
- foreach ( var profile in profiles )
128
- RemoveProfile ( profile ) ;
120
+ ProfileManager . RemoveProfiles ( profiles ) ;
129
121
130
- viewModel . RefreshProfiles ( ) ;
131
122
} , async instance =>
132
123
{
133
124
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
@@ -158,9 +149,7 @@ public static async Task ShowAddGroupDialog(IProfileManager viewModel, IDialogCo
158
149
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
159
150
viewModel . OnProfileDialogClose ( ) ;
160
151
161
- AddGroup ( instance ) ;
162
-
163
- viewModel . RefreshProfiles ( ) ;
152
+ ProfileManager . AddGroup ( ParseGroupInfo ( instance ) ) ;
164
153
} , async instance =>
165
154
{
166
155
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
@@ -189,10 +178,7 @@ public static async Task ShowEditGroupDialog(IProfileManager viewModel, IDialogC
189
178
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
190
179
viewModel . OnProfileDialogClose ( ) ;
191
180
192
- RemoveGroup ( instance . Group ) ;
193
- AddGroup ( instance ) ;
194
-
195
- viewModel . RefreshProfiles ( ) ;
181
+ ProfileManager . ReplaceGroup ( instance . Group , ParseGroupInfo ( instance ) ) ;
196
182
} , async instance =>
197
183
{
198
184
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
@@ -220,9 +206,7 @@ public static async Task ShowDeleteGroupDialog(IProfileManager viewModel, IDialo
220
206
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
221
207
viewModel . OnProfileDialogClose ( ) ;
222
208
223
- RemoveGroup ( group ) ;
224
-
225
- viewModel . RefreshProfiles ( ) ;
209
+ ProfileManager . RemoveGroup ( group ) ;
226
210
} , async instance =>
227
211
{
228
212
await dialogCoordinator . HideMetroDialogAsync ( viewModel , customDialog ) ;
@@ -240,9 +224,9 @@ public static async Task ShowDeleteGroupDialog(IProfileManager viewModel, IDialo
240
224
#endregion
241
225
242
226
#region Methods to add and remove profile
243
- public static void AddProfile ( ProfileViewModel instance )
227
+ public static ProfileInfo ParseProfileInfo ( ProfileViewModel instance )
244
228
{
245
- ProfileManager . AddProfile ( new ProfileInfo
229
+ return new ProfileInfo
246
230
{
247
231
Name = instance . Name . Trim ( ) ,
248
232
Host = instance . Host . Trim ( ) ,
@@ -383,17 +367,12 @@ public static void AddProfile(ProfileViewModel instance)
383
367
Whois_Enabled = instance . Whois_Enabled ,
384
368
Whois_InheritHost = instance . Whois_InheritHost ,
385
369
Whois_Domain = instance . Whois_InheritHost ? instance . Host ? . Trim ( ) : instance . Whois_Domain ? . Trim ( )
386
- } ) ;
387
- }
388
-
389
- public static void RemoveProfile ( ProfileInfo profile )
390
- {
391
- ProfileManager . RemoveProfile ( profile ) ;
370
+ } ;
392
371
}
393
372
#endregion
394
373
395
374
#region Methods to add and remove group
396
- public static void AddGroup ( GroupViewModel instance )
375
+ public static GroupInfo ParseGroupInfo ( GroupViewModel instance )
397
376
{
398
377
List < ProfileInfo > profiles = instance . Group . Profiles ;
399
378
@@ -413,7 +392,7 @@ public static void AddGroup(GroupViewModel instance)
413
392
}
414
393
}
415
394
416
- ProfileManager . AddGroup ( new GroupInfo
395
+ return new GroupInfo
417
396
{
418
397
Name = name ,
419
398
@@ -498,12 +477,7 @@ public static void AddGroup(GroupViewModel instance)
498
477
TigerVNC_Enabled = instance . TigerVNC_Enabled ,
499
478
TigerVNC_OverridePort = instance . TigerVNC_OverridePort ,
500
479
TigerVNC_Port = instance . TigerVNC_Port
501
- } ) ;
502
- }
503
-
504
- public static void RemoveGroup ( GroupInfo group )
505
- {
506
- ProfileManager . RemoveGroup ( group ) ;
480
+ } ;
507
481
}
508
482
#endregion
509
483
}
0 commit comments