Esempio n. 1
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            DataTemplate rc = null;

            ValidationStatusWrapper wrapper = item as ValidationStatusWrapper;

            if (wrapper != null)
            {
                if (wrapper.Status == ValidationStatus.Error)
                {
                    rc = Error;
                }

                if (wrapper.Status == ValidationStatus.Warning)
                {
                    rc = Warning;
                }

                if (wrapper.Status == ValidationStatus.Information)
                {
                    rc = Information;
                }
            }

            return(rc);
        }
Esempio n. 2
0
        public override void Update()
        {
            List <ValidationStatusWrapper> sms = new List <ValidationStatusWrapper>();

            ValidationStatus max = MaxStatus;

            ValidationStatusWrapper e = new ValidationStatusWrapper()
            {
                Status = ValidationStatus.Error
            };
            ValidationStatusWrapper w = new ValidationStatusWrapper()
            {
                Status = ValidationStatus.Warning
            };
            ValidationStatusWrapper i = new ValidationStatusWrapper()
            {
                Status = ValidationStatus.Information
            };

            foreach (ValidationInfo vi in _ValidationInfo)
            {
                if (vi.HasError && (!Max || (Max && max == ValidationStatus.Error)))
                {
                    if (_Status.Contains(ValidationStatus.Error))
                    {
                        if (Group)
                        {
                            e.AppendMessage(vi.ErrorMessage);
                        }
                        else
                        {
                            sms.Add(new ValidationStatusWrapper()
                            {
                                Status = ValidationStatus.Error, Message = vi.ErrorMessage
                            });
                        }
                    }
                }

                if (vi.HasWarning && (!Max || (Max && max == ValidationStatus.Warning)))
                {
                    if (_Status.Contains(ValidationStatus.Warning))
                    {
                        if (Group)
                        {
                            w.AppendMessage(vi.WarningMessage);
                        }
                        else
                        {
                            sms.Add(new ValidationStatusWrapper()
                            {
                                Status = ValidationStatus.Warning, Message = vi.WarningMessage
                            });
                        }
                    }
                }

                if (vi.HasInformation && (!Max || (Max && max == ValidationStatus.Information)))
                {
                    if (_Status.Contains(ValidationStatus.Information))
                    {
                        if (Group)
                        {
                            i.AppendMessage(vi.InformationMessage);
                        }
                        else
                        {
                            sms.Add(new ValidationStatusWrapper()
                            {
                                Status = ValidationStatus.Information, Message = vi.InformationMessage
                            });
                        }
                    }
                }
            }

            if (Group)
            {
                if (e.HasMessage)
                {
                    sms.Add(e);
                }

                if (w.HasMessage)
                {
                    sms.Add(w);
                }

                if (i.HasMessage)
                {
                    sms.Add(i);
                }
            }

            StatusMessages.Clear();
            StatusMessages.AddRange(sms.OrderBy(wrapper => wrapper.Status).ToList());
        }