예제 #1
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            bool result = true;

            if (value is string path)
            {
                if (!File.Exists(path))
                {
                    result = false;
                }

                if (LooseyBinding.IsBindingFormat(path))
                {
                    return(new ValidationResult(true, null));
                }

                if (result)
                {
                    try
                    {
                        ResourceManager.GetImageSourceFromPath(path);
                    }
                    catch
                    {
                        result = false;
                    }
                }
            }

            return(new ValidationResult(result, null));
        }
예제 #2
0
        public override ImageSource Convert(string value, object parameter)
        {
            if (LooseyBinding.IsBindingFormat(value))
            {
                return(null);
            }

            var img = ResourceManager.GetImageSourceFromPath(value);

            return(img);
        }
예제 #3
0
 private void Source_Changed(object sender, EventArgs e)
 {
     if (LooseyBinding.IsBindingFormat(this.Model.Source))
     {
         this.SetLooseyBinding(
             PImage.SourceProperty,
             LooseyBinding.GetBindingPropertyName(this.Model.Source));
     }
     else
     {
         this.RemoveLooseyBinding(PImage.SourceProperty);
     }
 }
예제 #4
0
 private void Text_Changed(object sender, EventArgs e)
 {
     if (LooseyBinding.IsBindingFormat(this.Model.Text))
     {
         this.SetLooseyBinding(
             PLabel.TextProperty,
             LooseyBinding.GetBindingPropertyName(this.Model.Text));
     }
     else
     {
         this.RemoveLooseyBinding(PLabel.TextProperty);
     }
 }