This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,156 @@
<base:BaseView x:Class="ChannelCodes.ChannelCodesListView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="clr-namespace:DTS.Common.Base;assembly=DTS.Common"
xmlns:converters="clr-namespace:DTS.Common.Converters;assembly=DTS.Common"
xmlns:controls="clr-namespace:DTS.Common.Controls;assembly=DTS.Common"
xmlns:behaviors="clr-namespace:DTS.Common.Behaviors;assembly=DTS.Common"
xmlns:strings="clr-namespace:ChannelCodes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1366"
x:Name="ChannelListView">
<base:BaseView.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/DTS.Common;component/Themes/CommonStyles.xaml"/>
<ResourceDictionary Source="pack://application:,,,/DTS.Common;component/Controls/combobox.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="ListView">
<Setter Property="ItemContainerStyle" Value="{StaticResource TTS_ListViewItemStyle}"/>
</Style>
<Style TargetType="TextBox" BasedOn="{StaticResource TTS_TextBoxStyle}"/>
<Style TargetType="TextBlock" BasedOn="{StaticResource TTS_TextBlockStyle}"/>
<Style TargetType="CheckBox" BasedOn="{StaticResource PageContentCheckBoxStyle}" />
<Style TargetType="ComboBox" BasedOn="{StaticResource TTS_ComboBoxStyle}"/>
<Style TargetType="Button" BasedOn="{StaticResource TTS_ButtonStyle}"/>
<Style TargetType="GridViewColumnHeader" BasedOn="{StaticResource Gray_GridViewColumnHeaderStyle}"/>
<Style TargetType="RadioButton" BasedOn="{StaticResource FlatRadioButtonStyle}" >
<Setter Property="Height" Value="24" />
<Setter Property="Margin" Value="5" />
</Style>
<converters:StatusToBorderThicknessConverter x:Key="StatusToBorderThickness" />
<converters:StatusToColorConverter x:Key="StatusToColor" />
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
</ResourceDictionary>
</base:BaseView.Resources>
<Grid Background="{DynamicResource Brush_ApplicationContentBackground}" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<RadioButton GroupName="Filters" Content="{strings:TranslateExtension ISO}" Checked="ISO_Checked" IsChecked="True" AutomationProperties.AutomationId="btnChannelCodeDetailsISO"/>
<RadioButton GroupName="Filters" Content="{strings:TranslateExtension User}" Checked="User_Checked" AutomationProperties.AutomationId="btnChannelCodeDetailsUser"/>
</StackPanel>
<ListView ItemsSource="{Binding ISOChannelCodes, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1"
AutomationProperties.AutomationId="ISOChannelCodeListView" Visibility="{Binding ISOVisibility}" SelectionMode="Extended" SelectionChanged="ISOCodes_SelectionChanged"
KeyboardNavigation.TabNavigation="Continue" x:Name="ISOChannelCodesListView" PreviewMouseLeftButtonUp="ISOChannelCodesListView_PreviewMouseLeftButtonUp">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="KeyboardNavigation.IsTabStop" Value="False" />
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<controls:AutoSizedGridView AutomationProperties.AutomationId="ChannelCodesListGridView">
<GridViewColumn AutomationProperties.AutomationId="ChannelCodeColumn" Width="315">
<GridViewColumn.Header>
<controls:GridViewColumnHeaderSearchable Tag="ISOCode" HeaderTitle="{strings:TranslateExtension ISOCode}" Search="GridViewColumnHeaderSearchable_OnSearch"
x:Name="ISOCodeColumnHeader" ClickHandler="GridViewColumnHeader_OnClick"/>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<ItemContainerTemplate>
<controls:ChannelCodeBuilder Width="300" AutomationProperties.AutomationId="ChannelCodeTextBox" Code="{Binding Code, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
KeyDown="ChannelCodeTextBox_KeyDown" TextChanged="ChannelCodeTextBoxIso_TextChanged" CodeType="ISO"
ChannelCodeSelected="ChannelCodeBuilder_OnChannelCodeSelected"
SelectionChanged="ChannelCodeBuilder_SelectionChanged"
ChannelCodesFunc="{Binding DataContext.ChannelCodesFunc, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"
ShowChannelCodeLookupHelper="{Binding DataContext.ShowChannelCodeLookupHelper, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"
ShowISOStringBuilder="{Binding DataContext.ShowISOStringBuilder, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"
UniqueISOCodesRequired="{Binding DataContext.UniqueISOCodesRequired, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"
PasteId="ChannelCode" behaviors:TextBoxPasteBehavior.PasteCommand="{Binding PasteCommand}" Tag="ISOCode"
BorderBrush="{Binding ItemStatus, Converter={StaticResource StatusToColor}}"
BorderThickness="{Binding ItemStatus, Converter={StaticResource StatusToBorderThickness}}"
IsEnabled="{Binding DataContext.IsReadOnly, Converter={StaticResource InverseBooleanConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"/>
</ItemContainerTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn AutomationProperties.AutomationId="DisplayNameColumn" Width="315">
<GridViewColumn.Header>
<controls:GridViewColumnHeaderSearchable Tag="ISOChannelName" HeaderTitle="{strings:TranslateExtension ISOChannelName}"
Search="GridViewColumnHeaderSearchable_OnSearch" x:Name="ISOChannelNameColumnHeader"/>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<ItemContainerTemplate>
<TextBox Width="300" AutomationProperties.AutomationId="DisplayNameTextBox"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" KeyDown="DisplayNameTextBox_KeyDown" SelectionChanged="DisplayNameTextBoxIso_SelectionChanged" TextChanged="DisplayNameTextBoxIso_TextChanged" MaxLength="250"
behaviors:TextBoxPasteBehavior.PasteCommand="{Binding PasteCommand}" Tag="ISOChannelName"
BorderBrush="{Binding ItemStatus, Converter={StaticResource StatusToColor}}"
BorderThickness="{Binding ItemStatus, Converter={StaticResource StatusToBorderThickness}}"
IsEnabled="{Binding DataContext.IsReadOnly, Converter={StaticResource InverseBooleanConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}" />
</ItemContainerTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</controls:AutoSizedGridView>
</ListView.View>
</ListView>
<ListView ItemsSource="{Binding UserChannelCodes, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1"
AutomationProperties.AutomationId="UserChannelCodeListView" Visibility="{Binding UserVisibility}" SelectionMode="Extended" SelectionChanged="UserCodes_SelectionChanged"
KeyboardNavigation.TabNavigation="Continue" x:Name="UserChannelCodesListView" PreviewMouseLeftButtonUp="UserChannelCodesListView_PreviewMouseLeftButtonUp">
<ListView.ItemContainerStyle>
<Style>
<Setter Property="KeyboardNavigation.IsTabStop" Value="False" />
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<controls:AutoSizedGridView AutomationProperties.AutomationId="ChannelCodesListGridView">
<GridViewColumn AutomationProperties.AutomationId="ChannelCodeColumn" Width="315">
<GridViewColumn.Header>
<controls:GridViewColumnHeaderSearchable Tag="UserCode" HeaderTitle="{strings:TranslateExtension UserCode}" Search="GridViewColumnHeaderSearchable_OnSearch"
ListviewId="{Binding ListViewId}" x:Name="UserCodeColumnHeader" ClickHandler="GridViewColumnHeader_OnClick"/>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<ItemContainerTemplate>
<controls:ChannelCodeBuilder Width="300" AutomationProperties.AutomationId="ChannelCodeTextBox" Code="{Binding Code, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
KeyDown="ChannelCodeTextBox_KeyDown" TextChanged="ChannelCodeTextBoxUser_TextChanged" CodeType="User"
ChannelCodeSelected="ChannelCodeBuilder_OnChannelCodeSelected"
ChannelCodesFunc="{Binding DataContext.ChannelCodesFunc, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"
ShowChannelCodeLookupHelper="{Binding DataContext.ShowChannelCodeLookupHelper, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"
ShowISOStringBuilder="{Binding DataContext.ShowISOStringBuilder, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"
UniqueISOCodesRequired="{Binding DataContext.UniqueISOCodesRequired, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"
PasteId="ChannelCode" behaviors:TextBoxPasteBehavior.PasteCommand="{Binding PasteCommand}" Tag="UserCode"
BorderBrush="{Binding ItemStatus, Converter={StaticResource StatusToColor}}"
SelectionChanged="ChannelCodeTextBoxUser_SelectionChanged"
BorderThickness="{Binding ItemStatus, Converter={StaticResource StatusToBorderThickness}}"
IsEnabled="{Binding DataContext.IsReadOnly, Converter={StaticResource InverseBooleanConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}" />
</ItemContainerTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn AutomationProperties.AutomationId="DisplayNameColumn" Width="315">
<GridViewColumn.Header>
<controls:GridViewColumnHeaderSearchable Tag="UserChannelName" HeaderTitle="{strings:TranslateExtension UserChannelName}" Search="GridViewColumnHeaderSearchable_OnSearch"
ListviewId="{Binding ListViewId}" x:Name="UserChannelNameColumnHeader"/>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<ItemContainerTemplate>
<TextBox Width="300" AutomationProperties.AutomationId="DisplayNameTextBox"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" KeyDown="DisplayNameTextBox_KeyDown"
TextChanged="DisplayNameTextBoxUser_TextChanged" MaxLength="250"
behaviors:TextBoxPasteBehavior.PasteCommand="{Binding PasteCommand}" Tag="UserChannelName"
BorderBrush="{Binding ItemStatus, Converter={StaticResource StatusToColor}}"
BorderThickness="{Binding ItemStatus, Converter={StaticResource StatusToBorderThickness}}"
SelectionChanged="DisplayNameTextBoxUser_SelectionChanged"
IsEnabled="{Binding DataContext.IsReadOnly, Converter={StaticResource InverseBooleanConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}" />
</ItemContainerTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</controls:AutoSizedGridView>
</ListView.View>
</ListView>
</Grid>
</base:BaseView>

View File

@@ -0,0 +1,279 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using DTS.Common.Controls;
using DTS.Common.Enums.Channels;
using DTS.Common.Interface.Channels.ChannelCodes;
using DTS.Common.Utils;
// ReSharper disable CheckNamespace
namespace ChannelCodes
{
/// <inheritdoc cref="IChannelCodesListView" />
/// <summary>
/// Interaction logic for ChannelCodesListView.xaml
/// </summary>
public partial class ChannelCodesListView : IChannelCodesListView
{
public ChannelCodesListView()
{
InitializeComponent();
}
private void GridViewColumnHeaderSearchable_OnSearch(object sender, RoutedEventArgs e)
{
var searchTerm = (string)e.OriginalSource;
var columnTag = (sender as GridViewColumnHeaderSearchable)?.Tag;
var viewModel = (IChannelCodesListViewModel)DataContext;
viewModel.Filter(columnTag, searchTerm);
}
//private void ChannelType_SelectionChanged(object sender, SelectionChangedEventArgs e)
//{
// if( e.RemovedItems.Count == 0) { return; }
// if( !(DataContext is ChannelCodesListViewModel vm)) { return; }
// if( !(((System.Windows.Controls.Control) e.Source).DataContext is IChannelCode channelCode)) { return; }
// vm.MarkModified(channelCode);
//}
private void GridViewColumnHeader_OnClick(object sender, RoutedEventArgs e)
{
var vm = (IChannelCodesListViewModel)DataContext;
var columnTag = (sender as GridViewColumnHeaderSearchable)?.Tag ?? Utils.FindChild<GridViewColumnHeaderSearchable>((DependencyObject)e.OriginalSource, null)?.Tag;
vm?.Sort(columnTag, true);
}
private void ChannelCodeTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(((System.Windows.Controls.Control)e.Source).DataContext is IChannelCode channelCode)) { return; }
vm.MarkModified(channelCode);
}
private void ChannelCodeTextBoxUser_TextChanged(object sender, TextChangedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(sender is Control control)) { return; }
if (!(control.DataContext is IChannelCode channelCode)) { return; }
var notUsed1 = new List<string>();
var notUsed2 = new List<string>();
vm.MarkModified(channelCode);
vm.ValidateUser(ref notUsed1, ref notUsed2);
}
private void ChannelCodeTextBoxIso_TextChanged(object sender, TextChangedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(sender is Control control)) { return; }
if (!(control.DataContext is IChannelCode channelCode)) { return; }
vm.MarkModified(channelCode);
var notUsed1 = new List<string>();
var notUsed2 = new List<string>();
vm.ValidateISO(ref notUsed1, ref notUsed2);
}
private void DisplayNameTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(((System.Windows.Controls.Control)e.Source).DataContext is IChannelCode channelCode)) { return; }
vm.MarkModified(channelCode);
}
private void DisplayNameTextBoxUser_TextChanged(object sender, TextChangedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(e.Source is TextBox textBox)) { return; }
if (!(textBox.DataContext is IChannelCode channelCode)) { return; }
vm.MarkModified(channelCode);
var notUsed1 = new List<string>();
var notUsed2 = new List<string>();
vm.ValidateUser(ref notUsed1, ref notUsed2);
}
private void DisplayNameTextBoxIso_TextChanged(object sender, TextChangedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(e.Source is TextBox textBox)) { return; }
if (!(textBox.DataContext is IChannelCode channelCode)) { return; }
vm.MarkModified(channelCode);
var notUsed1 = new List<string>();
var notUsed2 = new List<string>();
vm.ValidateISO(ref notUsed1, ref notUsed2);
}
private void ISO_Checked(object sender, RoutedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
vm.ViewMode = ChannelCodesListViewModel.ViewModes.ISO;
}
private void User_Checked(object sender, RoutedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
vm.ViewMode = ChannelCodesListViewModel.ViewModes.User;
}
private void ISOCodes_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(sender is ListView lv)) { return; }
var list = new List<IChannelCode>();
foreach (var item in lv.SelectedItems)
{
if (!(item is IChannelCode code))
{
continue;
}
list.Add(code);
}
vm.SetISOSelection(list.ToArray());
}
private void UserCodes_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(sender is ListView lv)) { return; }
var list = new List<IChannelCode>();
foreach (var item in lv.SelectedItems)
{
if (!(item is IChannelCode code))
{
continue;
}
list.Add(code);
}
vm.SetUserSelection(list.ToArray());
}
private void ChannelCodeBuilder_OnChannelCodeSelected(object sender, string code, string name, ChannelEnumsAndConstants.ChannelCodeType codetype)
{
if (!(DataContext is ChannelCodesListViewModel viewModel)) { return; }
if (!(sender is Control control)) { return; }
if (!(control.DataContext is IChannelCode channelCode)) { return; }
channelCode.Code = code;
if (string.IsNullOrWhiteSpace(channelCode.Name))
{
channelCode.Name = name;
}
viewModel.MarkModified(channelCode);
}
private void ISOChannelCodesListView_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
var point = e.GetPosition(ISOChannelCodesListView);
//we have to do multiple hittests unfortunately, because borders and rectangles...
var result = VisualTreeHelper.HitTest((UIElement)sender, point);
if (null == result) { return; }
if (!(result.VisualHit is UIElement element)) { return; }
var result2 = ISOChannelCodesListView.InputHitTest(point);
if (!(result2 is UIElement element2)) { return; }
//clicking on the bottom of the listview produces a scrollviewer, if we get that we can return
if (element is ScrollViewer)
{
return;
}
var vm = (IChannelCodesListViewModel)DataContext;
if (element is TextBlock tb)
{
if (tb.Text == ChannelCodes.Resources.StringResources.ISOCode) { vm?.Sort(ISOCodeColumnHeader.Tag, true); }
if (tb.Text == ChannelCodes.Resources.StringResources.ISOChannelName) { vm?.Sort(ISOChannelNameColumnHeader.Tag, true); }
return;
}
if (ISOCodeColumnHeader.IsDescendantOf(element) || ISOCodeColumnHeader.IsDescendantOf(element2))
{
vm?.Sort(ISOCodeColumnHeader.Tag, true);
return;
}
if (ISOChannelNameColumnHeader.IsDescendantOf(element) || ISOChannelNameColumnHeader.IsDescendantOf(element2))
{
vm?.Sort(ISOChannelNameColumnHeader.Tag, true);
}
}
private void UserChannelCodesListView_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
var point = e.GetPosition(UserChannelCodesListView);
//we have to do multiple hittests unfortunately, because borders and rectangles...
var result = VisualTreeHelper.HitTest((UIElement)sender, point);
if (null == result) { return; }
if (!(result.VisualHit is UIElement element)) { return; }
var result2 = UserChannelCodesListView.InputHitTest(point);
if (!(result2 is UIElement element2)) { return; }
//clicking on the bottom of the listview produces a scrollviewer, if we get that we can return
if (element is ScrollViewer)
{
return;
}
var vm = (IChannelCodesListViewModel)DataContext;
if (element is TextBlock tb)
{
if (tb.Text == ChannelCodes.Resources.StringResources.UserCode) { vm?.Sort(UserCodeColumnHeader.Tag, true); }
if (tb.Text == ChannelCodes.Resources.StringResources.UserChannelName) { vm?.Sort(UserChannelNameColumnHeader.Tag, true); }
return;
}
if (UserCodeColumnHeader.IsDescendantOf(element) || UserCodeColumnHeader.IsDescendantOf(element2))
{
vm?.Sort(UserCodeColumnHeader.Tag, true);
return;
}
if (UserChannelNameColumnHeader.IsDescendantOf(element) || UserChannelNameColumnHeader.IsDescendantOf(element2))
{
vm?.Sort(UserChannelNameColumnHeader.Tag, true);
}
}
//FB 25725 ISO selection has been changed, update the iso selection
private void DisplayNameTextBoxIso_SelectionChanged(object sender, RoutedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(((Control)e.Source).DataContext is IChannelCode channelCode)) { return; }
vm.SetISOSelection(new List<IChannelCode> { channelCode }.ToArray());
}
//FB 25725 ISO selection has been changed, update the iso selection
private void ChannelCodeBuilder_SelectionChanged(object sender, RoutedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(sender is Control control)) { return; }
if (!(control.DataContext is IChannelCode channelCode)) { return; }
vm.SetISOSelection(new List<IChannelCode> { channelCode }.ToArray());
}
//FB 25725 User code selection has been changed, update the user code selection
private void DisplayNameTextBoxUser_SelectionChanged(object sender, RoutedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(((Control)e.Source).DataContext is IChannelCode channelCode)) { return; }
vm.SetUserSelection(new List<IChannelCode> { channelCode }.ToArray());
}
//FB 25725 User code selection has been changed, update the user code selection
private void ChannelCodeTextBoxUser_SelectionChanged(object sender, RoutedEventArgs e)
{
if (!(DataContext is ChannelCodesListViewModel vm)) { return; }
if (!(sender is Control control)) { return; }
if (!(control.DataContext is IChannelCode channelCode)) { return; }
vm.SetUserSelection(new List<IChannelCode> { channelCode }.ToArray());
}
}
}