Exemplo n.º 1
0
 public void SetErrorMessage(BaseContainerValidator extendee, string value)
 {
     if (value != null)
     {
         _errorMessages[extendee] = value;
     }
     else
     {
         _errorMessages.Remove(extendee);
     }
 }
Exemplo n.º 2
0
 public string GetErrorCaption(BaseContainerValidator extendee)
 {
     if (_errorCaptions.Contains(extendee))
     {
         return((string)_errorCaptions[extendee]);
     }
     else
     {
         return("");
     }
 }
Exemplo n.º 3
0
 public string GetErrorMessage(BaseContainerValidator extendee)
 {
     if (_errorMessages.Contains(extendee))
     {
         return((string)_errorMessages[extendee]);
     }
     else
     {
         return("");
     }
 }
Exemplo n.º 4
0
 public ValidationSummaryDisplayMode GetDisplayMode(BaseContainerValidator extendee)
 {
     if (_displayModes.Contains(extendee))
     {
         return((ValidationSummaryDisplayMode)_displayModes[extendee]);
     }
     else
     {
         return(ValidationSummaryDisplayMode.Simple);
     }
 }
Exemplo n.º 5
0
 public bool GetShowSummary(BaseContainerValidator extendee)
 {
     if (_showSummaries.Contains(extendee))
     {
         return((bool)_showSummaries[extendee]);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 6
0
 public void SetErrorMessage(BaseContainerValidator extendee, string value)
 {
   if (value != null)
   {
     _errorMessages[extendee] = value;
   }
   else
   {
     _errorMessages.Remove(extendee);
   }
 }
Exemplo n.º 7
0
 public ValidationSummaryDisplayMode GetDisplayMode(BaseContainerValidator extendee)
 {
   if (_displayModes.Contains(extendee))
   {
     return (ValidationSummaryDisplayMode)_displayModes[extendee];
   }
   else
   {
     return ValidationSummaryDisplayMode.Simple;
   }
 }
Exemplo n.º 8
0
 public string GetErrorMessage(BaseContainerValidator extendee)
 {
   if (_errorMessages.Contains(extendee))
   {
     return (string)_errorMessages[extendee];
   }
   else
   {
     return "";
   }
 }
Exemplo n.º 9
0
 public bool GetShowSummary(BaseContainerValidator extendee)
 {
   if (_showSummaries.Contains(extendee))
   {
     return (bool)_showSummaries[extendee];
   }
   else
   {
     return false;
   }
 }
Exemplo n.º 10
0
 public void SetShowSummary(BaseContainerValidator extendee, bool value)
 {
   if (value == true)
   {
     _showSummaries[extendee] = value;
     extendee.Summarize += new SummarizeEventHandler(Summarize);
   }
   else
   {
     _showSummaries.Remove(extendee);
   }
 }
Exemplo n.º 11
0
 public void SetShowSummary(BaseContainerValidator extendee, bool value)
 {
     if (value == true)
     {
         _showSummaries[extendee] = value;
         extendee.Summarize      += new SummarizeEventHandler(Summarize);
     }
     else
     {
         _showSummaries.Remove(extendee);
     }
 }
Exemplo n.º 12
0
        protected override void Summarize(object sender, SummarizeEventArgs e)
        {
            // Close form if open and nothing invalid
            if (e.Validators.Count == 0)
            {
                if (_dlg != null)
                {
                    _dlg.Close();
                    _dlg            = null;
                    currentExtendee = null;
                }
                return;
            }

            BaseContainerValidator extendee = (BaseContainerValidator)sender;

            // If the ValidationSummaryForm is open, but refers to a different extendee
            // (BaseContainerValidator), get rid of it
            if ((_dlg != null) && (currentExtendee != null) && (extendee != currentExtendee))
            {
                _dlg.Close();
                _dlg            = null;
                currentExtendee = extendee;
            }

            // Open ValidationSummaryForm if it hasn't been opened,
            // or has been closed since Summarize was last called
            if (_dlg == null)
            {
                _dlg = new ValidationSummaryForm();
                _dlg.ErrorCaption = GetErrorCaption(extendee);
                _dlg.ErrorMessage = GetErrorMessage(extendee);
                _dlg.Owner        = extendee.HostingForm;

                // Register Disposed to handle clean up when user closes form
                _dlg.Disposed += new EventHandler(ValidationSummaryForm_Disposed);
            }

            // Get complete set of Validators under the jurisdiction
            // of the BaseContainerValidator
            _dlg.LoadValidators(Sort(extendee.GetValidators()));

            // Show dialog if not already visible
            if (!_dlg.Visible)
            {
                _dlg.Show();
            }
        }
Exemplo n.º 13
0
    protected override void Summarize(object sender, SummarizeEventArgs e)
    {

      // Close form if open and nothing invalid
      if (e.Validators.Count == 0)
      {
        if (_dlg != null)
        {
          _dlg.Close();
          _dlg = null;
          currentExtendee = null;
        }
        return;
      }

      BaseContainerValidator extendee = (BaseContainerValidator)sender;

      // If the ValidationSummaryForm is open, but refers to a different extendee
      // (BaseContainerValidator), get rid of it
      if ((_dlg != null) && (currentExtendee != null) && (extendee != currentExtendee))
      {
        _dlg.Close();
        _dlg = null;
        currentExtendee = extendee;
      }

      // Open ValidationSummaryForm if it hasn't been opened,
      // or has been closed since Summarize was last called
      if (_dlg == null)
      {
        _dlg = new ValidationSummaryForm();
        _dlg.ErrorCaption = GetErrorCaption(extendee);
        _dlg.ErrorMessage = GetErrorMessage(extendee);
        _dlg.Owner = extendee.HostingForm;

        // Register Disposed to handle clean up when user closes form
        _dlg.Disposed += new EventHandler(ValidationSummaryForm_Disposed);
      }

      // Get complete set of Validators under the jurisdiction
      // of the BaseContainerValidator
      _dlg.LoadValidators(Sort(extendee.GetValidators()));

      // Show dialog if not already visible
      if (!_dlg.Visible) _dlg.Show();
    }
Exemplo n.º 14
0
 public string GetErrorCaption(BaseContainerValidator extendee)
 {
   if (_errorCaptions.Contains(extendee))
   {
     return (string)_errorCaptions[extendee];
   }
   else
   {
     return "";
   }
 }
Exemplo n.º 15
0
        protected override void Summarize(object sender, SummarizeEventArgs e)
        {
            // Don’t validate if no validators were passed
            if (e.Validators.Count == 0)
            {
                return;
            }

            BaseContainerValidator       extendee    = (BaseContainerValidator)sender;
            ValidationSummaryDisplayMode displayMode = GetDisplayMode(extendee);
            ValidatorCollection          validators  = e.Validators;

            // Make sure there are validators
            if ((validators == null) || (validators.Count == 0))
            {
                return;
            }

            string errorMessage = GetErrorMessage(extendee);
            string errorCaption = GetErrorCaption(extendee);

            // Get error text, if provided
            if (errorMessage == null)
            {
                errorMessage = "";
            }

            // Get error caption, if provided
            if (errorCaption == null)
            {
                errorCaption = "";
            }

            // Build summary message body
            string errors = "";

            if (displayMode == ValidationSummaryDisplayMode.Simple)
            {
                // Build Simple message
                errors = errorMessage;
            }
            else
            {
                // Build List, BulletList or SingleParagraph
                foreach (object validator in base.Sort(validators))
                {
                    BaseValidator current = (BaseValidator)validator;
                    if (!current.IsValid)
                    {
                        switch (displayMode)
                        {
                        case ValidationSummaryDisplayMode.List:
                            errors += string.Format("{0}\n", current.ErrorMessage);
                            break;

                        case ValidationSummaryDisplayMode.BulletList:
                            errors += string.Format("- {0}\n", current.ErrorMessage);
                            break;

                        case ValidationSummaryDisplayMode.SingleParagraph:
                            errors += string.Format("{0}. ", current.ErrorMessage);
                            break;
                        }
                    }
                }
                // Prepend error message, if provided
                if ((errors != "") && (errorMessage != ""))
                {
                    errors = string.Format("{0}\n\n{1}", errorMessage.Trim(), errors);
                }
            }

            // Display summary message
            // "if( errors.Trim().Length > 0 )" thanks to John V. Barone and Jorge Matos
            if (errors.Trim().Length > 0)
            {
                MessageBox.Show(errors, errorCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 16
0
 public void SetDisplayMode(BaseContainerValidator extendee, ValidationSummaryDisplayMode value)
 {
     _displayModes[extendee] = value;
 }
Exemplo n.º 17
0
 public void SetDisplayMode(BaseContainerValidator extendee, ValidationSummaryDisplayMode value)
 {
     _displayModes[extendee] = value;
 }