- Add clock in query bar (sublime theme only)

This commit is contained in:
Dobin Park 2021-10-07 00:20:53 +09:00
parent 1149ff5cb5
commit c74a2dbc70
5 changed files with 95 additions and 3 deletions

View file

@ -96,6 +96,10 @@
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
<StackPanel x:Name="ClockPanel" Style="{DynamicResource ClockPanel}">
<TextBlock x:Name="ClockBox" Style="{DynamicResource ClockBox}"></TextBlock>
<TextBlock x:Name="DateBox" Style="{DynamicResource DateBox}"></TextBlock>
</StackPanel>
<Canvas Style="{DynamicResource SearchIconPosition}">
<Path Data="{DynamicResource SearchIconImg}" Style="{DynamicResource SearchIconStyle}" Margin="0" Stretch="Fill"/>
</Canvas>

View file

@ -11,6 +11,8 @@ using Flow.Launcher.Core.Resource;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.ViewModel;
using System.Windows.Threading;
using System.Globalization;
using Application = System.Windows.Application;
using Screen = System.Windows.Forms.Screen;
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
@ -31,7 +33,6 @@ namespace Flow.Launcher
private Settings _settings;
private NotifyIcon _notifyIcon;
private MainViewModel _viewModel;
#endregion
public MainWindow(Settings settings, MainViewModel mainVM)
@ -39,14 +40,30 @@ namespace Flow.Launcher
DataContext = mainVM;
_viewModel = mainVM;
_settings = settings;
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += Timer_Tick;
timer.Start();
InitializeComponent();
}
public MainWindow()
{
InitializeComponent();
}
private void Timer_Tick(object sender, EventArgs e)
{
ClockBox.Text = System.DateTime.Now.ToString("tt hh:mm");
DateBox.Text = System.DateTime.Now.ToString("ddd MM/dd", CultureInfo.InvariantCulture);
}
private async void OnClosing(object sender, CancelEventArgs e)
{
_notifyIcon.Visible = false;

View file

@ -586,7 +586,10 @@
<Canvas Style="{DynamicResource SearchIconPosition}">
<Path Data="{DynamicResource SearchIconImg}" Style="{DynamicResource SearchIconStyle}" Margin="0" Stretch="Fill"/>
</Canvas>
<StackPanel x:Name="ClockPanel" Style="{DynamicResource ClockPanel}">
<TextBlock x:Name="ClockBox" Style="{DynamicResource ClockBox}"></TextBlock>
<TextBlock x:Name="DateBox" Style="{DynamicResource DateBox}"></TextBlock>
</StackPanel>
<Border Margin="0 0 0 0" Grid.Row="1">
<Rectangle Width="Auto" HorizontalAlignment="Stretch" Style="{DynamicResource SeparatorStyle}" Visibility="visible"/>
</Border>

View file

@ -270,6 +270,28 @@
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
<Style x:Key="BaseClockPanel" TargetType="{x:Type StackPanel}">
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Height" Value="Auto" />
<Setter Property="Margin" Value="0 0 14 0" />
<Setter Property="Visibility" Value="Collapsed" />
</Style>
<Style x:Key="BaseClockBox" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="20" />
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Margin" Value="0 0 0 -5" />
</Style>
<Style x:Key="BaseDateBox" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Margin" Value="0 0 0 0" />
</Style>
<!--for classic themes-->
<Style x:Key="SearchIconStyle" TargetType="{x:Type Path}">
<Setter Property="Fill" Value="#555555" />
@ -293,5 +315,12 @@
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="Opacity" Value="0.5" />
</Style>
<Style x:Key="ClockBox" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseClockBox}">
</Style>
<Style x:Key="DateBox" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseDateBox}">
</Style>
<Style x:Key="ClockPanel" TargetType="{x:Type StackPanel}" BasedOn="{StaticResource BaseClockPanel}">
</Style>
</ResourceDictionary>

View file

@ -59,7 +59,7 @@
<Setter Property="Cursor" Value="Arrow" />
<Setter Property="Foreground" Value="#cc8ec8" />
</Style>
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#3c454e</SolidColorBrush>
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#3C454E</SolidColorBrush>
<Style x:Key="ItemImageSelectedStyle" BasedOn="{StaticResource BaseItemImageSelectedStyle}" TargetType="{x:Type Image}" >
<Setter Property="Cursor" Value="Arrow" />
</Style>
@ -100,5 +100,44 @@
<Setter Property="Fill" Value="#3c454e" />
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Visibility" Value="Collapsed" />
</Style>
<Style x:Key="ClockBox" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseClockBox}">
<Setter Property="Foreground" Value="#cc8ec8" />
</Style>
<Style x:Key="DateBox" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseDateBox}">
<Setter Property="Foreground" Value="#cc8ec8" />
</Style>
<Style x:Key="ClockPanel" TargetType="{x:Type StackPanel}" BasedOn="{StaticResource BaseClockPanel}">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=QueryTextBox, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
From="0.0" To="1.0" Duration="0:0:0.2"
/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.0" Duration="0:0:0.2"
/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>