Skip to content
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
6 changes: 3 additions & 3 deletions src/Nullinside.TwitchStreamingTools/Controls/Keybind.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
x:Class="Nullinside.TwitchStreamingTools.Controls.Keybind"
x:DataType="viewModels:KeybindViewModel">
<StackPanel>
<Button IsVisible="{Binding !Listening}"
<Button IsVisible="{Binding !Listening}"
Content="{Binding Keybind, TargetNullValue='[None]'}"
Command="{Binding ListenForKeystroke}"
Command="{Binding StartListenKeystrokeCommand}"
ToolTip.Tip="ESC to unset" />
<StackPanel IsVisible="{Binding Listening}"
Orientation="Horizontal">
<controls:Loading Width="25"
<controls:Loading Width="25"
Height="25" />
<Label>Press a key...</Label>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Reactive;

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

using Nullinside.TwitchStreamingTools.Models;
using Nullinside.TwitchStreamingTools.Services;
using Nullinside.TwitchStreamingTools.ViewModels;

using ReactiveUI;

Expand All @@ -11,7 +13,7 @@ namespace Nullinside.TwitchStreamingTools.Controls.ViewModels;
/// <summary>
/// Handles storing information required to visualize a keybind.
/// </summary>
public class KeybindViewModel : ViewModelBase {
public partial class KeybindViewModel : ObservableObject {
/// <summary>
/// The listener for keystrokes on the keyboard.
/// </summary>
Expand All @@ -20,46 +22,25 @@ public class KeybindViewModel : ViewModelBase {
/// <summary>
/// The keybind, if set.
/// </summary>
private Keybind? _keybind;
[ObservableProperty] private Keybind? _keybind;

/// <summary>
/// True if listening for keystrokes, false otherwise.
/// </summary>
private bool _listening;
[ObservableProperty] private bool _listening;

/// <summary>
/// Initializes a new instance of the <see cref="KeybindViewModel" /> class.
/// </summary>
/// <param name="service">The listener for keystrokes on the keyboard.</param>
public KeybindViewModel(IGlobalKeyPressService service) {
_service = service;
ListenForKeystroke = ReactiveCommand.Create(StartListenKeystroke);
}

/// <summary>
/// The keybind.
/// </summary>
public Keybind? Keybind {
get => _keybind;
set => this.RaiseAndSetIfChanged(ref _keybind, value);
}

/// <summary>
/// True if listening for keystrokes, false otherwise.
/// </summary>
public bool Listening {
get => _listening;
set => this.RaiseAndSetIfChanged(ref _listening, value);
}

/// <summary>
/// Listens for keystrokes.
/// </summary>
public ReactiveCommand<Unit, Unit> ListenForKeystroke { get; }

/// <summary>
/// Starts listening for keystrokes.
/// </summary>
[RelayCommand]
private void StartListenKeystroke() {
Listening = true;
_service.OnKeystroke -= OnKeystroke;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using System.Collections.ObjectModel;

using Nullinside.TwitchStreamingTools.ViewModels;
using CommunityToolkit.Mvvm.ComponentModel;

using ReactiveUI;
using Nullinside.TwitchStreamingTools.ViewModels;

namespace Nullinside.TwitchStreamingTools.Controls.ViewModels;

/// <summary>
/// Handles maintaining two lists and moving items between them.
/// </summary>
public class TwoListViewModel : ViewModelBase {
public partial class TwoListViewModel : ViewModelBase {
/// <summary>
/// The behavior to maintain when double clicking
/// </summary>
Expand All @@ -26,44 +26,50 @@ public enum DoubleClickBehavior {
DELETE_FROM_LIST
}

private string? _leftHeader;
/// <summary>
/// The header on the left list.
/// </summary>
[ObservableProperty] private string? _leftHeader;

/// <summary>
/// The collection of items in the left list.
/// </summary>
private ObservableCollection<string> _leftList;
[ObservableProperty] private ObservableCollection<string> _leftList;

/// <summary>
/// The method to call when an item in the left list is double clicked.
/// </summary>
private Action<string?>? _onLeftDoubleClick;
[ObservableProperty] private Action<string?>? _onLeftDoubleClick;

/// <summary>
/// The method to call when an item in the right list is double clicked.
/// </summary>
private Action<string?>? _onRightDoubleClick;
[ObservableProperty] private Action<string?>? _onRightDoubleClick;

private string? _rightHeader;
/// <summary>
/// The header on the right list.
/// </summary>
[ObservableProperty] private string? _rightHeader;

/// <summary>
/// The collection of items in the right list.
/// </summary>
private ObservableCollection<string> _rightList;
[ObservableProperty] private ObservableCollection<string> _rightList;

/// <summary>
/// The behavior of how to handle double clicking on items in the right list.
/// </summary>
private DoubleClickBehavior _rightListBehavior;
[ObservableProperty] private DoubleClickBehavior _rightListBehavior;

/// <summary>
/// A value indicating whether the left list should be sorted.
/// </summary>
private bool _sortLeftList;
[ObservableProperty] private bool _sortLeftList;

/// <summary>
/// A value indicating whether the right list should be sorted.
/// </summary>
private bool _sortRightList;
[ObservableProperty] private bool _sortRightList;

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

/// <summary>
/// Gets or sets the collection of items in the left list.
/// </summary>
public ObservableCollection<string> LeftList {
get => _leftList;
set => this.RaiseAndSetIfChanged(ref _leftList, value);
}

/// <summary>
/// Gets or sets the collection of items in the right list.
/// </summary>
public Action<string?>? OnLeftDoubleClick {
get => _onLeftDoubleClick;
set => this.RaiseAndSetIfChanged(ref _onLeftDoubleClick, value);
}

/// <summary>
/// Gets or sets the method to call when an item in the left list is double clicked.
/// </summary>
public Action<string?>? OnRightDoubleClick {
get => _onRightDoubleClick;
set => this.RaiseAndSetIfChanged(ref _onRightDoubleClick, value);
}

/// <summary>
/// Gets or sets the method to call when an item in the right list is double clicked.
/// </summary>
public ObservableCollection<string> RightList {
get => _rightList;
set => this.RaiseAndSetIfChanged(ref _rightList, value);
}

/// <summary>
/// Gets or sets the behavior of how to handle double clicking on items in the right list.
/// </summary>
public DoubleClickBehavior RightListBehavior {
get => _rightListBehavior;
set => this.RaiseAndSetIfChanged(ref _rightListBehavior, value);
}

/// <summary>
/// Gets or sets a value indicating whether the left list should be sorted.
/// </summary>
public bool SortLeftList {
get => _sortLeftList;
set => this.RaiseAndSetIfChanged(ref _sortLeftList, value);
}

/// <summary>
/// Gets or sets a value indicating whether the right list should be sorted.
/// </summary>
public bool SortRightList {
get => _sortRightList;
set => this.RaiseAndSetIfChanged(ref _sortRightList, value);
}

/// <summary>
/// The left header.
/// </summary>
public string? LeftHeader {
get => _leftHeader;
set => this.RaiseAndSetIfChanged(ref _leftHeader, value);
}

/// <summary>
/// The right header.
/// </summary>
public string? RightHeader {
get => _rightHeader;
set => this.RaiseAndSetIfChanged(ref _rightHeader, value);
}

/// <summary>
/// Adds an item to the left list.
/// </summary>
Expand Down
32 changes: 8 additions & 24 deletions src/Nullinside.TwitchStreamingTools/Models/PhoneticWord.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Nullinside.TwitchStreamingTools.ViewModels;
using Nullinside.TwitchStreamingTools.ViewModels.Pages.SettingsView;
using CommunityToolkit.Mvvm.ComponentModel;

using ReactiveUI;
using Nullinside.TwitchStreamingTools.ViewModels;
using Nullinside.TwitchStreamingTools.ViewModels.Pages.SettingsView;

namespace Nullinside.TwitchStreamingTools.Models;

/// <summary>
/// A representation of a word that needs to be pronounced phonetically.
/// </summary>
public class PhoneticWord : ViewModelBase {
public partial class PhoneticWord : ViewModelBase {
/// <summary>
/// The view model that owns this object.
/// </summary>
Expand All @@ -17,12 +17,12 @@ public class PhoneticWord : ViewModelBase {
/// <summary>
/// The phonetic pronunciation of the word.
/// </summary>
private string _phonetic;
[ObservableProperty] private string _phonetic;

/// <summary>
/// The word to pronounce phonetically.
/// </summary>
private string _word;
[ObservableProperty] private string _word;

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

/// <summary>
/// Gets or sets the phonetic pronunciation of the word.
/// </summary>
public string Phonetic {
get => _phonetic;
set => this.RaiseAndSetIfChanged(ref _phonetic, value);
}

/// <summary>
/// Gets or sets the word to pronounce phonetically.
/// </summary>
public string Word {
get => _word;
set => this.RaiseAndSetIfChanged(ref _word, value);
}

/// <summary>
/// Deletes this word from the list.
/// </summary>
public void DeletePhonetic() {
_viewModel.DeletePhonetic(_word);
_viewModel.DeletePhonetic(Word);
}

/// <summary>
/// Edits this word in the list.
/// </summary>
public void EditPhonetic() {
_viewModel.EditPhonetic(_word);
_viewModel.EditPhonetic(Word);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.6"/>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.6"/>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/>
<PackageReference Include="DynamicData" Version="9.4.1"/>
<PackageReference Include="log4net" Version="3.2.0"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9"/>
<PackageReference Include="NAudio.Wasapi" Version="2.2.1"/>
<PackageReference Include="NAudio.WinMM" Version="2.2.1"/>
<PackageReference Include="PInvoke.User32" Version="0.7.124"/>
<PackageReference Include="System.Speech" Version="9.0.9"/>
<PackageReference Include="Xaml.Behaviors.Avalonia" Version="11.3.6.4"/>
<PackageReference Include="Xaml.Behaviors.Interactivity" Version="11.3.6.4"/>
</ItemGroup>

<ItemGroup>
Expand Down
Loading