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 [] { "ECG", "NIBP", "SPO2", "RR", "ETCO2", "ABP", "CVP", "T", "PA", "ICP", "IAP" });
            }
            else if (numericTypes.Count < rowsNumerics)
            {
                List <string> buffer = new List <string> (new string [] { "ECG", "NIBP", "SPO2", "RR", "ETCO2", "ABP", "CVP", "T", "PA", "ICP", "IAP" });
                buffer.RemoveRange(0, numericTypes.Count);
                numericTypes.AddRange(buffer);
            }

            // Cap available amount of numerics
            rowsNumerics = Utility.Clamp(rowsNumerics, 1, numericTypes.Count);
            for (int i = listNumerics.Count; i < rowsNumerics && i < numericTypes.Count; i++)
            {
                Controls.MonitorNumeric newNum;
                newNum = new Controls.MonitorNumeric((Controls.MonitorNumeric.ControlType.Values)Enum.Parse(typeof(Controls.MonitorNumeric.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", "ECG_III", "SPO2", "RR", "ETCO2", "ABP", "CVP", "PA", "ICP" });
            }
            else if (tracingTypes.Count < rowsTracings)
            {
                List <string> buffer = new List <string> (new string [] { "ECG_II", "ECG_III", "SPO2", "RR", "ETCO2", "ABP", "CVP", "PA", "ICP" });
                buffer.RemoveRange(0, tracingTypes.Count);
                tracingTypes.AddRange(buffer);
            }

            // Cap available amount of tracings
            rowsTracings = Utility.Clamp(rowsTracings, 1, tracingTypes.Count);
            for (int i = listTracings.Count; i < rowsTracings && i < tracingTypes.Count; i++)
            {
                Strip newStrip = new Strip(6f, (Leads.Values)Enum.Parse(typeof(Leads.Values), tracingTypes [i]));
                Controls.MonitorTracing newTracing = new Controls.MonitorTracing(newStrip);
                listTracings.Add(newTracing);
            }

            // Reset the UI container and repopulate with the UI elements
            gridNumerics.Children.Clear();
            gridNumerics.RowDefinitions.Clear();
            for (int i = 0; i < rowsNumerics && i < listNumerics.Count; i++)
            {
                gridNumerics.RowDefinitions.Add(new RowDefinition());
                listNumerics [i].SetValue(Grid.RowProperty, 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.MonitorNumeric requestSender)
 {
     rowsNumerics -= 1;
     listNumerics.Remove(requestSender);
     OnLayoutChange();
 }