Skip to content

Commit 4077762

Browse files
Merge pull request #133 from nullinside-development-group/feat/rtfm
Feat/rtfm
2 parents 282b72c + 04bf92c commit 4077762

18 files changed

+151
-514
lines changed

src/Nullinside.TwitchStreamingTools/Controls/Keybind.axaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
x:Class="Nullinside.TwitchStreamingTools.Controls.Keybind"
99
x:DataType="viewModels:KeybindViewModel">
1010
<StackPanel>
11-
<Button IsVisible="{Binding !Listening}"
11+
<Button IsVisible="{Binding !Listening}"
1212
Content="{Binding Keybind, TargetNullValue='[None]'}"
13-
Command="{Binding ListenForKeystroke}"
13+
Command="{Binding StartListenKeystrokeCommand}"
1414
ToolTip.Tip="ESC to unset" />
1515
<StackPanel IsVisible="{Binding Listening}"
1616
Orientation="Horizontal">
17-
<controls:Loading Width="25"
17+
<controls:Loading Width="25"
1818
Height="25" />
1919
<Label>Press a key...</Label>
2020
</StackPanel>

src/Nullinside.TwitchStreamingTools/Controls/ViewModels/KeybindViewModel.cs

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System.Reactive;
22

3+
using CommunityToolkit.Mvvm.ComponentModel;
4+
using CommunityToolkit.Mvvm.Input;
5+
36
using Nullinside.TwitchStreamingTools.Models;
47
using Nullinside.TwitchStreamingTools.Services;
5-
using Nullinside.TwitchStreamingTools.ViewModels;
68

79
using ReactiveUI;
810

@@ -11,7 +13,7 @@ namespace Nullinside.TwitchStreamingTools.Controls.ViewModels;
1113
/// <summary>
1214
/// Handles storing information required to visualize a keybind.
1315
/// </summary>
14-
public class KeybindViewModel : ViewModelBase {
16+
public partial class KeybindViewModel : ObservableObject {
1517
/// <summary>
1618
/// The listener for keystrokes on the keyboard.
1719
/// </summary>
@@ -20,46 +22,25 @@ public class KeybindViewModel : ViewModelBase {
2022
/// <summary>
2123
/// The keybind, if set.
2224
/// </summary>
23-
private Keybind? _keybind;
25+
[ObservableProperty] private Keybind? _keybind;
2426

2527
/// <summary>
2628
/// True if listening for keystrokes, false otherwise.
2729
/// </summary>
28-
private bool _listening;
30+
[ObservableProperty] private bool _listening;
2931

3032
/// <summary>
3133
/// Initializes a new instance of the <see cref="KeybindViewModel" /> class.
3234
/// </summary>
3335
/// <param name="service">The listener for keystrokes on the keyboard.</param>
3436
public KeybindViewModel(IGlobalKeyPressService service) {
3537
_service = service;
36-
ListenForKeystroke = ReactiveCommand.Create(StartListenKeystroke);
3738
}
3839

39-
/// <summary>
40-
/// The keybind.
41-
/// </summary>
42-
public Keybind? Keybind {
43-
get => _keybind;
44-
set => this.RaiseAndSetIfChanged(ref _keybind, value);
45-
}
46-
47-
/// <summary>
48-
/// True if listening for keystrokes, false otherwise.
49-
/// </summary>
50-
public bool Listening {
51-
get => _listening;
52-
set => this.RaiseAndSetIfChanged(ref _listening, value);
53-
}
54-
55-
/// <summary>
56-
/// Listens for keystrokes.
57-
/// </summary>
58-
public ReactiveCommand<Unit, Unit> ListenForKeystroke { get; }
59-
6040
/// <summary>
6141
/// Starts listening for keystrokes.
6242
/// </summary>
43+
[RelayCommand]
6344
private void StartListenKeystroke() {
6445
Listening = true;
6546
_service.OnKeystroke -= OnKeystroke;

src/Nullinside.TwitchStreamingTools/Controls/ViewModels/TwoListViewModel.cs

Lines changed: 18 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
using System;
22
using System.Collections.ObjectModel;
33

4-
using Nullinside.TwitchStreamingTools.ViewModels;
4+
using CommunityToolkit.Mvvm.ComponentModel;
55

6-
using ReactiveUI;
6+
using Nullinside.TwitchStreamingTools.ViewModels;
77

88
namespace Nullinside.TwitchStreamingTools.Controls.ViewModels;
99

1010
/// <summary>
1111
/// Handles maintaining two lists and moving items between them.
1212
/// </summary>
13-
public class TwoListViewModel : ViewModelBase {
13+
public partial class TwoListViewModel : ViewModelBase {
1414
/// <summary>
1515
/// The behavior to maintain when double clicking
1616
/// </summary>
@@ -26,44 +26,50 @@ public enum DoubleClickBehavior {
2626
DELETE_FROM_LIST
2727
}
2828

29-
private string? _leftHeader;
29+
/// <summary>
30+
/// The header on the left list.
31+
/// </summary>
32+
[ObservableProperty] private string? _leftHeader;
3033

3134
/// <summary>
3235
/// The collection of items in the left list.
3336
/// </summary>
34-
private ObservableCollection<string> _leftList;
37+
[ObservableProperty] private ObservableCollection<string> _leftList;
3538

3639
/// <summary>
3740
/// The method to call when an item in the left list is double clicked.
3841
/// </summary>
39-
private Action<string?>? _onLeftDoubleClick;
42+
[ObservableProperty] private Action<string?>? _onLeftDoubleClick;
4043

4144
/// <summary>
4245
/// The method to call when an item in the right list is double clicked.
4346
/// </summary>
44-
private Action<string?>? _onRightDoubleClick;
47+
[ObservableProperty] private Action<string?>? _onRightDoubleClick;
4548

46-
private string? _rightHeader;
49+
/// <summary>
50+
/// The header on the right list.
51+
/// </summary>
52+
[ObservableProperty] private string? _rightHeader;
4753

4854
/// <summary>
4955
/// The collection of items in the right list.
5056
/// </summary>
51-
private ObservableCollection<string> _rightList;
57+
[ObservableProperty] private ObservableCollection<string> _rightList;
5258

5359
/// <summary>
5460
/// The behavior of how to handle double clicking on items in the right list.
5561
/// </summary>
56-
private DoubleClickBehavior _rightListBehavior;
62+
[ObservableProperty] private DoubleClickBehavior _rightListBehavior;
5763

5864
/// <summary>
5965
/// A value indicating whether the left list should be sorted.
6066
/// </summary>
61-
private bool _sortLeftList;
67+
[ObservableProperty] private bool _sortLeftList;
6268

6369
/// <summary>
6470
/// A value indicating whether the right list should be sorted.
6571
/// </summary>
66-
private bool _sortRightList;
72+
[ObservableProperty] private bool _sortRightList;
6773

6874
/// <summary>
6975
/// Initializes a new instance of the <see cref="TwoListViewModel" /> class.
@@ -75,78 +81,6 @@ public TwoListViewModel() {
7581
OnRightDoubleClick += OnRightDoubleClicked;
7682
}
7783

78-
/// <summary>
79-
/// Gets or sets the collection of items in the left list.
80-
/// </summary>
81-
public ObservableCollection<string> LeftList {
82-
get => _leftList;
83-
set => this.RaiseAndSetIfChanged(ref _leftList, value);
84-
}
85-
86-
/// <summary>
87-
/// Gets or sets the collection of items in the right list.
88-
/// </summary>
89-
public Action<string?>? OnLeftDoubleClick {
90-
get => _onLeftDoubleClick;
91-
set => this.RaiseAndSetIfChanged(ref _onLeftDoubleClick, value);
92-
}
93-
94-
/// <summary>
95-
/// Gets or sets the method to call when an item in the left list is double clicked.
96-
/// </summary>
97-
public Action<string?>? OnRightDoubleClick {
98-
get => _onRightDoubleClick;
99-
set => this.RaiseAndSetIfChanged(ref _onRightDoubleClick, value);
100-
}
101-
102-
/// <summary>
103-
/// Gets or sets the method to call when an item in the right list is double clicked.
104-
/// </summary>
105-
public ObservableCollection<string> RightList {
106-
get => _rightList;
107-
set => this.RaiseAndSetIfChanged(ref _rightList, value);
108-
}
109-
110-
/// <summary>
111-
/// Gets or sets the behavior of how to handle double clicking on items in the right list.
112-
/// </summary>
113-
public DoubleClickBehavior RightListBehavior {
114-
get => _rightListBehavior;
115-
set => this.RaiseAndSetIfChanged(ref _rightListBehavior, value);
116-
}
117-
118-
/// <summary>
119-
/// Gets or sets a value indicating whether the left list should be sorted.
120-
/// </summary>
121-
public bool SortLeftList {
122-
get => _sortLeftList;
123-
set => this.RaiseAndSetIfChanged(ref _sortLeftList, value);
124-
}
125-
126-
/// <summary>
127-
/// Gets or sets a value indicating whether the right list should be sorted.
128-
/// </summary>
129-
public bool SortRightList {
130-
get => _sortRightList;
131-
set => this.RaiseAndSetIfChanged(ref _sortRightList, value);
132-
}
133-
134-
/// <summary>
135-
/// The left header.
136-
/// </summary>
137-
public string? LeftHeader {
138-
get => _leftHeader;
139-
set => this.RaiseAndSetIfChanged(ref _leftHeader, value);
140-
}
141-
142-
/// <summary>
143-
/// The right header.
144-
/// </summary>
145-
public string? RightHeader {
146-
get => _rightHeader;
147-
set => this.RaiseAndSetIfChanged(ref _rightHeader, value);
148-
}
149-
15084
/// <summary>
15185
/// Adds an item to the left list.
15286
/// </summary>
Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using Nullinside.TwitchStreamingTools.ViewModels;
2-
using Nullinside.TwitchStreamingTools.ViewModels.Pages.SettingsView;
1+
using CommunityToolkit.Mvvm.ComponentModel;
32

4-
using ReactiveUI;
3+
using Nullinside.TwitchStreamingTools.ViewModels;
4+
using Nullinside.TwitchStreamingTools.ViewModels.Pages.SettingsView;
55

66
namespace Nullinside.TwitchStreamingTools.Models;
77

88
/// <summary>
99
/// A representation of a word that needs to be pronounced phonetically.
1010
/// </summary>
11-
public class PhoneticWord : ViewModelBase {
11+
public partial class PhoneticWord : ViewModelBase {
1212
/// <summary>
1313
/// The view model that owns this object.
1414
/// </summary>
@@ -17,12 +17,12 @@ public class PhoneticWord : ViewModelBase {
1717
/// <summary>
1818
/// The phonetic pronunciation of the word.
1919
/// </summary>
20-
private string _phonetic;
20+
[ObservableProperty] private string _phonetic;
2121

2222
/// <summary>
2323
/// The word to pronounce phonetically.
2424
/// </summary>
25-
private string _word;
25+
[ObservableProperty] private string _word;
2626

2727
/// <summary>
2828
/// Initializes a new instance of the <see cref="PhoneticWord" /> class.
@@ -36,33 +36,17 @@ public PhoneticWord(TtsPhoneticWordsViewModel viewModel, string word, string pho
3636
_phonetic = phonetic;
3737
}
3838

39-
/// <summary>
40-
/// Gets or sets the phonetic pronunciation of the word.
41-
/// </summary>
42-
public string Phonetic {
43-
get => _phonetic;
44-
set => this.RaiseAndSetIfChanged(ref _phonetic, value);
45-
}
46-
47-
/// <summary>
48-
/// Gets or sets the word to pronounce phonetically.
49-
/// </summary>
50-
public string Word {
51-
get => _word;
52-
set => this.RaiseAndSetIfChanged(ref _word, value);
53-
}
54-
5539
/// <summary>
5640
/// Deletes this word from the list.
5741
/// </summary>
5842
public void DeletePhonetic() {
59-
_viewModel.DeletePhonetic(_word);
43+
_viewModel.DeletePhonetic(Word);
6044
}
6145

6246
/// <summary>
6347
/// Edits this word in the list.
6448
/// </summary>
6549
public void EditPhonetic() {
66-
_viewModel.EditPhonetic(_word);
50+
_viewModel.EditPhonetic(Word);
6751
}
6852
}

src/Nullinside.TwitchStreamingTools/Nullinside.TwitchStreamingTools.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,14 @@
6060
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
6161
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.6"/>
6262
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.6"/>
63+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/>
6364
<PackageReference Include="DynamicData" Version="9.4.1"/>
6465
<PackageReference Include="log4net" Version="3.2.0"/>
6566
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9"/>
6667
<PackageReference Include="NAudio.Wasapi" Version="2.2.1"/>
6768
<PackageReference Include="NAudio.WinMM" Version="2.2.1"/>
6869
<PackageReference Include="PInvoke.User32" Version="0.7.124"/>
6970
<PackageReference Include="System.Speech" Version="9.0.9"/>
70-
<PackageReference Include="Xaml.Behaviors.Avalonia" Version="11.3.6.4"/>
71-
<PackageReference Include="Xaml.Behaviors.Interactivity" Version="11.3.6.4"/>
7271
</ItemGroup>
7372

7473
<ItemGroup>

0 commit comments

Comments
 (0)