diff --git a/src/Riverside.Toolkit/Controls/Card.cs b/src/Riverside.Toolkit/Controls/Card.cs index 1355ba0..8c84a25 100644 --- a/src/Riverside.Toolkit/Controls/Card.cs +++ b/src/Riverside.Toolkit/Controls/Card.cs @@ -3,13 +3,16 @@ using Microsoft.UI.Xaml.Input; using System.ComponentModel; -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - namespace Riverside.Toolkit.Controls { + /// + /// Represents a custom Card control. + /// public sealed class Card : Control { + /// + /// Initializes a new instance of the class. + /// public Card() { this.DefaultStyleKey = typeof(Card); @@ -19,6 +22,9 @@ public Card() this.PointerExited += Card_PointerExited; } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( "Title", // The name of the property @@ -27,6 +33,9 @@ public Card() new PropertyMetadata("Title") // Default value ); + /// + /// Gets or sets the title of the Card. + /// [Browsable(true)] [Category("Common")] [Description("The title of the Card")] @@ -36,6 +45,9 @@ public string Title set { SetValue(TitleProperty, value); } } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty SubtitleProperty = DependencyProperty.Register( "Subtitle", // The name of the property @@ -44,6 +56,9 @@ public string Title new PropertyMetadata("Subtitle") // Default value ); + /// + /// Gets or sets the subtitle of the Card. + /// [Browsable(true)] [Category("Common")] [Description("The Subtitle of the Card")] @@ -53,6 +68,9 @@ public string Subtitle set { SetValue(SubtitleProperty, value); } } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( "Content", // The name of the property @@ -61,6 +79,9 @@ public string Subtitle new PropertyMetadata("Content") // Default value ); + /// + /// Gets or sets the content of the Card. + /// [Browsable(true)] [Category("Common")] [Description("The Content of the Card")] @@ -72,17 +93,35 @@ public string Content private bool invokedFromLeftButton; + /// + /// Handles the PointerExited event of the Card control. + /// Changes the visual state to "Normal". + /// + /// The source of the event. + /// The instance containing the event data. private void Card_PointerExited(object sender, PointerRoutedEventArgs e) { VisualStateManager.GoToState(this, "Normal", true); } + /// + /// Handles the PointerReleased event of the Card control. + /// Changes the visual state to "PointerOver" and invokes the Click event if the left button was pressed. + /// + /// The source of the event. + /// The instance containing the event data. private void Card_PointerReleased(object sender, PointerRoutedEventArgs e) { VisualStateManager.GoToState(this, "PointerOver", true); if (invokedFromLeftButton == true) this.Click?.Invoke(this, new RoutedEventArgs()); } + /// + /// Handles the PointerPressed event of the Card control. + /// Changes the visual state to "Pressed" if the left button is pressed. + /// + /// The source of the event. + /// The instance containing the event data. private void Card_PointerPressed(object sender, PointerRoutedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == true) @@ -93,12 +132,21 @@ private void Card_PointerPressed(object sender, PointerRoutedEventArgs e) else invokedFromLeftButton = false; } + /// + /// Handles the PointerEntered event of the Card control. + /// Changes the visual state to "PointerOver" or "Pressed" based on the pointer state. + /// + /// The source of the event. + /// The instance containing the event data. private void Card_PointerEntered(object sender, PointerRoutedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == false) VisualStateManager.GoToState(this, "PointerOver", true); if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == true) VisualStateManager.GoToState(this, "Pressed", true); } + /// + /// Occurs when the Card is clicked. + /// public event RoutedEventHandler Click; } -} \ No newline at end of file +} diff --git a/src/Riverside.Toolkit/Controls/ChatBubble.cs b/src/Riverside.Toolkit/Controls/ChatBubble.cs index ef43256..59a5222 100644 --- a/src/Riverside.Toolkit/Controls/ChatBubble.cs +++ b/src/Riverside.Toolkit/Controls/ChatBubble.cs @@ -2,18 +2,24 @@ using Microsoft.UI.Xaml.Controls; using System.ComponentModel; -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - namespace Riverside.Toolkit.Controls { + /// + /// Represents a custom ChatBubble control. + /// public sealed class ChatBubble : Control { + /// + /// Initializes a new instance of the class. + /// public ChatBubble() { this.DefaultStyleKey = typeof(ChatBubble); } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", // The name of the property @@ -22,6 +28,9 @@ public ChatBubble() new PropertyMetadata("Text") // Default value ); + /// + /// Gets or sets the text in the ChatBubble. + /// [Browsable(true)] [Category("Common")] [Description("The text in the ChatBubble")] diff --git a/src/Riverside.Toolkit/Controls/CommandLink.cs b/src/Riverside.Toolkit/Controls/CommandLink.cs index 5d08a56..6d3d343 100644 --- a/src/Riverside.Toolkit/Controls/CommandLink.cs +++ b/src/Riverside.Toolkit/Controls/CommandLink.cs @@ -3,13 +3,16 @@ using Microsoft.UI.Xaml.Input; using System.ComponentModel; -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - namespace Riverside.Toolkit.Controls { + /// + /// Represents a custom CommandLink control. + /// public sealed class CommandLink : Control { + /// + /// Initializes a new instance of the class. + /// public CommandLink() { this.DefaultStyleKey = typeof(CommandLink); @@ -19,6 +22,9 @@ public CommandLink() this.PointerExited += CommandLink_PointerExited; } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( "Title", // The name of the property @@ -27,6 +33,9 @@ public CommandLink() new PropertyMetadata("Title") // Default value ); + /// + /// Gets or sets the title of the CommandLink. + /// [Browsable(true)] [Category("Common")] [Description("The title of the CommandLink")] @@ -36,6 +45,9 @@ public string Title set { SetValue(TitleProperty, value); } } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register( "Description", // The name of the property @@ -44,6 +56,9 @@ public string Title new PropertyMetadata("Description") // Default value ); + /// + /// Gets or sets the description of the CommandLink. + /// [Browsable(true)] [Category("Common")] [Description("The description of the CommandLink")] @@ -55,17 +70,35 @@ public string Description private bool invokedFromLeftButton; + /// + /// Handles the PointerExited event of the CommandLink control. + /// Changes the visual state to "Normal". + /// + /// The source of the event. + /// The instance containing the event data. private void CommandLink_PointerExited(object sender, PointerRoutedEventArgs e) { VisualStateManager.GoToState(this, "Normal", true); } + /// + /// Handles the PointerReleased event of the CommandLink control. + /// Changes the visual state to "PointerOver" and invokes the Click event if the left button was pressed. + /// + /// The source of the event. + /// The instance containing the event data. private void CommandLink_PointerReleased(object sender, PointerRoutedEventArgs e) { VisualStateManager.GoToState(this, "PointerOver", true); if (invokedFromLeftButton == true) this.Click?.Invoke(this, new RoutedEventArgs()); } + /// + /// Handles the PointerPressed event of the CommandLink control. + /// Changes the visual state to "Pressed" if the left button is pressed. + /// + /// The source of the event. + /// The instance containing the event data. private void CommandLink_PointerPressed(object sender, PointerRoutedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == true) @@ -76,12 +109,21 @@ private void CommandLink_PointerPressed(object sender, PointerRoutedEventArgs e) else invokedFromLeftButton = false; } + /// + /// Handles the PointerEntered event of the CommandLink control. + /// Changes the visual state to "PointerOver" or "Pressed" based on the pointer state. + /// + /// The source of the event. + /// The instance containing the event data. private void CommandLink_PointerEntered(object sender, PointerRoutedEventArgs e) { if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == false) VisualStateManager.GoToState(this, "PointerOver", true); if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == true) VisualStateManager.GoToState(this, "Pressed", true); } + /// + /// Occurs when the CommandLink is clicked. + /// public event RoutedEventHandler Click; } -} \ No newline at end of file +} diff --git a/src/Riverside.Toolkit/Controls/OpacityMaskView.cs b/src/Riverside.Toolkit/Controls/OpacityMaskView.cs index 00bcec1..68962b8 100644 --- a/src/Riverside.Toolkit/Controls/OpacityMaskView.cs +++ b/src/Riverside.Toolkit/Controls/OpacityMaskView.cs @@ -10,8 +10,14 @@ namespace Riverside.Toolkit.Controls; +/// +/// A custom control that provides an opacity mask view. +/// public partial class OpacityMaskView : RedirectVisualView { + /// + /// Initializes a new instance of the class. + /// public OpacityMaskView() { opacityMaskHost = new Rectangle(); @@ -39,15 +45,26 @@ public OpacityMaskView() private CompositionSurfaceBrush opacityMaskVisualBrush; private CompositionMaskBrush maskBrush; + /// + /// Gets or sets the opacity mask brush. + /// public Brush OpacityMask { get { return (Brush)GetValue(OpacityMaskProperty); } set { SetValue(OpacityMaskProperty, value); } } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty OpacityMaskProperty = DependencyProperty.Register("OpacityMask", typeof(Brush), typeof(OpacityMaskView), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)), OnOpacityMaskPropertyChanged)); + /// + /// Called when the property changes. + /// + /// The dependency object. + /// The event data. private static void OnOpacityMaskPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is OpacityMaskView sender && !Equals(e.NewValue, e.OldValue)) @@ -63,6 +80,9 @@ private static void OnOpacityMaskPropertyChanged(DependencyObject d, DependencyP } } + /// + /// Detaches the visuals from the control. + /// protected override void OnDetachVisuals() { base.OnDetachVisuals(); @@ -84,6 +104,9 @@ protected override void OnDetachVisuals() } } + /// + /// Attaches the visuals to the control. + /// protected override void OnAttachVisuals() { base.OnAttachVisuals(); @@ -105,6 +128,9 @@ protected override void OnAttachVisuals() } } + /// + /// Updates the size of the control. + /// protected override void OnUpdateSize() { base.OnUpdateSize(); @@ -120,4 +146,4 @@ protected override void OnUpdateSize() opacityMaskVisualSurface.SourceSize = new Vector2((float)LayoutRoot.ActualWidth, (float)LayoutRoot.ActualHeight); } } -} \ No newline at end of file +} diff --git a/src/Riverside.Toolkit/Controls/RedirectVisualView.cs b/src/Riverside.Toolkit/Controls/RedirectVisualView.cs index 2918fc7..204793c 100644 --- a/src/Riverside.Toolkit/Controls/RedirectVisualView.cs +++ b/src/Riverside.Toolkit/Controls/RedirectVisualView.cs @@ -9,9 +9,15 @@ namespace Riverside.Toolkit.Controls; +/// +/// A custom control that redirects visual content. +/// [ContentProperty(Name = nameof(Child))] public partial class RedirectVisualView : Control { + /// + /// Initializes a new instance of the class. + /// public RedirectVisualView() { DefaultStyleKey = typeof(RedirectVisualView); @@ -41,11 +47,16 @@ public RedirectVisualView() RegisterPropertyChangedCallback(PaddingProperty, OnPaddingPropertyChanged); } + /// + /// Gets a value indicating whether the child visual brush offset is enabled. + /// protected virtual bool ChildVisualBrushOffsetEnabled => true; - private bool measureChildInBoundingBox = true; + /// + /// Gets or sets a value indicating whether to measure the child in the bounding box. + /// protected bool MeasureChildInBoundingBox { get => measureChildInBoundingBox; @@ -59,8 +70,14 @@ protected bool MeasureChildInBoundingBox } } + /// + /// Gets a value indicating whether the redirect visual is attached. + /// protected bool RedirectVisualAttached => attached; + /// + /// Gets or sets a value indicating whether the redirect visual is enabled. + /// protected bool RedirectVisualEnabled { get => redirectVisualEnabled; @@ -85,7 +102,6 @@ protected bool RedirectVisualEnabled } } - private bool attached; private bool redirectVisualEnabled = true; private bool childVisualBrushOffsetEnabled; @@ -96,7 +112,9 @@ protected bool RedirectVisualEnabled private Canvas ChildHost; private Canvas opacityMaskContainer; - + /// + /// Gets or sets the layout root grid. + /// protected Grid LayoutRoot { get => layoutRoot; @@ -121,6 +139,9 @@ private set } } + /// + /// Gets or sets the child presenter. + /// protected ContentPresenter ChildPresenter { get => childPresenter; @@ -145,6 +166,9 @@ private set } } + /// + /// Gets or sets the child presenter container. + /// protected Grid ChildPresenterContainer { get => childPresenterContainer; @@ -159,7 +183,9 @@ private set } } - + /// + /// Gets or sets the opacity mask container. + /// protected Canvas OpacityMaskContainer { get => opacityMaskContainer; @@ -175,14 +201,23 @@ protected Canvas OpacityMaskContainer private SpriteVisual redirectVisual; private ExpressionAnimation offsetBind; + /// + /// Gets the child visual brush. + /// protected CompositionBrush ChildVisualBrush => childVisualBrush; + /// + /// Gets or sets the root visual. + /// protected SpriteVisual RootVisual { get => redirectVisual; set => redirectVisual = value; } + /// + /// Applies the control template and attaches visuals if enabled. + /// protected override void OnApplyTemplate() { base.OnApplyTemplate(); @@ -201,15 +236,24 @@ protected override void OnApplyTemplate() } } + /// + /// Gets or sets the child element. + /// public UIElement Child { get { return (UIElement)GetValue(ChildProperty); } set { SetValue(ChildProperty, value); } } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty ChildProperty = DependencyProperty.Register("Child", typeof(UIElement), typeof(RedirectVisualView), new PropertyMetadata(null)); + /// + /// Attaches the visuals to the control. + /// private void AttachVisuals() { if (attached) return; @@ -252,6 +296,9 @@ private void AttachVisuals() OnAttachVisuals(); } + /// + /// Detaches the visuals from the control. + /// private void DetachVisuals() { if (!attached) return; @@ -287,11 +334,17 @@ private void DetachVisuals() OnDetachVisuals(); } + /// + /// Handles the Unloaded event of the control. + /// private void RedirectVisualView_Unloaded(object sender, RoutedEventArgs e) { DetachVisuals(); } + /// + /// Handles the Loaded event of the control. + /// private void RedirectVisualView_Loaded(object sender, RoutedEventArgs e) { if (RedirectVisualEnabled) @@ -300,22 +353,33 @@ private void RedirectVisualView_Loaded(object sender, RoutedEventArgs e) } } + /// + /// Handles the Padding property changed event. + /// private void OnPaddingPropertyChanged(DependencyObject sender, DependencyProperty dp) { UpdateSize(); } + /// + /// Handles the SizeChanged event of the layout root. + /// private void LayoutRoot_SizeChanged(object sender, SizeChangedEventArgs e) { UpdateSize(); } - + /// + /// Handles the SizeChanged event of the child presenter. + /// private void ChildPresenter_SizeChanged(object sender, SizeChangedEventArgs e) { UpdateSize(); } + /// + /// Updates the size of the control. + /// private void UpdateSize() { if (attached && LayoutRoot != null) @@ -329,6 +393,9 @@ private void UpdateSize() OnUpdateSize(); } + /// + /// Updates the measure child in bounding box property. + /// private void UpdateMeasureChildInBoundingBox() { if (ChildPresenterContainer != null) @@ -348,18 +415,27 @@ private void UpdateMeasureChildInBoundingBox() } } + /// + /// Called when visuals are attached. + /// protected virtual void OnAttachVisuals() { } + /// + /// Called when visuals are detached. + /// protected virtual void OnDetachVisuals() { } + /// + /// Called when the size is updated. + /// protected virtual void OnUpdateSize() { } -} \ No newline at end of file +} diff --git a/src/Riverside.Toolkit/Converters/BooleanToVisibilityConverter.cs b/src/Riverside.Toolkit/Converters/BooleanToVisibilityConverter.cs index 5d20a07..07e5621 100644 --- a/src/Riverside.Toolkit/Converters/BooleanToVisibilityConverter.cs +++ b/src/Riverside.Toolkit/Converters/BooleanToVisibilityConverter.cs @@ -1,17 +1,32 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Data; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Riverside.Toolkit.Converters { + /// + /// Converts a boolean value to a Visibility value. + /// public class BooleanToVisibilityConverter : IValueConverter { + /// + /// Converts a boolean value to a Visibility value. + /// + /// The boolean value to convert. + /// The type of the target property. + /// An optional parameter to use in the conversion. + /// The language of the conversion. + /// Visibility.Visible if the value is true; otherwise, Visibility.Collapsed. public object Convert(object value, Type targetType, object parameter, string language) => (bool)value ? Visibility.Visible : Visibility.Collapsed; + /// + /// Converts a Visibility value back to a boolean value. + /// + /// The Visibility value to convert. + /// The type of the target property. + /// An optional parameter to use in the conversion. + /// The language of the conversion. + /// True if the value is Visibility.Visible; otherwise, false. public object ConvertBack(object value, Type targetType, object parameter, string language) => (Visibility)value == Visibility.Visible; } } diff --git a/src/Riverside.Toolkit/Helpers/NativeHelper.cs b/src/Riverside.Toolkit/Helpers/NativeHelper.cs index 64b6f74..7e20861 100644 --- a/src/Riverside.Toolkit/Helpers/NativeHelper.cs +++ b/src/Riverside.Toolkit/Helpers/NativeHelper.cs @@ -8,6 +8,9 @@ namespace Riverside.Toolkit.Helpers { + /// + /// Provides helper methods for native interop. + /// public static class NativeHelper { public const int MONITOR_DEFAULTTOPRIMARY = 1; @@ -24,21 +27,56 @@ public static class NativeHelper public const int VERTRES = 10; // Vertical height of the display public const int LOGPIXELSX = 88; // Logical pixels/inch in X + /// + /// Retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen. + /// + /// A handle to the window whose DC is to be retrieved. + /// The handle to the DC for the specified window's client area. [DllImport(Libraries.User32)] public static extern IntPtr GetDC(IntPtr hWnd); + /// + /// Releases a device context (DC), freeing it for use by other applications. + /// + /// A handle to the window whose DC is to be released. + /// A handle to the DC to be released. + /// The return value indicates whether the DC was released. [DllImport(Libraries.User32)] public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); + /// + /// Retrieves device-specific information for the specified device. + /// + /// A handle to the DC. + /// The item to be returned. + /// The value of the specified item. [DllImport(Libraries.GraphicsDeviceInterface)] public static extern int GetDeviceCaps(IntPtr hdc, int nIndex); + /// + /// Extracts the X-coordinate from the lParam parameter of a window message. + /// + /// The lParam parameter of a window message. + /// The X-coordinate. public static int GetXFromLParam(IntPtr lParam) => unchecked((short)(long)lParam); + /// + /// Extracts the Y-coordinate from the lParam parameter of a window message. + /// + /// The lParam parameter of a window message. + /// The Y-coordinate. public static int GetYFromLParam(IntPtr lParam) => unchecked((short)((long)lParam >> 16)); + /// + /// Provides methods for display-related operations. + /// public static class Display { + /// + /// Gets the scale factor of the display. + /// + /// The window for which to get the scale factor. + /// The scale factor of the display. public static double Scale(WindowEx? win) { // Get the handle to the current window @@ -56,6 +94,11 @@ public static double Scale(WindowEx? win) return dpiX / 96.0; } + /// + /// Gets the rectangle representing the display area. + /// + /// The window for which to get the display rectangle. + /// The rectangle representing the display area. public static Rect GetDisplayRect(WindowEx win) { // Get the handle to the current window @@ -80,6 +123,11 @@ public static Rect GetDisplayRect(WindowEx win) }; } + /// + /// Gets the rectangle representing the display area, adjusted for DPI. + /// + /// The window for which to get the DPI-aware display rectangle. + /// The rectangle representing the DPI-aware display area. public static Rect GetDPIAwareDisplayRect(WindowEx win) { // Get the handle to the current window diff --git a/src/Riverside.Toolkit/UserControls/ImageFrame.xaml.cs b/src/Riverside.Toolkit/UserControls/ImageFrame.xaml.cs index 56c77dd..7fdf834 100644 --- a/src/Riverside.Toolkit/UserControls/ImageFrame.xaml.cs +++ b/src/Riverside.Toolkit/UserControls/ImageFrame.xaml.cs @@ -2,18 +2,24 @@ using Microsoft.UI.Xaml.Controls; using System.ComponentModel; -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - namespace Riverside.Toolkit.UserControls { + /// + /// A UserControl that represents an ImageFrame. + /// public sealed partial class ImageFrame : UserControl { + /// + /// Initializes a new instance of the class. + /// public ImageFrame() { this.InitializeComponent(); } + /// + /// Identifies the dependency property. + /// public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( "Source", // The name of the property @@ -22,6 +28,9 @@ public ImageFrame() new PropertyMetadata(null) // Default value ); + /// + /// Gets or sets the source of the content of the ImageFrame. + /// [Browsable(true)] [Category("Common")] [Description("The source of the content of the ImageFrame")]