mirror of
https://github.com/ckaczor/WorldClockStatusWindow.git
synced 2026-01-13 17:23:18 -05:00
Improve time zone settings
- Add drag/drop reordering - Display time zone name and ID
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
mc:Ignorable="d"
|
||||
Title="TimeZoneWindow"
|
||||
ResizeMode="NoResize"
|
||||
@@ -42,12 +43,26 @@
|
||||
mah:TextBoxHelper.SelectAllOnFocus="True"
|
||||
Text="{Binding Path=Label, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True}" />
|
||||
<ComboBox Name="TimeZoneComboBox"
|
||||
DisplayMemberPath="DisplayName"
|
||||
SelectedValuePath="Id"
|
||||
SelectedValue="{Binding Path=TimeZoneId}"
|
||||
VirtualizingPanel.IsVirtualizing="False"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static properties:Resources.TimeZoneColumnHeader}" />
|
||||
mah:TextBoxHelper.Watermark="{x:Static properties:Resources.TimeZoneColumnHeader}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="system:TimeZoneInfo">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Path=DisplayName}"
|
||||
Height="Auto"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Path=Id}"
|
||||
Height="Auto"
|
||||
FontSize="11"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,2,0,2" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
@@ -62,7 +77,8 @@
|
||||
IsDefault="True"
|
||||
Click="HandleOkayButtonClick">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Style TargetType="Button"
|
||||
BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Text.Length, ElementName=LabelTextBox}"
|
||||
Value="0">
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
xmlns:worldClockStatusWindow="clr-namespace:WorldClockStatusWindow"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link"
|
||||
xmlns:dd="urn:gong-wpf-dragdrop"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150"
|
||||
d:DesignWidth="300">
|
||||
@@ -36,21 +37,37 @@
|
||||
GridLinesVisibility="None"
|
||||
CanUserResizeRows="False"
|
||||
IsReadOnly="True"
|
||||
CanUserSortColumns="False"
|
||||
SelectionUnit="FullRow"
|
||||
HeadersVisibility="Column"
|
||||
BorderThickness="1,1,1,1"
|
||||
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
|
||||
Background="{x:Null}"
|
||||
SelectionChanged="HandleTimeZoneDataGridSelectionChanged"
|
||||
d:DataContext="{d:DesignInstance worldClockStatusWindow:TimeZoneEntry }">
|
||||
d:DataContext="{d:DesignInstance worldClockStatusWindow:TimeZoneEntry }"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Path=Label}"
|
||||
Header="{x:Static properties:Resources.LabelColumnHeader}"
|
||||
SortDirection="Ascending"
|
||||
Width="*" />
|
||||
<DataGridTextColumn Binding="{Binding TimeZoneId}"
|
||||
Header="{x:Static properties:Resources.TimeZoneColumnHeader}"
|
||||
Width="*" />
|
||||
<DataGridTemplateColumn Header="{x:Static properties:Resources.TimeZoneColumnHeader}"
|
||||
Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Path=TimeZoneInfo.DisplayName}"
|
||||
Height="Auto"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Path=TimeZoneInfo.Id}"
|
||||
Height="Auto"
|
||||
FontSize="11"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,2,0,2" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
@@ -25,7 +24,6 @@ public partial class TimeZonesSettingsPanel
|
||||
if (_collectionViewSource == null)
|
||||
{
|
||||
_collectionViewSource = new CollectionViewSource { Source = Data.TimeZoneEntries };
|
||||
_collectionViewSource.SortDescriptions.Add(new SortDescription("Label", ListSortDirection.Ascending));
|
||||
|
||||
TimeZoneDataGrid.ItemsSource = _collectionViewSource.View;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ public class TimeZoneEntry : INotifyDataErrorInfo
|
||||
[JsonIgnore]
|
||||
public bool HasErrors => _dataErrorDictionary.Any();
|
||||
|
||||
[JsonIgnore]
|
||||
public TimeZoneInfo TimeZoneInfo => TimeZoneInfo.FindSystemTimeZoneById(TimeZoneId);
|
||||
|
||||
public IEnumerable GetErrors(string propertyName)
|
||||
{
|
||||
return _dataErrorDictionary.GetErrors(propertyName);
|
||||
|
||||
@@ -156,10 +156,7 @@ internal class WindowSource : IWindowSource, IDisposable
|
||||
|
||||
var settingsWindow = new CategoryWindow(categoryPanels, Resources.SettingsTitle, Resources.CloseButtonText);
|
||||
|
||||
var dialogResult = settingsWindow.ShowDialog();
|
||||
|
||||
if (!dialogResult.GetValueOrDefault(false))
|
||||
return;
|
||||
settingsWindow.ShowDialog();
|
||||
|
||||
Save();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<PackageReference Include="ChrisKaczor.Wpf.Validation" Version="1.0.4" />
|
||||
<PackageReference Include="ChrisKaczor.Wpf.Windows.CategoryWindow" Version="1.0.2" />
|
||||
<PackageReference Include="ChrisKaczor.Wpf.Windows.FloatingStatusWindow" Version="2.0.0.5" />
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Serilog" Version="4.0.2" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
|
||||
Reference in New Issue
Block a user