Skip to content

Commit 3b0551f

Browse files
committed
- Add Clock Code
- Add Base Clock Style
1 parent c74eafb commit 3b0551f

File tree

4 files changed

+91
-3
lines changed

4 files changed

+91
-3
lines changed

Flow.Launcher.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ Global
273273
{4792A74A-0CEA-4173-A8B2-30E6764C6217}.Release|x86.ActiveCfg = Release|Any CPU
274274
{4792A74A-0CEA-4173-A8B2-30E6764C6217}.Release|x86.Build.0 = Release|Any CPU
275275
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
276-
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|Any CPU.Build.0 = Debug|Any CPU
277276
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x64.ActiveCfg = Debug|Any CPU
278277
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x64.Build.0 = Debug|Any CPU
279278
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x86.ActiveCfg = Debug|Any CPU

Flow.Launcher/MainWindow.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@
192192
</ContextMenu>
193193
</TextBox.ContextMenu>
194194
</TextBox>
195+
<StackPanel x:Name="ClockPanel" Style="{DynamicResource ClockPanel}">
196+
<TextBlock x:Name="ClockBox" Style="{DynamicResource ClockBox}" />
197+
<TextBlock x:Name="DateBox" Style="{DynamicResource DateBox}" />
198+
</StackPanel>
195199
<Canvas Style="{DynamicResource SearchIconPosition}">
196200
<Image
197201
x:Name="PluginActivationIcon"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.ComponentModel;
33
using System.Threading.Tasks;
44
using System.Windows;
@@ -20,6 +20,8 @@
2020
using System.Windows.Media;
2121
using Flow.Launcher.Infrastructure.Hotkey;
2222
using Flow.Launcher.Plugin.SharedCommands;
23+
using System.Windows.Threading;
24+
using System.Globalization;
2325

2426
namespace Flow.Launcher
2527
{
@@ -43,6 +45,13 @@ public MainWindow(Settings settings, MainViewModel mainVM)
4345
DataContext = mainVM;
4446
_viewModel = mainVM;
4547
_settings = settings;
48+
49+
50+
DispatcherTimer timer = new DispatcherTimer();
51+
timer.Interval = new TimeSpan(0, 0, 1);
52+
timer.Tick += Timer_Tick;
53+
timer.Start();
54+
4655
InitializeComponent();
4756
InitializePosition();
4857
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
@@ -52,6 +61,12 @@ public MainWindow()
5261
{
5362
InitializeComponent();
5463
}
64+
private void Timer_Tick(object sender, EventArgs e)
65+
{
66+
ClockBox.Text = System.DateTime.Now.ToString("tt hh:mm");
67+
DateBox.Text = System.DateTime.Now.ToString("ddd MM/dd", CultureInfo.InvariantCulture);
68+
69+
}
5570
private void OnCopy(object sender, ExecutedRoutedEventArgs e)
5671
{
5772
if (QueryTextBox.SelectionLength == 0)
@@ -556,4 +571,4 @@ public void InitializeColorScheme()
556571
}
557572
}
558573
}
559-
}
574+
}

Flow.Launcher/Themes/Base.xaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,76 @@
7979
<Setter Property="Stroke" Value="Blue" />
8080
</Style>
8181

82+
<Style x:Key="BaseClockPanel" TargetType="{x:Type StackPanel}">
83+
<Setter Property="HorizontalAlignment" Value="Right" />
84+
<Setter Property="VerticalAlignment" Value="Center" />
85+
<Setter Property="Height" Value="Auto" />
86+
<Setter Property="Margin" Value="0,0,14,0" />
87+
<Setter Property="Visibility" Value="Collapsed" />
88+
</Style>
89+
<Style x:Key="BaseClockBox" TargetType="{x:Type TextBlock}">
90+
<Setter Property="FontSize" Value="20" />
91+
<Setter Property="Foreground" Value="#8f8f8f" />
92+
<Setter Property="VerticalAlignment" Value="Bottom" />
93+
<Setter Property="HorizontalAlignment" Value="Right" />
94+
<Setter Property="Margin" Value="0,0,0,-5" />
95+
</Style>
96+
<Style x:Key="BaseDateBox" TargetType="{x:Type TextBlock}">
97+
<Setter Property="FontSize" Value="14" />
98+
<Setter Property="Foreground" Value="#8f8f8f" />
99+
<Setter Property="VerticalAlignment" Value="Top" />
100+
<Setter Property="HorizontalAlignment" Value="Right" />
101+
<Setter Property="Margin" Value="0,0,0,0" />
102+
</Style>
103+
104+
<Style
105+
x:Key="ClockBox"
106+
BasedOn="{StaticResource BaseClockBox}"
107+
TargetType="{x:Type TextBlock}">
108+
<Setter Property="Foreground" Value="#cc8ec8" />
109+
</Style>
110+
<Style
111+
x:Key="DateBox"
112+
BasedOn="{StaticResource BaseDateBox}"
113+
TargetType="{x:Type TextBlock}">
114+
<Setter Property="Foreground" Value="#cc8ec8" />
115+
</Style>
116+
<Style
117+
x:Key="ClockPanel"
118+
BasedOn="{StaticResource BaseClockPanel}"
119+
TargetType="{x:Type StackPanel}">
120+
<Setter Property="Visibility" Value="Visible" />
121+
<Style.Triggers>
122+
<DataTrigger Binding="{Binding ElementName=QueryTextBox, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0">
123+
124+
<DataTrigger.EnterActions>
125+
<BeginStoryboard>
126+
<Storyboard>
127+
<DoubleAnimation
128+
Storyboard.TargetProperty="Opacity"
129+
From="0.0"
130+
To="1.0"
131+
Duration="0:0:0.2" />
132+
</Storyboard>
133+
</BeginStoryboard>
134+
</DataTrigger.EnterActions>
135+
<DataTrigger.ExitActions>
136+
<BeginStoryboard>
137+
<Storyboard>
138+
<DoubleAnimation
139+
Storyboard.TargetProperty="Opacity"
140+
From="1.0"
141+
To="0.0"
142+
Duration="0:0:0.2" />
143+
</Storyboard>
144+
</BeginStoryboard>
145+
</DataTrigger.ExitActions>
146+
147+
</DataTrigger>
148+
149+
</Style.Triggers>
150+
151+
</Style>
82152

83153
<!-- Item Style -->
84154
<Style x:Key="BaseItemTitleStyle" TargetType="{x:Type TextBlock}">

0 commit comments

Comments
 (0)