init
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<base:BaseView x:Class="ExtraProperties.ExtraPropertiesListView"
|
||||
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:ExtraProperties"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:ExtraProperties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<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="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<ListView ItemsSource="{Binding ExtraProperties, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1"
|
||||
AutomationProperties.AutomationId="ExtraPropertiesLv" SelectionMode="Extended" SelectionChanged="ExtraProperties_SelectionChanged"
|
||||
KeyboardNavigation.TabNavigation="Continue" x:Name="ExtraPropertiesListViewLV" PreviewMouseLeftButtonUp="ExtraPropertiesListView_PreviewMouseLeftButtonUp">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style>
|
||||
<Setter Property="KeyboardNavigation.IsTabStop" Value="False" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.View>
|
||||
<controls:AutoSizedGridView AutomationProperties.AutomationId="ExtraPropertiesListGridView">
|
||||
<GridViewColumn AutomationProperties.AutomationId="KeyColumn" Width="315">
|
||||
<GridViewColumn.Header>
|
||||
<controls:GridViewColumnHeaderSearchable Tag="ExtraPropertyKey" HeaderTitle="{strings:TranslateExtension Key}" Search="GridViewColumnHeaderSearchable_OnSearch"
|
||||
ListviewId="{Binding ListViewId}" x:Name="KeyColumnHeader" ClickHandler="GridViewColumnHeader_OnClick"/>
|
||||
</GridViewColumn.Header>
|
||||
<GridViewColumn.CellTemplate>
|
||||
<ItemContainerTemplate>
|
||||
<TextBox Width="300" AutomationProperties.AutomationId="ExtraPropertyKeyTextBox"
|
||||
Text="{Binding Key, UpdateSourceTrigger=PropertyChanged}" KeyDown="ExtraPropertyKeyTextBox_KeyDown"
|
||||
TextChanged="ExtraPropertyKeyTextBox_TextChanged" MaxLength="250"
|
||||
behaviors:TextBoxPasteBehavior.PasteCommand="{Binding PasteCommand}" Tag="ExtraPropertyKey"
|
||||
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="ExtraPropertyValue" HeaderTitle="{strings:TranslateExtension Value}" Search="GridViewColumnHeaderSearchable_OnSearch"
|
||||
ListviewId="{Binding ListViewId}" x:Name="ValueColumnHeader"/>
|
||||
</GridViewColumn.Header>
|
||||
<GridViewColumn.CellTemplate>
|
||||
<ItemContainerTemplate>
|
||||
<TextBox Width="300" AutomationProperties.AutomationId="DisplayNameTextBox"
|
||||
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" KeyDown="ExtraPropertyValueTextBox_KeyDown"
|
||||
TextChanged="ExtraPropertyValueTextBox_TextChanged" MaxLength="250"
|
||||
behaviors:TextBoxPasteBehavior.PasteCommand="{Binding PasteCommand}" Tag="ExtraPropertyValue"
|
||||
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>
|
||||
</Grid>
|
||||
</base:BaseView>
|
||||
@@ -0,0 +1,129 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using DTS.Common.Controls;
|
||||
using DTS.Common.Interface.ISO.ExtraProperties;
|
||||
using DTS.Common.Utils;
|
||||
|
||||
namespace ExtraProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ExtraPropertiesListView.xaml
|
||||
/// </summary>
|
||||
public partial class ExtraPropertiesListView : IExtraPropertiesListView
|
||||
{
|
||||
public ExtraPropertiesListView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void GridViewColumnHeaderSearchable_OnSearch(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var searchTerm = (string)e.OriginalSource;
|
||||
var columnTag = (sender as GridViewColumnHeaderSearchable)?.Tag;
|
||||
var viewModel = (IExtraPropertiesListViewModel)DataContext;
|
||||
viewModel.Filter(columnTag, searchTerm);
|
||||
}
|
||||
|
||||
private void GridViewColumnHeader_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var vm = (IExtraPropertiesListViewModel)DataContext;
|
||||
var columnTag = (sender as GridViewColumnHeaderSearchable)?.Tag ?? Utils.FindChild<GridViewColumnHeaderSearchable>((DependencyObject)e.OriginalSource, null)?.Tag;
|
||||
vm?.Sort(columnTag, true);
|
||||
}
|
||||
|
||||
private void ExtraPropertyKeyTextBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (!(DataContext is ExtraPropertiesListViewModel vm)) { return; }
|
||||
if (!(((System.Windows.Controls.Control)e.Source).DataContext is IExtraProperty iep)) { return; }
|
||||
|
||||
vm.MarkModified(iep);
|
||||
}
|
||||
|
||||
private void ExtraPropertyKeyTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (!(DataContext is ExtraPropertiesListViewModel vm)) { return; }
|
||||
if (!(e.Source is TextBox textBox)) { return; }
|
||||
if (!(textBox.DataContext is IExtraProperty iep)) { return; }
|
||||
|
||||
vm.MarkModified(iep);
|
||||
var notUsed1 = new List<string>();
|
||||
var notUsed2 = new List<string>();
|
||||
vm.Validate(ref notUsed1, ref notUsed2);
|
||||
}
|
||||
|
||||
private void ExtraProperties_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (!(DataContext is ExtraPropertiesListViewModel vm)) { return; }
|
||||
if (!(sender is ListView lv)) { return; }
|
||||
|
||||
var list = new List<IExtraProperty>();
|
||||
foreach (var item in lv.SelectedItems)
|
||||
{
|
||||
if (!(item is IExtraProperty exp))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(exp);
|
||||
}
|
||||
vm.SetSelection(list.ToArray());
|
||||
}
|
||||
|
||||
private void ExtraPropertiesListView_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var point = e.GetPosition(ExtraPropertiesListViewLV);
|
||||
|
||||
//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 = ExtraPropertiesListViewLV.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 = (IExtraPropertiesListViewModel)DataContext;
|
||||
if (element is TextBlock tb)
|
||||
{
|
||||
if (tb.Text == ExtraProperties.Resources.StringResources.Key) { vm?.Sort(KeyColumnHeader.Tag, true); }
|
||||
if (tb.Text == ExtraProperties.Resources.StringResources.Value) { vm?.Sort(ValueColumnHeader.Tag, true); }
|
||||
return;
|
||||
}
|
||||
if (KeyColumnHeader.IsDescendantOf(element) || KeyColumnHeader.IsDescendantOf(element2))
|
||||
{
|
||||
vm?.Sort(KeyColumnHeader.Tag, true);
|
||||
return;
|
||||
}
|
||||
if (ValueColumnHeader.IsDescendantOf(element) || ValueColumnHeader.IsDescendantOf(element2))
|
||||
{
|
||||
vm?.Sort(ValueColumnHeader.Tag, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtraPropertyValueTextBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (!(DataContext is ExtraPropertiesListViewModel vm)) { return; }
|
||||
if (!(((System.Windows.Controls.Control)e.Source).DataContext is IExtraProperty iep)) { return; }
|
||||
|
||||
vm.MarkModified(iep);
|
||||
}
|
||||
|
||||
private void ExtraPropertyValueTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (!(DataContext is ExtraPropertiesListViewModel vm)) { return; }
|
||||
if (!(e.Source is TextBox textBox)) { return; }
|
||||
if (!(textBox.DataContext is IExtraProperty iep)) { return; }
|
||||
|
||||
vm.MarkModified(iep);
|
||||
var notUsed1 = new List<string>();
|
||||
var notUsed2 = new List<string>();
|
||||
vm.Validate(ref notUsed1, ref notUsed2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user