Exemple #1
0
        /// <summary>
        /// Validates the dialog inputs before the dialog is closed.
        /// </summary>
        /// <param name="dlgResult">The current active <see cref="DialogResult"/>.</param>
        /// <returns><c>True</c> if all input is valid; otherwise <c>false</c>.</returns>
        protected override bool ValidateDialog(DialogResult dlgResult)
        {
            if (dlgResult == DialogResult.OK)
            {
                ILogSettingsCtrl oldSettingsCtrl = pnlLoggerPanel.Controls.Count > 0
          ? pnlLoggerPanel.Controls[0] as ILogSettingsCtrl
          : null;

                if (oldSettingsCtrl != null)
                {
                    ValidationResult result = oldSettingsCtrl.ValidateSettings();

                    if (!result.IsSuccess)
                    {
                        MessageBox.Show(
                            this
                            , result.ErrorMsg
                            , Application.ProductName
                            , MessageBoxButtons.OK
                            , MessageBoxIcon.Error);

                        return(false);
                    }
                }
            }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the <see cref="ListBox"/> <see cref="Control"/>.
        /// </summary>
        private void LstLoggerSelectedIndexChanged(object sender, System.EventArgs e)
        {
            ILogProvider logProvider = lstLogger.SelectedItem as ILogProvider;

            if (logProvider != null)
            {
                grpSettings.SuspendLayout();

                using (new WaitCursor(Cursors.Default, Settings.Default.WaitCursorTimeout))
                {
                    try
                    {
                        ILogSettingsCtrl newSettingsCtrl = logProvider.Settings;

                        if (newSettingsCtrl != null)
                        {
                            if (grpSettings.Controls.Count == 1)
                            {
                                ILogSettingsCtrl oldSettingsCtrl = grpSettings.Controls[0] as ILogSettingsCtrl;

                                if (oldSettingsCtrl != null)
                                {
                                    grpSettings.Controls.RemoveAt(0);
                                    oldSettingsCtrl.Dispose();
                                }
                            }

                            ((Control)newSettingsCtrl).Dock = DockStyle.Fill;

                            grpSettings.Controls.Add((Control)newSettingsCtrl);

                            grpSettings.Text = string.Format(
                                Resources.strNewLoggerPanelText
                                , logProvider.Name);
                        }
                    }
                    finally
                    {
                        grpSettings.ResumeLayout();

                        if (grpSettings.Controls.Count == 1)
                        {
                            grpSettings.Controls[0].Select();
                        }
                    }
                }
            }
        }