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
14 changes: 8 additions & 6 deletions src/Models/ResetMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ public class ResetMode
{
public static readonly ResetMode[] Supported =
[
new ResetMode("Soft", "Keep all changes. Stage differences", "--soft", Brushes.Green),
new ResetMode("Mixed", "Keep all changes. Unstage differences", "--mixed", Brushes.Orange),
new ResetMode("Merge", "Reset while keeping unmerged changes", "--merge", Brushes.Purple),
new ResetMode("Keep", "Reset while keeping local modifications", "--keep", Brushes.Purple),
new ResetMode("Hard", "Discard all changes", "--hard", Brushes.Red),
new ResetMode("Soft", "Keep all changes. Stage differences", "--soft", 'S', Brushes.Green),
new ResetMode("Mixed", "Keep all changes. Unstage differences", "--mixed", 'M',Brushes.Orange),
new ResetMode("Merge", "Reset while keeping unmerged changes", "--merge", 'G',Brushes.Purple),
new ResetMode("Keep", "Reset while keeping local modifications", "--keep", 'K',Brushes.Purple),
new ResetMode("Hard", "Discard all changes", "--hard", 'H',Brushes.Red),
];

public string Name { get; set; }
public string Desc { get; set; }
public string Arg { get; set; }
public char Key { get; set; }
public IBrush Color { get; set; }

public ResetMode(string n, string d, string a, IBrush b)
public ResetMode(string n, string d, string a, char k, IBrush b)
{
Name = n;
Desc = d;
Arg = a;
Key = k;
Color = b;
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/Views/Reset.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:c="using:SourceGit.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.Reset"
Loaded="Control_OnLoaded"
x:DataType="vm:Reset">
<StackPanel Orientation="Vertical" Margin="8,0">
<TextBlock FontSize="18"
Expand Down Expand Up @@ -36,17 +37,19 @@
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Text="{DynamicResource Text.Reset.Mode}"/>
<ComboBox Grid.Row="2" Grid.Column="1"
<ComboBox x:Name="ResetMode" Grid.Row="2" Grid.Column="1"
Height="28" Padding="8,0"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
KeyDown="InputElement_OnKeyDown"
ItemsSource="{Binding Source={x:Static m:ResetMode.Supported}}"
SelectedItem="{Binding SelectedMode, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate DataType="m:ResetMode">
<Grid ColumnDefinitions="16,60,*">
<Ellipse Grid.Column="0" Width="12" Height="12" Fill="{Binding Color}"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="4,0,0,0"/>
<TextBlock Grid.Column="2" Text="{Binding Desc}" FontSize="11" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="2,0,0,0"/>
<TextBlock Grid.Column="2" Text="{Binding Desc}" Margin="2,0,16,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="3" Text="{Binding Key}" FontSize="11" FontWeight="Bold" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
Expand Down
27 changes: 27 additions & 0 deletions src/Views/Reset.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System.Linq;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using SourceGit.Models;

namespace SourceGit.Views
{
Expand All @@ -8,5 +12,28 @@
{
InitializeComponent();
}

private void InputElement_OnKeyDown(object sender, KeyEventArgs e)
{
var key = e.Key.ToString().ToLower();

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows x64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows x64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows x64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows ARM64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows ARM64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows ARM64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Intel)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Intel)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Intel)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Apple Silicon)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Apple Silicon)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Apple Silicon)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux (arm64)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux (arm64)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 18 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux (arm64)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
foreach (var item in ResetMode.ItemsSource)
{
if (item.GetType() == typeof(ResetMode))
{
var resetMode = (ResetMode)item;
if (resetMode.Key.ToString().ToLower() == key)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows x64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows x64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows x64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows ARM64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows ARM64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Windows ARM64

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Intel)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Intel)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Intel)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Apple Silicon)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Apple Silicon)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build macOS (Apple Silicon)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux (arm64)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux (arm64)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in src/Views/Reset.axaml.cs

View workflow job for this annotation

GitHub Actions / Build / Build Linux (arm64)

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Reset.InputElement_OnKeyDown(object, KeyEventArgs)' with a call to 'string.ToLower(CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
{
ResetMode.SelectedValue = resetMode;
return;
}

}
}
}

private void Control_OnLoaded(object sender, RoutedEventArgs e)
{
ResetMode.Focus();
}
}
}