Exemplo n.º 1
0
        internal static int CompareValidationSummaryItems(ValidationSummaryItem x, ValidationSummaryItem y)
        {
            int num;

            if (ReferencesAreValid(x, y, out num))
            {
                if (TryCompareReferences(x.ItemType, y.ItemType, out num))
                {
                    return(num);
                }
                var objA = (x.Sources.Count > 0) ? x.Sources[0].Control : null;
                var objB = (y.Sources.Count > 0) ? y.Sources[0].Control : null;
                if (!ReferenceEquals(objA, objB))
                {
                    if (!ReferencesAreValid(objA, objB, out num))
                    {
                        return(num);
                    }
                    if (objA.TabIndex != objB.TabIndex)
                    {
                        return(objA.TabIndex.CompareTo(objB.TabIndex));
                    }
                    num = SortByVisualTreeOrdering(objA, objB);
                    if (num != 0)
                    {
                        return(num);
                    }
                    if (TryCompareReferences(objA.Name, objB.Name, out num))
                    {
                        return(num);
                    }
                }
                if (!TryCompareReferences(x.MessageHeader, y.MessageHeader, out num))
                {
                    TryCompareReferences(x.Message, y.Message, out num);
                }
            }
            return(num);
        }
Exemplo n.º 2
0
        private void Target_BindingValidationError(object sender, ValidationErrorEventArgs e)
        {
            var originalSource = e.OriginalSource as FrameworkElement;

            if (((e != null) && ((e.Error != null) && (e.Error.ErrorContent != null))) && (originalSource != null))
            {
                string name;
                var    message = e.Error.ErrorContent.ToString();
                if (!string.IsNullOrEmpty(originalSource.Name))
                {
                    name = originalSource.Name;
                }
                else
                {
                    name = originalSource.GetHashCode().ToString(CultureInfo.InvariantCulture);
                }
                var key = name + message;
                if (this._validationSummaryItemDictionary.ContainsKey(key))
                {
                    var item = this._validationSummaryItemDictionary[key];
                    this._errors.Remove(item);
                    this._validationSummaryItemDictionary.Remove(key);
                }
                if ((e.Action == ValidationErrorEventAction.Added) && GetShowErrorsInSummary(originalSource))
                {
                    object            obj2;
                    BindingExpression expression;
                    string            messageHeader = null;
                    var metadata = ValidationHelper.ParseMetadata(originalSource, false, out obj2, out expression);
                    if (metadata != null)
                    {
                        messageHeader = metadata.Caption;
                    }
                    var item = new ValidationSummaryItem(message, messageHeader, ValidationSummaryItemType.PropertyError, new ValidationSummaryItemSource(messageHeader, originalSource as Control), null);
                    this._errors.Add(item);
                    this._validationSummaryItemDictionary[key] = item;
                }
            }
        }
Exemplo n.º 3
0
 public FocusingInvalidControlEventArgs(ValidationSummaryItem item, ValidationSummaryItemSource target)
 {
     this.Handled = false;
     this.Item    = item;
     this.Target  = target;
 }