Skip to content

Commit

Permalink
Remove abstract on BackRequested even in NavigableViewModel to proper…
Browse files Browse the repository at this point in the history
…ly fix warnings
  • Loading branch information
Mrcubix committed Oct 9, 2024
1 parent df9e1ed commit 86f7395
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 47 deletions.
7 changes: 0 additions & 7 deletions Touch-Gestures.UX/ViewModels/BindingsOverviewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public BindingsOverviewViewModel()
IsReady = false;

NextViewModel = this;
BackRequested = null!;
}

public BindingsOverviewViewModel(MainViewModel mainViewModel)
Expand All @@ -83,7 +82,6 @@ public BindingsOverviewViewModel(MainViewModel mainViewModel)
_parentViewModel.Disconnected += OnDisconnected;

NextViewModel = this;
BackRequested = null!;
}

public BindingsOverviewViewModel(MainViewModel mainViewModel, SerializableSettings settings) : this(mainViewModel)
Expand All @@ -94,10 +92,6 @@ public BindingsOverviewViewModel(MainViewModel mainViewModel, SerializableSettin
#region Events

private event EventHandler? TabletChanged;

#pragma warning disable CS0067,CS8632
public override event EventHandler? BackRequested;
#pragma warning restore CS0067,CS8632
public event EventHandler<EventArgs>? SaveRequested;
public event EventHandler<SerializableProfile>? ProfileChanged;

Expand Down Expand Up @@ -480,7 +474,6 @@ public void Dispose()

SaveRequested = null;
ProfileChanged = null;
BackRequested = null;

GC.SuppressFinalize(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public partial class GestureSetupViewModel : NavigableViewModel, IDisposable

public GestureSetupViewModel()
{
BackRequested = null!;

CanGoBack = true;
CanGoNext = false;

Expand All @@ -98,8 +96,6 @@ protected virtual void SubscribeToSettingsChanges()

#region Events

public override event EventHandler? BackRequested;

public event EventHandler? SetupCompleted;

public event EventHandler? EditCompleted;
Expand Down Expand Up @@ -146,8 +142,6 @@ public int SelectedGestureSetupPickIndex

#region Methods

protected override void GoBack() => BackRequested?.Invoke(this, EventArgs.Empty);

[RelayCommand(CanExecute = nameof(CanGoNext))]
protected virtual void GoNext() => throw new NotImplementedException("GoNext has not been overriden.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ public string SearchText

#endregion

#region Events

public override event EventHandler? BackRequested;

#endregion

#region Methods

public void HideMultiTouchTiles(bool isMultiTouch = true)
Expand All @@ -90,8 +84,6 @@ public void HideMultiTouchTiles(bool isMultiTouch = true)
gestureTileViewModel.IsEnabled = isMultiTouch || gestureTileViewModel.IsMultiTouchOnly == false;
}

protected override void GoBack() => BackRequested?.Invoke(this, EventArgs.Empty);

#endregion

#region Event Handlers
Expand Down
14 changes: 2 additions & 12 deletions Touch-Gestures.UX/ViewModels/GestureSetupScreenViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,7 @@ public partial class GestureSetupScreenViewModel : NavigableViewModel
{
#region Constructors

public GestureSetupScreenViewModel()
{
BackRequested = null!;
CanGoBack = true;
}

#endregion

#region Events

public override event EventHandler? BackRequested;
public GestureSetupScreenViewModel() => CanGoBack = true;

#endregion

Expand Down Expand Up @@ -54,7 +44,7 @@ protected override void GoBack()
if (NextViewModel != null)
NextViewModel.BackRequested -= OnBackRequestedAhead;

BackRequested?.Invoke(this, EventArgs.Empty);
base.GoBack();
}

#endregion
Expand Down
6 changes: 3 additions & 3 deletions Touch-Gestures.UX/ViewModels/GestureSetupWizardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public GestureSetupWizardViewModel(bool isMultiTouch = true)
GestureSelectionScreenViewModel.GestureSelected += OnGestureSelected;
GestureSelectionScreenViewModel.HideMultiTouchTiles(isMultiTouch);

CanGoBack = true;

//GestureSetupScreenViewModel.BackRequested += OnBackRequestedAhead;
}

Expand All @@ -62,8 +64,6 @@ public GestureSetupWizardViewModel(Rect bounds, bool isMultiTouch = true) : this

#region Events

public override event EventHandler? BackRequested;

public event EventHandler<GestureAddedEventArgs>? SetupCompleted;

public event EventHandler<GestureChangedEventArgs>? EditCompleted;
Expand All @@ -77,7 +77,7 @@ protected override void GoBack()
if (NextViewModel is GestureSetupScreenViewModel && _editedGesture == null)
NextViewModel = GestureSelectionScreenViewModel;
else if (NextViewModel is GestureSelectionScreenViewModel || NextViewModel is GestureSetupScreenViewModel)
BackRequested?.Invoke(this, EventArgs.Empty);
base.GoBack();
}

/// <summary>
Expand Down
9 changes: 0 additions & 9 deletions Touch-Gestures.UX/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
using System.Linq;
using TouchGestures.Lib.Entities;
using System.Threading;
using TouchGestures.UX.Events;
using Avalonia.Threading;
using System.Numerics;
using Avalonia;
using Newtonsoft.Json;
using TouchGestures.Lib.Converters;
using TouchGestures.Lib.Entities.Tablet;
Expand Down Expand Up @@ -120,12 +117,6 @@ private void InitializeClient()

public event EventHandler<SerializableSettings>? SettingsChanged;

#pragma warning disable CS0067,CS8632

public override event EventHandler? BackRequested;

#pragma warning restore CS0067,CS8632

public event EventHandler? Ready;

public event EventHandler? Disconnected;
Expand Down
8 changes: 6 additions & 2 deletions Touch-Gestures.UX/ViewModels/NavigableViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ namespace TouchGestures.UX.ViewModels;

public abstract partial class NavigableViewModel : ViewModelBase
{
public abstract event EventHandler? BackRequested;
public event EventHandler? BackRequested;

public bool CanGoBack { get; init; }

[ObservableProperty]
protected NavigableViewModel? _nextViewModel = null;

[RelayCommand(CanExecute = nameof(CanGoBack))]
protected abstract void GoBack();
protected virtual void GoBack()
{
if (CanGoBack)
BackRequested?.Invoke(this, EventArgs.Empty);
}
}

0 comments on commit 86f7395

Please sign in to comment.