-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
FileImageSource.cs
52 lines (44 loc) · 1.8 KB
/
FileImageSource.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#nullable disable
using System.Threading.Tasks;
namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/FileImageSource.xml" path="Type[@FullName='Microsoft.Maui.Controls.FileImageSource']/Docs/*" />
[System.ComponentModel.TypeConverter(typeof(FileImageSourceConverter))]
public sealed partial class FileImageSource : ImageSource
{
/// <summary>Bindable property for <see cref="File"/>.</summary>
public static readonly BindableProperty FileProperty = BindableProperty.Create(nameof(File), typeof(string), typeof(FileImageSource), default(string));
/// <include file="../../docs/Microsoft.Maui.Controls/FileImageSource.xml" path="//Member[@MemberName='IsEmpty']/Docs/*" />
public override bool IsEmpty => string.IsNullOrEmpty(File);
/// <include file="../../docs/Microsoft.Maui.Controls/FileImageSource.xml" path="//Member[@MemberName='File']/Docs/*" />
public string File
{
get { return (string)GetValue(FileProperty); }
set { SetValue(FileProperty, value); }
}
/// <include file="../../docs/Microsoft.Maui.Controls/FileImageSource.xml" path="//Member[@MemberName='Cancel']/Docs/*" />
public override Task<bool> Cancel()
{
return Task.FromResult(false);
}
/// <include file="../../docs/Microsoft.Maui.Controls/FileImageSource.xml" path="//Member[@MemberName='ToString']/Docs/*" />
public override string ToString()
{
return $"File: {File}";
}
public static implicit operator FileImageSource(string file)
{
return (FileImageSource)FromFile(file);
}
public static implicit operator string(FileImageSource file)
{
return file?.File;
}
protected override void OnPropertyChanged(string propertyName = null)
{
if (propertyName == FileProperty.PropertyName)
OnSourceChanged();
base.OnPropertyChanged(propertyName);
}
}
}