aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Shared/Statistics/PresentationBrushStop.cs
blob: 2f5e7aea61f89a3f1a9230c41c8340d907f78c97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Enumerations;

namespace Tango.PPC.Shared.Statistics
{
    public class PresentationBrushStop
    {

        private List<PresentationLiquidVolume> _inputVolumes;
        public ColorSpaces ColorSpace { get; set; }
        public double StartMeters { get; set; }
        public int Red { get; set; }
        public int Green { get; set; }
        public int Blue { get; set; }
        public double L { get; set; }
        public double A { get; set; }
        public double B { get; set; }

        public String Catalog { get; set; }
        public String CatalogItem { get; set; }

        public int BestMatchR { get; set; }
        public int BestMatchG { get; set; }
        public int BestMatchB { get; set; }

        public List<PresentationLiquidVolume> LiquidVolumes { get; set; }

        public double GetLiquidVolumeOutputOrZero(LiquidTypes liquidType)
        {
            var lv = LiquidVolumes.FirstOrDefault(x => x.LiquidType.Type == liquidType);
            return lv != null ? lv.Volume : 0.0;
        }

        public double GetLiquidVolumeInputOrZero(LiquidTypes liquidType)
        {
            var lv = GetVolumeInputs().FirstOrDefault(x => x.LiquidType.Type == liquidType);
            return lv != null ? lv.Volume : 0.0;
        }

        public List<PresentationLiquidVolume> GetVolumeInputs()
        {
            if (_inputVolumes == null)
            {
                _inputVolumes = new List<PresentationLiquidVolume>();
                var clones = LiquidVolumes.Select(x => new PresentationLiquidVolume() { LiquidType = x.LiquidType, Volume = x.Volume }).ToList();


                foreach (var liquidVolume in clones.Where(x => x.LiquidType.HasPigment))
                {
                    if (liquidVolume.LiquidType.IsLightInk && liquidVolume.Volume > 0)
                    {
                        var darkInk = clones.FirstOrDefault(x => x.LiquidType.Code == liquidVolume.LiquidType.DarkInkCode);
                        if (darkInk != null)
                        {
                            darkInk.Volume = (double)((decimal)liquidVolume.Volume / 10m);

                            continue;
                        }
                    }

                    _inputVolumes.Add(liquidVolume);
                }
            }

            return _inputVolumes;
        }


        public PresentationBrushStop()
        {
            LiquidVolumes = new List<PresentationLiquidVolume>();
        }
    }
}