mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
reorganize logic for date/time dropdown
This commit is contained in:
parent
8159b6edf1
commit
45e9a43060
3 changed files with 36 additions and 31 deletions
|
|
@ -1815,6 +1815,7 @@
|
|||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0">
|
||||
<TextBox
|
||||
x:Name="QueryTextBox"
|
||||
IsReadOnly="True"
|
||||
Style="{DynamicResource QueryBoxStyle}"
|
||||
Text="{DynamicResource hiThere}" />
|
||||
|
|
@ -2170,7 +2171,8 @@
|
|||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
ItemsSource="{Binding TimeFormatDisplayList}"
|
||||
SelectedIndex="{Binding TimeFormatIndex, Mode=OneTime}"
|
||||
SelectedIndex="{Binding TimeFormatIndex, Mode=OneWayToSource}"
|
||||
DropDownOpened="RefreshDateTimeList"
|
||||
SelectionChanged="PreviewClockAndDate" />
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding UseClock, Mode=TwoWay}"
|
||||
|
|
@ -2208,7 +2210,8 @@
|
|||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
ItemsSource="{Binding DateFormatDisplayList}"
|
||||
SelectedIndex="{Binding DateFormatIndex, Mode=OneTime}"
|
||||
SelectedIndex="{Binding DateFormatIndex, Mode=OneWayToSource}"
|
||||
DropDownOpened="RefreshDateTimeList"
|
||||
SelectionChanged="PreviewClockAndDate" />
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding UseDate, Mode=TwoWay}"
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ namespace Flow.Launcher
|
|||
API = api;
|
||||
InitializePosition();
|
||||
InitializeComponent();
|
||||
|
||||
RefreshDateTimeListLogic(viewModel.DateFormatIndex, viewModel.TimeFormatIndex);
|
||||
}
|
||||
|
||||
#region General
|
||||
|
|
@ -517,19 +519,6 @@ namespace Flow.Launcher
|
|||
|
||||
private void PreviewClockAndDate(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DateFormat != null && TimeFormat != null)
|
||||
{
|
||||
if (DateFormat.SelectedIndex == -1 || TimeFormat.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
viewModel.UpdateDateTimeDisplayList(DateFormat.SelectedIndex, TimeFormat.SelectedIndex);
|
||||
DateFormat.Items.Refresh();
|
||||
TimeFormat.Items.Refresh(); // selected = -1
|
||||
// todo avoid recursion
|
||||
DateFormat.SelectedIndex = viewModel.DateFormatIndex;
|
||||
TimeFormat.SelectedIndex = viewModel.TimeFormatIndex;
|
||||
}
|
||||
ClockDisplay();
|
||||
}
|
||||
|
||||
|
|
@ -605,5 +594,23 @@ namespace Flow.Launcher
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
private void RefreshDateTimeList(object sender, EventArgs e)
|
||||
{
|
||||
RefreshDateTimeListLogic(DateFormat.SelectedIndex, TimeFormat.SelectedIndex);
|
||||
}
|
||||
|
||||
private void RefreshDateTimeListLogic(int dateIndex, int timeIndex)
|
||||
{
|
||||
viewModel.UpdateDateTimeDisplayList();
|
||||
RefreshComboBox(DateFormat, dateIndex);
|
||||
RefreshComboBox(TimeFormat, timeIndex);
|
||||
}
|
||||
|
||||
private static void RefreshComboBox(System.Windows.Controls.ComboBox box, int index)
|
||||
{
|
||||
box.Items.Refresh();
|
||||
box.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -482,8 +482,11 @@ namespace Flow.Launcher.ViewModel
|
|||
get => timeFormatIndex;
|
||||
set
|
||||
{
|
||||
timeFormatIndex = value;
|
||||
Settings.TimeFormat = TimeFormatList[TimeFormatIndex];
|
||||
if (value != -1)
|
||||
{
|
||||
timeFormatIndex = value;
|
||||
Settings.TimeFormat = TimeFormatList[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -493,8 +496,11 @@ namespace Flow.Launcher.ViewModel
|
|||
get => dateFormatIndex;
|
||||
set
|
||||
{
|
||||
dateFormatIndex = value;
|
||||
Settings.DateFormat = DateFormatList[DateFormatIndex];
|
||||
if (value != -1)
|
||||
{
|
||||
dateFormatIndex = value;
|
||||
Settings.DateFormat = DateFormatList[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -502,17 +508,8 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
public List<string> DateFormatDisplayList { get; set; } = null;
|
||||
|
||||
public void UpdateSettingsDateTimeFormat()
|
||||
public void UpdateDateTimeDisplayList()
|
||||
{
|
||||
Settings.DateFormat = DateFormatList[DateFormatIndex];
|
||||
Settings.TimeFormat = TimeFormatList[TimeFormatIndex];
|
||||
}
|
||||
|
||||
public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex)
|
||||
{
|
||||
DateFormatIndex = dateIndex;
|
||||
TimeFormatIndex = timeIndex;
|
||||
|
||||
for (int i = 0; i < TimeFormatList.Count; ++i)
|
||||
{
|
||||
TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture);
|
||||
|
|
@ -522,8 +519,6 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
//UpdateSettingsDateTimeFormat();
|
||||
}
|
||||
|
||||
public double WindowWidthSize
|
||||
|
|
|
|||
Loading…
Reference in a new issue