diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-13 15:19:55 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-13 15:19:55 +0200 |
| commit | 2a51f05523c1397b77eca5e5188520919205638c (patch) | |
| tree | edc40c2ca201be6e881ea6746469fb5cb412e8bc /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB | |
| parent | 2c376ac3ae651dd6c6592cc4cbf72768dc97a93d (diff) | |
| download | Tango-2a51f05523c1397b77eca5e5188520919205638c.tar.gz Tango-2a51f05523c1397b77eca5e5188520919205638c.zip | |
Successfully separated Machine Studio to modules...
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB')
44 files changed, 1911 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/App.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/App.config new file mode 100644 index 000000000..2fb423e8b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/App.config @@ -0,0 +1,13 @@ +<?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> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml new file mode 100644 index 000000000..d1c62ed7e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml @@ -0,0 +1,41 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Controls.DbTableView" + 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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280"> + <Grid> + + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="60"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Grid Background="#E9E9E9"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10"> + <materialDesign:PackIcon VerticalAlignment="Center" Width="24" Height="24" Foreground="{Binding ElementName=txtSearch, Path=BorderBrush}" Kind="AccountSearch" /> + <TextBox x:Name="txtSearch" Text="{Binding Filter,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" materialDesign:HintAssist.Hint="Search" Width="200" FontSize="14" /> + </StackPanel> + + <StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal" Margin="0 0 10 0"> + <Button Style="{StaticResource MaterialDesignFloatingActionDarkButton}" ToolTip="Remove" Command="{Binding DeleteCommand}" Width="40" Height="40"> + <materialDesign:PackIcon Width="20" Height="20" Kind="Delete" /> + </Button> + <Button Style="{StaticResource MaterialDesignFloatingActionDarkButton}" ToolTip="Edit" Command="{Binding EditCommand}" Margin="10 0 0 0" Width="40" Height="40"> + <materialDesign:PackIcon Width="20" Height="20" Kind="Pencil" /> + </Button> + <Button Style="{StaticResource MaterialDesignFloatingActionDarkButton}" ToolTip="Add" Command="{Binding AddCommand}" Margin="10 0 0 0" Width="40" Height="40"> + <materialDesign:PackIcon Width="20" Height="20" Kind="Plus" /> + </Button> + </StackPanel> + </Grid> + + <Grid Grid.Row="1"> + <ContentControl Content="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=MainContent}" Margin="0 60 0 0"></ContentControl> + </Grid> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml.cs new file mode 100644 index 000000000..9ae14952b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml.cs @@ -0,0 +1,38 @@ +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.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Controls +{ + /// <summary> + /// Interaction logic for DbTableView.xaml + /// </summary> + [ContentProperty(nameof(MainContent))] + public partial class DbTableView : UserControl + { + public FrameworkElement MainContent + { + get { return (FrameworkElement)GetValue(MainContentProperty); } + set { SetValue(MainContentProperty, value); } + } + public static readonly DependencyProperty MainContentProperty = + DependencyProperty.Register("MainContent", typeof(FrameworkElement), typeof(DbTableView), new PropertyMetadata(null)); + + public DbTableView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/TableGrid.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/TableGrid.cs new file mode 100644 index 000000000..53a990d4d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/TableGrid.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace Tango.MachineStudio.DB.Controls +{ + public class TableGrid : Grid + { + public TableGrid() + { + ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); + ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); + this.Loaded += TableGrid_Loaded; + } + + private void TableGrid_Loaded(object sender, RoutedEventArgs e) + { + InvalidateGrid(); + } + + protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) + { + base.OnVisualChildrenChanged(visualAdded, visualRemoved); + } + + protected override Size ArrangeOverride(Size arrangeSize) + { + return base.ArrangeOverride(arrangeSize); + } + + private void InvalidateGrid() + { + RowDefinitions.Clear(); + RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) }); + + int currentRow = 0; + + for (int i = 0; i < Children.Count; i++) + { + SetRow(Children[i], currentRow); + + if (i % 2 != 0) + { + SetColumn(Children[i], 1); + (Children[i] as FrameworkElement).Margin = new Thickness(20, 0, 0, 0); + currentRow++; + RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) }); + } + + (Children[i] as FrameworkElement).VerticalAlignment = VerticalAlignment.Bottom; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/UsersRolesToStringConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/UsersRolesToStringConverter.cs new file mode 100644 index 000000000..220572db4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/UsersRolesToStringConverter.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.DAL.Observables; +using Tango.MachineStudio.DB.ViewModels.DBViewModels; + +namespace Tango.MachineStudio.DB.Converters +{ + public class UsersRolesToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) return ""; + + if (value is IEnumerable<UsersRole>) + { + IEnumerable<UsersRole> userRoles = value as IEnumerable<UsersRole>; + return String.Join(", ", userRoles.Where(x => !x.Deleted).Select(x => x.Role.Name)); + } + else + { + IEnumerable<MultiComboVM<Role>> userRoles = value as IEnumerable<MultiComboVM<Role>>; + return String.Join(", ", userRoles.Where(x => x.IsSelected).Select(x => x.Entity.Name)); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/CustomAttributes/DBViewAttribute.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/CustomAttributes/DBViewAttribute.cs new file mode 100644 index 000000000..4bf920015 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/CustomAttributes/DBViewAttribute.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.DB.CustomAttributes +{ + public class DBViewAttribute : Attribute + { + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs new file mode 100644 index 000000000..c38cb8d04 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs @@ -0,0 +1,27 @@ +using MaterialDesignThemes.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.DB.ViewModels.DBViewModels; +using Tango.MachineStudio.DB.Views.DBViews; + +namespace Tango.MachineStudio.DB.ExtensionMethods +{ + public static class INotificationProviderExtensions + { + public static bool ShowDialog<T>(this INotificationProvider provider, DialogOpenMode mode, DbTableViewModel<T> context) where T : IObservableEntity + { + Type viewType = typeof(INotificationProviderExtensions).Assembly.GetType(typeof(OrganizationView).Namespace + "." + typeof(T).Name + "View"); + return provider.ShowDialog( + (mode == DialogOpenMode.Editing ? PackIconKind.TableEdit : PackIconKind.Plus), + (mode == DialogOpenMode.Editing ? "Edit " : "Add New ") + typeof(T).Name, + Activator.CreateInstance(viewType) as FrameworkElement, + context); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs new file mode 100644 index 000000000..00c7d341a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.Core.Commands; + +namespace Tango.MachineStudio.DB.Managers +{ + public class RegisteredView + { + public String Header { get; set; } + public FrameworkElement View { get; set; } + public RelayCommand AddCommand { get; set; } + + public RegisteredView(String header, FrameworkElement view, Action action) + { + Header = header; + View = view; + + if (action != null) + { + AddCommand = new RelayCommand(action); + } + else + { + AddCommand = new RelayCommand(() => + { + if (!ViewsManager.DisplayedViews.Contains(this)) + { + ViewsManager.DisplayedViews.Add(this); + } + else + { + View.BringIntoView(); + View.Focus(); + } + }); + } + } + + public RegisteredView(String header, FrameworkElement view) : this(header, view, null) + { + Header = header; + View = view; + } + + public override string ToString() + { + return Header; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/ViewsManager.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/ViewsManager.cs new file mode 100644 index 000000000..ba68fa358 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/ViewsManager.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.Core.Commands; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Views.DBViews; + +namespace Tango.MachineStudio.DB.Managers +{ + public static class ViewsManager + { + public static ObservableCollection<RegisteredView> DisplayedViews { get; set; } + + public static ObservableCollection<RegisteredView> DbViews { get; set; } + + static ViewsManager() + { + DisplayedViews = new ObservableCollection<RegisteredView>(); + DbViews = new ObservableCollection<RegisteredView>(); + + foreach (var type in typeof(ViewsManager).Assembly.GetTypes().Where(x => x.CustomAttributes.Count() > 0 && x.CustomAttributes.First().AttributeType == typeof(DBViewAttribute))) + { + DbViews.Add(new RegisteredView(type.Name.Replace("View", ""), Activator.CreateInstance(type) as FrameworkElement)); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..73a5c7c86 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Machine Studio DB Module")] + +[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.DB/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.Designer.cs new file mode 100644 index 000000000..02b7b332e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/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.DB.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.DB.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.DB/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/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.DB/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.Designer.cs new file mode 100644 index 000000000..6699c6cbf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/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.DB.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.DB/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/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.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj new file mode 100644 index 000000000..5ffe9dca9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -0,0 +1,220 @@ +<?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>{94F7ACF8-55E1-4A02-B9BC-A818413FDBBF}</ProjectGuid> + <OutputType>library</OutputType> + <RootNamespace>Tango.MachineStudio.DB</RootNamespace> + <AssemblyName>Tango.MachineStudio.DB</AssemblyName> + <TargetFrameworkVersion>v4.6</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\Build\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>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Dragablz, Version=0.0.3.197, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Dragablz.0.0.3.197\lib\net45\Dragablz.dll</HintPath> + </Reference> + <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\EntityFramework.6.0.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.0.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="GalaSoft.MvvmLight, Version=5.3.0.19026, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath> + </Reference> + <Reference Include="GalaSoft.MvvmLight.Extras, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath> + </Reference> + <Reference Include="GalaSoft.MvvmLight.Platform, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.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="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.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\MvvmLightLibs.5.3.0.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="ExtensionMethods\INotificationProviderExtensions.cs" /> + <Compile Include="ViewModels\AddressesViewVM.cs" /> + <Compile Include="ViewModels\DbTableViewModel.cs" /> + <Compile Include="ViewModels\DialogOpenMode.cs" /> + <Compile Include="ViewModels\MachinesViewVM.cs" /> + <Compile Include="ViewModels\MultiComboVM.cs" /> + <Compile Include="ViewModels\OrganizationsViewVM.cs" /> + <Compile Include="ViewModels\UsersViewVM.cs" /> + <Compile Include="ViewModels\EntityViewModel.cs" /> + <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="ViewModelLocator.cs" /> + <Compile Include="Views\DBViews\AddressesView.xaml.cs"> + <DependentUpon>AddressesView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\AddressView.xaml.cs"> + <DependentUpon>AddressView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\MachinesView.xaml.cs"> + <DependentUpon>MachinesView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\MachineView.xaml.cs"> + <DependentUpon>MachineView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\OrganizationsView.xaml.cs"> + <DependentUpon>OrganizationsView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\OrganizationView.xaml.cs"> + <DependentUpon>OrganizationView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\UsersView.xaml.cs"> + <DependentUpon>UsersView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\UserView.xaml.cs"> + <DependentUpon>UserView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\MainDBView.xaml.cs"> + <DependentUpon>MainDBView.xaml</DependentUpon> + </Compile> + <Page Include="Controls\DbTableView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> + <Link>GlobalVersionInfo.cs</Link> + </Compile> + <Compile Include="Controls\DbTableView.xaml.cs"> + <DependentUpon>DbTableView.xaml</DependentUpon> + </Compile> + <Compile Include="Controls\TableGrid.cs" /> + <Compile Include="Converters\UsersRolesToStringConverter.cs" /> + <Compile Include="CustomAttributes\DBViewAttribute.cs" /> + <Compile Include="Managers\RegisteredView.cs" /> + <Compile Include="Managers\ViewsManager.cs" /> + <Page Include="Views\DBViews\AddressesView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\AddressView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\MachinesView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\MachineView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\OrganizationsView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\OrganizationView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\UsersView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\UserView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\MainDBView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </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> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.DAL.Observables\Tango.DAL.Observables.csproj"> + <Project>{0ecd6da8-7aa6-48d9-8b65-279d176ad9af}</Project> + <Name>Tango.DAL.Observables</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.DAL.Remote\Tango.DAL.Remote.csproj"> + <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> + <Name>Tango.DAL.Remote</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 /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs new file mode 100644 index 000000000..0f9666137 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -0,0 +1,68 @@ +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Ioc; +using Microsoft.Practices.ServiceLocation; +using Tango.MachineStudio.DB.ViewModels; +using Tango.MachineStudio.DB.ViewModels.DBViewModels; + +namespace Tango.MachineStudio.DB +{ + /// <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() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + SimpleIoc.Default.Register<MainViewVM>(); + SimpleIoc.Default.Register<MachinesViewVM>(); + SimpleIoc.Default.Register<OrganizationsViewVM>(); + SimpleIoc.Default.Register<AddressesViewVM>(); + SimpleIoc.Default.Register<UsersViewVM>(); + } + + public static MainViewVM MainViewVM + { + get + { + return ServiceLocator.Current.GetInstance<MainViewVM>(); + } + } + + public static MachinesViewVM MachinesViewVM + { + get + { + return ServiceLocator.Current.GetInstance<MachinesViewVM>(); + } + } + + public static OrganizationsViewVM OrganizationsViewVM + { + get + { + return ServiceLocator.Current.GetInstance<OrganizationsViewVM>(); + } + } + + public static AddressesViewVM AddressesViewVM + { + get + { + return ServiceLocator.Current.GetInstance<AddressesViewVM>(); + } + } + + public static UsersViewVM UsersViewVM + { + get + { + return ServiceLocator.Current.GetInstance<UsersViewVM>(); + } + } + } +}
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/AddressesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/AddressesViewVM.cs new file mode 100644 index 000000000..c5f95c803 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/AddressesViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class AddressesViewVM : DbTableViewModel<Address> + { + public AddressesViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs new file mode 100644 index 000000000..db72055df --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI; +using Tango.MachineStudio.DB.ExtensionMethods; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public abstract class DbTableViewModel<T> : ViewModel where T : IObservableEntity + { + private INotificationProvider _notification; + + /// <summary> + /// Initializes a new instance of the <see cref="DbTableViewModel"/> class. + /// </summary> + public DbTableViewModel(INotificationProvider notification) : base() + { + _notification = notification; + Adapter = ObservablesEntitiesAdapter.Instance; + + AddCommand = new RelayCommand(OnAdd); + EditCommand = new RelayCommand(OnEdit); + DeleteCommand = new RelayCommand(OnDelete); + DialogOKCommand = new RelayCommand(() => OnDialogOKPressed(DialogOpenMode, EditEntity)); + DialogCancelCommand = new RelayCommand(() => OnDialogCancelPressed(DialogOpenMode, EditEntity)); + + IsDialogOpen = false; + } + + private T _editEntity; + /// <summary> + /// Gets or sets the edit entity. + /// </summary> + public T EditEntity + { + get { return _editEntity; } + set { _editEntity = value; RaisePropertyChangedAuto(); } + } + + private DialogOpenMode _dialogOpenMode; + /// <summary> + /// Gets or sets the dialog open mode. + /// </summary> + public DialogOpenMode DialogOpenMode + { + get { return _dialogOpenMode; } + set { _dialogOpenMode = value; RaisePropertyChangedAuto(); } + } + + private bool _isDialogOpen; + /// <summary> + /// Gets or sets a value indicating whether this instance is dialog open. + /// </summary> + public bool IsDialogOpen + { + get { return _isDialogOpen; } + set { _isDialogOpen = value; RaisePropertyChangedAuto(); } + } + + private ObservablesEntitiesAdapter _adapter; + /// <summary> + /// Gets or sets the DB adapter. + /// </summary> + public ObservablesEntitiesAdapter Adapter + { + get { return _adapter; } + set { _adapter = value; RaisePropertyChangedAuto(); } + } + + private T _selectedEntity; + /// <summary> + /// Gets or sets the selected entity. + /// </summary> + public T SelectedEntity + { + get { return _selectedEntity; } + set { _selectedEntity = value; RaisePropertyChangedAuto(); } + } + + private String _filter; + /// <summary> + /// Gets or sets the search filter. + /// </summary> + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(value); } + } + + /// <summary> + /// Gets or sets the dialog OK command. + /// </summary> + public RelayCommand DialogOKCommand { get; set; } + + /// <summary> + /// Gets or sets the dialog cancel command. + /// </summary> + public RelayCommand DialogCancelCommand { get; set; } + + /// <summary> + /// Gets or sets the add command. + /// </summary> + public RelayCommand AddCommand { get; set; } + + /// <summary> + /// Gets or sets the edit command. + /// </summary> + public RelayCommand EditCommand { get; set; } + + /// <summary> + /// Gets or sets the delete command. + /// </summary> + public RelayCommand DeleteCommand { get; set; } + + /// <summary> + /// Called when delete command invoked. + /// </summary> + protected virtual void OnDelete() + { + SelectedEntity.Deleted = true; + SelectedEntity.Save(); + } + + /// <summary> + /// Called when edit command invoked. + /// </summary> + protected virtual void OnEdit() + { + DialogOpenMode = DialogOpenMode.Editing; + EditEntity = GetEditableEntity(DialogOpenMode); + _notification.ShowDialog(DialogOpenMode, this); + IsDialogOpen = true; + } + + /// <summary> + /// Called when add command invoked. + /// </summary> + protected virtual void OnAdd() + { + DialogOpenMode = DialogOpenMode.Adding; + EditEntity = GetEditableEntity(DialogOpenMode); + _notification.ShowDialog(DialogOpenMode, this); + IsDialogOpen = true; + } + + /// <summary> + /// Called when dialog closes with OK button. + /// </summary> + /// <param name="mode">The mode.</param> + protected virtual void OnDialogOKPressed(DialogOpenMode mode, T entity) + { + if (mode == DialogOpenMode.Editing) + { + entity.ShallowCopyTo(SelectedEntity); + entity = SelectedEntity; + } + + OnBeforeEntitySave(mode, entity); + + entity.Save(); + IsDialogOpen = false; + SelectedEntity = EditEntity; + } + + /// <summary> + /// Called when [before entity save]. + /// </summary> + /// <param name="mode">The mode.</param> + /// <param name="entity">The entity.</param> + protected virtual void OnBeforeEntitySave(DialogOpenMode mode,T entity) + { + + } + + /// <summary> + /// Called when dialog closes with cancel button. + /// </summary> + /// <param name="mode">The mode.</param> + protected virtual void OnDialogCancelPressed(DialogOpenMode mode, T entity) + { + IsDialogOpen = false; + } + + /// <summary> + /// Gets the editable entity. + /// </summary> + /// <param name="mode">The mode.</param> + /// <returns></returns> + private T GetEditableEntity(DialogOpenMode mode) + { + if (mode == DialogOpenMode.Adding) + { + var newEntity = Activator.CreateInstance<T>(); + InitializeEntity(newEntity); + return newEntity; + } + else + { + return SelectedEntity.ShallowClone(); + } + } + + protected virtual void OnFilterChanged(String filter) + { + + } + + protected virtual void InitializeEntity(T entity) + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DialogOpenMode.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DialogOpenMode.cs new file mode 100644 index 000000000..7a7e9bd41 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DialogOpenMode.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public enum DialogOpenMode + { + Editing, + Adding, + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EntityViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EntityViewModel.cs new file mode 100644 index 000000000..946a73088 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EntityViewModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class EntityViewModel<T> : ViewModel + { + private T _entity; + + public T Entity + { + get { return _entity; } + set { _entity = value; RaisePropertyChanged(nameof(Entity)); } + } + + public EntityViewModel() : base() + { + + } + + public EntityViewModel(T entity) : this() + { + Entity = entity; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MachinesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MachinesViewVM.cs new file mode 100644 index 000000000..fd2f88c2f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MachinesViewVM.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class MachinesViewVM : DbTableViewModel<Machine> + { + public MachinesViewVM(INotificationProvider notification) : base(notification) + { + } + + protected override void InitializeEntity(Machine entity) + { + base.InitializeEntity(entity); + entity.ProductionDate = DateTime.Now; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..11c0adc0e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class MainViewVM : ViewModel + { + public String Text { get; set; } + + public MainViewVM() : base() + { + Text = "Hi ROy"; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MultiComboVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MultiComboVM.cs new file mode 100644 index 000000000..4a3709050 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MultiComboVM.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class MultiComboVM<T> : EntityViewModel<T> + { + private Action _onSelectionChanged; + + public event EventHandler SelectionChanged; + + public MultiComboVM(T entity) : base(entity) + { + + } + + public MultiComboVM(T entity, Action onSelectionChanged) : this(entity) + { + _onSelectionChanged = onSelectionChanged; + } + + private bool _isSelected; + + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); OnSelectionChanged(); } + } + + protected virtual void OnSelectionChanged() + { + if (_onSelectionChanged != null) + { + _onSelectionChanged(); + } + + SelectionChanged?.Invoke(this, new EventArgs()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/OrganizationsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/OrganizationsViewVM.cs new file mode 100644 index 000000000..ff0ec3b77 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/OrganizationsViewVM.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class OrganizationsViewVM : DbTableViewModel<Organization> + { + public OrganizationsViewVM(INotificationProvider notification) : base(notification) + { + } + + protected override void OnFilterChanged(string filter) + { + Adapter.OrganizationsViewSource.Filter = (x) => + { + var org = x as Organization; + return org.Name.Contains(filter); + }; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs new file mode 100644 index 000000000..1dde969d6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class UsersViewVM : DbTableViewModel<User> + { + private ObservableCollection<MultiComboVM<Role>> _selectedRoles; + + public UsersViewVM(INotificationProvider notification) : base(notification) + { + SelectedRoles = new ObservableCollection<MultiComboVM<Role>>(); + } + + public ObservableCollection<MultiComboVM<Role>> SelectedRoles + { + get { return _selectedRoles; } + set { _selectedRoles = value; RaisePropertyChangedAuto(); } + } + + protected override void OnEdit() + { + SelectedRoles = Adapter.Roles.Select(x => new MultiComboVM<Role>(x, () => RaisePropertyChanged(nameof(SelectedRoles)))).ToObservableCollection(); + + foreach (var role in SelectedRoles) + { + if (SelectedEntity.UsersRoles.ToList().Exists(x => x.Role == role.Entity && !x.Deleted)) + { + role.IsSelected = true; + } + } + + base.OnEdit(); + } + + protected override void OnAdd() + { + SelectedRoles = Adapter.Roles.Select(x => new MultiComboVM<Role>(x, () => RaisePropertyChanged(nameof(SelectedRoles)))).ToObservableCollection(); + + base.OnAdd(); + } + + protected override void OnBeforeEntitySave(DialogOpenMode mode, User user) + { + base.OnBeforeEntitySave(mode, user); + + foreach (var role in SelectedRoles) + { + var userRole = user.UsersRoles.SingleOrDefault(x => x.Role == role.Entity); + + if (userRole != null) + { + userRole.Deleted = !role.IsSelected; + } + else + { + if (role.IsSelected) + { + user.UsersRoles.Add(new UsersRole() + { + Role = role.Entity, + User = user, + RoleGuid = role.Entity.Guid, + UserGuid = user.Guid + }); + } + } + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml new file mode 100644 index 000000000..9c132295b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml @@ -0,0 +1,34 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.AddressView" + 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:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300"> + <Grid> + <controls:TableGrid> + <TextBlock Text="ID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.ID}" IsReadOnly="True"></TextBox> + <TextBlock Text="GUID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Guid}" IsReadOnly="True"></TextBox> + <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True"></TextBox> + <TextBlock Text="Address:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.AddressString,Mode=TwoWay}"></TextBox> + <TextBlock Text="Locality:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Locality,Mode=TwoWay}"></TextBox> + <TextBlock Text="Country:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Country,Mode=TwoWay}"></TextBox> + <TextBlock Text="City:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.City,Mode=TwoWay}"></TextBox> + <TextBlock Text="State:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.State,Mode=TwoWay}"></TextBox> + <TextBlock Text="Country Code:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.CountryCode,Mode=TwoWay}"></TextBox> + <TextBlock Text="Postal Code:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.PostalCode,Mode=TwoWay}"></TextBox> + </controls:TableGrid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml.cs new file mode 100644 index 000000000..cc890eb26 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.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.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for AddressView.xaml + /// </summary> + public partial class AddressView : UserControl + { + public AddressView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml new file mode 100644 index 000000000..ee46a9c11 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml @@ -0,0 +1,28 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.AddressesView" + 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:global="clr-namespace:Tango.MachineStudio.DB" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.AddressesViewVM}"> + <Grid> + <controls:DbTableView> + <DataGrid Background="Transparent" ItemsSource="{Binding Adapter.Addresses}" SelectedItem="{Binding SelectedEntity}" AutoGenerateColumns="False" IsReadOnly="True"> + <DataGrid.Columns> + <DataGridTextColumn Header="ID" Binding="{Binding ID}"></DataGridTextColumn> + <DataGridTextColumn Header="GUID" Binding="{Binding Guid}"></DataGridTextColumn> + <DataGridTextColumn Header="Address" Binding="{Binding AddressString}"></DataGridTextColumn> + <DataGridTextColumn Header="Locality" Binding="{Binding Locality}"></DataGridTextColumn> + <DataGridTextColumn Header="Country" Binding="{Binding Country}"></DataGridTextColumn> + <DataGridTextColumn Header="City" Binding="{Binding City}"></DataGridTextColumn> + <DataGridTextColumn Header="State" Binding="{Binding State}"></DataGridTextColumn> + <DataGridTextColumn Header="Country Code" Binding="{Binding CountryCode}"></DataGridTextColumn> + <DataGridTextColumn Header="Postal Code" Binding="{Binding PostalCode}"></DataGridTextColumn> + </DataGrid.Columns> + </DataGrid> + </controls:DbTableView> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml.cs new file mode 100644 index 000000000..b6ead64e3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml.cs @@ -0,0 +1,31 @@ +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.DB.CustomAttributes; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for MachinesView.xaml + /// </summary> + [DBView] + public partial class AddressesView : UserControl + { + public AddressesView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml new file mode 100644 index 000000000..45ada50ca --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml @@ -0,0 +1,28 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.MachineView" + 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:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300"> + <Grid> + <controls:TableGrid> + <TextBlock Text="ID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.ID}" IsReadOnly="True"></TextBox> + <TextBlock Text="GUID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Guid}" IsReadOnly="True"></TextBox> + <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True"></TextBox> + <TextBlock Text="Serial Number:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.SerialNumber,Mode=TwoWay}"></TextBox> + <TextBlock Text="Name:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Name,Mode=TwoWay}"></TextBox> + <TextBlock Text="Organization:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.Organizations}" SelectedItem="{Binding EditEntity.Organization,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> + <TextBlock Text="Version:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.MachineVersions}" SelectedItem="{Binding EditEntity.MachineVersions,Mode=TwoWay}" DisplayMemberPath="Version"></ComboBox> + </controls:TableGrid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml.cs new file mode 100644 index 000000000..b14dcc6c7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.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.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for MachineView.xaml + /// </summary> + public partial class MachineView : UserControl + { + public MachineView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml new file mode 100644 index 000000000..f5913bd2c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml @@ -0,0 +1,26 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.MachinesView" + 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:global="clr-namespace:Tango.MachineStudio.DB" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.MachinesViewVM}"> + <Grid> + <controls:DbTableView> + <DataGrid Background="Transparent" ItemsSource="{Binding Adapter.Machines}" SelectedItem="{Binding SelectedEntity}" AutoGenerateColumns="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsReadOnly="True"> + <DataGrid.Columns> + <DataGridTextColumn Header="ID" Binding="{Binding ID}"></DataGridTextColumn> + <DataGridTextColumn Header="GUID" Binding="{Binding Guid}"></DataGridTextColumn> + <DataGridTextColumn Header="Serial Number" Binding="{Binding SerialNumber}"></DataGridTextColumn> + <DataGridTextColumn Header="Name" Binding="{Binding Name}"></DataGridTextColumn> + <DataGridTextColumn Header="Version" Binding="{Binding MachineVersions.Version}"></DataGridTextColumn> + <DataGridTextColumn Header="Organization" Binding="{Binding Organization.Name}"></DataGridTextColumn> + <DataGridTextColumn Header="Configuration" Binding="{Binding MachinesConfigurations[0].Configuration.Name}"></DataGridTextColumn> + </DataGrid.Columns> + </DataGrid> + </controls:DbTableView> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml.cs new file mode 100644 index 000000000..a3865ce4e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml.cs @@ -0,0 +1,32 @@ +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.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for MachinesView.xaml + /// </summary> + [DBView] + public partial class MachinesView : UserControl + { + public MachinesView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml new file mode 100644 index 000000000..229ddacb2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml @@ -0,0 +1,26 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.OrganizationView" + 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.DB.Views.DBViews" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300"> + <Grid> + <controls:TableGrid> + <TextBlock Text="ID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.ID}" IsReadOnly="True"></TextBox> + <TextBlock Text="GUID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Guid}" IsReadOnly="True"></TextBox> + <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True"></TextBox> + <TextBlock Text="Name:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Name,Mode=TwoWay}"></TextBox> + <TextBlock Text="Address:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.Addresses}" SelectedItem="{Binding EditEntity.Address}" DisplayMemberPath="AddressString"></ComboBox> + <TextBlock Text="Contact:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.Contacts}" SelectedItem="{Binding EditEntity.Contact}" DisplayMemberPath="FullName"></ComboBox> + </controls:TableGrid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml.cs new file mode 100644 index 000000000..a9f4ec880 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.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.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for OrganizationView.xaml + /// </summary> + public partial class OrganizationView : UserControl + { + public OrganizationView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml new file mode 100644 index 000000000..ff5e7df4a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml @@ -0,0 +1,27 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.OrganizationsView" + 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:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:global="clr-namespace:Tango.MachineStudio.DB" + xmlns:system="clr-namespace:System;assembly=mscorlib" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.OrganizationsViewVM}"> + <Grid> + <controls:DbTableView> + <DataGrid Background="Transparent" ItemsSource="{Binding Adapter.OrganizationsViewSource}" SelectedItem="{Binding SelectedEntity}" AutoGenerateColumns="False" IsReadOnly="True"> + <DataGrid.Columns> + <DataGridTextColumn Header="ID" Binding="{Binding ID}"></DataGridTextColumn> + <DataGridTextColumn Header="GUID" Binding="{Binding Guid}"></DataGridTextColumn> + <DataGridTextColumn Header="Name" Binding="{Binding Name}"></DataGridTextColumn> + <DataGridTextColumn Header="Address" Binding="{Binding Address.AddressString}"></DataGridTextColumn> + <DataGridTextColumn Header="Contact" Binding="{Binding Contact.FullName}"></DataGridTextColumn> + <DataGridTextColumn Header="Machines" Binding="{Binding Machines.Count}"></DataGridTextColumn> + <DataGridTextColumn Header="Users" Binding="{Binding Users.Count}"></DataGridTextColumn> + </DataGrid.Columns> + </DataGrid> + </controls:DbTableView> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml.cs new file mode 100644 index 000000000..2b76305a5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml.cs @@ -0,0 +1,30 @@ +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.DB.CustomAttributes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for OrganizationsView.xaml + /// </summary> + [DBView] + public partial class OrganizationsView : UserControl + { + public OrganizationsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml new file mode 100644 index 000000000..bb5f08f4a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml @@ -0,0 +1,48 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.UserView" + 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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:converters="clr-namespace:Tango.MachineStudio.DB.Converters" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300"> + + <UserControl.Resources> + <converters:UsersRolesToStringConverter x:Key="UsersRolesToStringConverter"></converters:UsersRolesToStringConverter> + </UserControl.Resources> + + <Grid> + <controls:TableGrid> + <TextBlock Text="ID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.ID}" IsReadOnly="True" IsEnabled="False"></TextBox> + <TextBlock Text="GUID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Guid}" IsReadOnly="True" IsEnabled="False"></TextBox> + <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True" IsEnabled="False"></TextBox> + <TextBlock Text="Email:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Email,Mode=TwoWay}"></TextBox> + <TextBlock Text="Password:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Password,Mode=TwoWay}"></TextBox> + <TextBlock Text="Roles:" FontWeight="Bold"></TextBlock> + <ComboBox x:Name="comboRoles" SelectionChanged="comboRoles_SelectionChanged" ItemsSource="{Binding SelectedRoles}" materialDesign:HintAssist.Hint="{Binding SelectedRoles,Converter={StaticResource UsersRolesToStringConverter},UpdateSourceTrigger=PropertyChanged}"> + <ComboBox.ItemTemplate> + <DataTemplate> + <StackPanel Orientation="Horizontal"> + <CheckBox IsChecked="{Binding IsSelected}" Width="20"/> + <TextBlock Text="{Binding Entity.Name}" Width="100" /> + </StackPanel> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> + <TextBlock Text="Organization:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.Organizations}" SelectedItem="{Binding EditEntity.Organization,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> + <TextBlock Text="Address:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.Addresses}" SelectedItem="{Binding EditEntity.Address}" DisplayMemberPath="AddressString"></ComboBox> + <TextBlock Text="Contact:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.Contacts}" SelectedItem="{Binding EditEntity.Contact}" DisplayMemberPath="FullName"></ComboBox> + </controls:TableGrid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml.cs new file mode 100644 index 000000000..1c84eed8e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml.cs @@ -0,0 +1,34 @@ +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.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for UserView.xaml + /// </summary> + public partial class UserView : UserControl + { + public UserView() + { + InitializeComponent(); + } + + private void comboRoles_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + comboRoles.SelectedItem = null; + comboRoles.Text = "Press to select"; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml new file mode 100644 index 000000000..5b6c2e842 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml @@ -0,0 +1,33 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.UsersView" + 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:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:global="clr-namespace:Tango.MachineStudio.DB" + xmlns:converters="clr-namespace:Tango.MachineStudio.DB.Converters" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.UsersViewVM}"> + + <UserControl.Resources> + <converters:UsersRolesToStringConverter x:Key="UsersRolesToStringConverter"></converters:UsersRolesToStringConverter> + </UserControl.Resources> + + <Grid> + <controls:DbTableView> + <DataGrid Background="Transparent" ItemsSource="{Binding Adapter.Users}" SelectedItem="{Binding SelectedEntity}" AutoGenerateColumns="False" IsReadOnly="True"> + <DataGrid.Columns> + <DataGridTextColumn Header="ID" Binding="{Binding ID}"></DataGridTextColumn> + <DataGridTextColumn Header="GUID" Binding="{Binding Guid}"></DataGridTextColumn> + <DataGridTextColumn Header="Name" Binding="{Binding Contact.FullName}"></DataGridTextColumn> + <DataGridTextColumn Header="Email" Binding="{Binding Email}"></DataGridTextColumn> + <DataGridTextColumn Header="Password" Binding="{Binding Password}"></DataGridTextColumn> + <DataGridTextColumn Header="Organization" Binding="{Binding Organization.Name}"></DataGridTextColumn> + <DataGridTextColumn Header="Roles" Binding="{Binding UsersRoles,Converter={StaticResource UsersRolesToStringConverter}}"></DataGridTextColumn> + <DataGridTextColumn Header="Address" Binding="{Binding Address.AddressString}"></DataGridTextColumn> + </DataGrid.Columns> + </DataGrid> + </controls:DbTableView> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml.cs new file mode 100644 index 000000000..492e846fe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml.cs @@ -0,0 +1,30 @@ +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.DB.CustomAttributes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for UsersView.xaml + /// </summary> + [DBView] + public partial class UsersView : UserControl + { + public UsersView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml new file mode 100644 index 000000000..d3149849f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml @@ -0,0 +1,74 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.MainDBView" + 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:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz" + xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:managers="clr-namespace:Tango.MachineStudio.DB.Managers" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1270" Background="White" DataContext="{Binding MainViewVM, Source={StaticResource Locator}}"> + <Grid> + <DockPanel> + <Grid> + <Grid> + <Grid> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Grid> + <Menu IsMainMenu="True"> + <MenuItem Header="DataBase" ItemsSource="{x:Static managers:ViewsManager.DbViews}" DisplayMemberPath="Header"> + <MenuItem.ItemContainerStyle> + <Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}"> + <Setter Property="Command" Value="{Binding AddCommand}"></Setter> + </Style> + </MenuItem.ItemContainerStyle> + </MenuItem> + <MenuItem Header="Edit"></MenuItem> + </Menu> + </Grid> + + <dockablz:Layout Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible" FloatingItemsSource="{x:Static managers:ViewsManager.DisplayedViews}" FloatingItemDisplayMemberPath="View" FloatingItemHeaderMemberPath="Header"> + + </dockablz:Layout> + + <!--<dragablz:TabablzControl BorderThickness="0" FontSize="14" ItemContainerStyle="{DynamicResource TabItemStyle}"> + <dragablz:TabablzControl.Resources> + <Style x:Key="TabItemStyle" TargetType="{x:Type dragablz:DragablzItem}" BasedOn="{StaticResource MaterialDesignDragableTabItemStyle}"> + <Setter Property="Height" Value="60" /> + <Setter Property="Padding" Value="24,0,24,0" /> + </Style> + </dragablz:TabablzControl.Resources> + <dragablz:TabablzControl.InterTabController> + <dragablz:InterTabController /> + </dragablz:TabablzControl.InterTabController> + <TabItem Header="ORGANIZATIONS"> + <local:OrganizationsView></local:OrganizationsView> + </TabItem> + <TabItem Header="MACHINES"> + <local:MachinesView></local:MachinesView> + </TabItem> + <TabItem Header="ADDRESSES"> + <local:AddressesView></local:AddressesView> + </TabItem> + <TabItem Header="DISPENSERS"> + <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Looks Quite Nice</TextBlock> + </TabItem> + <TabItem Header="MEDIA LIST"> + <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Looks Quite Nice</TextBlock> + </TabItem> + </dragablz:TabablzControl>--> + </Grid> + </Grid> + </Grid> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs new file mode 100644 index 000000000..9e327b575 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs @@ -0,0 +1,30 @@ +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.SharedUI; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views +{ + /// <summary> + /// Interaction logic for MainView.xaml + /// </summary> + public partial class MainDBView : UserControl + { + public MainDBView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config new file mode 100644 index 000000000..ccf9158d8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="CommonServiceLocator" version="1.3" targetFramework="net46" /> + <package id="Dragablz" version="0.0.3.197" targetFramework="net46" /> + <package id="EntityFramework" version="6.0.0" targetFramework="net46" /> + <package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" /> + <package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net46" /> + <package id="MvvmLight" version="5.3.0.0" targetFramework="net46" /> + <package id="MvvmLightLibs" version="5.3.0.0" targetFramework="net46" /> +</packages>
\ No newline at end of file |
