Skip to content

Commit 5d08b1a

Browse files
authored
Merge pull request #64 from TruePadawan/dev
Refactor export feature and enhance documentation across classes
2 parents 5a11141 + dcda46e commit 5d08b1a

39 files changed

+423
-324
lines changed

Scribble.Shared/Lib/StrokePaint.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ namespace Scribble.Shared.Lib;
66

77
public class StrokePaint
88
{
9-
public bool IsAntialias { get; init; }
10-
public bool IsStroke { get; init; }
11-
public SKStrokeCap StrokeCap { get; init; }
9+
public bool IsAntialias { get; set; } = true;
10+
public bool IsStroke { get; set; } = true;
11+
public SKStrokeCap StrokeCap { get; set; } = SKStrokeCap.Round;
1212
public SKStrokeJoin StrokeJoin { get; set; }
1313
public float StrokeWidth { get; set; } = 1;
1414
public float TextSize { get; set; }

Scribble/Behaviours/ToggleButtonGroup.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
namespace Scribble.Behaviours;
77

8+
/// <summary>
9+
/// Provides the ability to group ToggleButtons and have them act like Radio buttons
10+
/// via the GroupName attached property
11+
/// </summary>
812
public class ToggleButtonGroup
913
{
1014
public static readonly AttachedProperty<string?> GroupNameProperty =

Scribble/Controls/ScribbleColorPicker/ScribbleColorPicker.axaml.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
namespace Scribble.Controls.ScribbleColorPicker;
88

9+
/// <summary>
10+
/// Custom control for picking a color
11+
/// It provides a button that opens a flyout with a programmable set of colors that can be selected
12+
/// </summary>
913
public partial class ScribbleColorPicker : UserControl
1014
{
1115
private static readonly IReadOnlyList<Color> DefaultPalette = GenerateMaterialPalette();
@@ -27,12 +31,14 @@ private static List<Color> GenerateMaterialPalette()
2731
return colors;
2832
}
2933

30-
// Properties
3134
public static readonly StyledProperty<IEnumerable<Color>> PaletteColorsProperty =
3235
AvaloniaProperty.Register<ScribbleColorPicker, IEnumerable<Color>>(
3336
nameof(PaletteColors),
3437
defaultValue: DefaultPalette);
3538

39+
/// <summary>
40+
/// Property representing the colors that can be selected
41+
/// </summary>
3642
public IEnumerable<Color> PaletteColors
3743
{
3844
get => GetValue(PaletteColorsProperty);
@@ -45,6 +51,9 @@ public IEnumerable<Color> PaletteColors
4551
Colors.White,
4652
defaultBindingMode: BindingMode.TwoWay);
4753

54+
/// <summary>
55+
/// Property representing the currently selected color
56+
/// </summary>
4857
public Color SelectedColor
4958
{
5059
get => GetValue(SelectedColorProperty);
@@ -59,6 +68,7 @@ public ScribbleColorPicker()
5968
InitializeComponent();
6069
}
6170

71+
// Update the textbox to show the hex code of the currently selected color
6272
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
6373
{
6474
base.OnPropertyChanged(change);
@@ -77,6 +87,7 @@ private void UpdateHexTextBox(Color color)
7787
_isUpdatingHex = false;
7888
}
7989

90+
// Update the selected color when the inputted text is a valid hex code
8091
private void HexTextBox_OnTextChanged(object? sender, TextChangedEventArgs e)
8192
{
8293
if (_isUpdatingHex) return;
@@ -94,6 +105,7 @@ private void HexTextBox_OnTextChanged(object? sender, TextChangedEventArgs e)
94105
}
95106
}
96107

108+
// Close the flyout when a color is selected
97109
private void ColorListBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
98110
{
99111
if (e.AddedItems.Count > 0)

Scribble/Controls/SkiaCanvas.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
namespace Scribble.Controls;
1515

16+
/// <summary>
17+
/// The SkiaCanvas control represents the canvas/whiteboard of the application
18+
/// </summary>
1619
public class SkiaCanvas : Control
1720
{
1821
public static readonly StyledProperty<List<Stroke>> StrokesProperty =
@@ -43,10 +46,10 @@ public override void Render(DrawingContext context)
4346
var strokesToDraw = Strokes;
4447
var bgColor = CanvasBackground;
4548
context.Custom(
46-
new SkiaDrawOperation(bounds, canvas => { DrawContent(canvas, strokesToDraw, bgColor); }));
49+
new SkiaDrawOperation(bounds, canvas => { DrawStrokesOnCanvas(canvas, strokesToDraw, bgColor); }));
4750
}
4851

49-
private void DrawContent(SKCanvas canvas, IEnumerable<Stroke> strokesToDraw, Color bgColor)
52+
private void DrawStrokesOnCanvas(SKCanvas canvas, IEnumerable<Stroke> strokesToDraw, Color bgColor)
5053
{
5154
canvas.Clear(Utilities.ToSkColor(bgColor));
5255

Scribble/Converters/EnumToBoolConverter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Scribble.Converters;
77

8+
/// <summary>
9+
/// This converter allows the ToggleButton control's IsChecked status to be converted between a boolean and an enum
10+
/// </summary>
811
public class EnumToBoolConverter : IValueConverter
912
{
1013
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -16,4 +19,4 @@ public object ConvertBack(object? value, Type targetType, object? parameter, Cul
1619
{
1720
return value is true && parameter != null ? parameter : BindingOperations.DoNothing;
1821
}
19-
}
22+
}

Scribble/Extensions/ServiceCollectionExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Scribble.Extensions;
1010

11+
/// <summary>
12+
/// Extension methods for registering services in the application
13+
/// </summary>
1114
public static class ServiceCollectionExtensions
1215
{
1316
public static void AddCommonServices(this IServiceCollection collection)

Scribble/Lib/CanvasExporter.cs

Lines changed: 0 additions & 89 deletions
This file was deleted.

Scribble/Lib/CollaborativeDrawing/CollaborativeDrawingRoom.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
namespace Scribble.Lib.CollaborativeDrawing;
55

6+
/// <summary>
7+
/// Represents a multi-user drawing room
8+
/// </summary>
9+
/// <param name="roomId">The unique ID of the room</param>
10+
/// <param name="connectionId">The client's connection ID from SignalR</param>
11+
/// <param name="displayName">The client's display name</param>
612
public class CollaborativeDrawingRoom(string roomId, string connectionId, string displayName)
713
{
814
public string RoomId { get; } = roomId;

Scribble/Lib/CollaborativeDrawing/CollaborativeDrawingService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class CollaborativeDrawingService(string serverUrl)
2222
public event Action<CollaborativeDrawingUser, List<CollaborativeDrawingUser>>? ClientJoinedRoom;
2323
public event Action<CollaborativeDrawingUser, List<CollaborativeDrawingUser>>? ClientLeftRoom;
2424

25+
// Set up the event handlers and starts a connection to the SignalR server
2526
public async Task StartAsync()
2627
{
2728
// Listen for draw events from others in the room
@@ -50,6 +51,7 @@ public async Task StartAsync()
5051
ConnectionStarted?.Invoke();
5152
}
5253

54+
// Kill the SignalR connection
5355
public async Task StopAsync()
5456
{
5557
await _connection.StopAsync();

Scribble/Lib/Selection.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
namespace Scribble.Lib;
66

7+
/// <summary>
8+
/// Represents the current selection in the application
9+
/// It encapsulates the data that represents an active selection
10+
/// </summary>
711
public class Selection
812
{
913
public Point SelectionMoveCoord = new Point(-1, -1);

0 commit comments

Comments
 (0)