Skip to content

Commit

Permalink
Switch to file-scoped namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Dec 25, 2024
1 parent d6c144b commit d2d708b
Show file tree
Hide file tree
Showing 124 changed files with 12,092 additions and 12,214 deletions.
45 changes: 22 additions & 23 deletions components/Notifications/src/Adaptive/AdaptiveGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,35 @@
using System.Collections.Generic;
using CommunityToolkit.Notifications.Adaptive.Elements;

namespace CommunityToolkit.Notifications
namespace CommunityToolkit.Notifications;

/// <summary>
/// Groups semantically identify that the content in the group must either be displayed as a whole, or not displayed if it cannot fit. Groups also allow creating multiple columns. Supported on Tiles since RTM. Supported on Toasts since Anniversary Update.
/// </summary>
public sealed class AdaptiveGroup : ITileBindingContentAdaptiveChild, IAdaptiveChild, IToastBindingGenericChild
{
/// <summary>
/// Groups semantically identify that the content in the group must either be displayed as a whole, or not displayed if it cannot fit. Groups also allow creating multiple columns. Supported on Tiles since RTM. Supported on Toasts since Anniversary Update.
/// Gets the only valid children of groups are <see cref="AdaptiveSubgroup"/>.
/// Each subgroup is displayed as a separate vertical column. Note that you must
/// include at least one subgroup in your group, otherwise an <see cref="InvalidOperationException"/>
/// will be thrown when you try to retrieve the XML for the notification.
/// </summary>
public sealed class AdaptiveGroup : ITileBindingContentAdaptiveChild, IAdaptiveChild, IToastBindingGenericChild
{
/// <summary>
/// Gets the only valid children of groups are <see cref="AdaptiveSubgroup"/>.
/// Each subgroup is displayed as a separate vertical column. Note that you must
/// include at least one subgroup in your group, otherwise an <see cref="InvalidOperationException"/>
/// will be thrown when you try to retrieve the XML for the notification.
/// </summary>
public IList<AdaptiveSubgroup> Children { get; private set; } = new List<AdaptiveSubgroup>();
public IList<AdaptiveSubgroup> Children { get; private set; } = new List<AdaptiveSubgroup>();

internal Element_AdaptiveGroup ConvertToElement()
internal Element_AdaptiveGroup ConvertToElement()
{
if (Children.Count == 0)
{
if (Children.Count == 0)
{
throw new InvalidOperationException("Groups must have at least one child subgroup. The Children property had zero items in it.");
}

Element_AdaptiveGroup group = new Element_AdaptiveGroup();
throw new InvalidOperationException("Groups must have at least one child subgroup. The Children property had zero items in it.");
}

foreach (var subgroup in Children)
{
group.Children.Add(subgroup.ConvertToElement());
}
Element_AdaptiveGroup group = new Element_AdaptiveGroup();

return group;
foreach (var subgroup in Children)
{
group.Children.Add(subgroup.ConvertToElement());
}

return group;
}
}
57 changes: 28 additions & 29 deletions components/Notifications/src/Adaptive/AdaptiveHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,37 @@

using System;

namespace CommunityToolkit.Notifications.Adaptive
namespace CommunityToolkit.Notifications.Adaptive;

internal static class AdaptiveHelper
{
internal static class AdaptiveHelper
internal static object ConvertToElement(object obj)
{
internal static object ConvertToElement(object obj)
if (obj is AdaptiveText)
{
return (obj as AdaptiveText).ConvertToElement();
}

if (obj is AdaptiveImage)
{
return (obj as AdaptiveImage).ConvertToElement();
}

if (obj is AdaptiveGroup)
{
if (obj is AdaptiveText)
{
return (obj as AdaptiveText).ConvertToElement();
}

if (obj is AdaptiveImage)
{
return (obj as AdaptiveImage).ConvertToElement();
}

if (obj is AdaptiveGroup)
{
return (obj as AdaptiveGroup).ConvertToElement();
}

if (obj is AdaptiveSubgroup)
{
return (obj as AdaptiveSubgroup).ConvertToElement();
}

if (obj is AdaptiveProgressBar)
{
return (obj as AdaptiveProgressBar).ConvertToElement();
}

throw new NotImplementedException("Unknown object: " + obj.GetType());
return (obj as AdaptiveGroup).ConvertToElement();
}

if (obj is AdaptiveSubgroup)
{
return (obj as AdaptiveSubgroup).ConvertToElement();
}

if (obj is AdaptiveProgressBar)
{
return (obj as AdaptiveProgressBar).ConvertToElement();
}

throw new NotImplementedException("Unknown object: " + obj.GetType());
}
}
137 changes: 68 additions & 69 deletions components/Notifications/src/Adaptive/AdaptiveImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,88 @@

using CommunityToolkit.Notifications.Adaptive.Elements;

namespace CommunityToolkit.Notifications
namespace CommunityToolkit.Notifications;

/// <summary>
/// An inline image.
/// </summary>
public sealed class AdaptiveImage
: IBaseImage,
IToastBindingGenericChild,
ITileBindingContentAdaptiveChild,
IAdaptiveChild,
IAdaptiveSubgroupChild
{
/// <summary>
/// An inline image.
/// Gets or sets the desired cropping of the image.
/// Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// </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; }
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 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; }
/// <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;
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 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 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>
/// 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()
/// <summary>
/// Returns the image's source string.
/// </summary>
/// <returns>The image's source string.</returns>
public override string ToString()
{
if (Source == null)
{
if (Source == null)
{
return "Source is null";
}

return Source;
return "Source is null";
}

internal Element_AdaptiveImage ConvertToElement()
{
Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
return Source;
}

image.Crop = HintCrop;
image.RemoveMargin = HintRemoveMargin;
image.Align = HintAlign;
image.Placement = AdaptiveImagePlacement.Inline;
internal Element_AdaptiveImage ConvertToElement()
{
Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);

return image;
}
image.Crop = HintCrop;
image.RemoveMargin = HintRemoveMargin;
image.Align = HintAlign;
image.Placement = AdaptiveImagePlacement.Inline;

return image;
}
}
101 changes: 50 additions & 51 deletions components/Notifications/src/Adaptive/AdaptiveImageEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,56 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace CommunityToolkit.Notifications
namespace CommunityToolkit.Notifications;

/// <summary>
/// Specifies the horizontal alignment for an image.
/// </summary>
public enum AdaptiveImageAlign
{
/// <summary>
/// Default value, alignment behavior determined by renderer.
/// </summary>
Default,

/// <summary>
/// Image stretches to fill available width (and potentially available height too, depending on where the image is).
/// </summary>
Stretch,

/// <summary>
/// Align the image to the left, displaying the image at its native resolution.
/// </summary>
Left,

/// <summary>
/// Align the image in the center horizontally, displaying the image at its native resolution.
/// </summary>
Center,

/// <summary>
/// Align the image to the right, displaying the image at its native resolution.
/// </summary>
Right
}

/// <summary>
/// Specify the desired cropping of the image.
/// </summary>
public enum AdaptiveImageCrop
{
/// <summary>
/// Specifies the horizontal alignment for an image.
/// </summary>
public enum AdaptiveImageAlign
{
/// <summary>
/// Default value, alignment behavior determined by renderer.
/// </summary>
Default,

/// <summary>
/// Image stretches to fill available width (and potentially available height too, depending on where the image is).
/// </summary>
Stretch,

/// <summary>
/// Align the image to the left, displaying the image at its native resolution.
/// </summary>
Left,

/// <summary>
/// Align the image in the center horizontally, displaying the image at its native resolution.
/// </summary>
Center,

/// <summary>
/// Align the image to the right, displaying the image at its native resolution.
/// </summary>
Right
}

/// <summary>
/// Specify the desired cropping of the image.
/// </summary>
public enum AdaptiveImageCrop
{
/// <summary>
/// Default value, cropping behavior determined by renderer.
/// </summary>
Default,

/// <summary>
/// Image is not cropped.
/// </summary>
None,

/// <summary>
/// Image is cropped to a circle shape.
/// </summary>
Circle
}
/// Default value, cropping behavior determined by renderer.
/// </summary>
Default,

/// <summary>
/// Image is not cropped.
/// </summary>
None,

/// <summary>
/// Image is cropped to a circle shape.
/// </summary>
Circle
}
Loading

0 comments on commit d2d708b

Please sign in to comment.