Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(models): enhance data binding and encapsulation #42

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SketchNow/Controls/CustomInkCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace SketchNow.Controls;

public class CustomInkCanvas : InkCanvas
{
CustomStylusPlugin _customStylusPlugin = new();
private readonly CustomStylusPlugin _customStylusPlugin = new();

public CustomInkCanvas()
{
this.StylusPlugIns.Add(_customStylusPlugin);
StylusPlugIns.Add(_customStylusPlugin);
}
}
9 changes: 5 additions & 4 deletions SketchNow/Models/CanvasPages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ namespace SketchNow.Models;

public partial class CanvasPage : ObservableObject
{
[ObservableProperty] private StrokeCollection _strokes = [];
[ObservableProperty]
public partial StrokeCollection Strokes { get; set; } = [];

#region Undo/Redo

/// <summary>
/// To Notify the Not ObservableProperty <see cref="_strokes"/>
/// To Notify the Not ObservableProperty <see cref="Strokes"/>
/// </summary>
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(UndoCommand), nameof(RedoCommand), nameof(ClearCommand))]
private int _counter;
public partial int Counter { get; set; }

private readonly ObservableCollection<StrokeCollection> _undoStack = [];
private readonly ObservableCollection<StrokeCollection> _redoStack = [];
Expand Down Expand Up @@ -77,7 +78,7 @@ public CanvasPage()
{
// Listen for changes in the Strokes property
Strokes.StrokesChanged += Strokes_Changed;
_undoStack.Add(CloneStrokeCollection(_strokes));
_undoStack.Add(CloneStrokeCollection(Strokes));
}

[RelayCommand(CanExecute = nameof(CanClear))]
Expand Down
8 changes: 5 additions & 3 deletions SketchNow/Models/Progress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ namespace SketchNow.Models;
public partial class Progress : ObservableObject
{
[ObservableProperty]
private int _value;
public partial int Value { get; set; }

[ObservableProperty]
private bool _isIndeterminate;
public partial bool IsIndeterminate { get; set; }

[ObservableProperty]
private bool _isVisible;
public partial bool IsVisible { get; set; }
}
8 changes: 4 additions & 4 deletions SketchNow/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ namespace SketchNow.Models;
public partial class Settings : ObservableObject
{
[ObservableProperty]
private bool _isFitToCurve;
public partial bool IsFitToCurve { get; set; }

[ObservableProperty]
private bool _isIgnorePressure;
public partial bool IsIgnorePressure { get; set; }

[ObservableProperty]
private bool _isEraseByStroke;
public partial bool IsEraseByStroke { get; set; }

[ObservableProperty]
private Brush _selectedBackground;
public partial Brush SelectedBackground { get; set; }

public Settings()
{
Expand Down
Loading