From 4e48c569f1cae820ffade8a786354b2ba79b50b4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 6 Mar 2018 18:28:51 +0200 Subject: Some improvements on hive. --- .../Tango.MachineStudio.ColorLab.csproj | 1 + .../ViewModels/MainViewVM.cs | 62 ++++++++++++++++++- .../ViewModels/RgbVM.cs | 69 ++++++++++++++++++++++ .../Views/MainView.xaml | 33 ++++------- .../Views/MainView.xaml.cs | 11 ++++ .../ViewModels/MainViewVM.cs | 2 +- .../Views/EmbroideryImportView.xaml | 2 +- .../Views/JobView.xaml | 4 +- .../Views/JobView.xaml.cs | 2 +- 9 files changed, 158 insertions(+), 28 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/RgbVM.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj index 91bc51933..44e55a12e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj @@ -89,6 +89,7 @@ + MainView.xaml diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs index 8260f000a..c6cc95930 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs @@ -5,15 +5,19 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using Tango.BL; using Tango.BL.Entities; +using Tango.MachineStudio.Common.Controls; using Tango.SharedUI; +using Tango.SharedUI.Controls; namespace Tango.MachineStudio.ColorLab.ViewModels { public class MainViewVM : ViewModel { private ObservablesContext _dbContext; + private HiveComboControl _hiveCombo; #region Properties @@ -57,6 +61,7 @@ namespace Tango.MachineStudio.ColorLab.ViewModels set { _selectedMachine = value; RaisePropertyChangedAuto(); + OnSelectedMachineChanged(); } } @@ -86,7 +91,9 @@ namespace Tango.MachineStudio.ColorLab.ViewModels } private ObservableCollection _liquidVolumes; - + /// + /// Gets or sets the liquid volumes. + /// public ObservableCollection LiquidVolumes { get { return _liquidVolumes; } @@ -94,24 +101,74 @@ namespace Tango.MachineStudio.ColorLab.ViewModels } private ObservableCollection _liquidsCalibrationData; - + /// + /// Gets or sets the liquids calibration data. + /// public ObservableCollection LiquidsCalibrationData { get { return _liquidsCalibrationData; } set { _liquidsCalibrationData = value; RaisePropertyChangedAuto(); } } + private RgbVM _sourceColor; + /// + /// Gets or sets the color of the source. + /// + public RgbVM SourceColor + { + get { return _sourceColor; } + set { _sourceColor = value; RaisePropertyChangedAuto(); } + } + + private HexagonControl _selectedHexagon; + /// + /// Gets or sets the selected hexagon. + /// + public HexagonControl SelectedHexagon + { + get { return _selectedHexagon; } + set { _selectedHexagon = value; RaisePropertyChangedAuto(); } + } + #endregion public MainViewVM() : base() { _dbContext = ObservablesContext.CreateDefault(); + SourceColor = new RgbVM(); + SourceColor.ColorChanged += SourceColor_ColorChanged; Machines = _dbContext.Machines.ToObservableCollection(); ColorSpaces = _dbContext.ColorSpaces.ToObservableCollection(); Rmls = _dbContext.Rmls.ToObservableCollection(); } + private void SourceColor_ColorChanged(object sender, Color color) + { + if (_hiveCombo != null) + { + _hiveCombo.GenerateDemoModeHiveColors(color); + _hiveCombo.SelectHeagon(_hiveCombo.CenterHexagon); + } + } + + public void PutComboHiveControl(HiveComboControl hiveCombo) + { + _hiveCombo = hiveCombo; + } + + #region Liquid Volumes + + private void OnSelectedMachineChanged() + { + if (SelectedMachine != null) + { + LiquidVolumes = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => new LiquidVolumeVM() { Color = x.LiquidType.Color, Name = x.LiquidType.Name }).ToObservableCollection(); + } + } + + #endregion + #region RML private void InvalidateLiquidFactorsAndProcessTables() @@ -120,7 +177,6 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { LiquidTypesRmls = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); //RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); - LiquidVolumes = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => new LiquidVolumeVM() { Color = x.LiquidType.Color, Name = x.LiquidType.Name }).ToObservableCollection(); LiquidsCalibrationData = new ObservableCollection(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/RgbVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/RgbVM.cs new file mode 100644 index 000000000..badb238fb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/RgbVM.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.SharedUI; + +namespace Tango.MachineStudio.ColorLab.ViewModels +{ + public class RgbVM : ViewModel + { + public event EventHandler ColorChanged; + + public RgbVM() + { + Color = Colors.DimGray; + } + + private double _red; + public double Red + { + get { return _red; } + set { _red = value; SynchronizeColor(); RaisePropertyChangedAuto(); } + } + + private double _green; + public double Green + { + get { return _green; } + set { _green = value; SynchronizeColor(); RaisePropertyChangedAuto(); } + } + + private double _blue; + public double Blue + { + get { return _blue; } + set { _blue = value; SynchronizeColor(); RaisePropertyChangedAuto(); } + } + + private Color _color; + public Color Color + { + get { return _color; } + set { _color = value; RaisePropertyChanged(nameof(Color)); SynchronizeComponents(); } + } + + private void SynchronizeColor() + { + _color = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue); + RaisePropertyChanged(nameof(Color)); + ColorChanged?.Invoke(this, _color); + } + + private void SynchronizeComponents() + { + _red = Color.R; + _green = Color.G; + _blue = Color.B; + + RaisePropertyChanged(nameof(Red)); + RaisePropertyChanged(nameof(Green)); + RaisePropertyChanged(nameof(Blue)); + RaisePropertyChanged(nameof(Color)); + + ColorChanged?.Invoke(this, Color); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml index 92ef15231..72a1bdd4e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml @@ -8,6 +8,7 @@ xmlns:observables="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:vm="clr-namespace:Tango.MachineStudio.ColorLab.ViewModels" xmlns:brushPicker="clr-namespace:Tango.BrushPicker;assembly=Tango.BrushPicker" @@ -164,9 +165,9 @@ - + + - @@ -179,41 +180,33 @@ - - - - - - - - - + - - + + - - + + - - + + SOURCE / INVERSE RGB - SUGGESTIONS + SUGGESTIONS LIQUID VOLUMES - + @@ -281,7 +274,7 @@ COMPOSITE - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml.cs index 1a96386f6..d78750050 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml.cs @@ -12,6 +12,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.MachineStudio.ColorLab.ViewModels; namespace Tango.MachineStudio.ColorLab.Views { @@ -20,9 +21,19 @@ namespace Tango.MachineStudio.ColorLab.Views /// public partial class MainView : UserControl { + private MainViewVM _vm; + public MainView() { InitializeComponent(); + + this.Loaded += MainView_Loaded; + } + + private void MainView_Loaded(object sender, RoutedEventArgs e) + { + _vm = DataContext as MainViewVM; + _vm.PutComboHiveControl(hiveCombo); } } } 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 index 566dc7a16..dfaeb7044 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1710,7 +1710,7 @@ namespace Tango.MachineStudio.Developer.ViewModels Red = stop.Color.R, Green = stop.Color.G, Blue = stop.Color.B, - OffsetPercent = stop.Offset, + OffsetPercent = stop.Offset * 100d, ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()), }); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml index 42d0bb106..8d25719e8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml @@ -46,7 +46,7 @@ Region Brush - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 1dea01de7..4c0784d1d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -157,13 +157,13 @@ - + - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs index 905caa96d..0c99dfe5f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs @@ -125,7 +125,7 @@ namespace Tango.MachineStudio.Developer.Views } - private void HiveColorPickerControl_SelectedColorChanged(object sender, Color e) + private void HiveColorPickerControl_SelectedColorChanged(object sender, Color color) { UpdateGradientBrushDisplay(); } -- cgit v1.3.1