Skip to content

Commit

Permalink
Document main project
Browse files Browse the repository at this point in the history
most of it
  • Loading branch information
Lamparter committed Jan 4, 2025
1 parent 2991df4 commit e753311
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 25 deletions.
56 changes: 52 additions & 4 deletions src/Riverside.Toolkit/Controls/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Represents a custom Card control.
/// </summary>
public sealed class Card : Control
{
/// <summary>
/// Initializes a new instance of the <see cref="Card"/> class.
/// </summary>
public Card()
{
this.DefaultStyleKey = typeof(Card);
Expand All @@ -19,6 +22,9 @@ public Card()
this.PointerExited += Card_PointerExited;
}

/// <summary>
/// Identifies the <see cref="Title"/> dependency property.
/// </summary>
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register(
"Title", // The name of the property
Expand All @@ -27,6 +33,9 @@ public Card()
new PropertyMetadata("Title") // Default value
);

/// <summary>
/// Gets or sets the title of the Card.
/// </summary>
[Browsable(true)]
[Category("Common")]
[Description("The title of the Card")]
Expand All @@ -36,6 +45,9 @@ public string Title
set { SetValue(TitleProperty, value); }
}

/// <summary>
/// Identifies the <see cref="Subtitle"/> dependency property.
/// </summary>
public static readonly DependencyProperty SubtitleProperty =
DependencyProperty.Register(
"Subtitle", // The name of the property
Expand All @@ -44,6 +56,9 @@ public string Title
new PropertyMetadata("Subtitle") // Default value
);

/// <summary>
/// Gets or sets the subtitle of the Card.
/// </summary>
[Browsable(true)]
[Category("Common")]
[Description("The Subtitle of the Card")]
Expand All @@ -53,6 +68,9 @@ public string Subtitle
set { SetValue(SubtitleProperty, value); }
}

/// <summary>
/// Identifies the <see cref="Content"/> dependency property.
/// </summary>
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register(
"Content", // The name of the property
Expand All @@ -61,6 +79,9 @@ public string Subtitle
new PropertyMetadata("Content") // Default value
);

/// <summary>
/// Gets or sets the content of the Card.
/// </summary>
[Browsable(true)]
[Category("Common")]
[Description("The Content of the Card")]
Expand All @@ -72,17 +93,35 @@ public string Content

private bool invokedFromLeftButton;

/// <summary>
/// Handles the PointerExited event of the Card control.
/// Changes the visual state to "Normal".
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PointerRoutedEventArgs"/> instance containing the event data.</param>
private void Card_PointerExited(object sender, PointerRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "Normal", true);
}

/// <summary>
/// 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.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PointerRoutedEventArgs"/> instance containing the event data.</param>
private void Card_PointerReleased(object sender, PointerRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "PointerOver", true);
if (invokedFromLeftButton == true) this.Click?.Invoke(this, new RoutedEventArgs());
}

/// <summary>
/// Handles the PointerPressed event of the Card control.
/// Changes the visual state to "Pressed" if the left button is pressed.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PointerRoutedEventArgs"/> instance containing the event data.</param>
private void Card_PointerPressed(object sender, PointerRoutedEventArgs e)
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == true)
Expand All @@ -93,12 +132,21 @@ private void Card_PointerPressed(object sender, PointerRoutedEventArgs e)
else invokedFromLeftButton = false;
}

/// <summary>
/// Handles the PointerEntered event of the Card control.
/// Changes the visual state to "PointerOver" or "Pressed" based on the pointer state.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PointerRoutedEventArgs"/> instance containing the event data.</param>
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);
}

/// <summary>
/// Occurs when the Card is clicked.
/// </summary>
public event RoutedEventHandler Click;
}
}
}
15 changes: 12 additions & 3 deletions src/Riverside.Toolkit/Controls/ChatBubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Represents a custom ChatBubble control.
/// </summary>
public sealed class ChatBubble : Control
{
/// <summary>
/// Initializes a new instance of the <see cref="ChatBubble"/> class.
/// </summary>
public ChatBubble()
{
this.DefaultStyleKey = typeof(ChatBubble);
}

/// <summary>
/// Identifies the <see cref="Text"/> dependency property.
/// </summary>
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(
"Text", // The name of the property
Expand All @@ -22,6 +28,9 @@ public ChatBubble()
new PropertyMetadata("Text") // Default value
);

/// <summary>
/// Gets or sets the text in the ChatBubble.
/// </summary>
[Browsable(true)]
[Category("Common")]
[Description("The text in the ChatBubble")]
Expand Down
50 changes: 46 additions & 4 deletions src/Riverside.Toolkit/Controls/CommandLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Represents a custom CommandLink control.
/// </summary>
public sealed class CommandLink : Control
{
/// <summary>
/// Initializes a new instance of the <see cref="CommandLink"/> class.
/// </summary>
public CommandLink()
{
this.DefaultStyleKey = typeof(CommandLink);
Expand All @@ -19,6 +22,9 @@ public CommandLink()
this.PointerExited += CommandLink_PointerExited;
}

/// <summary>
/// Identifies the <see cref="Title"/> dependency property.
/// </summary>
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register(
"Title", // The name of the property
Expand All @@ -27,6 +33,9 @@ public CommandLink()
new PropertyMetadata("Title") // Default value
);

/// <summary>
/// Gets or sets the title of the CommandLink.
/// </summary>
[Browsable(true)]
[Category("Common")]
[Description("The title of the CommandLink")]
Expand All @@ -36,6 +45,9 @@ public string Title
set { SetValue(TitleProperty, value); }
}

/// <summary>
/// Identifies the <see cref="Description"/> dependency property.
/// </summary>
public static readonly DependencyProperty DescriptionProperty =
DependencyProperty.Register(
"Description", // The name of the property
Expand All @@ -44,6 +56,9 @@ public string Title
new PropertyMetadata("Description") // Default value
);

/// <summary>
/// Gets or sets the description of the CommandLink.
/// </summary>
[Browsable(true)]
[Category("Common")]
[Description("The description of the CommandLink")]
Expand All @@ -55,17 +70,35 @@ public string Description

private bool invokedFromLeftButton;

/// <summary>
/// Handles the PointerExited event of the CommandLink control.
/// Changes the visual state to "Normal".
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PointerRoutedEventArgs"/> instance containing the event data.</param>
private void CommandLink_PointerExited(object sender, PointerRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "Normal", true);
}

/// <summary>
/// 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.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PointerRoutedEventArgs"/> instance containing the event data.</param>
private void CommandLink_PointerReleased(object sender, PointerRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "PointerOver", true);
if (invokedFromLeftButton == true) this.Click?.Invoke(this, new RoutedEventArgs());
}

/// <summary>
/// Handles the PointerPressed event of the CommandLink control.
/// Changes the visual state to "Pressed" if the left button is pressed.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PointerRoutedEventArgs"/> instance containing the event data.</param>
private void CommandLink_PointerPressed(object sender, PointerRoutedEventArgs e)
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == true)
Expand All @@ -76,12 +109,21 @@ private void CommandLink_PointerPressed(object sender, PointerRoutedEventArgs e)
else invokedFromLeftButton = false;
}

/// <summary>
/// Handles the PointerEntered event of the CommandLink control.
/// Changes the visual state to "PointerOver" or "Pressed" based on the pointer state.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PointerRoutedEventArgs"/> instance containing the event data.</param>
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);
}

/// <summary>
/// Occurs when the CommandLink is clicked.
/// </summary>
public event RoutedEventHandler Click;
}
}
}
28 changes: 27 additions & 1 deletion src/Riverside.Toolkit/Controls/OpacityMaskView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@

namespace Riverside.Toolkit.Controls;

/// <summary>
/// A custom control that provides an opacity mask view.
/// </summary>
public partial class OpacityMaskView : RedirectVisualView
{
/// <summary>
/// Initializes a new instance of the <see cref="OpacityMaskView"/> class.
/// </summary>
public OpacityMaskView()
{
opacityMaskHost = new Rectangle();
Expand Down Expand Up @@ -39,15 +45,26 @@ public OpacityMaskView()
private CompositionSurfaceBrush opacityMaskVisualBrush;
private CompositionMaskBrush maskBrush;

/// <summary>
/// Gets or sets the opacity mask brush.
/// </summary>
public Brush OpacityMask
{
get { return (Brush)GetValue(OpacityMaskProperty); }
set { SetValue(OpacityMaskProperty, value); }
}

/// <summary>
/// Identifies the <see cref="OpacityMask"/> dependency property.
/// </summary>
public static readonly DependencyProperty OpacityMaskProperty =
DependencyProperty.Register("OpacityMask", typeof(Brush), typeof(OpacityMaskView), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)), OnOpacityMaskPropertyChanged));

/// <summary>
/// Called when the <see cref="OpacityMask"/> property changes.
/// </summary>
/// <param name="d">The dependency object.</param>
/// <param name="e">The event data.</param>
private static void OnOpacityMaskPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is OpacityMaskView sender && !Equals(e.NewValue, e.OldValue))
Expand All @@ -63,6 +80,9 @@ private static void OnOpacityMaskPropertyChanged(DependencyObject d, DependencyP
}
}

/// <summary>
/// Detaches the visuals from the control.
/// </summary>
protected override void OnDetachVisuals()
{
base.OnDetachVisuals();
Expand All @@ -84,6 +104,9 @@ protected override void OnDetachVisuals()
}
}

/// <summary>
/// Attaches the visuals to the control.
/// </summary>
protected override void OnAttachVisuals()
{
base.OnAttachVisuals();
Expand All @@ -105,6 +128,9 @@ protected override void OnAttachVisuals()
}
}

/// <summary>
/// Updates the size of the control.
/// </summary>
protected override void OnUpdateSize()
{
base.OnUpdateSize();
Expand All @@ -120,4 +146,4 @@ protected override void OnUpdateSize()
opacityMaskVisualSurface.SourceSize = new Vector2((float)LayoutRoot.ActualWidth, (float)LayoutRoot.ActualHeight);
}
}
}
}
Loading

0 comments on commit e753311

Please sign in to comment.