init
This commit is contained in:
110
DataPRO/Modules/ISO/ExtraProperties/ExtraProperties.csproj
Normal file
110
DataPRO/Modules/ISO/ExtraProperties/ExtraProperties.csproj
Normal file
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{CC693402-5F7C-4AAF-9DBE-5382B204C62B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ExtraProperties</RootNamespace>
|
||||
<AssemblyName>ExtraProperties</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Xaml.Behaviors">
|
||||
<HintPath>..\..\..\..\Common\DTS.Common\lib\PrismLibrary\Microsoft.Xaml.Behaviors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Prism">
|
||||
<HintPath>..\..\..\..\Common\DTS.Common\lib\PrismLibrary\Prism.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Unity.Wpf">
|
||||
<HintPath>..\..\..\..\Common\DTS.Common\lib\PrismLibrary\Prism.Unity.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Wpf">
|
||||
<HintPath>..\..\..\..\Common\DTS.Common\lib\PrismLibrary\Prism.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Unity.Abstractions">
|
||||
<HintPath>..\..\..\..\Common\DTS.Common\lib\PrismLibrary\Unity.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Container">
|
||||
<HintPath>..\..\..\..\Common\DTS.Common\lib\PrismLibrary\Unity.Container.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ExtraPropertiesModule.cs" />
|
||||
<Compile Include="Model\ExtraPropertyModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resources\StringResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>StringResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Resources\TranslateExtension.cs" />
|
||||
<Compile Include="ViewModel\ExtraPropertiesListViewModel.cs" />
|
||||
<Compile Include="View\ExtraPropertiesListView.xaml.cs">
|
||||
<DependentUpon>ExtraPropertiesListView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\Common\DTS.Common.Utilities\DTS.Common.Utilities.csproj">
|
||||
<Project>{d6da1b74-c711-43c2-91b1-1908a8d04dbf}</Project>
|
||||
<Name>DTS.Common.Utilities</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\Common\DTS.Common\DTS.Common.csproj">
|
||||
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
|
||||
<Name>DTS.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Page Include="View\ExtraPropertiesListView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\StringResources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>StringResources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
141
DataPRO/Modules/ISO/ExtraProperties/ExtraPropertiesModule.cs
Normal file
141
DataPRO/Modules/ISO/ExtraProperties/ExtraPropertiesModule.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Windows.Media.Imaging;
|
||||
using DTS.Common;
|
||||
|
||||
using ExtraProperties;
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Interface.ISO.ExtraProperties;
|
||||
using Prism.Modularity;
|
||||
using Unity;
|
||||
using Prism.Ioc;
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
// ReSharper disable RedundantAttributeUsageProperty
|
||||
// ReSharper disable UnusedParameter.Local
|
||||
|
||||
[assembly: ExtraPropertiesModuleName]
|
||||
[assembly: ExtraPropertiesModuleImageAttribute]
|
||||
namespace ExtraProperties
|
||||
{
|
||||
[Export(typeof(IModule))]
|
||||
[Module(ModuleName = "ExtraPropertiesModule")]
|
||||
public class ExtraPropertiesModule : IModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Injected unity container
|
||||
/// </summary>
|
||||
private readonly IUnityContainer _unityContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExtraPropertiesModule"/> class.
|
||||
/// </summary>
|
||||
/// <param name="unityContainer">Obtained reference of the unity container by using dependency injection.</param>
|
||||
public ExtraPropertiesModule(IUnityContainer unityContainer)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
// Register View & View-Model with Unity dependency injection container as a singleton.
|
||||
_unityContainer.RegisterType<IExtraPropertiesListViewModel, ExtraPropertiesListViewModel>();
|
||||
_unityContainer.RegisterType<IExtraPropertiesListView, ExtraPropertiesListView>();
|
||||
|
||||
}
|
||||
|
||||
public void OnInitialized(IContainerProvider containerProvider)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute class contains assembly name
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
||||
public class ExtraPropertiesModuleNameAttribute : TextAttribute
|
||||
{
|
||||
public ExtraPropertiesModuleNameAttribute() : this(null) { }
|
||||
|
||||
public ExtraPropertiesModuleNameAttribute(string s)
|
||||
{
|
||||
AssemblyName = AssemblyNames.ExtraProperties.ToString();
|
||||
}
|
||||
|
||||
public override string AssemblyName { get; }
|
||||
|
||||
public override Type GetAttributeType()
|
||||
{
|
||||
return typeof(TextAttribute);
|
||||
}
|
||||
|
||||
public override string GetAssemblyName()
|
||||
{
|
||||
return AssemblyName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute class contains assembly image and name - used on the Main screen to SummaryModule available components
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
||||
public class ExtraPropertiesModuleImageAttribute : ImageAttribute
|
||||
{
|
||||
private BitmapImage _img;
|
||||
|
||||
public ExtraPropertiesModuleImageAttribute() : this(null) { }
|
||||
public override BitmapImage AssemblyImage
|
||||
{
|
||||
get { _img = AssemblyInfo.GetImage(AssemblyNames.ExtraProperties.ToString()); return _img; }
|
||||
}
|
||||
public ExtraPropertiesModuleImageAttribute(string s)
|
||||
{
|
||||
_img = AssemblyInfo.GetImage(AssemblyNames.ExtraProperties.ToString());
|
||||
}
|
||||
|
||||
public override Type GetAttributeType()
|
||||
{
|
||||
return typeof(ImageAttribute);
|
||||
}
|
||||
public override BitmapImage GetAssemblyImage()
|
||||
{
|
||||
return AssemblyImage;
|
||||
}
|
||||
private string _name;
|
||||
public override string AssemblyName
|
||||
{
|
||||
get { _name = AssemblyNames.ExtraProperties.ToString(); return _name; }
|
||||
}
|
||||
|
||||
public override string GetAssemblyName()
|
||||
{
|
||||
return AssemblyName;
|
||||
}
|
||||
private string _group;
|
||||
public override string AssemblyGroup
|
||||
{
|
||||
get { _group = eAssemblyGroups.Prepare.ToString(); return _group; }
|
||||
}
|
||||
|
||||
public override string GetAssemblyGroup()
|
||||
{
|
||||
return AssemblyGroup;
|
||||
}
|
||||
|
||||
private eAssemblyRegion _region;
|
||||
public override eAssemblyRegion AssemblyRegion
|
||||
{
|
||||
get { _region = eAssemblyRegion.ExtraPropertiesRegion; return _region; }
|
||||
}
|
||||
public override eAssemblyRegion GetAssemblyRegion()
|
||||
{
|
||||
return AssemblyRegion;
|
||||
}
|
||||
}
|
||||
}
|
||||
169
DataPRO/Modules/ISO/ExtraProperties/Model/ExtraPropertyModel.cs
Normal file
169
DataPRO/Modules/ISO/ExtraProperties/Model/ExtraPropertyModel.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using DTS.Common.ISO.ExtraProperties;
|
||||
using DTS.Common.Controls;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Events;
|
||||
using DTS.Common.Interface.ISO.ExtraProperties;
|
||||
using Prism.Ioc;
|
||||
using Prism.Events;
|
||||
|
||||
namespace ExtraProperties.Model
|
||||
{
|
||||
public class ExtraPropertyModel : DTS.Common.Base.BasePropertyChanged, IExtraProperty
|
||||
{
|
||||
//in case this object is held onto longer before cleanup, attempt to empty
|
||||
//private storage
|
||||
~ExtraPropertyModel()
|
||||
{
|
||||
_key = null;
|
||||
_value = null;
|
||||
PasteCommand = null;
|
||||
}
|
||||
|
||||
public ExtraPropertyModel(IExtraProperty extraProperty)
|
||||
{
|
||||
RegisterCommands();
|
||||
Key = extraProperty.Key;
|
||||
Value = extraProperty.Value;
|
||||
}
|
||||
|
||||
public ExtraPropertyModel()
|
||||
{
|
||||
RegisterCommands();
|
||||
}
|
||||
|
||||
public ExtraPropertyModel(KeyValuePair<string, string> extraProperty)
|
||||
{
|
||||
RegisterCommands();
|
||||
Key = extraProperty.Key;
|
||||
Value = extraProperty.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// status of the item in the UI
|
||||
/// </summary>
|
||||
private UIItemStatus _itemStatus = UIItemStatus.None;
|
||||
public UIItemStatus ItemStatus
|
||||
{
|
||||
get => _itemStatus;
|
||||
set => SetProperty(ref _itemStatus, value, "ItemStatus");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the code (isocode or usercode) value
|
||||
/// </summary>
|
||||
private string _key;
|
||||
public string Key
|
||||
{
|
||||
get => _key;
|
||||
set => SetProperty(ref _key, value, "Key");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the name (iso channel name or user channel name)
|
||||
/// associated with code
|
||||
/// </summary>
|
||||
private string _value;
|
||||
public string Value
|
||||
{
|
||||
get => _value;
|
||||
set => SetProperty(ref _value, value, "Value");
|
||||
}
|
||||
|
||||
public ICommand PasteCommand { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// this could be passed into the constructors in the future, but since it's only used in one place right now, I'll just put it here
|
||||
/// </summary>
|
||||
public const string PASTE_ID = "ExtraProperty";
|
||||
private void RegisterCommands()
|
||||
{
|
||||
PasteCommand = new PasteCommandClass(PASTE_ID);
|
||||
CommandManager.RegisterClassCommandBinding(GetType(),
|
||||
new CommandBinding(PasteCommand, Paste));
|
||||
}
|
||||
|
||||
private void Paste(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class PasteCommandClass : ICommand
|
||||
{
|
||||
public string Id { get; }
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
var eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
try
|
||||
{
|
||||
if (!(parameter is TextBox tb))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!(tb.DataContext is IExtraProperty extraProperty))
|
||||
{
|
||||
if (tb.DataContext is ChannelCodeBuilder ccb)
|
||||
{
|
||||
extraProperty = ccb.DataContext as IExtraProperty;
|
||||
}
|
||||
else if (tb.DataContext is ChannelNameBuilder cnb)
|
||||
{
|
||||
extraProperty = cnb.DataContext as IExtraProperty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Clipboard.ContainsText())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var text = Clipboard.GetText();
|
||||
var lines = text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (1 == lines.Length)
|
||||
{
|
||||
var line = lines[0];
|
||||
if (line.IndexOfAny(new[] { ',', ';', '\t' }) < 0)
|
||||
{
|
||||
//this is a single field paste, don't do any further processing, let textchanged take care of it
|
||||
|
||||
eventAggregator.GetEvent<PageModifiedEvent>().Publish(new PageModifiedArg(PageModifiedArg.Status.Modified, null));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//wipe out the built in effect of the paste
|
||||
extraProperty.Key = extraProperty.Key;
|
||||
extraProperty.Value = extraProperty.Value;
|
||||
|
||||
eventAggregator.GetEvent<TextPastedEvent>().Publish(new TextPastedArgs(text, extraProperty, Id, tb.Tag));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
eventAggregator.GetEvent<PageErrorEvent>().Publish(new PageErrorArg(new[] { ex.Message }, null));
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public PasteCommandClass(string id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ExtraProperties")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ExtraProperties")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("cc693402-5f7c-4aaf-9dbe-5382b204c62b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
108
DataPRO/Modules/ISO/ExtraProperties/Resources/StringResources.Designer.cs
generated
Normal file
108
DataPRO/Modules/ISO/ExtraProperties/Resources/StringResources.Designer.cs
generated
Normal file
@@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ExtraProperties.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class StringResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal StringResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ExtraProperties.Resources.StringResources", typeof(StringResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Invalid pasted channel code, line: {0}.
|
||||
/// </summary>
|
||||
internal static string InvalidLine {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidLine", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Key.
|
||||
/// </summary>
|
||||
internal static string Key {
|
||||
get {
|
||||
return ResourceManager.GetString("Key", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The following keys have no value:.
|
||||
/// </summary>
|
||||
internal static string NoValueWarning {
|
||||
get {
|
||||
return ResourceManager.GetString("NoValueWarning", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Keys must be unique. The following repeat:.
|
||||
/// </summary>
|
||||
internal static string RepeatKeyError {
|
||||
get {
|
||||
return ResourceManager.GetString("RepeatKeyError", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value.
|
||||
/// </summary>
|
||||
internal static string Value {
|
||||
get {
|
||||
return ResourceManager.GetString("Value", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="InvalidLine" xml:space="preserve">
|
||||
<value>Invalid pasted channel code, line: {0}</value>
|
||||
</data>
|
||||
<data name="Key" xml:space="preserve">
|
||||
<value>Key</value>
|
||||
</data>
|
||||
<data name="NoValueWarning" xml:space="preserve">
|
||||
<value>The following keys have no value:</value>
|
||||
</data>
|
||||
<data name="RepeatKeyError" xml:space="preserve">
|
||||
<value>Keys must be unique. The following repeat:</value>
|
||||
</data>
|
||||
<data name="Value" xml:space="preserve">
|
||||
<value>Value</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Windows.Markup;
|
||||
using ExtraProperties.Resources;
|
||||
|
||||
namespace ExtraProperties
|
||||
{
|
||||
[MarkupExtensionReturnType(typeof(string))]
|
||||
public class TranslateExtension : MarkupExtension
|
||||
{
|
||||
private readonly string _key;
|
||||
public TranslateExtension(string key) { _key = key; }
|
||||
|
||||
private const string NotFound = "#stringnotfound#";
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_key)) { return NotFound; }
|
||||
return StringResources.ResourceManager.GetString(_key) ?? NotFound + " " + _key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DTS.Common.Events;
|
||||
using DTS.Common.Events.ISO;
|
||||
using DTS.Common.Interactivity;
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Interface.ISO.ExtraProperties;
|
||||
using ExtraProperties.Model;
|
||||
using ExtraProperties.Resources;
|
||||
using Prism.Events;
|
||||
using Prism.Regions;
|
||||
using Unity;
|
||||
|
||||
namespace ExtraProperties
|
||||
{
|
||||
[PartCreationPolicy(CreationPolicy.Shared)]
|
||||
public class ExtraPropertiesListViewModel : IExtraPropertiesListViewModel
|
||||
{
|
||||
public IExtraPropertiesListView View { get; set; }
|
||||
|
||||
private IEventAggregator _eventAggregator { get; }
|
||||
private IUnityContainer UnityContainer { get; }
|
||||
|
||||
public InteractionRequest<Notification> NotificationRequest { get; }
|
||||
public InteractionRequest<Confirmation> ConfirmationRequest { get; }
|
||||
|
||||
#region constructors and initializers
|
||||
private static bool _bAddListeners = false;
|
||||
/// <summary>
|
||||
/// Creates a new instance of the ExtraPropertiesListViewModel
|
||||
/// </summary>
|
||||
/// <param name="view"></param>
|
||||
/// <param name="regionManager">The logical placeholder defined within the application's UI (in the shell or within views) into which views are displayed.</param>
|
||||
/// <param name="eventAggregator">The EventAggregator which allows different components to publish/subscribe to events without being coupled to each other.</param>
|
||||
/// <param name="unityContainer">The unityContainer.</param>
|
||||
public ExtraPropertiesListViewModel(IExtraPropertiesListView view, IRegionManager regionManager,
|
||||
IEventAggregator eventAggregator, IUnityContainer unityContainer)
|
||||
{
|
||||
View = view;
|
||||
View.DataContext = this;
|
||||
|
||||
NotificationRequest = new InteractionRequest<Notification>();
|
||||
ConfirmationRequest = new InteractionRequest<Confirmation>();
|
||||
|
||||
_eventAggregator = eventAggregator;
|
||||
UnityContainer = unityContainer;
|
||||
_eventAggregator.GetEvent<RaiseNotification>().Subscribe(OnRaiseNotification);
|
||||
_eventAggregator.GetEvent<BusyIndicatorChangeNotification>()
|
||||
.Subscribe(OnBusyIndicatorNotification, ThreadOption.PublisherThread, true);
|
||||
//this is a hack, the app startup is calling this, then the app itself, we only want the
|
||||
//app itself to be handling the listeners
|
||||
if (_bAddListeners)
|
||||
{
|
||||
_eventAggregator.GetEvent<TextPastedEvent>().Subscribe(OnTextPasted);
|
||||
}
|
||||
_bAddListeners = true;
|
||||
}
|
||||
|
||||
private void OnTextPasted(ITextPastedEventArgs args)
|
||||
{
|
||||
if (args.Id != ExtraPropertyModel.PASTE_ID) { return; }
|
||||
|
||||
if (!(args.Sender is IExtraProperty iep))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Paste(iep, args.Text, args.Tag);
|
||||
var last = ExtraProperties.Last();
|
||||
if (!string.IsNullOrWhiteSpace(last.Key) || !string.IsNullOrWhiteSpace(last.Value))
|
||||
{
|
||||
MarkModified(last);
|
||||
}
|
||||
|
||||
_eventAggregator.GetEvent<PageModifiedEvent>()
|
||||
.Publish(new PageModifiedArg(PageModifiedArg.Status.Modified, Page));
|
||||
}
|
||||
|
||||
private void OnBusyIndicatorNotification(bool eventArg)
|
||||
{
|
||||
IsBusy = eventArg;
|
||||
}
|
||||
|
||||
private void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)
|
||||
{
|
||||
// The NotificationRequest.Raise triggers the Invoke() method of the PopupWindowAction object to show the NotificationWindow window
|
||||
// Notification object expects a NotificationContentEventArgsWithoutTitle object and a Title string.
|
||||
var eventArgsWithoutTitle = new NotificationContentEventArgs(eventArgsWithTitle.Message, "",
|
||||
eventArgsWithTitle.Image, string.Empty);
|
||||
|
||||
NotificationRequest.Raise(new Notification
|
||||
{
|
||||
Content = eventArgsWithoutTitle,
|
||||
Title = eventArgsWithTitle.Title
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Occurs when a property value changes.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
if ("ExtraProperties" == propertyName)
|
||||
{
|
||||
_eventAggregator.GetEvent<ExtraPropertiesChangedEvent>()
|
||||
.Publish(new ExtraPropertiesChangedEventArgs(AllExtraProperties.Where(exp => !string.IsNullOrEmpty(exp.Key)).ToList(), this, Parent));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPage(IDataPROPage page)
|
||||
{
|
||||
Page = page;
|
||||
}
|
||||
|
||||
public void SetParent(object parent)
|
||||
{
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
public Task CleanupAsync()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Initialize(object parameter)
|
||||
{
|
||||
}
|
||||
|
||||
public void Initialize(object parameter, object model)
|
||||
{
|
||||
}
|
||||
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task InitializeAsync(object parameter)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Activated()
|
||||
{
|
||||
}
|
||||
|
||||
internal void MarkModified(IExtraProperty iep)
|
||||
{
|
||||
if (ExtraProperties.ToList().Last() == iep)
|
||||
{
|
||||
var newXP = new ExtraPropertyModel();
|
||||
ExtraProperties.Add(newXP);
|
||||
AllExtraProperties.Add(newXP);
|
||||
}
|
||||
OnPropertyChanged("ExtraProperties");
|
||||
_eventAggregator.GetEvent<PageModifiedEvent>()
|
||||
.Publish(new PageModifiedArg(PageModifiedArg.Status.Modified, Page));
|
||||
}
|
||||
|
||||
public void Filter(object tag, string term)
|
||||
{
|
||||
if (!(tag is string s))
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (s)
|
||||
{
|
||||
case "Key":
|
||||
_searchTermForField[Fields.Key] = term;
|
||||
Filter();
|
||||
break;
|
||||
case "Value":
|
||||
_searchTermForField[Fields.Key] = term;
|
||||
Filter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Sort(object columnTag, bool columnClick)
|
||||
{
|
||||
if (!(columnTag is string s)) { return; }
|
||||
switch (s)
|
||||
{
|
||||
case "Key":
|
||||
Sort(Fields.Key, true);
|
||||
Filter();
|
||||
break;
|
||||
case "Value":
|
||||
Sort(Fields.Value, true);
|
||||
Filter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void Sort(Fields field, bool bColumnClick)
|
||||
{
|
||||
if (bColumnClick)
|
||||
{
|
||||
if (field != _sortField)
|
||||
{
|
||||
_sortField = field;
|
||||
_sortAscending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_sortAscending = !_sortAscending;
|
||||
}
|
||||
}
|
||||
var comparer = new PropertyComparer();
|
||||
comparer.SortField = _sortField;
|
||||
comparer.SortAscending = _sortAscending;
|
||||
AllExtraProperties.Sort(comparer);
|
||||
}
|
||||
|
||||
public enum Fields
|
||||
{
|
||||
Key,
|
||||
Value
|
||||
}
|
||||
private Fields _sortField = Fields.Key;
|
||||
private bool _sortAscending = true;
|
||||
|
||||
private void Filter()
|
||||
{
|
||||
ExtraProperties.Clear();
|
||||
foreach (var extraProperty in AllExtraProperties)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(extraProperty.Key) && string.IsNullOrWhiteSpace(extraProperty.Value))
|
||||
{
|
||||
ExtraProperties.Add(extraProperty);
|
||||
continue;
|
||||
}
|
||||
if (_searchTermForField.ContainsKey(Fields.Value))
|
||||
{
|
||||
var term = _searchTermForField[Fields.Value];
|
||||
if (!string.IsNullOrEmpty(term))
|
||||
{
|
||||
if (extraProperty.Value.IndexOf(term, StringComparison.CurrentCultureIgnoreCase) < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_searchTermForField.ContainsKey(Fields.Key))
|
||||
{
|
||||
var term = _searchTermForField[Fields.Key];
|
||||
if (!string.IsNullOrWhiteSpace(term))
|
||||
{
|
||||
if (extraProperty.Key.IndexOf(term, StringComparison.CurrentCultureIgnoreCase) < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
ExtraProperties.Add(extraProperty);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Validate(ref List<string> errors, ref List<string> warnings)
|
||||
{
|
||||
var repeatKeys = AllExtraProperties.GroupBy(exp => exp.Key).Where(grp => grp.Count() > 1).Select(exp => exp.Key).ToArray();
|
||||
if (repeatKeys.Length > 0)
|
||||
{
|
||||
var error = StringResources.RepeatKeyError + Environment.NewLine + string.Join(Environment.NewLine, repeatKeys);
|
||||
errors.Add(error);
|
||||
}
|
||||
var noValueKeys = AllExtraProperties.Where(exp => string.IsNullOrWhiteSpace(exp.Value)).Select(exp => exp.Key).ToArray();
|
||||
if (noValueKeys.Length > 0)
|
||||
{
|
||||
var warning = StringResources.NoValueWarning + Environment.NewLine + string.Join(Environment.NewLine, noValueKeys);
|
||||
warnings.Add(warning);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Validate(ref List<string> errors)
|
||||
{
|
||||
var before = errors.Count;
|
||||
var notUsed = new List<string>();
|
||||
Validate(ref errors, ref notUsed);
|
||||
return before == errors.Count;
|
||||
}
|
||||
|
||||
private readonly Dictionary<Fields, string> _searchTermForField = new Dictionary<Fields, string>();
|
||||
|
||||
private IExtraProperty[] _selectedItems = null;
|
||||
|
||||
public IDataPROPage Page { get; private set; }
|
||||
public object Parent { get; private set; }
|
||||
public bool IsDirty { get; private set; }
|
||||
private bool _isBusy = false;
|
||||
public bool IsBusy
|
||||
{
|
||||
get => _isBusy;
|
||||
set
|
||||
{
|
||||
_isBusy = value;
|
||||
OnPropertyChanged("IsBusy");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isMenuIncluded;
|
||||
|
||||
private void NotifySelectionChanged(int count)
|
||||
{
|
||||
_eventAggregator.GetEvent<PageSelectionChanged>().Publish(new PageSelectionChangedArg(count, Page));
|
||||
}
|
||||
internal void SetSelection(IExtraProperty[] ieps)
|
||||
{
|
||||
_selectedItems = ieps;
|
||||
NotifySelectionChanged(_selectedItems?.Length ?? 0);
|
||||
}
|
||||
|
||||
public bool IsMenuIncluded
|
||||
{
|
||||
get => _isMenuIncluded;
|
||||
set
|
||||
{
|
||||
_isMenuIncluded = value;
|
||||
OnPropertyChanged("IsMenuIncluded");
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isNavigationIncluded;
|
||||
public bool IsNavigationIncluded
|
||||
{
|
||||
get => _isNavigationIncluded;
|
||||
set
|
||||
{
|
||||
_isNavigationIncluded = value;
|
||||
OnPropertyChanged("IsNavigationIncluded");
|
||||
}
|
||||
}
|
||||
|
||||
//FB14098: Ability to disable editing View if user doesn't have the permissions, but still view current data
|
||||
private bool _isReadOnly;
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => _isReadOnly;
|
||||
set
|
||||
{
|
||||
_isReadOnly = value;
|
||||
OnPropertyChanged("IsReadOnly");
|
||||
}
|
||||
}
|
||||
|
||||
public List<IExtraProperty> AllExtraProperties { get; set; } = new List<IExtraProperty>();
|
||||
|
||||
public ObservableCollection<IExtraProperty> ExtraProperties { get; set; } =
|
||||
new ObservableCollection<IExtraProperty>();
|
||||
|
||||
public IExtraProperty[] SelectedProperties => throw new NotImplementedException();
|
||||
|
||||
private void Paste(IExtraProperty extraProperty, string text, object tag)
|
||||
{
|
||||
bool bKey = tag.Equals("ExtraProperty");
|
||||
var extraProperties = ParseText(text, bKey, out var oneColumn);
|
||||
int index = ExtraProperties.IndexOf(extraProperty);
|
||||
|
||||
foreach (var extraproperty in extraProperties)
|
||||
{
|
||||
if (index > (ExtraProperties.Count - 1))
|
||||
{
|
||||
ExtraProperties.Add(extraProperty);
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
var exp = ExtraProperties[index++];
|
||||
if (oneColumn)
|
||||
{
|
||||
exp.Key = bKey ? extraproperty.Key : exp.Key;
|
||||
exp.Value = bKey ? exp.Value : extraproperty.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
exp.Key = extraproperty.Key;
|
||||
exp.Value = extraproperty.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sort(_sortField, false);
|
||||
Filter();
|
||||
}
|
||||
|
||||
private IExtraProperty[] ParseText(string text, bool bKey, out bool oneColumn)
|
||||
{
|
||||
oneColumn = false;
|
||||
var list = new List<IExtraProperty>();
|
||||
var errors = new List<string>();
|
||||
var lines = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
||||
for (var i = 0; i < lines.Length; i++)
|
||||
{
|
||||
var line = lines[i];
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var tokens = line.Split(',');
|
||||
if (tokens.Length != 2)
|
||||
{
|
||||
tokens = line.Split('\t');
|
||||
}
|
||||
if (tokens.Length != 2)
|
||||
{
|
||||
tokens = line.Split(';');
|
||||
}
|
||||
|
||||
var newProperty = new ExtraPropertyModel();
|
||||
if (tokens.Length == 1)
|
||||
{
|
||||
oneColumn = true;
|
||||
if (bKey)
|
||||
{
|
||||
newProperty.Key = tokens[0];
|
||||
newProperty.Value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
newProperty.Value = tokens[0];
|
||||
newProperty.Key = "";
|
||||
}
|
||||
}
|
||||
else if (tokens.Length == 2)
|
||||
{
|
||||
newProperty.Key = tokens[0];
|
||||
newProperty.Value = tokens[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
errors.Add(string.Format(Resources.StringResources.InvalidLine, 1 + i));
|
||||
continue;
|
||||
}
|
||||
|
||||
list.Add(newProperty);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public void SetExtraProperties(IList<IExtraProperty> properties)
|
||||
{
|
||||
AllExtraProperties.Clear();
|
||||
|
||||
AllExtraProperties.AddRange(properties.Select(iep => new ExtraPropertyModel(iep)));
|
||||
AllExtraProperties.Add(new ExtraPropertyModel());
|
||||
|
||||
_sortField = Fields.Key;
|
||||
_sortAscending = true;
|
||||
|
||||
Sort(_sortField, false);
|
||||
Filter();
|
||||
}
|
||||
|
||||
public void CopySelected()
|
||||
{
|
||||
if (null == _selectedItems) { return; }
|
||||
|
||||
foreach (var item in _selectedItems)
|
||||
{
|
||||
AllExtraProperties.Insert(AllExtraProperties.Count - 1, new ExtraPropertyModel(item));
|
||||
}
|
||||
Sort(_sortField, false);
|
||||
Filter();
|
||||
_eventAggregator.GetEvent<PageModifiedEvent>()
|
||||
.Publish(new PageModifiedArg(PageModifiedArg.Status.Modified, Page));
|
||||
}
|
||||
|
||||
public void DeleteSelected()
|
||||
{
|
||||
if (null == _selectedItems) { return; }
|
||||
bool bAddLast = false;
|
||||
|
||||
foreach (var exp in _selectedItems)
|
||||
{
|
||||
if (ExtraProperties.Last() == exp)
|
||||
{
|
||||
bAddLast = true;
|
||||
}
|
||||
ExtraProperties.Remove(exp);
|
||||
AllExtraProperties.Remove(exp);
|
||||
}
|
||||
|
||||
if (bAddLast)
|
||||
{
|
||||
var newXP = new ExtraPropertyModel();
|
||||
ExtraProperties.Add(newXP);
|
||||
AllExtraProperties.Add(newXP);
|
||||
}
|
||||
OnPropertyChanged("ExtraProperties");
|
||||
_eventAggregator.GetEvent<PageModifiedEvent>()
|
||||
.Publish(new PageModifiedArg(PageModifiedArg.Status.Modified, Page));
|
||||
}
|
||||
|
||||
public class PropertyComparer : IComparer<IExtraProperty>
|
||||
{
|
||||
public Fields SortField { get; set; }
|
||||
public bool SortAscending { get; set; }
|
||||
public int Compare(IExtraProperty left, IExtraProperty right)
|
||||
{
|
||||
if (left == right)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var a = left; var b = right;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(a.Key) && string.IsNullOrWhiteSpace(a.Value))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(b.Key) && string.IsNullOrWhiteSpace(b.Value))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!SortAscending) { a = right; b = left; }
|
||||
if (null == a)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (null == b)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
switch (SortField)
|
||||
{
|
||||
case Fields.Key:
|
||||
return DTS.Common.Utilities.NaturalStringComparer.StaticCompare(a.Key.ToUpper(), b.Key.ToUpper());
|
||||
case Fields.Value:
|
||||
return DTS.Common.Utilities.NaturalStringComparer.StaticCompare(a.Value.ToUpper(), b.Value.ToUpper());
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user