17
17
using Stratis . VS . StratisEVM . UI . ViewModel ;
18
18
using Stratis . DevEx . Ethereum ;
19
19
using static Stratis . DevEx . Result ;
20
+ using System . IO ;
21
+ using Stratis . DevEx ;
20
22
21
23
namespace Stratis . VS . StratisEVM . UI
22
24
{
@@ -28,7 +30,7 @@ public partial class BlockchainExplorerToolWindowControl : UserControl
28
30
/// <summary>
29
31
/// Initializes a new instance of the <see cref="BlockchainExplorerToolWindowControl"/> class.
30
32
/// </summary>
31
- public BlockchainExplorerToolWindowControl ( )
33
+ public BlockchainExplorerToolWindowControl ( ) : base ( )
32
34
{
33
35
var _ = new Wpf . Ui . Controls . Card ( ) ; // Bug workaround, see https://github.com/microsoft/XamlBehaviorsWpf/issues/86
34
36
InitializeComponent ( ) ;
@@ -149,14 +151,20 @@ private async void NewNetworkCmd_Executed(object sender, ExecutedRoutedEventArgs
149
151
endpoints . AddChild ( BlockchainInfoKind . Endpoint , rpcurl . Text ) ;
150
152
if ( ! tree . RootItem . Save ( "BlockchainExplorerTree" , out var ex ) )
151
153
{
152
- #if ! IS_VSIX
153
- System . Windows . MessageBox . Show ( "Error saving tree data: " + ex ? . Message ) ;
154
+ #if IS_VSIX
155
+ VSUtil . ShowModalErrorDialogBox ( "Error saving tree data: " + ex ? . Message ) ;
156
+ #else
157
+ System . Windows . MessageBox . Show ( "Error saving tree data: " + ex ? . Message ) ;
154
158
#endif
155
159
}
156
160
}
157
161
catch ( Exception ex )
158
162
{
159
- System . Windows . MessageBox . Show ( ex . Message ) ;
163
+ #if IS_VSIX
164
+ VSUtil . ShowModalErrorDialogBox ( ex ? . Message ) ;
165
+ #else
166
+ System . Windows . MessageBox . Show ( ex ? . Message ) ;
167
+ #endif
160
168
}
161
169
}
162
170
@@ -230,7 +238,11 @@ private async void NewEndpointCmd_Executed(object sender, ExecutedRoutedEventArg
230
238
}
231
239
catch ( Exception ex )
232
240
{
233
- System . Windows . MessageBox . Show ( ex . Message ) ;
241
+ #if IS_VSIX
242
+ VSUtil . ShowModalErrorDialogBox ( ex ? . Message ) ;
243
+ #else
244
+ System . Windows . MessageBox . Show ( ex ? . Message ) ;
245
+ #endif
234
246
}
235
247
}
236
248
@@ -355,30 +367,19 @@ private async void NewFolderCmd_Executed(object sender, ExecutedRoutedEventArgs
355
367
var f = item . AddChild ( BlockchainInfoKind . UserFolder , foldername . Text ) ;
356
368
if ( ! item . Save ( "BlockchainExplorerTree" , out var ex ) )
357
369
{
358
- #if ! IS_VSIX
359
- System . Windows . MessageBox . Show ( "Error saving tree data: " + ex ? . Message ) ;
370
+ #if IS_VSIX
371
+ VSUtil . ShowModalErrorDialogBox ( "Error saving tree data: " + ex ? . Message ) ;
360
372
#else
361
- var dialog = new Microsoft . VisualStudio . PlatformUI . DialogWindow ( )
362
- {
363
- Title = "Error" ,
364
- Content = "Error saving Blockchain Explorer tree state: " + ex ? . Message ,
365
- } ;
366
- dialog . ShowModal ( ) ;
373
+ System . Windows . MessageBox . Show ( "Error saving tree data: " + ex ? . Message ) ;
367
374
#endif
368
375
}
369
376
}
370
377
catch ( Exception ex )
371
378
{
372
- #if ! IS_VSIX
373
- System . Windows . MessageBox . Show ( ex . Message ) ;
379
+ #if IS_VSIX
380
+ VSUtil . ShowModalErrorDialogBox ( ex ? . Message ) ;
374
381
#else
375
-
376
- var dialog = new Microsoft . VisualStudio . PlatformUI . DialogWindow ( )
377
- {
378
- Title = "Error" ,
379
- Content = "Error saving Blockchain Explorer tree state: " + ex ? . Message ,
380
- } ;
381
- dialog . ShowModal ( ) ;
382
+ System . Windows . MessageBox . Show ( ex ? . Message ) ;
382
383
#endif
383
384
}
384
385
}
@@ -391,8 +392,10 @@ private void DeleteFolderCmd_Executed(object sender, ExecutedRoutedEventArgs e)
391
392
item . Parent . DeleteChild ( item ) ;
392
393
if ( ! tree . RootItem . Save ( "BlockchainExplorerTree" , out var ex ) )
393
394
{
394
- #if ! IS_VSIX
395
- System . Windows . MessageBox . Show ( "Error saving tree data: " + ex ? . Message ) ;
395
+ #if IS_VSIX
396
+ VSUtil . ShowModalErrorDialogBox ( "Error saving tree data: " + ex ? . Message ) ;
397
+ #else
398
+ System . Windows . MessageBox . Show ( "Error saving tree data: " + ex ? . Message ) ;
396
399
#endif
397
400
}
398
401
}
@@ -405,15 +408,16 @@ private void DeleteNetworkCmd_Executed(object sender, ExecutedRoutedEventArgs e)
405
408
item . Parent . DeleteChild ( item ) ;
406
409
if ( ! tree . RootItem . Save ( "BlockchainExplorerTree" , out var ex ) )
407
410
{
408
- #if ! IS_VSIX
409
- System . Windows . MessageBox . Show ( "Error saving tree data: " + ex ? . Message ) ;
411
+ #if IS_VSIX
412
+ VSUtil . ShowModalErrorDialogBox ( "Error saving tree data: " + ex ? . Message ) ;
413
+ #else
414
+ System . Windows . MessageBox . Show ( "Error saving tree data: " + ex ? . Message ) ;
410
415
#endif
411
416
}
412
417
}
413
418
414
419
private void DeleteNetworkCmd_CanExecute ( object sender , CanExecuteRoutedEventArgs e )
415
420
{
416
-
417
421
var item = GetSelectedItem ( sender ) ;
418
422
if ( item . Name == "Stratis Mainnet" )
419
423
{
@@ -422,8 +426,7 @@ private void DeleteNetworkCmd_CanExecute(object sender, CanExecuteRoutedEventArg
422
426
else
423
427
{
424
428
e . CanExecute = true ;
425
- }
426
-
429
+ }
427
430
}
428
431
}
429
432
}
0 commit comments