File tree Expand file tree Collapse file tree 3 files changed +56
-28
lines changed Expand file tree Collapse file tree 3 files changed +56
-28
lines changed Original file line number Diff line number Diff line change 343
343
<StackPanel
344
344
x : Name =" ResultArea"
345
345
Grid.Column=" 0"
346
- Grid.ColumnSpan=" 2 " >
346
+ Grid.ColumnSpan=" {Binding ResultAreaColumn} " >
347
347
<Border Style =" {DynamicResource WindowRadius}" >
348
348
<Border .Clip>
349
349
<MultiBinding Converter =" {StaticResource BorderClipConverter}" >
397
397
x : Name =" Preview"
398
398
Grid.Column=" 1"
399
399
VerticalAlignment =" Stretch"
400
- d : DataContext =" {d:DesignInstance vm:ResultViewModel}"
401
- DataContext =" {Binding SelectedItem, ElementName=ResultListBox}"
402
400
Style =" {DynamicResource PreviewArea}"
403
- Visibility =" Collapsed" >
404
- <Border Style =" {DynamicResource PreviewBorderStyle}" Visibility =" {Binding ShowDefaultPreview}" >
401
+ Visibility =" {Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}" >
402
+ <Border
403
+ Style =" {DynamicResource PreviewBorderStyle}"
404
+ d : DataContext =" {d:DesignInstance vm:ResultViewModel}"
405
+ DataContext =" {Binding SelectedItem, ElementName=ResultListBox}"
406
+ Visibility =" {Binding ShowDefaultPreview}" >
405
407
<Grid
406
408
Margin =" 20,0,10,0"
407
409
VerticalAlignment =" Stretch"
472
474
</StackPanel >
473
475
</Grid >
474
476
</Border >
475
- <Border Style =" {DynamicResource PreviewBorderStyle}" Visibility =" {Binding ShowCustomizedPreview}" >
477
+ <Border
478
+ d : DataContext =" {d:DesignInstance vm:ResultViewModel}"
479
+ DataContext =" {Binding SelectedItem, ElementName=ResultListBox}"
480
+ Style =" {DynamicResource PreviewBorderStyle}"
481
+ Visibility =" {Binding ShowCustomizedPreview}" >
476
482
<ContentControl Content =" {Binding Result.PreviewPanel.Value}" />
477
483
</Border >
478
484
</Grid >
Original file line number Diff line number Diff line change @@ -633,30 +633,11 @@ private void OnKeyDown(object sender, KeyEventArgs e)
633
633
634
634
public void PreviewReset ( )
635
635
{
636
- if ( _settings . AlwaysPreview == true )
637
- {
638
- ResultArea . SetValue ( Grid . ColumnSpanProperty , 1 ) ;
639
- Preview . Visibility = Visibility . Visible ;
640
- }
641
- else
642
- {
643
- ResultArea . SetValue ( Grid . ColumnSpanProperty , 2 ) ;
644
- Preview . Visibility = Visibility . Collapsed ;
645
- }
636
+ _viewModel . ResetPreview ( ) ;
646
637
}
647
638
public void PreviewToggle ( )
648
639
{
649
-
650
- if ( Preview . Visibility == Visibility . Collapsed )
651
- {
652
- ResultArea . SetValue ( Grid . ColumnSpanProperty , 1 ) ;
653
- Preview . Visibility = Visibility . Visible ;
654
- }
655
- else
656
- {
657
- ResultArea . SetValue ( Grid . ColumnSpanProperty , 2 ) ;
658
- Preview . Visibility = Visibility . Collapsed ;
659
- }
640
+ _viewModel . TogglePreview ( ) ;
660
641
}
661
642
662
643
private void MoveQueryTextToEnd ( )
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ public MainViewModel(Settings settings)
104
104
RegisterResultsUpdatedEvent ( ) ;
105
105
RegisterClockAndDateUpdateAsync ( ) ;
106
106
107
- SetOpenResultModifiers ( ) ;
107
+ SetOpenResultModifiers ( ) ; // TODO?
108
108
}
109
109
110
110
private void RegisterViewUpdate ( )
@@ -424,6 +424,43 @@ private void DecreaseMaxResult()
424
424
Settings . MaxResultsToShow -= 1 ;
425
425
}
426
426
427
+ [ RelayCommand ]
428
+ public void TogglePreview ( )
429
+ {
430
+ if ( ! PreviewVisible )
431
+ {
432
+ ShowPreview ( ) ;
433
+ }
434
+ else
435
+ {
436
+ HidePreview ( ) ;
437
+ }
438
+ }
439
+
440
+ private void ShowPreview ( )
441
+ {
442
+ ResultAreaColumn = 1 ;
443
+ PreviewVisible = true ;
444
+ }
445
+
446
+ private void HidePreview ( )
447
+ {
448
+ ResultAreaColumn = 2 ;
449
+ PreviewVisible = false ;
450
+ }
451
+
452
+ public void ResetPreview ( )
453
+ {
454
+ if ( Settings . AlwaysPreview == true )
455
+ {
456
+ ShowPreview ( ) ;
457
+ }
458
+ else
459
+ {
460
+ HidePreview ( ) ;
461
+ }
462
+ }
463
+
427
464
/// <summary>
428
465
/// we need move cursor to end when we manually changed query
429
466
/// but we don't want to move cursor to end when query is updated from TextBox
@@ -519,6 +556,10 @@ public double MainWindowWidth
519
556
520
557
public bool StartWithEnglishMode => Settings . AlwaysStartEn ;
521
558
559
+ public bool PreviewVisible { get ; set ; } = false ;
560
+
561
+ public int ResultAreaColumn { get ; set ; } = 1 ;
562
+
522
563
#endregion
523
564
524
565
public void Query ( )
You can’t perform that action at this time.
0 commit comments