/// Read in EVERY position in the layout from a CSV list of TypeId, GroupNum
        public void InitFromCSVStringAllPositions(string csv, int width, int height)
        {
            LayoutDimensions = new LayoutDimensions(width, height);
            singleLayoutLight = new SingleLayoutLight(csv);

            if (singleLayoutLight.NumPositions != width * height)
            {
                throw new InvalidProgramException();
            }

            // Infer Sample types if they have not already been setup
            if (sampleTypes.Count == 0)
            {
                var usedTypes = (from LayoutPos pos in singleLayoutLight.LayoutPositions
                                 where pos.TypeId != 1      // Ignore unused type in this list
                                 select pos.TypeId).Distinct();

                // Always add unused
                sampleTypes.Add(new SampleType() { Name = "Unused", Colour = "White", Id = 1 });

                foreach (var type in usedTypes)
                {

                    SampleType sampleType;
                    switch (type)
                    {
                        case 2:
                            sampleType = new SampleType() { Name = "Standard", Colour = "Red" };
                            break;
                        case 3:
                            sampleType = new SampleType() { Name = "Blank", Colour = "Yellow" };
                            break;
                        case 4:
                            sampleType = new SampleType() { Name = "Control", Colour = "Aqua" };
                            break;
                        case 5:
                            sampleType = new SampleType() { Name = "Unknown", Colour = "Lime" };
                            break;
                        case 7:
                            sampleType = new SampleType() { Name = "Pos Control", Colour = "#7dffff" };
                            break;
                        case 8:
                            sampleType = new SampleType() { Name = "Neg Control", Colour = "#fefccf" };
                            break;
                        case 24:
                            sampleType = new SampleType() { Name = "B0", Colour = "#FFD080" };
                            break;
                        case 25:
                            sampleType = new SampleType() { Name = "NSB", Colour = "#FF80FF" };
                            break;
                        case 26:
                            sampleType = new SampleType() { Name = "TA", Colour = "#9E8010" };
                            break;
                        case 109:
                            sampleType = new SampleType() { Name = "Unknown 1:1", Colour = "#408040" };
                            break;
                        case 110:
                            sampleType = new SampleType() { Name = "Unknown 1:10", Colour = "#00c000" };
                            break;
                        case 111:
                            sampleType = new SampleType() { Name = "Unknown 1:200", Colour = "#c0ffc0" };
                            break;

                        default:
                            sampleType = new SampleType() { Name = typeNotSupported, Colour = "Black" };
                            break;
                    }
                    sampleType.Id = type;
                    sampleTypes.Add(sampleType);
                }
            }
        }
        // Creates a SingleLayoutEditor from a SingleLayoutLight object
        // This is used when data is received from the server, it is converted to a form more suitable
        // for working with the PlateControl.
        // The main differences are that:
        // 1. A SingleLayoutLight only lists used wells, whereas a SingleLayoutEditor has an entry for every position
        public SingleLayoutEditor CreateSingleLayoutEditor(SingleLayoutLight singleLayoutLight, int width, int height, FillSettingsModel fillSettings)
        {
            SingleLayoutEditor singleLayoutEditor = new SingleLayoutEditor(width, height);
            foreach (LayoutPos layoutPos in singleLayoutLight.LayoutPositions)
            {
                int position = layoutPos.Id;
                singleLayoutEditor.CheckPositionInRangeOneBased(position);

                LayoutPosEditor layoutPosEditor = singleLayoutEditor[position - 1];
                ModifyLayoutPosEditorForPosition(layoutPos, ref layoutPosEditor, fillSettings);
            }
            return singleLayoutEditor;
        }
 public void OnUpdateUserLayout(SingleLayoutLight userLayout, string flaggedPositions)
 {
     // The UserLayout has changed, therefore convert this to a SingleLayoutEditor and update the EditorState
     var singleLayoutEditor = _editorStateHelper.CreateSingleLayoutEditor(userLayout,
                                           _layoutEditorPopulation.Width,
                                           _layoutEditorPopulation.Height,
                                           FillSettings);
     // Apply flags to singleLayoutEditor
     if (ControlSettings.IsFlagMode)
         singleLayoutEditor.InitFlaggedPositionsFromCsv(flaggedPositions);
     FillSettings.MaxGroupNum = singleLayoutEditor.NumPositions;
     // Update the editor state
     _editorStateHelper.CurrentState = singleLayoutEditor;
 }