Skip to content

Commit

Permalink
Use data bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyfish committed Jun 30, 2024
1 parent 5bd550e commit 94c8eae
Show file tree
Hide file tree
Showing 6 changed files with 1,215 additions and 1,090 deletions.
25 changes: 25 additions & 0 deletions Converters/RadioButtonToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Globalization;
using Avalonia.Data;
using Avalonia.Data.Converters;

namespace HellDivers2OneKeyStratagem;

public class RadioButtonToStringConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is string currentStringValue && parameter is string stringValue)
return currentStringValue == stringValue;

return BindingOperations.DoNothing;
}

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool isChecked && parameter is string stringValue)
if (isChecked)
return stringValue;

return BindingOperations.DoNothing;
}
}
2 changes: 1 addition & 1 deletion Dialogs/InfoWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void SetInfo(string info)

private void InfoWindow_OnClosed(object? sender, EventArgs e)
{
_mainWindow.NotifyInfoWindowClosed();
MainViewModel.Instance.ShowSpeechInfoWindow = false;
}

private void Window_OnPointerPressed(object? sender, PointerPressedEventArgs e)
Expand Down
1 change: 1 addition & 0 deletions HellDivers2OneKeyStratagem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0-rc1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-rc1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0-rc1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="EdgeTTS" Version="1.0.3" />
<PackageReference Include="GlobalHotKeys.Windows" Version="0.1.0" />
Expand Down
Loading

0 comments on commit 94c8eae

Please sign in to comment.