[NUI] Rollback split-nui (#887)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / FileImageSource.cs
1 using System.Threading.Tasks;
2
3 namespace Tizen.NUI.Binding
4 {
5     [TypeConverter(typeof(FileImageSourceConverter))]
6     internal sealed class FileImageSource : ImageSource
7     {
8         public static readonly BindableProperty FileProperty = BindableProperty.Create("File", typeof(string), typeof(FileImageSource), default(string));
9
10         public string File
11         {
12             get { return (string)GetValue(FileProperty); }
13             set { SetValue(FileProperty, value); }
14         }
15
16         public override Task<bool> Cancel()
17         {
18             return Task.FromResult(false);
19         }
20
21         public override string ToString()
22         {
23             return $"File: {File}";
24         }
25
26         public static implicit operator FileImageSource(string file)
27         {
28             return (FileImageSource)FromFile(file);
29         }
30
31         public static implicit operator string(FileImageSource file)
32         {
33             return file != null ? file.File : null;
34         }
35
36         protected override void OnPropertyChanged(string propertyName = null)
37         {
38             if (propertyName == FileProperty.PropertyName)
39                 OnSourceChanged();
40             base.OnPropertyChanged(propertyName);
41         }
42     }
43 }