private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (validatePassword == null)
            {
                DialogResult = true;
                Close();
            }
            else
            {
                if (!validatePassword(txtOldPassword.Password))
                {
                    MessageDialogEx.ShowDialog("The old password is wrong!", "Error", MessageButtons.OK, MessageIcons.Error);
                    return;
                }
                else
                {
                    if (!txtNewPassword.Password.Equals(txtNewPasswordRepeating.Password))
                    {
                        MessageDialogEx.ShowDialog("The confirmed password is wrong!", "Error", MessageButtons.OK, MessageIcons.Error);
                        return;
                    }

                    DialogResult = true;
                    Close();
                }
            }
        }
Example #2
0
        private static MessageResults ShowDialog(
            String message, String title, MessageButtons button, MessageIcons icon,
            ImageSource image, SkinBundle bundle)
        {
            MessageDialogEx dlg = new MessageDialogEx
            {
                Title      = title,
                lblMessage = { Text = message },
                icon       = icon,
                imgIcon    = { Source = MessageIconHelper.GetIcon(icon, bundle) }
            };

            if (dlg.imgIcon.Source == null)
            {
                if (image != null)
                {
                    dlg.imgIcon.Source = image;
                }
            }

            switch (button)
            {
            case MessageButtons.OK:
                dlg.btnOK.Visibility = Visibility.Visible;
                break;

            case MessageButtons.OKCancel:
                dlg.btnOK.Visibility     = Visibility.Visible;
                dlg.btnCancel.Visibility = Visibility.Visible;
                break;

            case MessageButtons.YesNo:
                dlg.btnYes.Visibility = Visibility.Visible;
                dlg.btnNo.Visibility  = Visibility.Visible;
                break;

            case MessageButtons.YesNoCancel:
                dlg.btnYes.Visibility    = Visibility.Visible;
                dlg.btnNo.Visibility     = Visibility.Visible;
                dlg.btnCancel.Visibility = Visibility.Visible;
                break;

            default:
                throw new NotImplementedException();
            }

            if (bundle != null)
            {
                bundle.SetBundle(dlg);
            }

            dlg.ShowDialog();

            return(dlg.Result);
        }
Example #3
0
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     if (validate == null)
     {
         DialogResult = true;
         Close();
     }
     else
     {
         if (!validate(txtUsername.Text, txtPassword.Password))
         {
             imgState.Source = BitmapFrame.Create(new Uri(@"pack://*****:*****@"pack://application:,,, /NET.Tools.WPF.Dialogs;component/Resources/State/User020.png"));
             DialogResult    = true;
             Close();
         }
     }
 }
        private static MessageResults ShowDialog(
            String message, String title, MessageButtons button, MessageIcons icon,
            ImageSource image, SkinBundle bundle)
        {
            MessageDialogEx dlg = new MessageDialogEx
                                      {
                                          Title = title,
                                          lblMessage = {Text = message},
                                          icon = icon,
                                          imgIcon = {Source = MessageIconHelper.GetIcon(icon, bundle)}
                                      };

            if (dlg.imgIcon.Source == null)
                if (image != null)
                    dlg.imgIcon.Source = image;

            switch (button)
            {
                case MessageButtons.OK:
                    dlg.btnOK.Visibility = Visibility.Visible;
                    break;
                case MessageButtons.OKCancel:
                    dlg.btnOK.Visibility = Visibility.Visible;
                    dlg.btnCancel.Visibility = Visibility.Visible;
                    break;
                case MessageButtons.YesNo:
                    dlg.btnYes.Visibility = Visibility.Visible;
                    dlg.btnNo.Visibility = Visibility.Visible;
                    break;
                case MessageButtons.YesNoCancel:
                    dlg.btnYes.Visibility = Visibility.Visible;
                    dlg.btnNo.Visibility = Visibility.Visible;
                    dlg.btnCancel.Visibility = Visibility.Visible;
                    break;
                default:
                    throw new NotImplementedException();
            }

            if (bundle != null)
                bundle.SetBundle(dlg);

            dlg.ShowDialog();

            return dlg.Result;
        }