예제 #1
0
        private void ClearErrorsButton_Click(object sender, RoutedEventArgs e)
        {
            var dir = new DirectoryInfo(LogHelper.Current.LogsFolder);
            var fis = dir.GetFiles("*.htm").OrderByDescending(x => x.CreationTime).ToArray();

            if (fis.Count() > 0)
            {
                var form = new MessageBoxForm();
                form.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
                ControlsHelper.CheckTopMost(form);
                var result = form.ShowForm("Do you want to clear all errors?", "Clear Errors?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button2);
                if (result != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                foreach (var fi in fis)
                {
                    try
                    {
                        fi.Delete();
                    }
                    catch (Exception)
                    {
                    }
                }
                //RefreshErrorsComboBox();
            }
            var win = (Window)Parent;

            win.DialogResult = false;
        }
예제 #2
0
        /// <summary>Displays a message box with the specified text, caption, buttons, icon, and default button.</summary>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the <see cref="T:System.Windows.Forms.MessageBoxButtons" /> values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the <see cref="T:System.Windows.Forms.MessageBoxIcon" /> values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the <see cref="T:System.Windows.Forms.MessageBoxDefaultButton" /> values that specifies the default button for the message box.</param>
        /// <returns>One of the <see cref="T:System.Windows.Forms.DialogResult" /> values.</returns>
        public static DialogResult Show(string text, string caption = "", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information, MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1)
        {
            var form = new MessageBoxForm();

            form.StartPosition = FormStartPosition.CenterParent;
            ControlsHelper.CheckTopMost(form);
            return(form.ShowForm(text, caption, buttons, icon, defaultButton));
        }
예제 #3
0
        public static void ShowFormInfo(Control c)
        {
            var frmInfo = new InfoForm();

            frmInfo.SelectedControl = c;
            frmInfo.StartPosition   = FormStartPosition.CenterParent;
            ControlsHelper.CheckTopMost(frmInfo);
            frmInfo.ShowDialog();
            frmInfo.Dispose();
            lock (ShowLock)
            {
                IsVisible = false;
            }
        }
예제 #4
0
파일: InfoForm.cs 프로젝트: x360ce/x360ce
 /// <summary>
 /// Displays form's name + some other info
 /// </summary>
 /// <remarks></remarks>
 public static void ShowFormInfo(Control c)
 {
     if (_infoForm != null)
     {
         return;
     }
     _infoForm = new InfoForm();
     _infoForm.SelectedControl = c;
     _infoForm.StartPosition   = FormStartPosition.CenterParent;
     ControlsHelper.CheckTopMost(_infoForm);
     _infoForm.ShowDialog();
     _infoForm.Dispose();
     _infoForm = null;
     lock (ShowLock)
         IsVisible = false;
 }
예제 #5
0
        /// <summary>Displays a message box with the specified text, caption, buttons, icon, and default button.</summary>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the <see cref="T:System.Windows.Forms.MessageBoxButtons" /> values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the <see cref="T:System.Windows.Forms.MessageBoxIcon" /> values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the <see cref="T:System.Windows.Forms.MessageBoxDefaultButton" /> values that specifies the default button for the message box.</param>
        /// <returns>One of the <see cref="T:System.Windows.Forms.DialogResult" /> values.</returns>
        public DialogResult ShowForm(string text, string caption = "", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information, MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1)
        {
            AddResizeEvents();
            TextLabel.Text  = text;
            Text            = caption;
            Button1.Visible = false;
            Button2.Visible = false;
            Button3.Visible = false;
            switch (buttons)
            {
            case MessageBoxButtons.AbortRetryIgnore:
                EnableButtons(DialogResult.Abort, DialogResult.Retry, DialogResult.Ignore);
                break;

            case MessageBoxButtons.OK:
                EnableButtons(DialogResult.OK);
                break;

            case MessageBoxButtons.OKCancel:
                EnableButtons(DialogResult.OK, DialogResult.Cancel);
                break;

            case MessageBoxButtons.RetryCancel:
                EnableButtons(DialogResult.Retry, DialogResult.Cancel);
                break;

            case MessageBoxButtons.YesNo:
                EnableButtons(DialogResult.Yes, DialogResult.No);
                break;

            case MessageBoxButtons.YesNoCancel:
                EnableButtons(DialogResult.Yes, DialogResult.No, DialogResult.Cancel);
                break;
            }
            var resources = new System.ComponentModel.ComponentResourceManager(GetType());
            var image     = (Bitmap)resources.GetObject("MessageBoxIcon_Information_32x32");

            switch (icon)
            {
            case MessageBoxIcon.None:
                if (PlaySounds)
                {
                    System.Media.SystemSounds.Beep.Play();
                }
                break;

            case MessageBoxIcon.Error:                     // Same as 'Hand' and 'Stop'.
                image = (Bitmap)resources.GetObject("MessageBoxIcon_Error_32x32");
                if (PlaySounds)
                {
                    System.Media.SystemSounds.Hand.Play();
                }
                break;

            case MessageBoxIcon.Question:
                image = (Bitmap)resources.GetObject("MessageBoxIcon_Question_32x32");
                if (PlaySounds)
                {
                    System.Media.SystemSounds.Question.Play();
                }
                break;

            case MessageBoxIcon.Warning:                     // Same as 'Exclamation'.
                image = (Bitmap)resources.GetObject("MessageBoxIcon_Warning_32x32");
                if (PlaySounds)
                {
                    System.Media.SystemSounds.Exclamation.Play();
                }
                break;

            case MessageBoxIcon.Information:                     // Same as 'Asterisk'.
                if (PlaySounds)
                {
                    System.Media.SystemSounds.Asterisk.Play();
                }
                break;
            }
            IconPictureBox.Image = image;
            switch (defaultButton)
            {
            case MessageBoxDefaultButton.Button1:
                ActiveControl = Button1;
                break;

            case MessageBoxDefaultButton.Button2:
                ActiveControl = Button2;
                break;

            case MessageBoxDefaultButton.Button3:
                ActiveControl = Button3;
                break;
            }
            ControlsHelper.CheckTopMost(this);
            return(ShowDialog());
        }