mirror of
https://github.com/ckaczor/WorldClockStatusWindow.git
synced 2026-01-14 01:25:44 -05:00
Add time zones settings panel
This commit is contained in:
43
SettingsWindow/TimeZoneWindow.xaml.cs
Normal file
43
SettingsWindow/TimeZoneWindow.xaml.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using ChrisKaczor.Wpf.Validation;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace WorldClockStatusWindow.SettingsWindow;
|
||||
|
||||
public partial class TimeZoneWindow
|
||||
{
|
||||
public TimeZoneWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool? Display(TimeZoneEntry timeZoneEntry, Window owner)
|
||||
{
|
||||
DataContext = timeZoneEntry;
|
||||
|
||||
TimeZoneComboBox.ItemsSource = TimeZoneInfo.GetSystemTimeZones();
|
||||
|
||||
Title = string.IsNullOrWhiteSpace(timeZoneEntry.Label) ? Properties.Resources.TimeZoneWindowAdd : Properties.Resources.TimeZoneWindowEdit;
|
||||
|
||||
Owner = owner;
|
||||
|
||||
return ShowDialog();
|
||||
}
|
||||
|
||||
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!this.IsValid())
|
||||
return;
|
||||
|
||||
var timeZoneEntry = (TimeZoneEntry)DataContext;
|
||||
|
||||
if (!Data.TimeZoneEntries.Contains(timeZoneEntry))
|
||||
Data.TimeZoneEntries.Add(timeZoneEntry);
|
||||
|
||||
Data.Save();
|
||||
|
||||
DialogResult = true;
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user