-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathAdaptiveImage.cs
More file actions
92 lines (79 loc) · 3.29 KB
/
AdaptiveImage.cs
File metadata and controls
92 lines (79 loc) · 3.29 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using CommunityToolkit.Notifications.Adaptive.Elements;
namespace CommunityToolkit.Notifications
{
/// <summary>
/// An inline image.
/// </summary>
public sealed class AdaptiveImage
: IBaseImage,
IToastBindingGenericChild,
ITileBindingContentAdaptiveChild,
IAdaptiveChild,
IAdaptiveSubgroupChild
{
/// <summary>
/// Gets or sets the desired cropping of the image.
/// Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// </summary>
public AdaptiveImageCrop HintCrop { get; set; }
/// <summary>
/// Gets or sets a value whether a margin is removed. images have an 8px margin around them.
/// You can remove this margin by setting this property to true.
/// Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// </summary>
public bool? HintRemoveMargin { get; set; }
/// <summary>
/// Gets or sets the horizontal alignment of the image.
/// For Toast, this is only supported when inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public AdaptiveImageAlign HintAlign { get; set; }
private string _source;
/// <summary>
/// Gets or sets the URI of the image (Required).
/// Can be from your application package, application data, or the internet.
/// Internet images must be less than 200 KB in size.
/// </summary>
public string Source
{
get { return _source; }
set { BaseImageHelper.SetSource(ref _source, value); }
}
/// <summary>
/// Gets or sets a description of the image, for users of assistive technologies.
/// </summary>
public string AlternateText { get; set; }
/// <summary>
/// Gets or sets set to true to allow Windows to append a query string to the image URI
/// supplied in the Tile notification. Use this attribute if your server hosts
/// images and can handle query strings, either by retrieving an image variant based
/// on the query strings or by ignoring the query string and returning the image
/// as specified without the query string. This query string specifies scale,
/// contrast setting, and language.
/// </summary>
public bool? AddImageQuery { get; set; }
/// <summary>
/// Returns the image's source string.
/// </summary>
/// <returns>The image's source string.</returns>
public override string ToString()
{
if (Source == null)
{
return "Source is null";
}
return Source;
}
internal Element_AdaptiveImage ConvertToElement()
{
Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
image.Crop = HintCrop;
image.RemoveMargin = HintRemoveMargin;
image.Align = HintAlign;
image.Placement = AdaptiveImagePlacement.Inline;
return image;
}
}
}