using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; using Tango.BL.Enumerations; namespace Tango.PPC.Jobs.Models { public class LiquidVolumesCollection : ObservableCollection { public void RaiseMaxVolume() { this.ToList().ForEach(x => x.RaiseMaxVolume()); } public void RaiseVolume() { this.ToList().ForEach(x => x.RaiseVolume()); } public void ResetVolume() { this.ToList().ForEach(x => x.Volume = 0); } public void ResetVolumeSilent() { this.ToList().ForEach(x => x.SetVolumeSilent(0)); } public LiquidVolumeModel GetLiquidVolume(LiquidTypes type) { return this.FirstOrDefault(x => x.IdsPack.LiquidType.Type == type); } public LiquidVolumeModel GetLiquidVolume(PMR.ColorLab.LiquidType type) { return this.FirstOrDefault(x => x.IdsPack.LiquidType.Type == (LiquidTypes)type); } public void Undo() { this.ToList().ForEach(x => x.Undo()); } public void SaveState() { this.ToList().ForEach(x => x.SaveState()); } public double GetMaxNanoliterPerCM() { return this.Sum(x => x.GetColorNLPerCm()); } public void SetVolumesFromBrushStop(BrushStop stop) { foreach (var model in this) { model.Volume = 0; try { var stopVolume = stop.GetVolume(model.IdsPack.PackIndex); model.Volume = stopVolume; } catch { Debug.WriteLine($"No volume found for {model.IdsPack.LiquidType.Name} at index {model.IdsPack.PackIndex}"); } } } public void SetVolumesFromBrushStopSilent(BrushStop stop) { foreach (var model in this) { model.SetVolumeSilent(0); try { var stopVolume = stop.GetVolume(model.IdsPack.PackIndex); model.SetVolumeSilent(stopVolume); } catch { Debug.WriteLine($"No volume found for {model.IdsPack.LiquidType.Name} at index {model.IdsPack.PackIndex}"); } } } public void SetVolumesFromBrushStop(BrushStopModel brushStop) { foreach (var model in this) { model.Volume = 0; var b = brushStop.LiquidVolumes.GetLiquidVolume(model.IdsPack.LiquidType.Type); if (b != null) { model.Volume = b.Volume; } } } public void SetVolumesOnBrushStop(BrushStop brushStop) { foreach (var model in this) { try { brushStop.SetVolume(model.IdsPack.PackIndex, model.Volume); } catch { Debug.WriteLine($"Could not set brush stop volume for {model.IdsPack.LiquidType.Name} at index {model.IdsPack.PackIndex}"); } } } } }