private void tabControl_Deselecting(object sender, TabControlCancelEventArgs e)
        {
            if (!_back)
            {
                _history.Push(e.TabPageIndex);
                buttonPrev.Enabled = true;
            }

            if (_skip)
            {
                return;
            }

            var errorText = string.Empty;

            switch (e.TabPageIndex)
            {
            case TabEventPeriod: {
                int eventPeriod;
                if (int.TryParse(textBoxEventPeriod.Text, out eventPeriod))
                {
                    if (eventPeriod < Vendor.MinimumEventPeriod)
                    {
                        errorText = String.Format(Resources.EventPeriodTooShort, Vendor.MinimumEventPeriod);
                        textBoxEventPeriod.Text = Vendor.MinimumEventPeriod.ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        _eventSequence.EventPeriod = eventPeriod;
                    }
                }
                else
                {
                    errorText = textBoxChannelCount.Text + Resources.EventPeriodInvalid;
                }
                break;
            }

            case TabProfile:
                if (comboBoxProfiles.SelectedIndex == 0)
                {
                    _eventSequence.FileIOHandler = FileIOHelper.GetNativeHelper();
                    _eventSequence.Profile       = null;
                }
                else
                {
                    var profilePath = Path.Combine(Paths.ProfilePath, comboBoxProfiles.SelectedItem + ".pro");
                    _eventSequence.FileIOHandler = FileIOHelper.GetProfileVersion(profilePath);
                    _eventSequence.Profile       = _eventSequence.FileIOHandler.OpenProfile(profilePath);
                }

                if (_eventSequence.Profile != null)
                {
                    _eventSequence.Groups = _eventSequence.Profile.Groups;
                }
                break;

            case TabChannelCount: {
                int channelCount;
                if (int.TryParse(textBoxChannelCount.Text, out channelCount))
                {
                    if (channelCount < 1)
                    {
                        errorText = Resources.ChannelCountMinimums;
                    }
                    else
                    {
                        if ((channelCount > 1024) &&
                            (MessageBox.Show(string.Format(Resources.ConfirmChannelCount, channelCount), Vendor.ProductName,
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes))
                        {
                            tabControl.TabIndex = 1;
                        }
                        else
                        {
                            Cursor = Cursors.WaitCursor;
                            try {
                                _eventSequence.FullChannelCount = channelCount;
                            }
                            finally {
                                Cursor = Cursors.Default;
                            }
                        }
                    }
                }
                else
                {
                    errorText = textBoxChannelCount.Text + Resources.InvalidChannelCount;
                }
                break;
            }

            case TabChannelNames:
                if (textBoxChannelNames.Lines.Length == Convert.ToInt32(textBoxChannelCount.Text))
                {
                    if (textBoxChannelNames.Lines.Any(str2 => str2.Trim() == string.Empty))
                    {
                        errorText = Resources.ChannelNameCantBeBlank;
                    }
                    Cursor = Cursors.WaitCursor;
                    try {
                        for (var i = 0; i < _eventSequence.FullChannelCount; i++)
                        {
                            _eventSequence.FullChannels[i].Name = textBoxChannelNames.Lines[i];
                        }
                    }
                    finally {
                        Cursor = Cursors.Default;
                    }
                    break;
                }
                errorText = Resources.ChannelCountAndNameInequal;
                break;

            case TabSequenceTime: {
                var sequenceTimeInMills = ParseTimeString(textBoxTime.Text);
                if (sequenceTimeInMills != 0)
                {
                    _eventSequence.Time = sequenceTimeInMills;
                }
                else
                {
                    errorText = "Bad time format";
                }
                break;
            }
            }

            if (errorText == string.Empty)
            {
                return;
            }
            e.Cancel = true;
            MessageBox.Show(errorText, Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }