private void OnLayoutChange(List <string> numericTypes = null, List <string> tracingTypes = null)
        {
            // If numericTypes or tracingTypes are not null... then we are loading a file; clear lNumerics and lTracings!
            if (numericTypes != null)
            {
                listNumerics.Clear();
            }
            if (tracingTypes != null)
            {
                listTracings.Clear();
            }

            // Set default numeric types to populate
            if (numericTypes == null || numericTypes.Count == 0)
            {
                numericTypes = new List <string> (new string [] { "DEFIB", "ECG", "NIBP", "SPO2", "ETCO2", "ABP" });
            }
            else if (numericTypes.Count < colsNumerics)
            {
                List <string> buffer = new List <string> (new string [] { "DEFIB", "ECG", "NIBP", "SPO2", "ETCO2", "ABP" });
                buffer.RemoveRange(0, numericTypes.Count);
                numericTypes.AddRange(buffer);
            }

            for (int i = listNumerics.Count; i < colsNumerics && i < numericTypes.Count; i++)
            {
                Controls.DefibNumeric newNum;
                newNum = new Controls.DefibNumeric((Controls.DefibNumeric.ControlType.Values)Enum.Parse(typeof(Controls.DefibNumeric.ControlType.Values), numericTypes [i]));
                listNumerics.Add(newNum);
            }

            // Set default tracing types to populate
            if (tracingTypes == null || tracingTypes.Count == 0)
            {
                tracingTypes = new List <string> (new string [] { "ECG_II", "SPO2", "ETCO2", "ABP" });
            }
            else if (tracingTypes.Count < rowsTracings)
            {
                List <string> buffer = new List <string> (new string [] { "ECG_II", "SPO2", "ETCO2", "ABP" });
                buffer.RemoveRange(0, tracingTypes.Count);
                tracingTypes.AddRange(buffer);
            }

            for (int i = listTracings.Count; i < rowsTracings && i < tracingTypes.Count; i++)
            {
                Strip newStrip = new Strip((Lead.Values)Enum.Parse(typeof(Lead.Values), tracingTypes [i]), 6f);
                Controls.DefibTracing newTracing = new Controls.DefibTracing(newStrip);
                listTracings.Add(newTracing);
            }

            // Reset the UI container and repopulate with the UI elements
            gridNumerics.Children.Clear();
            gridNumerics.ColumnDefinitions.Clear();
            for (int i = 0; i < colsNumerics && i < listNumerics.Count; i++)
            {
                gridNumerics.ColumnDefinitions.Add(new ColumnDefinition());
                listNumerics [i].SetValue(Grid.ColumnProperty, i);
                gridNumerics.Children.Add(listNumerics [i]);
            }

            gridTracings.Children.Clear();
            gridTracings.RowDefinitions.Clear();
            for (int i = 0; i < rowsTracings && i < listTracings.Count; i++)
            {
                gridTracings.RowDefinitions.Add(new RowDefinition());
                listTracings [i].SetValue(Grid.RowProperty, i);
                gridTracings.Children.Add(listTracings [i]);
            }
        }
 public void RemoveNumeric(Controls.DefibNumeric requestSender)
 {
     colsNumerics -= 1;
     listNumerics.Remove(requestSender);
     OnLayoutChange();
 }