mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use data binding
This commit is contained in:
parent
cc45deec8b
commit
7f0e735cb6
3 changed files with 56 additions and 28 deletions
|
|
@ -343,7 +343,7 @@
|
||||||
<StackPanel
|
<StackPanel
|
||||||
x:Name="ResultArea"
|
x:Name="ResultArea"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Grid.ColumnSpan="2">
|
Grid.ColumnSpan="{Binding ResultAreaColumn}">
|
||||||
<Border Style="{DynamicResource WindowRadius}">
|
<Border Style="{DynamicResource WindowRadius}">
|
||||||
<Border.Clip>
|
<Border.Clip>
|
||||||
<MultiBinding Converter="{StaticResource BorderClipConverter}">
|
<MultiBinding Converter="{StaticResource BorderClipConverter}">
|
||||||
|
|
@ -397,11 +397,13 @@
|
||||||
x:Name="Preview"
|
x:Name="Preview"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
|
|
||||||
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
|
|
||||||
Style="{DynamicResource PreviewArea}"
|
Style="{DynamicResource PreviewArea}"
|
||||||
Visibility="Collapsed">
|
Visibility="{Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||||
<Border Style="{DynamicResource PreviewBorderStyle}" Visibility="{Binding ShowDefaultPreview}">
|
<Border
|
||||||
|
Style="{DynamicResource PreviewBorderStyle}"
|
||||||
|
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
|
||||||
|
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
|
||||||
|
Visibility="{Binding ShowDefaultPreview}">
|
||||||
<Grid
|
<Grid
|
||||||
Margin="20,0,10,0"
|
Margin="20,0,10,0"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
|
|
@ -472,7 +474,11 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
<Border Style="{DynamicResource PreviewBorderStyle}" Visibility="{Binding ShowCustomizedPreview}">
|
<Border
|
||||||
|
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
|
||||||
|
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
|
||||||
|
Style="{DynamicResource PreviewBorderStyle}"
|
||||||
|
Visibility="{Binding ShowCustomizedPreview}">
|
||||||
<ContentControl Content="{Binding Result.PreviewPanel.Value}" />
|
<ContentControl Content="{Binding Result.PreviewPanel.Value}" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
|
|
@ -633,30 +633,11 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
public void PreviewReset()
|
public void PreviewReset()
|
||||||
{
|
{
|
||||||
if (_settings.AlwaysPreview == true)
|
_viewModel.ResetPreview();
|
||||||
{
|
|
||||||
ResultArea.SetValue(Grid.ColumnSpanProperty, 1);
|
|
||||||
Preview.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ResultArea.SetValue(Grid.ColumnSpanProperty, 2);
|
|
||||||
Preview.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void PreviewToggle()
|
public void PreviewToggle()
|
||||||
{
|
{
|
||||||
|
_viewModel.TogglePreview();
|
||||||
if (Preview.Visibility == Visibility.Collapsed)
|
|
||||||
{
|
|
||||||
ResultArea.SetValue(Grid.ColumnSpanProperty, 1);
|
|
||||||
Preview.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ResultArea.SetValue(Grid.ColumnSpanProperty, 2);
|
|
||||||
Preview.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveQueryTextToEnd()
|
private void MoveQueryTextToEnd()
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
RegisterResultsUpdatedEvent();
|
RegisterResultsUpdatedEvent();
|
||||||
RegisterClockAndDateUpdateAsync();
|
RegisterClockAndDateUpdateAsync();
|
||||||
|
|
||||||
SetOpenResultModifiers();
|
SetOpenResultModifiers(); // TODO?
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterViewUpdate()
|
private void RegisterViewUpdate()
|
||||||
|
|
@ -424,6 +424,43 @@ namespace Flow.Launcher.ViewModel
|
||||||
Settings.MaxResultsToShow -= 1;
|
Settings.MaxResultsToShow -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
public void TogglePreview()
|
||||||
|
{
|
||||||
|
if (!PreviewVisible)
|
||||||
|
{
|
||||||
|
ShowPreview();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HidePreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowPreview()
|
||||||
|
{
|
||||||
|
ResultAreaColumn = 1;
|
||||||
|
PreviewVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HidePreview()
|
||||||
|
{
|
||||||
|
ResultAreaColumn = 2;
|
||||||
|
PreviewVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetPreview()
|
||||||
|
{
|
||||||
|
if (Settings.AlwaysPreview == true)
|
||||||
|
{
|
||||||
|
ShowPreview();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HidePreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// we need move cursor to end when we manually changed query
|
/// we need move cursor to end when we manually changed query
|
||||||
/// but we don't want to move cursor to end when query is updated from TextBox
|
/// but we don't want to move cursor to end when query is updated from TextBox
|
||||||
|
|
@ -519,6 +556,10 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
public bool StartWithEnglishMode => Settings.AlwaysStartEn;
|
public bool StartWithEnglishMode => Settings.AlwaysStartEn;
|
||||||
|
|
||||||
|
public bool PreviewVisible { get; set; } = false;
|
||||||
|
|
||||||
|
public int ResultAreaColumn { get; set; } = 1;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void Query()
|
public void Query()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue