コード例 #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
ファイル: ImageRenderer.cs プロジェクト: sunfom/DeXign
 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);
     }
 }