- Add Clock/Date in SettingWindow

This commit is contained in:
DB p 2022-09-01 16:19:00 +09:00
parent 9dc86fdfb4
commit d2332abd95
5 changed files with 114 additions and 11 deletions

View file

@ -42,7 +42,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public bool UseAnimation { get; set; } = true;
public bool UseSound { get; set; } = true;
public bool UseClock { get; set; } = true;
public bool UseDate { get; set; } = true;
public bool UseDate { get; set; } = false;
public bool FirstLaunch { get; set; } = true;
public int CustomExplorerIndex { get; set; } = 0;

View file

@ -105,6 +105,8 @@
<system:String x:Key="SoundEffectTip">Play a small sound when the search window opens</system:String>
<system:String x:Key="Animation">Animation</system:String>
<system:String x:Key="AnimationTip">Use Animation in UI</system:String>
<system:String x:Key="Clock">Clock</system:String>
<system:String x:Key="Date">Date</system:String>
<!-- Setting Hotkey -->
<system:String x:Key="hotkey">Hotkey</system:String>

View file

@ -81,6 +81,29 @@ namespace Flow.Launcher
}
}
public void ClockDisplay()
{
if (_settings.UseClock == true)
{
ClockBox.Visibility = Visibility.Visible;
ClockBox.Text = System.DateTime.Now.ToString("tt hh:mm");
}
else if (_settings.UseClock == false)
{
ClockBox.Visibility = Visibility.Collapsed;
}
if (_settings.UseDate == true)
{
DateBox.Visibility = Visibility.Visible;
DateBox.Text = System.DateTime.Now.ToString("MM/dd ddd");
}
else if (_settings.UseDate == false)
{
DateBox.Visibility = Visibility.Collapsed;
}
}
private void OnCopy(object sender, ExecutedRoutedEventArgs e)
{
@ -206,6 +229,12 @@ namespace Flow.Launcher
case nameof(Settings.Hotkey):
UpdateNotifyIconText();
break;
case nameof(Settings.UseClock):
ClockDisplay();
break;
case nameof(Settings.UseDate):
ClockDisplay();
break;
}
};
}
@ -378,7 +407,6 @@ namespace Flow.Launcher
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
iconsb.Begin(SearchIcon);
iconsb.Begin(ClockPanel);
sb.Begin(FlowMainWindow);
}

View file

@ -597,9 +597,7 @@
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource startFlowLauncherOnSystemStartup}" />
</StackPanel>
<CheckBox
IsChecked="{Binding StartFlowLauncherOnSystemStartup}"
Style="{DynamicResource SideControlCheckBox}" />
<CheckBox IsChecked="{Binding StartFlowLauncherOnSystemStartup}" Style="{DynamicResource SideControlCheckBox}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe8fc;
</TextBlock>
@ -1555,8 +1553,17 @@
IsReadOnly="True"
Style="{DynamicResource QueryBoxStyle}"
Text="{DynamicResource hiThere}" />
</Border>
<StackPanel x:Name="ClockPanel" Style="{DynamicResource ClockPanel}">
<TextBlock
x:Name="DateBox"
Style="{DynamicResource DateBox}"
Text="09-01 Thu" />
<TextBlock
x:Name="ClockBox"
Style="{DynamicResource ClockBox}"
Text="PM 12:04" />
</StackPanel>
<Canvas Style="{DynamicResource SearchIconPosition}">
<Path
Margin="0"
@ -1792,9 +1799,9 @@
Margin="20,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Source={StaticResource SortedFonts}}"
SelectedItem="{Binding SelectedQueryBoxFont}"
IsSynchronizedWithCurrentItem="False" />
SelectedItem="{Binding SelectedQueryBoxFont}" />
<ComboBox
Width="130"
Margin="10,0,0,0"
@ -1843,9 +1850,9 @@
Margin="20,-2,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Source={StaticResource SortedFonts}}"
SelectedItem="{Binding SelectedResultFont}"
IsSynchronizedWithCurrentItem="False" />
SelectedItem="{Binding SelectedResultFont}" />
<ComboBox
Width="130"
Margin="10,-2,0,0"
@ -1877,7 +1884,60 @@
<StackPanel>
<Border
Margin="0,30,0,0"
Margin="0,24,0,12"
Padding="0"
CornerRadius="5"
Style="{DynamicResource SettingGroupBox}">
<StackPanel Orientation="Vertical">
<Border
Margin="0"
BorderThickness="0"
Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource Clock}" />
</StackPanel>
<ui:ToggleSwitch
Grid.Row="0"
Grid.Column="2"
IsOn="{Binding UseClock, Mode=TwoWay}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}"
Style="{DynamicResource SideToggleSwitch}" />
<TextBlock Style="{StaticResource Glyph}">
&#xec92;
</TextBlock>
</ItemsControl>
</Border>
<Separator
Width="Auto"
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Border
Margin="0"
BorderThickness="0"
Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource Date}" />
</StackPanel>
<ui:ToggleSwitch
Grid.Row="0"
Grid.Column="2"
IsOn="{Binding UseDate, Mode=TwoWay}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}"
Style="{DynamicResource SideToggleSwitch}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe787;
</TextBlock>
</ItemsControl>
</Border>
</StackPanel>
</Border>
<Border
Margin="0,12,0,12"
Padding="0"
CornerRadius="5"
Style="{DynamicResource SettingGroupBox}">

View file

@ -385,6 +385,19 @@ namespace Flow.Launcher.ViewModel
set => Settings.UseSound = value;
}
public bool UseClock
{
get => Settings.UseClock;
set => Settings.UseClock = value;
}
public bool UseDate
{
get => Settings.UseDate;
set => Settings.UseDate = value;
}
public Brush PreviewBackground
{
get