From dd18ae0c096a34048477297ba848a089a99eece1 Mon Sep 17 00:00:00 2001 From: Roy Date: Sun, 7 Jan 2018 09:27:42 +0200 Subject: Progress on machine designer... --- .../Images/android.png | Bin 0 -> 1416 bytes .../Images/dispenser.png | Bin 16541 -> 11951 bytes .../Images/hardware.png | Bin 0 -> 1005 bytes .../Images/mid-tank.png | Bin 2624 -> 2164 bytes .../Images/ti-tm4c129x.png | Bin 352430 -> 271765 bytes .../Tango.MachineStudio.MachineDesigner.csproj | 4 + .../ViewModels/MainViewVM.cs | 181 +++++- .../Views/MainView.xaml | 685 +++++++++++++-------- .../Views/MainView.xaml.cs | 74 ++- 9 files changed, 688 insertions(+), 256 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/android.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/hardware.png (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/android.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/android.png new file mode 100644 index 000000000..7fc5fbfe1 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/android.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/dispenser.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/dispenser.png index b7c292bf9..a070c94e0 100644 Binary files a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/dispenser.png and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/dispenser.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/hardware.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/hardware.png new file mode 100644 index 000000000..856cf1ec7 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/hardware.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/mid-tank.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/mid-tank.png index 6603d1b9f..4da752a42 100644 Binary files a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/mid-tank.png and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/mid-tank.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/ti-tm4c129x.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/ti-tm4c129x.png index 9c280255e..e414e3355 100644 Binary files a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/ti-tm4c129x.png and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Images/ti-tm4c129x.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index 2c3f6c674..96d7ddb8f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -197,5 +197,9 @@ + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 241297d85..22e350745 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -1,9 +1,14 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; +using System.Windows.Data; using Tango.Core.Commands; +using Tango.Core.Helpers; using Tango.DAL.Observables; using Tango.MachineStudio.Common.Notifications; using Tango.SharedUI; @@ -32,7 +37,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public Machine Machine { get { return _machine; } - set { _machine = value; RaisePropertyChangedAuto(); OnMachineChanged(); } + set { _machine = value; RaisePropertyChangedAuto(); } + } + + private Machine _selectedMachine; + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); OnSelectedMachineChanged(); } } private Configuration _configuration; @@ -55,6 +67,33 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _selectedIds = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private ObservableCollection _history; + + public ObservableCollection History + { + get { return _history; } + set { _history = value; RaisePropertyChangedAuto(); } + } + + + private Configuration _selectedHistoryConfiguration; + /// + /// Gets or sets the selected history configuration. + /// + public Configuration SelectedHistoryConfiguration + { + get { return _selectedHistoryConfiguration; } + set { _selectedHistoryConfiguration = value; RaisePropertyChangedAuto(); OnHistoryConfigurationSelected(); } + } + + private String _filter; + + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + public RelayCommand SaveCommand { get; set; } public RelayCommand AddIdsCommand { get; set; } @@ -71,21 +110,34 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels Adapter = ObservablesEntitiesAdapter.Instance; Configuration = new Configuration(); Configuration.Name = "Untitled"; + Machine = new Machine(); + Machine.Configuration = Configuration; + Configuration.ApplicationFirmwareVersions = Adapter.ApplicationFirmwareVersions.First(); SaveCommand = new RelayCommand(Save, (x) => !_isSaving); AddIdsCommand = new RelayCommand(AddIds, (x) => !_isSaving && Configuration.IdsPacks.Count < 8); RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => !_isSaving && SelectedIds != null); } - private void OnMachineChanged() + private void OnSelectedMachineChanged() { - if (Machine != null) + if (SelectedMachine != null) { - Configuration = Machine.Configuration; + Machine = SelectedMachine.CloneEntity(); + Configuration = Machine.Configuration.CloneConfiguration(); + History = SelectedMachine.MachinesConfigurations.Select(x => x.Configuration).ToObservableCollection(); } else { - Configuration = new Configuration() { Name = "Untitled" }; + History = new ObservableCollection(); + } + } + + private void OnHistoryConfigurationSelected() + { + if (SelectedHistoryConfiguration != null) + { + Configuration = SelectedHistoryConfiguration.CloneConfiguration(); } } @@ -101,6 +153,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels Configuration.ApplicationVersionGuid = applicationVersion.Guid; } + public void DropHardwareVersion(HardwareVersion hardwareVersion) + { + Configuration.HardwareVersions = hardwareVersion; + Configuration.HardwareVersionGuid = hardwareVersion.Guid; + } + public void DropEmbeddedFirmware(EmbeddedFirmwareVersion embeddedFirmwareVersion) { Configuration.EmbeddedFirmwareVersions = embeddedFirmwareVersion; @@ -113,6 +171,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels Configuration.EmbeddedSoftwareVersionGuid = embeddedSoftwareVersion.Guid; } + public void DropApplicationOsVersion(ApplicationOsVersion applicationOsVersion) + { + Configuration.ApplicationOsVersions = applicationOsVersion; + Configuration.ApplicationVersionGuid = applicationOsVersion.Guid; + } + private void RemoveIds() { Configuration.IdsPacks.Remove(SelectedIds); @@ -121,7 +185,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private void AddIds() { - Configuration.IdsPacks.Add(new IdsPack()); + Configuration.IdsPacks.Add(new IdsPack() { Configuration = Configuration }); InvalidateRelayCommands(); } @@ -149,6 +213,42 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels idsPack.LiquidTypeGuid = liquidType.Guid; } + private void OnFilterChanged() + { + + + List collections = new List(); + collections.Add(Adapter.ApplicationDisplayPanelVersionsViewSource); + collections.Add(Adapter.ApplicationVersionsViewSource); + collections.Add(Adapter.EmbeddedSoftwareVersionsViewSource); + collections.Add(Adapter.EmbeddedFirmwareVersionsViewSource); + collections.Add(Adapter.ApplicationOsVersionsViewSource); + collections.Add(Adapter.ApplicationVersionsViewSource); + collections.Add(Adapter.DispensersViewSource); + collections.Add(Adapter.CartridgeTypesViewSource); + collections.Add(Adapter.LiquidTypesViewSource); + collections.Add(Adapter.MidTankTypesViewSource); + collections.Add(Adapter.HardwareVersionsViewSource); + + foreach (var collection in collections) + { + collection.Filter = (x) => + { + foreach (var prop in x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(String))) + { + String value = prop.GetValue(x).ToStringSafe(); + + if (value != null) + { + return value.ToLower().Contains(Filter.ToLower()); + } + } + + return false; + }; + } + } + private async void Save() { _isSaving = true; @@ -156,10 +256,67 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels try { - using (_notification.PushTaskItem("Saving Configuration...")) + using (_notification.PushTaskItem("Saving Machine Configuration...")) { - await Configuration.SaveAsync(); - Configuration = Adapter.Configurations.SingleOrDefault(x => x.Guid == Configuration.Guid); + if (!Adapter.Machines.ToList().Exists(x => x.SerialNumber.ToLower() == Machine.SerialNumber.ToLower())) + { + if (!_notification.ShowQuestion("The specified machine serial number does not exist. Do you wish to create a new machine?")) + { + return; + } + else + { + Machine.Configuration = Configuration; + Configuration.CreationDate = DateTime.UtcNow; + Machine.ProductionDate = DateTime.UtcNow; + Machine.MachinesConfigurations.Add(new MachinesConfiguration() + { + Configuration = Configuration, + Machine = Machine, + }); + await Machine.SaveAsync(); + + Machine = Adapter.Machines.SingleOrDefault(x => x.Guid == Machine.Guid); + Configuration = Machine.Configuration.CloneConfiguration(); + } + } + else + { + foreach (var ids in Configuration.IdsPacks) + { + ids.Configuration = Configuration; + ids.ConfigurationGuid = Configuration.Guid; + } + + var machine = Adapter.Machines.Single(x => x.SerialNumber.ToLower() == Machine.SerialNumber.ToLower()); + + //Set 'Real machine' parameters... + + bool add_history = History.Count == 0 || History.First().Name != Configuration.Name; + + machine.Name = Machine.Name; + machine.SerialNumber = Machine.SerialNumber; + machine.Configuration = Configuration; + machine.Organization = Machine.Organization; + + + if (add_history) + { + machine.MachinesConfigurations.Add(new MachinesConfiguration() + { + Configuration = Configuration, + Machine = machine + }); + } + + await machine.SaveAsync(); + + Machine = Adapter.Machines.SingleOrDefault(x => x.Guid == machine.Guid); + Configuration = Machine.Configuration.CloneConfiguration(); + } + + SetHistory(Machine); + Machine = Machine.CloneEntity(); } } catch (Exception ex) @@ -172,5 +329,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels InvalidateRelayCommands(); } } + + private void SetHistory(Machine machine) + { + History = machine.MachinesConfigurations.Select(x => x.Configuration).ToObservableCollection(); + History.Insert(0, machine.Configuration); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml index 48b90aa6b..03a3e2636 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml @@ -79,16 +79,16 @@ - + - - MACHINE DESIGNER - - + + + MACHINE DESIGNER + - + @@ -100,17 +100,39 @@ + + + - - - - + + + + + - + + + + + + + + + + + + + + + Hardware + + + + Add IDS @@ -131,7 +153,7 @@ - + + + + + + + + + + + + + + + + + + + @@ -226,59 +280,60 @@ - + - + - - - - - - - + + + + + + + + - - + + - Touch Panel: + Touch Panel - Embedded Firmware: + Embedded Firmware - Dispensers: + Dispensers - Mid Tanks: + Mid Tanks - + @@ -286,18 +341,32 @@ + - + + + + - - - - + + + + + + - - + + + + + + + + + + @@ -343,238 +412,362 @@ - - + + - - - - - - - - - - - - - - - + + + + + + Serial Number + + + Machine Name + + + Machine Version + + + Organization + + + + Enable Synchronization + + + + Configuration Name + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - v - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - v + + + + + + + + + + + + + + + + + + + + v + + + + + + - - - - - - - - - - - - - - - - - - - - - v + + + + + + + + + + + + + + + + + + + + v + - - - - - - - - - - - - - - - - - - - - - v + + + + + + + + + + + + + + + + + + + + v + - - - - - - - - - - - - - - - - - - - - - v + + + + + + + + + + + + + + + + + + + + v + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs index ebf45624d..7c2a38401 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs @@ -10,6 +10,7 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; @@ -25,15 +26,54 @@ namespace Tango.MachineStudio.MachineDesigner.Views public partial class MainView : UserControl { private MainViewVM _vm; + private Rectangle _highlightRect; + private bool _highlightShown; + private DoubleAnimation _highlightAnimation; public MainView() { InitializeComponent(); DraggingSurface = dragSufrace; - this.Loaded += (x, y) => + this.Loaded += (x, y) => { _vm = DataContext as MainViewVM; }; + + DragAndDropService.DragStarted += DragAndDropService_DragStarted; + DragAndDropService.DragEnded += DragAndDropService_DragEnded; + + _highlightRect = new Rectangle(); + _highlightRect.IsHitTestVisible = false; + _highlightRect.Stroke = Application.Current.Resources["AccentColorBrush"] as Brush; + _highlightRect.StrokeThickness = 2; + _highlightRect.StrokeDashArray = new DoubleCollection(new double[] { 3, 3, 3, 3 }); + } + + private void DragAndDropService_DragEnded(object sender, FrameworkElement e) + { + canvas.Children.Remove(_highlightRect); + _highlightShown = false; + _highlightRect.BeginAnimation(Rectangle.OpacityProperty, null); + } + + private void DragAndDropService_DragStarted(object sender, FrameworkElement e) + { + if (e.DataContext is HardwareVersion) + { + SetHighlightRegion(hardwareGrid); + } + else if (e.DataContext is ApplicationVersion || e.DataContext is ApplicationOsVersion || e.DataContext is ApplicationDisplayPanelVersion) + { + SetHighlightRegion(gridTablet); + } + else if (e.DataContext is EmbeddedFirmwareVersion || e.DataContext is EmbeddedSoftwareVersion) + { + SetHighlightRegion(gridEmbedded); + } + else if (e.DataContext is Dispenser || e.DataContext is Cartridge || e.DataContext is LiquidType || e.DataContext is MidTankType) + { + SetHighlightRegion(gridIds); + } } public DraggingSurface DraggingSurface @@ -74,6 +114,10 @@ namespace Tango.MachineStudio.MachineDesigner.Views { _vm.DropApplicationVersion(e.Draggable.DataContext as ApplicationVersion); } + else if (e.Draggable.DataContext is ApplicationOsVersion) + { + _vm.DropApplicationOsVersion(e.Draggable.DataContext as ApplicationOsVersion); + } } private void OnEmbeddedDrop(object sender, DropEventArgs e) @@ -87,5 +131,33 @@ namespace Tango.MachineStudio.MachineDesigner.Views _vm.DropEmbeddedSoftware(e.Draggable.DataContext as EmbeddedSoftwareVersion); } } + + private void MachineDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is HardwareVersion) + { + _vm.DropHardwareVersion(e.Draggable.DataContext as HardwareVersion); + } + } + + private void SetHighlightRegion(FrameworkElement element) + { + if (!_highlightShown) + { + _highlightRect.Width = element.Width; + _highlightRect.Height = element.Height; + Canvas.SetLeft(_highlightRect, Canvas.GetLeft(element)); + Canvas.SetTop(_highlightRect, Canvas.GetTop(element)); + canvas.Children.Add(_highlightRect); + _highlightShown = true; + _highlightAnimation = new DoubleAnimation(); + _highlightAnimation.From = 0; + _highlightAnimation.To = 1; + _highlightAnimation.Duration = TimeSpan.FromSeconds(0.2); + _highlightAnimation.AutoReverse = true; + _highlightAnimation.RepeatBehavior = RepeatBehavior.Forever; + _highlightRect.BeginAnimation(Rectangle.OpacityProperty, _highlightAnimation); + } + } } } -- cgit v1.3.1