diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-09-16 17:48:16 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-09-16 17:48:16 +0300 |
| commit | 161fe6f6d2b29ba3deb641cdc049ad0d8f58004e (patch) | |
| tree | 20318bb7ea4a243b8c2e9757e4635e8d5f5cb728 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs | |
| parent | 30fcfa4100a9d00e887c6e17e32e427b05296ce7 (diff) | |
| parent | b674a2e7751daa80c0d74207968bf8e3d18d7faf (diff) | |
| download | Tango-161fe6f6d2b29ba3deb641cdc049ad0d8f58004e.tar.gz Tango-161fe6f6d2b29ba3deb641cdc049ad0d8f58004e.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs')
28 files changed, 1794 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/App.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/App.config new file mode 100644 index 000000000..2285e8847 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/App.config @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> + </configSections> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> + </providers> + </entityFramework> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/CatalogsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/CatalogsModule.cs new file mode 100644 index 000000000..389a2cb5d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/CatalogsModule.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media.Imaging; +using Tango.BL.Enumerations; +using Tango.MachineStudio.Catalogs.Views; +using Tango.MachineStudio.Common; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Catalogs +{ + [StudioModule(20)] + public class CatalogsModule : StudioModuleBase + { + public override string Name + { + get + { + return "Catalogs"; + } + } + + public override string Description + { + get + { + return "Create and manage Twine's global color catalogs."; + } + } + + public override BitmapSource Image + { + get + { + return ResourceHelper.GetImageFromResources("Images/catalogs_module.jpg"); + } + } + + public override Type MainViewType + { + get + { + return typeof(MainView); + } + } + + public override Permissions Permission + { + get + { + return Permissions.RunCatalogsModule; + } + } + + public override void Dispose() + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Contracts/IMainView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Contracts/IMainView.cs new file mode 100644 index 000000000..615dec081 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Contracts/IMainView.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Catalogs.Contracts +{ + public enum CatalogsNavigationView + { + CatalogsView, + CatalogView, + } + + public interface IMainView : IView + { + void NavigateTo(CatalogsNavigationView view); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Converters/ObservableCollectionToViewSourceConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Converters/ObservableCollectionToViewSourceConverter.cs new file mode 100644 index 000000000..050539741 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Converters/ObservableCollectionToViewSourceConverter.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.MachineStudio.Catalogs.Converters +{ + public class ObservableCollectionToViewSourceConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + String sortMember = parameter != null ? parameter.ToString() : null; + IList list = value as IList; + if (list != null) + { + var view = CollectionViewSource.GetDefaultView(list); + view.SortDescriptions.Clear(); + + //Delay because the DataGrid clears the sort description after source change. + Task.Factory.StartNew(() => + { + Thread.Sleep(10); + + Application.Current.Dispatcher.BeginInvoke(new Action(() => + { + view.SortDescriptions.Add(new SortDescription(sortMember, ListSortDirection.Ascending)); + view.Refresh(); + })); + }); + return view; + } + + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorGroup.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorGroup.cs new file mode 100644 index 000000000..852311883 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorGroup.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace Tango.MachineStudio.Catalogs.Excel +{ + public class ColorGroup + { + public Color GroupColor { get; set; } + public String GroupName { get; set; } + public int GroupIndex { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorItem.cs new file mode 100644 index 000000000..9d5011325 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorItem.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace Tango.MachineStudio.Catalogs.Excel +{ + public class ColorItem + { + public Color ItemColor { get; set; } + public String Group { get; set; } + public int Code { get; set; } + public String Name { get; set; } + public int ItemIndex { get; set; } + public int Red { get; set; } + public int Green { get; set; } + public int Blue { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + public double Cyan { get; set; } + public double Magenta { get; set; } + public double Yellow { get; set; } + public double Black { get; set; } + public int Region { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorRecipe.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorRecipe.cs new file mode 100644 index 000000000..724652cd4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/ColorRecipe.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace Tango.MachineStudio.Catalogs.Excel +{ + public class ColorRecipe + { + public Color R_Color { get; set; } + public String R_Name { get; set; } + public String R_Media { get; set; } + public double R_Cyan { get; set; } + public double R_Magenta { get; set; } + public double R_Yellow { get; set; } + public double R_Black { get; set; } + public int R_Region { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/Media.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/Media.cs new file mode 100644 index 000000000..d65b1a986 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Excel/Media.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Catalogs.Excel +{ + public class Media + { + public String MediaName { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Images/catalogs.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Images/catalogs.png Binary files differnew file mode 100644 index 000000000..4e38508f5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Images/catalogs.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Images/catalogs_module.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Images/catalogs_module.jpg Binary files differnew file mode 100644 index 000000000..bc551452b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Images/catalogs_module.jpg diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..9cafc7e46 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Machine Studio Catalogs Module")] +[assembly: AssemblyVersion("2.0.12.1608")] + +[assembly: ComVisible(false)] + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Resources.Designer.cs new file mode 100644 index 000000000..c272c440d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// <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 Tango.MachineStudio.Catalogs.Properties { + + + /// <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", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// <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 ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.Catalogs.Properties.Resources", typeof(Resources).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; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Resources.resx @@ -0,0 +1,117 @@ +<?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.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: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" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </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" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Settings.Designer.cs new file mode 100644 index 000000000..8a2599f0a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// <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 Tango.MachineStudio.Catalogs.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Properties/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Tango.MachineStudio.Catalogs.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Tango.MachineStudio.Catalogs.csproj new file mode 100644 index 000000000..5473c28bc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Tango.MachineStudio.Catalogs.csproj @@ -0,0 +1,174 @@ +<?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>{7D0FCE3C-9A37-439C-9F9F-B26CFD6A8A33}</ProjectGuid> + <OutputType>library</OutputType> + <RootNamespace>Tango.MachineStudio.Catalogs</RootNamespace> + <AssemblyName>Tango.MachineStudio.Catalogs</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\Build\Machine Studio\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\Build\Machine Studio\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> + </Reference> + <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath> + </Reference> + <Reference Include="MaterialDesignColors, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll</HintPath> + </Reference> + <Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Data" /> + <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath> + </Reference> + <Reference Include="System.Xml" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xaml"> + <RequiredTargetFramework>4.0</RequiredTargetFramework> + </Reference> + <Reference Include="WindowsBase" /> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Contracts\IMainView.cs" /> + <Compile Include="Converters\ObservableCollectionToViewSourceConverter.cs" /> + <Compile Include="Excel\ColorGroup.cs" /> + <Compile Include="Excel\ColorItem.cs" /> + <Compile Include="Excel\ColorRecipe.cs" /> + <Compile Include="Excel\Media.cs" /> + <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="Views\CatalogView.xaml.cs"> + <DependentUpon>CatalogView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\CatalogsView.xaml.cs"> + <DependentUpon>CatalogsView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\MainView.xaml.cs"> + <DependentUpon>MainView.xaml</DependentUpon> + </Compile> + <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> + <Link>GlobalVersionInfo.cs</Link> + </Compile> + <Compile Include="CatalogsModule.cs" /> + <Page Include="Views\CatalogView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\CatalogsView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\MainView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + <None Include="App.config" /> + <None Include="packages.config" /> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + <EmbeddedResource Include="Templates\ExportTemplate.xlsx" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.ColorConversion\Tango.ColorConversion.csproj"> + <Project>{b4fe6485-4161-4b36-bc08-67e0b53d01b7}</Project> + <Name>Tango.ColorConversion</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Documents\Tango.Documents.csproj"> + <Project>{ca87a608-7b17-4c98-88f2-42abee10f4c1}</Project> + <Name>Tango.Documents</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Settings\Tango.Settings.csproj"> + <Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project> + <Name>Tango.Settings</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.SharedUI\Tango.SharedUI.csproj"> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> + <Name>Tango.SharedUI</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.MachineStudio.Common\Tango.MachineStudio.Common.csproj"> + <Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project> + <Name>Tango.MachineStudio.Common</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\catalogs.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\catalogs_module.jpg" /> + </ItemGroup> + <ItemGroup> + <Folder Include="Models\" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate - BACKUP.xlsx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate - BACKUP.xlsx Binary files differnew file mode 100644 index 000000000..44abd31db --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate - BACKUP.xlsx diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate - bad.xlsx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate - bad.xlsx Binary files differnew file mode 100644 index 000000000..d95727038 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate - bad.xlsx diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate.xlsx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate.xlsx Binary files differnew file mode 100644 index 000000000..e57422725 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Templates/ExportTemplate.xlsx diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModelLocator.cs new file mode 100644 index 000000000..27970c466 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModelLocator.cs @@ -0,0 +1,29 @@ +using Tango.Core.DI; +using Tango.MachineStudio.Catalogs.ViewModels; +using Tango.MachineStudio.Catalogs.Views; + +namespace Tango.MachineStudio.Catalogs +{ + /// <summary> + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// </summary> + public static class ViewModelLocator + { + /// <summary> + /// Initializes a new instance of the ViewModelLocator class. + /// </summary> + static ViewModelLocator() + { + TangoIOC.Default.Register<MainViewVM>(); + } + + public static MainViewVM MainViewVM + { + get + { + return TangoIOC.Default.GetInstance<MainViewVM>(); + } + } + } +}
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..652ad3093 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs @@ -0,0 +1,602 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.MachineStudio.Common; +using System.Data.Entity; +using Tango.MachineStudio.Catalogs.Contracts; +using Tango.MachineStudio.Common.Notifications; +using Tango.Core.Commands; +using Tango.BL.Builders; +using Tango.Documents; +using Microsoft.Win32; +using Tango.Core.Helpers; +using System.IO; +using Tango.MachineStudio.Catalogs.Excel; + +namespace Tango.MachineStudio.Catalogs.ViewModels +{ + public class MainViewVM : StudioViewModel<IMainView> + { + private ObservablesContext _catalogsContext; + private ObservablesContext _activeCatalogContext; + private INotificationProvider _notification; + + #region Properties + + private ObservableCollection<ColorCatalog> _catalogs; + /// <summary> + /// Gets or sets the catalogs. + /// </summary> + public ObservableCollection<ColorCatalog> Catalogs + { + get { return _catalogs; } + set { _catalogs = value; RaisePropertyChangedAuto(); } + } + + private ColorCatalog _selectedCatalog; + /// <summary> + /// Gets or sets the selected catalog. + /// </summary> + public ColorCatalog SelectedCatalog + { + get { return _selectedCatalog; } + set { _selectedCatalog = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private ColorCatalog _activeCatalog; + /// <summary> + /// Gets or sets the active catalog. + /// </summary> + public ColorCatalog ActiveCatalog + { + get { return _activeCatalog; } + set { _activeCatalog = value; RaisePropertyChangedAuto(); } + } + + private ColorCatalogsGroup _selectedGroup; + /// <summary> + /// Gets or sets the selected group. + /// </summary> + public ColorCatalogsGroup SelectedGroup + { + get { return _selectedGroup; } + set { _selectedGroup = value; RaisePropertyChangedAuto(); } + } + + private ColorCatalogsItem _selectedItem; + /// <summary> + /// Gets or sets the selected item. + /// </summary> + public ColorCatalogsItem SelectedItem + { + get { return _selectedItem; } + set { _selectedItem = value; RaisePropertyChangedAuto(); } + } + + private List<Rml> _rmls; + /// <summary> + /// Gets or sets the RMLS. + /// </summary> + public List<Rml> RMLS + { + get { return _rmls; } + set { _rmls = value; RaisePropertyChangedAuto(); } + } + + #endregion + + #region Commands + + /// <summary> + /// Gets or sets the new catalog command. + /// </summary> + public RelayCommand NewCatalogCommand { get; set; } + + /// <summary> + /// Gets or sets the delete catalog command. + /// </summary> + public RelayCommand DeleteCatalogCommand { get; set; } + + /// <summary> + /// Gets or sets the edit catalog command. + /// </summary> + public RelayCommand EditCatalogCommand { get; set; } + + /// <summary> + /// Gets or sets the back to catalogs command. + /// </summary> + public RelayCommand BackToCatalogsCommand { get; set; } + + /// <summary> + /// Gets or sets the save active catalog command. + /// </summary> + public RelayCommand SaveActiveCatalogCommand { get; set; } + + /// <summary> + /// Gets or sets the export excel command. + /// </summary> + public RelayCommand ExportExcelCommand { get; set; } + + /// <summary> + /// Gets or sets the import excel command. + /// </summary> + public RelayCommand ImportExcelCommand { get; set; } + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="MainViewVM"/> class. + /// </summary> + public MainViewVM() + { + Catalogs = new ObservableCollection<ColorCatalog>(); + + EditCatalogCommand = new RelayCommand(EditSelectedCatalog, () => SelectedCatalog != null); + NewCatalogCommand = new RelayCommand(CreateNewCatalog); + DeleteCatalogCommand = new RelayCommand(DeleteSelectedCatalog, () => SelectedCatalog != null); + BackToCatalogsCommand = new RelayCommand(BackToCatalogs); + SaveActiveCatalogCommand = new RelayCommand(SaveActiveCatalog); + ExportExcelCommand = new RelayCommand(ExportCatalogToExcel); + ImportExcelCommand = new RelayCommand(ImportCatalogFromExcel); + } + + /// <summary> + /// Initializes a new instance of the <see cref="MainViewVM"/> class. + /// </summary> + /// <param name="notificationProvider">The notification provider.</param> + public MainViewVM(INotificationProvider notificationProvider) : this() + { + _notification = notificationProvider; + } + + #endregion + + #region Edit / Delete / Create Catalog + + public async Task LoadCatalogs() + { + using (_notification.PushTaskItem("Loading color catalogs...")) + { + IsFree = false; + + if (_catalogsContext != null) + { + _catalogsContext.Dispose(); + } + + _catalogsContext = ObservablesContext.CreateDefault(); + + Catalogs = (await _catalogsContext.ColorCatalogs.Include(x => x.ColorCatalogsGroups.Select(g => g.ColorCatalogsItems)).ToListAsync()).ToSynchronizedObservableCollection(); + SelectedCatalog = null; + + IsFree = true; + } + } + + public async void EditSelectedCatalog() + { + if (SelectedCatalog != null) + { + using (_notification.PushTaskItem("Loading selected catalog...")) + { + try + { + IsFree = false; + + if (_activeCatalogContext != null) + { + _activeCatalogContext.Dispose(); + } + + _activeCatalogContext = ObservablesContext.CreateDefault(); + + ActiveCatalog = await new ColorCatalogBuilder(_activeCatalogContext).Set(SelectedCatalog.Guid).WithGroups().WithItems().WithRecipes().BuildAsync(); + SelectedGroup = ActiveCatalog.ColorCatalogsGroups.FirstOrDefault(); + RMLS = await _activeCatalogContext.Rmls.ToListAsync(); + + if (SelectedGroup != null) + { + SelectedItem = SelectedGroup.ColorCatalogsItems.FirstOrDefault(); + } + + View.NavigateTo(CatalogsNavigationView.CatalogView); + } + catch (Exception ex) + { + _notification.ShowError($"An error occurred while trying to load the selected catalog.\n{ex.Message}"); + LogManager.Log(ex, $"Error loading selected catalog '{SelectedCatalog.Name}'."); + } + finally + { + IsFree = true; + } + } + } + } + + private async void DeleteSelectedCatalog() + { + if (SelectedCatalog != null) + { + if (_notification.ShowQuestion("Are you sure you want to delete the selected catalog ?")) + { + using (_notification.PushTaskItem("Deleting selected catalog...")) + { + try + { + IsFree = false; + await SelectedCatalog.DeleteCascadeAsync(_catalogsContext); + SelectedCatalog = null; + } + catch (Exception ex) + { + _notification.ShowError($"An error occurred while trying to delete the selected catalog.\n{ex.Message}"); + LogManager.Log(ex, $"Error deleting catalog {SelectedCatalog.Name}."); + } + finally + { + IsFree = true; + } + } + } + } + } + + private async void CreateNewCatalog() + { + String name = _notification.ShowTextInput("Please enter a catalog name", "Catalog name"); + if (!String.IsNullOrWhiteSpace(name)) + { + using (_notification.PushTaskItem("Generating catalog...")) + { + try + { + IsFree = false; + ColorCatalog newCatalog = new ColorCatalog(); + newCatalog.Name = name; + newCatalog.Description = name; + newCatalog.Company = "Twine"; + _catalogsContext.ColorCatalogs.Add(newCatalog); + await _catalogsContext.SaveChangesAsync(); + SelectedCatalog = newCatalog; + EditSelectedCatalog(); + } + catch (Exception ex) + { + _notification.ShowError($"An error occurred while trying to create the catalog.\n{ex.Message}"); + LogManager.Log(ex, $"Error creating new catalog."); + } + finally + { + IsFree = true; + } + } + } + } + + public void OnGroupDeleted(ColorCatalogsGroup group) + { + group.Delete(_activeCatalogContext); + } + + public void OnItemDeleted(ColorCatalogsItem item) + { + item.Delete(_activeCatalogContext); + } + + public void OnRecipeDeleted(ColorCatalogsItemsRecipe recipe) + { + recipe.Delete(_activeCatalogContext); + } + + private async void SaveActiveCatalog() + { + if (ActiveCatalog != null) + { + using (_notification.PushTaskItem("Updating catalog...")) + { + try + { + IsFree = false; + await _activeCatalogContext.SaveChangesAsync(); + await LoadCatalogs(); + _notification.ShowInfo("Catalog updated successfully."); + } + catch (Exception ex) + { + _notification.ShowError($"An error occurred while trying to update the catalog.\n{ex.Message}"); + LogManager.Log(ex, $"Error updating catalog {ActiveCatalog.Name}."); + } + finally + { + IsFree = true; + } + } + } + } + + private void BackToCatalogs() + { + View.NavigateTo(CatalogsNavigationView.CatalogsView); + } + + #endregion + + #region Export / Import Excel + + public void ExportCatalogToExcel() + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel Documents|*.xlsx"; + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem("Exporting catalog to file...")) + { + Task.Factory.StartNew(() => + { + try + { + IsFree = false; + + Stream stream = null; + bool dispose = false; + String file = AssemblyHelper.GetCurrentAssemblyFolder() + "\\Templates\\ExportTemplate.xlsx"; + + if (File.Exists(file)) + { + stream = File.OpenRead(file); + dispose = true; + } + else + { + stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Catalogs.Templates.ExportTemplate.xlsx"); + } + + byte[] data = new byte[stream.Length]; + stream.Read(data, 0, data.Length); + File.WriteAllBytes(dlg.FileName, data); + + if (dispose) + { + stream.Dispose(); + } + + ExcelWriter writer = new ExcelWriter(dlg.FileName); + + List<Media> medias = RMLS.Select(x => new Media() + { + MediaName = x.Name, + }).ToList(); + + writer.WriteData(medias, "RML"); + + List<ColorGroup> groups = ActiveCatalog.ColorCatalogsGroups.Select(x => new ColorGroup() + { + GroupColor = x.Color, + GroupName = x.Name, + GroupIndex = x.GroupIndex, + }).ToList(); + + writer.WriteData(groups, "Groups"); + + List<ColorItem> items = ActiveCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).Select(x => new ColorItem() + { + + ItemColor = x.Color, + Group = x.ColorCatalogsGroup.Name, + Code = x.Code, + Name = x.Name, + ItemIndex = x.ItemIndex, + Red = x.Red, + Green = x.Green, + Blue = x.Blue, + L = x.L, + A = x.A, + B = x.B, + Cyan = x.Cyan, + Magenta = x.Magenta, + Yellow = x.Yellow, + Black = x.Black, + Region = x.ProcessParametersTableIndex, + + }).ToList(); + + writer.WriteData(items, "Colors"); + + List<ColorRecipe> recipes = ActiveCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).SelectMany(x => x.ColorCatalogsItemsRecipes).Select(x => new ColorRecipe() + { + + R_Color = x.ColorCatalogsItem.Color, + R_Name = x.ColorCatalogsItem.Name, + R_Media = x.Rml.Name, + R_Cyan = x.Cyan, + R_Magenta = x.Magenta, + R_Yellow = x.Yellow, + R_Black = x.Black, + R_Region = x.ProcessParametersTableIndex, + + + }).ToList(); + + writer.WriteData(recipes, "Recipes"); + + writer.Dispose(); + + InvokeUI(() => + { + _notification.ShowInfo("Catalog exported successfully."); + }); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error exporting color catalog to {dlg.FileName}"); + + InvokeUI(() => + { + _notification.ShowError($"An error occurred while trying to export the catalog. Make sure the selected excel file is closed and data is valid.\n{ex.FlattenMessage()}"); + }); + } + finally + { + IsFree = true; + } + }); + } + } + } + + public void ImportCatalogFromExcel() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "Excel Documents|*.xlsx"; + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem("Merging catalog from file...")) + { + Task.Factory.StartNew(() => + { + try + { + ExcelReader reader = new ExcelReader(dlg.FileName); + var groups = reader.GetData<ColorGroup>("Groups"); + reader.Dispose(); + + reader = new ExcelReader(dlg.FileName); + var colors = reader.GetData<ColorItem>("Colors"); + reader.Dispose(); + + reader = new ExcelReader(dlg.FileName); + var recipes = reader.GetData<ColorRecipe>("Recipes"); + reader.Dispose(); + + foreach (var group in groups) + { + ColorCatalogsGroup existinGroup = ActiveCatalog.ColorCatalogsGroups.SingleOrDefault(x => x.Name == group.GroupName); + + bool inserting = false; + if (existinGroup == null) + { + existinGroup = new ColorCatalogsGroup(); + inserting = true; + } + + existinGroup.Name = group.GroupName; + existinGroup.GroupIndex = group.GroupIndex; + + if (inserting) + { + ActiveCatalog.ColorCatalogsGroups.Add(existinGroup); + } + } + + foreach (var item in colors) + { + var existinItem = ActiveCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).SingleOrDefault(x => x.Code == item.Code); + var group = ActiveCatalog.ColorCatalogsGroups.SingleOrDefault(x => x.Name == item.Group); + + bool inserting = false; + + if (existinItem == null) + { + existinItem = new ColorCatalogsItem(); + inserting = true; + } + else + { + if (existinItem.ColorCatalogsGroup != group) + { + existinItem.ColorCatalogsGroup.ColorCatalogsItems.Remove(existinItem); + group.ColorCatalogsItems.Add(existinItem); + } + } + + existinItem.ColorCatalogsGroup = group; + existinItem.Code = item.Code; + existinItem.Name = item.Name; + existinItem.ItemIndex = item.ItemIndex; + existinItem.Red = item.Red; + existinItem.Green = item.Green; + existinItem.Blue = item.Blue; + existinItem.L = item.L; + existinItem.A = item.A; + existinItem.B = item.B; + existinItem.Cyan = item.Cyan; + existinItem.Magenta = item.Magenta; + existinItem.Yellow = item.Yellow; + existinItem.Black = item.Black; + existinItem.ProcessParametersTableIndex = item.Region; + + if (inserting) + { + _activeCatalogContext.ColorCatalogsItems.Add(existinItem); + } + } + + foreach (var recipe in recipes) + { + var existingRecipe = ActiveCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).SelectMany(x => x.ColorCatalogsItemsRecipes).SingleOrDefault(x => x.ColorCatalogsItem.Name == recipe.R_Name && x.Rml.Name == recipe.R_Media); + + bool inserting = false; + + if (existingRecipe == null) + { + existingRecipe = new ColorCatalogsItemsRecipe(); + existingRecipe.Rml = RMLS.SingleOrDefault(x => x.Name == recipe.R_Media); + existingRecipe.ColorCatalogsItem = ActiveCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).SingleOrDefault(x => x.Name == recipe.R_Name); + inserting = true; + } + + existingRecipe.Cyan = recipe.R_Cyan; + existingRecipe.Magenta = recipe.R_Magenta; + existingRecipe.Yellow = recipe.R_Yellow; + existingRecipe.Black = recipe.R_Black; + existingRecipe.ProcessParametersTableIndex = recipe.R_Region; + + if (inserting) + { + _activeCatalogContext.ColorCatalogsItemsRecipes.Add(existingRecipe); + } + } + + InvokeUI(() => + { + _notification.ShowInfo("Catalog imported successfully."); + }); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error importing color catalog to {dlg.FileName}"); + + InvokeUI(() => + { + _notification.ShowError($"An error occurred while trying to merge the catalog. Please check your data.\n{ex.FlattenMessage()}"); + }); + } + finally + { + IsFree = true; + } + }); + } + } + } + + #endregion + + #region Application Ready + + public async override void OnApplicationReady() + { + await LoadCatalogs(); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml new file mode 100644 index 000000000..ded1acb2d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml @@ -0,0 +1,232 @@ +<UserControl x:Class="Tango.MachineStudio.Catalogs.Views.CatalogView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.MachineStudio.Catalogs.ViewModels" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:localConverters="clr-namespace:Tango.MachineStudio.Catalogs.Converters" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:global="clr-namespace:Tango.MachineStudio.Catalogs" + xmlns:local="clr-namespace:Tango.MachineStudio.Catalogs.Views" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" Foreground="#232323" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <localConverters:ObservableCollectionToViewSourceConverter x:Key="ObservableCollectionToViewSourceConverter" /> + + <Style x:Key="EditableGrid" TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}"> + <Setter Property="AutoGenerateColumns" Value="False"></Setter> + </Style> + + <Style x:Key="EditableCell" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type DataGridCell}"> + <Grid Background="{TemplateBinding Background}"> + <ContentPresenter VerticalAlignment="Center" Margin="8" /> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Style.Triggers> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="BorderBrush" Value="Cyan"/> + </Trigger> + </Style.Triggers> + </Style> + + </UserControl.Resources> + + <Grid Margin="20"> + <DockPanel> + <Grid DockPanel.Dock="Top"> + <StackPanel Orientation="Horizontal"> + <Button Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" Command="{Binding BackToCatalogsCommand}"> + <materialDesign:PackIcon Kind="ArrowLeft" Width="50" Height="50" Foreground="#202020" ToolTip="Back to RML list" /> + </Button> + <TextBlock Text="{Binding ActiveCatalog.Name}" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="34"></TextBlock> + </StackPanel> + + <StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> + <Button Background="#65C682" BorderBrush="#65C682" Width="170" Height="45" VerticalAlignment="Center" Command="{Binding ImportExcelCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Import" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">IMPORT EXCEL</TextBlock> + </StackPanel> + </Button> + <Button Margin="10 0 0 0" Background="#65C682" BorderBrush="#65C682" Width="170" Height="45" VerticalAlignment="Center" Command="{Binding ExportExcelCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Export" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">EXPORT EXCEL</TextBlock> + </StackPanel> + </Button> + <Button Margin="10 0 0 0" Width="170" Height="45" VerticalAlignment="Center" Command="{Binding SaveActiveCatalogCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">SAVE</TextBlock> + </StackPanel> + </Button> + </StackPanel> + </Grid> + + <Grid Margin="0 20"> + <Grid.RowDefinitions> + <RowDefinition Height="113*"/> + <RowDefinition Height="358*"/> + </Grid.RowDefinitions> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="302*"/> + <ColumnDefinition Width="399*"/> + <ColumnDefinition Width="1179*"/> + </Grid.ColumnDefinitions> + + <Grid Margin="10"> + <materialDesign:Card Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch"> + <Border Padding="20"> + <DockPanel> + <TextBlock DockPanel.Dock="Top" FontSize="16">PROPERTIES</TextBlock> + <controls:TableGrid RowHeight="35"> + <TextBlock Text="Company:" ></TextBlock> + <TextBox Text="{Binding ActiveCatalog.Company}"></TextBox> + + <TextBlock Text="Name:" ></TextBlock> + <TextBox Text="{Binding ActiveCatalog.Name,UpdateSourceTrigger=PropertyChanged}"></TextBox> + + <TextBlock Text="Description:" ></TextBlock> + <TextBox Text="{Binding ActiveCatalog.Description}"></TextBox> + + <TextBlock Text="Design:" ></TextBlock> + <ComboBox ItemsSource="{Binding Source={x:Type enumerations:CatalogDesignType},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding ActiveCatalog.Design}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"></ComboBox> + + </controls:TableGrid> + </DockPanel> + </Border> + </materialDesign:Card> + </Grid> + + <Grid Grid.Column="1" Margin="10"> + <materialDesign:Card Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch"> + <Border Padding="20"> + <DockPanel> + <TextBlock DockPanel.Dock="Top" FontSize="16">DESIGN CONTENT</TextBlock> + + </DockPanel> + </Border> + </materialDesign:Card> + </Grid> + + <Grid Grid.ColumnSpan="3"> + + </Grid> + </Grid> + + <Grid Grid.Row="1" Margin="0 20 0 0"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="300"/> + <ColumnDefinition Width="930"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + + <DockPanel Margin="10"> + <TextBlock DockPanel.Dock="Top" FontSize="16">CATALOG GROUPS</TextBlock> + + <materialDesign:Card Margin="0 5 0 0" Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch"> + <DataGrid x:Name="gridGroups" Style="{StaticResource EditableGrid}" CellStyle="{StaticResource EditableCell}" ItemsSource="{Binding ActiveCatalog.ColorCatalogsGroups,Converter={StaticResource ObservableCollectionToViewSourceConverter},ConverterParameter='GroupIndex'}" SelectedItem="{Binding SelectedGroup}" CanUserDeleteRows="False" PreviewKeyDown="OnGroupsGrid_PreviewKeyDown"> + <DataGrid.Columns> + <DataGridTemplateColumn Header="" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Ellipse Width="30" Height="30"> + <Ellipse.Fill> + <SolidColorBrush Color="{Binding Color}" /> + </Ellipse.Fill> + </Ellipse> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTextColumn Header="NAME" Binding="{Binding Name}" Width="150" /> + <DataGridTextColumn Header="IDX" Binding="{Binding GroupIndex}" Width="1*" SortMemberPath="GroupIndex" SortDirection="Ascending" /> + </DataGrid.Columns> + </DataGrid> + </materialDesign:Card> + </DockPanel> + + + <DockPanel Margin="10" Grid.Column="1"> + <TextBlock DockPanel.Dock="Top" FontSize="16"> + <Run>GROUP COLORS</Run> + <Run>(</Run><Run Text="{Binding SelectedGroup.ColorCatalogsItems.Count,Mode=OneWay}"></Run><Run>)</Run> + </TextBlock> + <materialDesign:Card Margin="0 5 0 0" Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch"> + <DataGrid x:Name="gridItems" Style="{StaticResource EditableGrid}" CellStyle="{StaticResource EditableCell}" ItemsSource="{Binding SelectedGroup.ColorCatalogsItems,Converter={StaticResource ObservableCollectionToViewSourceConverter},ConverterParameter='ItemIndex'}" SelectedItem="{Binding SelectedItem}" PreviewKeyDown="OnItemsGrid_PreviewKeyDown"> + <DataGrid.Columns> + <DataGridTemplateColumn Header="" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Ellipse Width="25" Height="25"> + <Ellipse.Fill> + <SolidColorBrush Color="{Binding Color}" /> + </Ellipse.Fill> + </Ellipse> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTextColumn Header="CODE" Binding="{Binding Code}" Width="Auto" /> + <DataGridTextColumn Header="NAME" Binding="{Binding Name}" Width="Auto" /> + <DataGridTextColumn Header="IDX" Binding="{Binding ItemIndex}" Width="Auto" /> + + <DataGridTextColumn Header="R" Binding="{Binding Red,UpdateSourceTrigger=PropertyChanged}" Width="Auto" /> + <DataGridTextColumn Header="G" Binding="{Binding Green,UpdateSourceTrigger=PropertyChanged}" Width="Auto" /> + <DataGridTextColumn Header="B" Binding="{Binding Blue,UpdateSourceTrigger=PropertyChanged}" Width="Auto" /> + + <DataGridTextColumn Header="L" Binding="{Binding L}" Width="60" /> + <DataGridTextColumn Header="A" Binding="{Binding A}" Width="60" /> + <DataGridTextColumn Header="B" Binding="{Binding B}" Width="60" /> + + <DataGridTextColumn Header="CYAN" Binding="{Binding Cyan}" Width="65" /> + <DataGridTextColumn Header="MAGENTA" Binding="{Binding Magenta}" Width="80" /> + <DataGridTextColumn Header="YELLOW" Binding="{Binding Yellow}" Width="70" /> + <DataGridTextColumn Header="BLACK" Binding="{Binding Black}" Width="65" /> + + <DataGridTextColumn Header="REGION" Binding="{Binding ProcessParametersTableIndex}" Width="69" /> + </DataGrid.Columns> + </DataGrid> + </materialDesign:Card> + </DockPanel> + + <DockPanel Margin="10" Grid.Column="2"> + <TextBlock DockPanel.Dock="Top" FontSize="16"> + <Run>COLOR MEDIA RECIPES</Run> + <Run>(</Run><Run Text="{Binding SelectedItem.ColorCatalogsItemsRecipes.Count,Mode=OneWay}"></Run><Run>)</Run> + </TextBlock> + <materialDesign:Card Margin="0 5 0 0" Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch"> + <DataGrid x:Name="gridRecipes" Style="{StaticResource EditableGrid}" CellStyle="{StaticResource EditableCell}" ItemsSource="{Binding SelectedItem.ColorCatalogsItemsRecipes}" PreviewKeyDown="OnRecipesGrid_PreviewKeyDown" CanUserSortColumns="False"> + <DataGrid.Columns> + <materialDesign:MaterialDataGridComboBoxColumn Header="MEDIA" Width="180" SortMemberPath="Name" ItemsSourceBinding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RMLS}" SelectedItemBinding="{Binding Rml}" DisplayMemberPath="Name" /> + <DataGridTextColumn Header="CYAN" Binding="{Binding Cyan}" Width="80" /> + <DataGridTextColumn Header="MAGENTA" Binding="{Binding Magenta}" Width="80" /> + <DataGridTextColumn Header="YELLOW" Binding="{Binding Yellow}" Width="80" /> + <DataGridTextColumn Header="BLACK" Binding="{Binding Black}" Width="80" /> + <DataGridTextColumn Header="REGION" Binding="{Binding ProcessParametersTableIndex}" Width="Auto" /> + </DataGrid.Columns> + </DataGrid> + </materialDesign:Card> + </DockPanel> + </Grid> + </Grid> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml.cs new file mode 100644 index 000000000..4ba37416d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.Catalogs.ViewModels; + +namespace Tango.MachineStudio.Catalogs.Views +{ + /// <summary> + /// Interaction logic for CatalogsView.xaml + /// </summary> + public partial class CatalogView : UserControl + { + private MainViewVM _vm; + + public CatalogView() + { + InitializeComponent(); + Loaded += (_, __) => _vm = DataContext as MainViewVM; + } + + private void OnGroupsGrid_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Delete && gridGroups.SelectedItem != null) + { + _vm.OnGroupDeleted(gridGroups.SelectedItem as BL.Entities.ColorCatalogsGroup); + e.Handled = true; + } + } + + private void OnItemsGrid_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Delete && gridItems.SelectedItem != null) + { + _vm.OnItemDeleted(gridItems.SelectedItem as BL.Entities.ColorCatalogsItem); + e.Handled = true; + } + } + + private void OnRecipesGrid_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Delete && gridRecipes.SelectedItem != null) + { + _vm.OnRecipeDeleted(gridRecipes.SelectedItem as BL.Entities.ColorCatalogsItemsRecipe); + e.Handled = true; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml new file mode 100644 index 000000000..221afe568 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml @@ -0,0 +1,78 @@ +<UserControl x:Class="Tango.MachineStudio.Catalogs.Views.CatalogsView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.MachineStudio.Catalogs.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.Catalogs" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:local="clr-namespace:Tango.MachineStudio.Catalogs.Views" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" Foreground="#BBBBBB" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + <converters:DateTimeUTCToShortDateTimeConverter x:Key="DateTimeUTCToShortDateTimeConverter" /> + <converters:ColorToIntegerConverter x:Key="ColorToIntegerConverter"></converters:ColorToIntegerConverter> + </UserControl.Resources> + + <Grid> + <DockPanel Margin="100" MaxWidth="1200"> + <Grid DockPanel.Dock="Top"> + <Image Source="../Images/catalogs.png" Width="200" Margin="10" /> + </Grid> + <Grid DockPanel.Dock="Bottom"> + <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 0"> + <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource RedBrush300}" BorderBrush="{StaticResource RedBrush300}" Command="{Binding DeleteCatalogCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Delete" Width="20" Height="20" /> + <TextBlock Margin="5 0 0 0" FontSize="16">DELETE</TextBlock> + </StackPanel> + </Button> + <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource GreenBrush300}" BorderBrush="{StaticResource GreenBrush300}" Command="{Binding NewCatalogCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Plus" Width="20" Height="20" /> + <TextBlock Margin="5 0 0 0" FontSize="16">NEW CATALOG</TextBlock> + </StackPanel> + </Button> + </StackPanel> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> + <Button Margin="50 0 0 0" MinWidth="200" Height="60" Command="{Binding EditCatalogCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Pencil" Width="24" Height="24" /> + <TextBlock Margin="10 0 0 0" FontSize="18">EDIT</TextBlock> + </StackPanel> + </Button> + </StackPanel> + </Grid> + <Grid> + <DataGrid Margin="0 0 0 10" BorderBrush="Silver" IsReadOnly="True" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding Catalogs}" SelectedItem="{Binding SelectedCatalog}"> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <!--<DataGridTemplateColumn Header="#" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn>--> + <DataGridTextColumn Header="COMPANY" Binding="{Binding Company}" Width="Auto" /> + <DataGridTextColumn Header="NAME" Binding="{Binding Name}" Width="Auto" /> + <DataGridTextColumn Header="DESCRIPTION" Binding="{Binding Description}" Width="Auto" /> + <DataGridTextColumn Header="DESIGN" Binding="{Binding Design}" Width="Auto" /> + <DataGridTextColumn Header="GROUPS" Binding="{Binding ColorCatalogsGroups.Count}" Width="Auto" /> + <DataGridTextColumn Header="COLORS" Binding="{Binding TotalColors}" Width="Auto" /> + <DataGridTextColumn Header="LAST UPDATED" Binding="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="1*" /> + </DataGrid.Columns> + </DataGrid> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml.cs new file mode 100644 index 000000000..02418b677 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Catalogs.Views +{ + /// <summary> + /// Interaction logic for CatalogsView.xaml + /// </summary> + public partial class CatalogsView : UserControl + { + public CatalogsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/MainView.xaml new file mode 100644 index 000000000..140a616e1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/MainView.xaml @@ -0,0 +1,18 @@ +<UserControl x:Class="Tango.MachineStudio.Catalogs.Views.MainView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.MachineStudio.Catalogs.Views" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:vm="clr-namespace:Tango.MachineStudio.Catalogs.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.Catalogs" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" Foreground="#BBBBBB" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + <Grid IsEnabled="{Binding IsFree}"> + <controls:NavigationControl x:Name="navigationControl" TransitionType="Slide"> + <local:CatalogsView /> + <local:CatalogView/> + </controls:NavigationControl> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/MainView.xaml.cs new file mode 100644 index 000000000..fdfd23c2b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/MainView.xaml.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Core.DI; +using Tango.MachineStudio.Catalogs.Contracts; + +namespace Tango.MachineStudio.Catalogs.Views +{ + /// <summary> + /// Interaction logic for MainView.xaml + /// </summary> + public partial class MainView : UserControl, IMainView + { + public MainView() + { + InitializeComponent(); + TangoIOC.Default.Register<IMainView>(this); + } + + public void NavigateTo(CatalogsNavigationView view) + { + navigationControl.NavigateTo(view.ToString()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/packages.config new file mode 100644 index 000000000..2c357dae6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/packages.config @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> + <package id="MahApps.Metro" version="1.5.0" targetFramework="net461" /> + <package id="MaterialDesignColors" version="1.1.2" targetFramework="net461" /> + <package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net461" /> +</packages>
\ No newline at end of file |
