Ejemplo n.º 1
0
        private List <IsolationWindow> GetIsolationWindows()
        {
            //Overlap requires an even number of windows
            if (Overlap && _gridViewDriver.Items.Count % 2 == 1)
            {
                MessageDlg.Show(this,
                                Resources.EditIsolationSchemeDlg_GetIsolationWindows_Overlap_requires_an_even_number_of_windows_);
                return(null);
            }

            // Validate prespecified windows.
            var windowList = new List <IsolationWindow>();

            for (int row = 0; row < _gridViewDriver.Items.Count; row++)
            {
                var editWindow = _gridViewDriver.Items[row];

                // Report any problems in this row.
                int errorCell = FindErrorCell(editWindow);
                if (errorCell >= COLUMN_START)
                {
                    _gridViewDriver.SelectCell(errorCell, row);
                    MessageDlg.Show(this,
                                    string.Format(Resources.EditIsolationSchemeDlg_OkDialog_Specify__0__for_isolation_window,
                                                  _gridViewDriver.GetHeaderText(errorCell)));
                    _gridViewDriver.EditCell();
                    return(null);
                }

                IsolationWindow isolationWindow;
                try
                {
                    double startValue = editWindow.Start.Value;
                    double endValue   = editWindow.End.Value;
                    if (Equals(comboIsolation.SelectedItem, WindowType.MEASUREMENT))
                    {
                        startValue += editWindow.StartMargin ?? 0;
                        endValue   -= editWindow.StartMargin ?? 0;
                    }
                    isolationWindow = new IsolationWindow(
                        // ReSharper disable PossibleInvalidOperationException
                        startValue,
                        endValue,
                        // ReSharper restore PossibleInvalidOperationException
                        null,
                        cbSpecifyMargin.Checked ? editWindow.StartMargin : null,
                        cbSpecifyMargin.Checked ? editWindow.StartMargin : null,
                        cbSpecifyCERange.Checked ? editWindow.CERange : null);
                }
                catch (InvalidDataException exception)
                {
                    _gridViewDriver.SelectRow(row);
                    MessageDlg.ShowException(this, exception);
                    return(null);
                }
                windowList.Add(isolationWindow);
            }
            return(windowList);
        }