Skip to content

Commit 7e0ef2a

Browse files
committed
- Refresh Preview when Change Time/Date Format
1 parent 7ae6f2a commit 7e0ef2a

File tree

2 files changed

+73
-47
lines changed

2 files changed

+73
-47
lines changed

Flow.Launcher/SettingWindow.xaml

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Window
22
x:Class="Flow.Launcher.SettingWindow"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
54
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6-
xmlns:ui="http://schemas.modernwpf.com/2019"
7-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
xmlns:flowlauncher="clr-namespace:Flow.Launcher"
95
xmlns:converters="clr-namespace:Flow.Launcher.Converters"
10-
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
11-
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:flowlauncher="clr-namespace:Flow.Launcher"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
129
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
1310
xmlns:sys="clr-namespace:System;assembly=mscorlib"
11+
xmlns:ui="http://schemas.modernwpf.com/2019"
12+
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure"
13+
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
1414
Title="{DynamicResource flowlauncher_settings}"
1515
Width="1000"
1616
Height="700"
@@ -1554,14 +1554,8 @@
15541554
Text="{DynamicResource hiThere}" />
15551555
</Border>
15561556
<StackPanel x:Name="ClockPanel" Style="{DynamicResource ClockPanel}">
1557-
<TextBlock
1558-
x:Name="DateBox"
1559-
Style="{DynamicResource DateBox}"
1560-
Text="09-01 Thu" />
1561-
<TextBlock
1562-
x:Name="ClockBox"
1563-
Style="{DynamicResource ClockBox}"
1564-
Text="PM 12:04" />
1557+
<TextBlock x:Name="DateBox" Style="{DynamicResource DateBox}" />
1558+
<TextBlock x:Name="ClockBox" Style="{DynamicResource ClockBox}" />
15651559
</StackPanel>
15661560
<Canvas Style="{DynamicResource SearchIconPosition}">
15671561
<Path
@@ -1896,23 +1890,25 @@
18961890
<StackPanel Style="{StaticResource TextPanel}">
18971891
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource Clock}" />
18981892
</StackPanel>
1899-
<StackPanel Grid.Row="0"
1900-
Grid.Column="2" Orientation="Horizontal">
1901-
<ComboBox
1902-
x:Name="TimeFormat"
1903-
Grid.Column="2"
1904-
MinWidth="180"
1905-
VerticalAlignment="Center"
1906-
Margin="0,0,18,0"
1907-
FontSize="14"
1908-
ItemsSource="{Binding TimeFormatList}"
1909-
SelectedValue="{Binding Settings.TimeFormat}"/>
1893+
<StackPanel
1894+
Grid.Row="0"
1895+
Grid.Column="2"
1896+
Orientation="Horizontal">
1897+
<ComboBox
1898+
x:Name="TimeFormat"
1899+
Grid.Column="2"
1900+
MinWidth="180"
1901+
Margin="0,0,18,0"
1902+
VerticalAlignment="Center"
1903+
FontSize="14"
1904+
ItemsSource="{Binding TimeFormatList}"
1905+
SelectedValue="{Binding Settings.TimeFormat}"
1906+
SelectionChanged="PreviewClockAndDate" />
19101907
<ui:ToggleSwitch
1911-
1912-
IsOn="{Binding UseClock, Mode=TwoWay}"
1913-
OffContent="{DynamicResource disable}"
1914-
OnContent="{DynamicResource enable}"
1915-
Style="{DynamicResource SideToggleSwitch}" />
1908+
IsOn="{Binding UseClock, Mode=TwoWay}"
1909+
OffContent="{DynamicResource disable}"
1910+
OnContent="{DynamicResource enable}"
1911+
Style="{DynamicResource SideToggleSwitch}" />
19161912
</StackPanel>
19171913
<TextBlock Style="{StaticResource Glyph}">
19181914
&#xec92;
@@ -1931,23 +1927,25 @@
19311927
<StackPanel Style="{StaticResource TextPanel}">
19321928
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource Date}" />
19331929
</StackPanel>
1934-
<StackPanel Grid.Row="0"
1935-
Grid.Column="2" Orientation="Horizontal">
1936-
<ComboBox
1937-
x:Name="DateFormat"
1938-
Grid.Column="2"
1939-
MinWidth="180"
1940-
VerticalAlignment="Center"
1941-
Margin="0,0,18,0"
1942-
FontSize="14"
1943-
ItemsSource="{Binding DateFormatList}"
1944-
SelectedValue="{Binding Settings.DateFormat}"
1945-
/>
1946-
<ui:ToggleSwitch
1947-
IsOn="{Binding UseDate, Mode=TwoWay}"
1948-
OffContent="{DynamicResource disable}"
1949-
OnContent="{DynamicResource enable}"
1950-
Style="{DynamicResource SideToggleSwitch}" />
1930+
<StackPanel
1931+
Grid.Row="0"
1932+
Grid.Column="2"
1933+
Orientation="Horizontal">
1934+
<ComboBox
1935+
x:Name="DateFormat"
1936+
Grid.Column="2"
1937+
MinWidth="180"
1938+
Margin="0,0,18,0"
1939+
VerticalAlignment="Center"
1940+
FontSize="14"
1941+
ItemsSource="{Binding DateFormatList}"
1942+
SelectedValue="{Binding Settings.DateFormat}"
1943+
SelectionChanged="PreviewClockAndDate" />
1944+
<ui:ToggleSwitch
1945+
IsOn="{Binding UseDate, Mode=TwoWay}"
1946+
OffContent="{DynamicResource disable}"
1947+
OnContent="{DynamicResource enable}"
1948+
Style="{DynamicResource SideToggleSwitch}" />
19511949
</StackPanel>
19521950
<TextBlock Style="{StaticResource Glyph}">
19531951
&#xe787;

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private void OnLoaded(object sender, RoutedEventArgs e)
5454
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
5555
HwndTarget hwndTarget = hwndSource.CompositionTarget;
5656
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
57+
ClockDisplay();
5758
}
5859

5960
private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
@@ -353,5 +354,32 @@ private void ColorSchemeSelectedIndexChanged(object sender, SelectionChangedEven
353354
{
354355

355356
}
357+
358+
private void PreviewClockAndDate(object sender, RoutedEventArgs e)
359+
{
360+
ClockDisplay();
361+
}
362+
public void ClockDisplay()
363+
{
364+
if (settings.UseClock == true)
365+
{
366+
ClockBox.Visibility = Visibility.Visible;
367+
ClockBox.Text = System.DateTime.Now.ToString(settings.TimeFormat);
368+
}
369+
else if (settings.UseClock == false)
370+
{
371+
ClockBox.Visibility = Visibility.Collapsed;
372+
}
373+
if (settings.UseDate == true)
374+
{
375+
DateBox.Visibility = Visibility.Visible;
376+
DateBox.Text = System.DateTime.Now.ToString(settings.DateFormat);
377+
}
378+
else if (settings.UseDate == false)
379+
{
380+
DateBox.Visibility = Visibility.Collapsed;
381+
}
382+
383+
}
356384
}
357385
}

0 commit comments

Comments
 (0)