mirror of
https://github.com/ckaczor/WorldClockStatusWindow.git
synced 2026-01-13 17:23:18 -05:00
43 lines
1004 B
C#
43 lines
1004 B
C#
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();
|
|
}
|
|
} |