- Add CustomQuery Hotkey Tips String

- Adjust CustomQueryHotkey Setting Popup Layout
- Change HotkeyControl to using popup
- Add some code to closing popup when click out area
This commit is contained in:
DB p 2021-10-30 08:33:52 +09:00
parent 43a62d0d12
commit 0e5d5ec90b
7 changed files with 84 additions and 7 deletions

View file

@ -5,7 +5,8 @@
Icon="Images\app.png"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Title="{DynamicResource customeQueryHotkeyTitle}" Height="200" Width="674.766">
MouseDown="window_MouseDown"
Title="{DynamicResource customeQueryHotkeyTitle}" Height="345" Width="500" Background="#F3F3F3" BorderBrush="#cecece">
<Window.InputBindings>
<KeyBinding Key="Escape" Command="Close"/>
</Window.InputBindings>
@ -13,6 +14,48 @@
<CommandBinding Command="Close" Executed="cmdEsc_OnPress"/>
</Window.CommandBindings>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Border BorderThickness="0 0 0 1" BorderBrush="#e5e5e5" Background="#ffffff" Padding="26 26 26 0">
<Grid>
<StackPanel>
<StackPanel Grid.Row="0" Margin="0 0 0 12">
<TextBlock Grid.Column="0" Text="{DynamicResource customeQueryHotkeyTitle}" FontSize="20" FontWeight="SemiBold" FontFamily="Segoe UI" TextAlignment="Left"
Margin="0 0 0 0" />
</StackPanel>
<StackPanel>
<TextBlock
Text="{DynamicResource customeQueryHotkeyTips}" Foreground="#1b1b1b" FontSize="14" TextWrapping="WrapWithOverflow" TextAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 20 0 0">
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
HorizontalAlignment="Left" Text="{DynamicResource hotkey}" Width="60"/>
<flowlauncher:HotkeyControl x:Name="ctlHotkey" Margin="10,0,10,0" Grid.Column="1" VerticalAlignment="Center" Height="32" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Width="200"/>
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"
HorizontalAlignment="Left" Text="{DynamicResource actionKeyword}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 0 0 0">
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Width="60"
HorizontalAlignment="Left" Text="{DynamicResource customQuery}" />
<TextBox x:Name="tbAction" Margin="10" Width="250" VerticalAlignment="Center" HorizontalAlignment="Left" />
<Button x:Name="btnTestActionKeyword" Padding="10 5 10 5" Height="30" Click="BtnTestActionKeyword_OnClick"
Content="{DynamicResource preview}" />
</StackPanel>
</StackPanel>
</Grid>
</Border>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1">
<Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 5 0" Width="100" Height="32"
Content="{DynamicResource cancel}" />
<Button x:Name="btnAdd" Margin="5 0 10 0" Width="100" Height="32" Click="btnAdd_OnClick">
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
</Button>
</StackPanel>
<!--
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
@ -41,5 +84,6 @@
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
</Button>
</StackPanel>
-->
</Grid>
</Window>

View file

@ -7,6 +7,8 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
namespace Flow.Launcher
{
@ -99,5 +101,15 @@ namespace Flow.Launcher
{
Close();
}
private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */
{
TextBox textBox = Keyboard.FocusedElement as TextBox;
if (textBox != null)
{
TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
textBox.MoveFocus(tRequest);
}
}
}
}

View file

@ -9,11 +9,18 @@
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="125" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="tbMsg" Visibility="Hidden" Margin="8 0 0 0" VerticalAlignment="Center" Grid.Column="0" HorizontalAlignment="Right"/>
<TextBox x:Name="tbHotkey" TabIndex="100" VerticalContentAlignment="Center" Grid.Column="1"
PreviewKeyDown="TbHotkey_OnPreviewKeyDown" input:InputMethod.IsInputMethodEnabled="False" Margin="5 0 18 0"/>
<Popup x:Name="popup" AllowDrop="True" PopupAnimation="Fade" PlacementTarget="{Binding ElementName=tbHotkey}" IsOpen="{Binding IsKeyboardFocused, ElementName=tbHotkey, Mode=OneWay}" StaysOpen="True" AllowsTransparency="True" Placement="Top" VerticalOffset="-5">
<Border Background="#f6f6f6" BorderBrush="#cecece" BorderThickness="1" CornerRadius="6" Width="120" Height="30">
<TextBlock x:Name="tbMsg" FontSize="13" FontWeight="SemiBold" Visibility="Visible" Margin="0 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Center">
press key
</TextBlock>
</Border>
</Popup>
<TextBox x:Name="tbHotkey" TabIndex="100" VerticalContentAlignment="Center"
PreviewKeyDown="TbHotkey_OnPreviewKeyDown" input:InputMethod.IsInputMethodEnabled="False" Margin="0 0 18 0">
</TextBox>
</Grid>
</UserControl>

View file

@ -81,6 +81,8 @@ namespace Flow.Launcher
}
}
public void SetHotkey(string keyStr, bool triggerValidate = true)
{
SetHotkey(new HotkeyModel(keyStr), triggerValidate);

View file

@ -149,7 +149,8 @@
<system:String x:Key="actionkeyword_tips">Use * if you don't want to specify an action keyword</system:String>
<!--Custom Query Hotkey Dialog-->
<system:String x:Key="customeQueryHotkeyTitle">Custom Plugin Hotkey</system:String>
<system:String x:Key="customeQueryHotkeyTitle">Custom Query Hotkey</system:String>
<system:String x:Key="customeQueryHotkeyTips">Press the custom hotkey to automatically insert the specified query.</system:String>
<system:String x:Key="preview">Preview</system:String>
<system:String x:Key="hotkeyIsNotUnavailable">Hotkey is unavailable, please select a new hotkey</system:String>
<system:String x:Key="invalidPluginHotkey">Invalid plugin hotkey</system:String>

View file

@ -19,6 +19,7 @@
Height="700" Width="1000"
MinWidth="900"
MinHeight="600"
MouseDown="window_MouseDown"
Loaded="OnLoaded"
Closed="OnClosed"
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">

View file

@ -281,5 +281,15 @@ namespace Flow.Launcher
API.ShowMainWindow();
}
}
private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */
{
TextBox textBox = Keyboard.FocusedElement as TextBox;
if (textBox != null)
{
TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
textBox.MoveFocus(tRequest);
}
}
}
}