Exemplo n.º 1
0
 private void CloseWithTagSave(object sender, RoutedEventArgs e)
 {
     if (QuestionBox.ShowMessage(this, Properties.Resources.SaveOnlyQuestion, Properties.Resources.ReallyClosing, false) == MessageBoxResult.Yes)
     {
         Result = (MessageBoxResult)((Button)sender).Tag;
     }
 }
        private bool CheckAndReturn(MessageBoxResult messageBoxResult)
        {
            if (!CheckPassword && messageBoxResult == MessageBoxResult.Cancel)
            {
                return(false);
            }
            if (CheckPassword && messageBoxResult == MessageBoxResult.OK && !GetPlainPassword().Equals(Password))
            {
                IsCorrectPassword = false;
                return(true);
            }

            if (!CheckPassword && messageBoxResult == MessageBoxResult.OK && string.IsNullOrEmpty(Password))
            {
                return(false);
            }

            if (!CheckPassword && (!Settings.Default.AllowEmptyQuestions && Settings.Default.AskForPassword) && string.IsNullOrEmpty(PasswordQuestion))
            {
                IsValidQuestion = false;
                return(true);
            }

            if (!CheckPassword && !ShowPlainText && Password != GetPlainPassword())
            {
                return(QuestionBox.ShowMessage(this, Properties.Resources.PasswordIsHidden, Properties.Resources.ApplyChanges, false) == MessageBoxResult.No);
            }


            return(false);
        }
        public static MessageBoxResult ShowMessage(Window owner, string text, string title, bool canCancel = true, double maxwidth = 1600, double fontsize = 20d)
        {
            var dlg = new QuestionBox()
            {
                Title = title, Message = text, Owner = owner, CanCanel = canCancel, MaxWidth = maxwidth, MessageFontSize = fontsize
            };

            dlg.ShowDialog();

            return(dlg.Result);
        }