mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use binding for date time preview
This commit is contained in:
parent
45e9a43060
commit
bde471afa8
3 changed files with 25 additions and 39 deletions
|
|
@ -39,6 +39,7 @@
|
|||
</Window.CommandBindings>
|
||||
|
||||
<Window.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<converters:BorderClipConverter x:Key="BorderClipConverter" />
|
||||
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
|
||||
<converters:TextConverter x:Key="TextConverter" />
|
||||
|
|
@ -1820,9 +1821,17 @@
|
|||
Style="{DynamicResource QueryBoxStyle}"
|
||||
Text="{DynamicResource hiThere}" />
|
||||
</Border>
|
||||
<StackPanel x:Name="ClockPanel" Style="{DynamicResource ClockPanel}">
|
||||
<TextBlock x:Name="DateBox" Style="{DynamicResource DateBox}" />
|
||||
<TextBlock x:Name="ClockBox" Style="{DynamicResource ClockBox}" />
|
||||
<StackPanel
|
||||
x:Name="ClockPanel"
|
||||
Style="{DynamicResource ClockPanel}">
|
||||
<TextBlock
|
||||
Style="{DynamicResource DateBox}"
|
||||
Text="{Binding DateText}"
|
||||
Visibility="{Binding Settings.UseDate, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<TextBlock
|
||||
Style="{DynamicResource ClockBox}"
|
||||
Text="{Binding ClockText}"
|
||||
Visibility="{Binding Settings.UseClock, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
</StackPanel>
|
||||
<Canvas Style="{DynamicResource SearchIconPosition}">
|
||||
<Path
|
||||
|
|
@ -2172,14 +2181,12 @@
|
|||
FontSize="14"
|
||||
ItemsSource="{Binding TimeFormatDisplayList}"
|
||||
SelectedIndex="{Binding TimeFormatIndex, Mode=OneWayToSource}"
|
||||
DropDownOpened="RefreshDateTimeList"
|
||||
SelectionChanged="PreviewClockAndDate" />
|
||||
DropDownOpened="RefreshDateTimeList"/>
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding UseClock, Mode=TwoWay}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
Style="{DynamicResource SideToggleSwitch}"
|
||||
Toggled="PreviewClockAndDate" />
|
||||
Style="{DynamicResource SideToggleSwitch}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||

|
||||
|
|
@ -2211,14 +2218,12 @@
|
|||
FontSize="14"
|
||||
ItemsSource="{Binding DateFormatDisplayList}"
|
||||
SelectedIndex="{Binding DateFormatIndex, Mode=OneWayToSource}"
|
||||
DropDownOpened="RefreshDateTimeList"
|
||||
SelectionChanged="PreviewClockAndDate" />
|
||||
DropDownOpened="RefreshDateTimeList"/>
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding UseDate, Mode=TwoWay}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
Style="{DynamicResource SideToggleSwitch}"
|
||||
Toggled="PreviewClockAndDate" />
|
||||
Style="{DynamicResource SideToggleSwitch}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||

|
||||
|
|
|
|||
|
|
@ -517,34 +517,6 @@ namespace Flow.Launcher
|
|||
}
|
||||
}
|
||||
|
||||
private void PreviewClockAndDate(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ClockDisplay();
|
||||
}
|
||||
|
||||
public void ClockDisplay()
|
||||
{
|
||||
if (settings.UseClock)
|
||||
{
|
||||
ClockBox.Visibility = Visibility.Visible;
|
||||
ClockBox.Text = DateTime.Now.ToString(settings.TimeFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClockBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (settings.UseDate)
|
||||
{
|
||||
DateBox.Visibility = Visibility.Visible;
|
||||
DateBox.Text = DateTime.Now.ToString(settings.DateFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
DateBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializePosition()
|
||||
{
|
||||
if (settings.SettingWindowTop >= 0 && settings.SettingWindowLeft >= 0)
|
||||
|
|
|
|||
|
|
@ -486,6 +486,7 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
timeFormatIndex = value;
|
||||
Settings.TimeFormat = TimeFormatList[value];
|
||||
ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -500,10 +501,15 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
dateFormatIndex = value;
|
||||
Settings.DateFormat = DateFormatList[value];
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ClockText { get; private set; }
|
||||
|
||||
public string DateText { get; private set; }
|
||||
|
||||
public List<string> TimeFormatDisplayList { get; set; } = null;
|
||||
|
||||
public List<string> DateFormatDisplayList { get; set; } = null;
|
||||
|
|
@ -519,6 +525,9 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture);
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
public double WindowWidthSize
|
||||
|
|
|
|||
Loading…
Reference in a new issue