From 3234e33cc4ba354f0395bb514b8b2fa102cf38ec Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 21 Jan 2018 15:56:57 +0200 Subject: Started working on Developer module. --- .../Converters/DbRmlViewToEntityConverter.cs | 38 ++++++ .../Tango.MachineStudio.Developer.csproj | 49 ++++++-- .../UserControl1.xaml | 12 -- .../UserControl1.xaml.cs | 28 ----- .../ViewModelLocator.cs | 31 +++++ .../ViewModels/DBViewContextWrapper.cs | 36 ++++++ .../ViewModels/MainViewVM.cs | 49 ++++++++ .../Views/MainView.xaml | 135 ++++++++++++++++++++- .../Tango.MachineStudio.Developer/packages.config | 8 ++ 9 files changed, 335 insertions(+), 51 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/DbRmlViewToEntityConverter.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/UserControl1.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/UserControl1.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/DBViewContextWrapper.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/DbRmlViewToEntityConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/DbRmlViewToEntityConverter.cs new file mode 100644 index 000000000..a2f0023cc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/DbRmlViewToEntityConverter.cs @@ -0,0 +1,38 @@ +using System; +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.Developer.ViewModels; + +namespace Tango.MachineStudio.Developer.Converters +{ + public class DbRmlViewToEntityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + DBViewContextWrapper db = value as DBViewContextWrapper; + return db; + } + + return null; + + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + Rml entity = value as Rml; + return new DBViewContextWrapper(entity); + } + + return null; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 44b50b443..5c90f04bd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -31,8 +31,32 @@ 4 + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll + + + ..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + + ..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll + @@ -47,21 +71,17 @@ + + + + MainView.xaml - - MSBuild:Compile - Designer - GlobalVersionInfo.cs - - UserControl1.xaml - Code - Designer MSBuild:Compile @@ -86,6 +106,7 @@ Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -100,6 +121,10 @@ {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} Tango.DAL.Observables + + {38197109-8610-4d3f-92b9-16d48df94d7c} + Tango.DAL.Remote + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI @@ -108,6 +133,14 @@ {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common + + {94f7acf8-55e1-4a02-b9bc-a818413fdbbf} + Tango.MachineStudio.DB + + + {d0ce8122-077d-42a2-9490-028ae4769b52} + Tango.MachineStudio.MachineDesigner + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/UserControl1.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/UserControl1.xaml deleted file mode 100644 index 95416b906..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/UserControl1.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/UserControl1.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/UserControl1.xaml.cs deleted file mode 100644 index e5519cb7e..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/UserControl1.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.Developer -{ - /// - /// Interaction logic for UserControl1.xaml - /// - public partial class UserControl1 : UserControl - { - public UserControl1() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs new file mode 100644 index 000000000..f11cee8d0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs @@ -0,0 +1,31 @@ +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Ioc; +using Microsoft.Practices.ServiceLocation; +using Tango.MachineStudio.Developer.ViewModels; + +namespace Tango.MachineStudio.Developer +{ + /// + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// + public static class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + static ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + SimpleIoc.Default.Register(); + } + + public static MainViewVM MainViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/DBViewContextWrapper.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/DBViewContextWrapper.cs new file mode 100644 index 000000000..231c27bf2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/DBViewContextWrapper.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; + +namespace Tango.MachineStudio.Developer.ViewModels +{ + public class DBViewContextWrapper where T : class, IObservableEntity + { + public T EditEntity { get; set; } + + public ObservablesEntitiesAdapter Adapter { get; set; } + + public DBViewContextWrapper() + { + Adapter = ObservablesEntitiesAdapter.Instance; + } + + public DBViewContextWrapper(T entity) : this() + { + EditEntity = entity; + } + + public static implicit operator DBViewContextWrapper(T entity) + { + return new DBViewContextWrapper(entity); + } + + public static implicit operator T(DBViewContextWrapper instance) + { + return instance.EditEntity; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..e7e97097b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -0,0 +1,49 @@ +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.StudioApplication; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Developer.ViewModels +{ + public class MainViewVM : ViewModel + { + public IStudioApplicationManager ApplicationManager { get; set; } + + public ObservablesEntitiesAdapter Adapter { get; set; } + + private Machine _selectedMachine; + + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private DBViewContextWrapper _selectedRML; + + public DBViewContextWrapper SelectedRML + { + get { return _selectedRML; } + set { _selectedRML = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand EditMachineCommand { get; set; } + + public MainViewVM(IStudioApplicationManager applicationManager) + { + Adapter = ObservablesEntitiesAdapter.Instance; + EditMachineCommand = new RelayCommand(EditMachine, (x) => SelectedMachine != null); + ApplicationManager = applicationManager; + } + + private void EditMachine() + { + ApplicationManager.RequestModule("Machine Designer", SelectedMachine); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index cd91b007f..5b26b7891 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -3,10 +3,139 @@ 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:global="clr-namespace:Tango.MachineStudio.Developer" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:db="clr-namespace:Tango.MachineStudio.DB.Views.DBViews;assembly=Tango.MachineStudio.DB" + xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" + xmlns:designer="clr-namespace:Tango.MachineStudio.MachineDesigner.Views;assembly=Tango.MachineStudio.MachineDesigner" + xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels" + xmlns:localConverters="clr-namespace:Tango.MachineStudio.Developer.Converters" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300" Background="#CBCBCB"> - - DEVLOPER MODULE + d:DesignHeight="720" d:DesignWidth="1280" Background="White" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config new file mode 100644 index 000000000..4fd672b32 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file -- cgit v1.3.1