mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Separate date/time format list refresh
This commit is contained in:
parent
bde471afa8
commit
e60635608d
3 changed files with 35 additions and 20 deletions
|
|
@ -2181,7 +2181,7 @@
|
|||
FontSize="14"
|
||||
ItemsSource="{Binding TimeFormatDisplayList}"
|
||||
SelectedIndex="{Binding TimeFormatIndex, Mode=OneWayToSource}"
|
||||
DropDownOpened="RefreshDateTimeList"/>
|
||||
DropDownOpened="RefreshTimeList"/>
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding UseClock, Mode=TwoWay}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
|
|
@ -2218,7 +2218,7 @@
|
|||
FontSize="14"
|
||||
ItemsSource="{Binding DateFormatDisplayList}"
|
||||
SelectedIndex="{Binding DateFormatIndex, Mode=OneWayToSource}"
|
||||
DropDownOpened="RefreshDateTimeList"/>
|
||||
DropDownOpened="RefreshDateList"/>
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding UseDate, Mode=TwoWay}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ namespace Flow.Launcher
|
|||
InitializePosition();
|
||||
InitializeComponent();
|
||||
|
||||
RefreshDateTimeListLogic(viewModel.DateFormatIndex, viewModel.TimeFormatIndex);
|
||||
RefreshDateListInternal(viewModel.DateFormatIndex);
|
||||
RefreshTimeListInternal(viewModel.TimeFormatIndex);
|
||||
}
|
||||
|
||||
#region General
|
||||
|
|
@ -67,7 +68,6 @@ namespace Flow.Launcher
|
|||
pluginStoreView.Filter = PluginStoreFilter;
|
||||
|
||||
InitializePosition();
|
||||
ClockDisplay();
|
||||
}
|
||||
|
||||
private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
|
||||
|
|
@ -567,16 +567,26 @@ namespace Flow.Launcher
|
|||
|
||||
}
|
||||
|
||||
private void RefreshDateTimeList(object sender, EventArgs e)
|
||||
private void RefreshDateList(object sender, EventArgs e)
|
||||
{
|
||||
RefreshDateTimeListLogic(DateFormat.SelectedIndex, TimeFormat.SelectedIndex);
|
||||
RefreshDateListInternal(DateFormat.SelectedIndex);
|
||||
}
|
||||
|
||||
private void RefreshDateTimeListLogic(int dateIndex, int timeIndex)
|
||||
private void RefreshDateListInternal(int index)
|
||||
{
|
||||
viewModel.UpdateDateTimeDisplayList();
|
||||
RefreshComboBox(DateFormat, dateIndex);
|
||||
RefreshComboBox(TimeFormat, timeIndex);
|
||||
viewModel.UpdateDateDisplayList();
|
||||
RefreshComboBox(DateFormat, index);
|
||||
}
|
||||
|
||||
private void RefreshTimeList(object sender, EventArgs e)
|
||||
{
|
||||
RefreshTimeListInternal(TimeFormat.SelectedIndex);
|
||||
}
|
||||
|
||||
private void RefreshTimeListInternal(int index)
|
||||
{
|
||||
viewModel.UpdateTimeDisplayList();
|
||||
RefreshComboBox(TimeFormat, index);
|
||||
}
|
||||
|
||||
private static void RefreshComboBox(System.Windows.Controls.ComboBox box, int index)
|
||||
|
|
|
|||
|
|
@ -52,10 +52,9 @@ namespace Flow.Launcher.ViewModel
|
|||
int tmp = 0;
|
||||
TimeFormatIndex = (tmp = TimeFormatList.FindIndex(x => x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0;
|
||||
DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0;
|
||||
// TODO: CurrentCulture may equal to settings.language when this is constructed
|
||||
// TODO: CurrentCulture may not equal to settings.language when this is constructed
|
||||
TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList();
|
||||
DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList();
|
||||
//UpdateSettingsDateTimeFormat(); // just in case something wrong
|
||||
}
|
||||
|
||||
public Settings Settings { get; set; }
|
||||
|
|
@ -514,20 +513,26 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
public List<string> DateFormatDisplayList { get; set; } = null;
|
||||
|
||||
public void UpdateDateTimeDisplayList()
|
||||
public void UpdateDateDisplayList()
|
||||
{
|
||||
for (int i = 0; i < DateFormatList.Count; ++i)
|
||||
{
|
||||
DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture);
|
||||
}
|
||||
// TODO: CurrentCulture may not equal to settings.language
|
||||
// Cross thread issue?
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
public void UpdateTimeDisplayList()
|
||||
{
|
||||
for (int i = 0; i < TimeFormatList.Count; ++i)
|
||||
{
|
||||
TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
for (int i = 0; i < DateFormatList.Count; ++i)
|
||||
{
|
||||
DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
// TODO: CurrentCulture may not equal to settings.language
|
||||
// Cross thread issue?
|
||||
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