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