Skip to content

Commit

Permalink
Merge pull request #335 from AvaloniaUI/updateToRc
Browse files Browse the repository at this point in the history
Update to Avalonia 11 RC
  • Loading branch information
maxkatz6 authored Jun 1, 2023
2 parents 41ed3f1 + 01257d1 commit 33d7342
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AvaloniaVersion>11.0.0-preview8</AvaloniaVersion>
<AvaloniaVersion>11.0.0-rc1.1</AvaloniaVersion>
<TextMateSharpVersion>1.0.55</TextMateSharpVersion>
<VersionSuffix>beta</VersionSuffix>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AvaloniaEdit.Demo/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public MyCompletionData(string text)
Text = text;
}

public IBitmap Image => null;
public Bitmap Image => null;

public string Text { get; }

Expand Down
2 changes: 1 addition & 1 deletion src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected override void OnKeyDown(KeyEventArgs e)
private void TextArea_PreviewTextInput(object sender, TextInputEventArgs e)
{
e.Handled = RaiseEventPair(this, null, TextInputEvent,
new TextInputEventArgs { Device = e.Device, Text = e.Text });
new TextInputEventArgs { Text = e.Text });
}

private void TextArea_MouseWheel(object sender, PointerWheelEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,15 @@ public override void OnPreviewKeyDown(KeyEventArgs e)
if (e.Key == Key.DeadCharProcessed)
return;
e.Handled = RaiseEventPair(Window, null, KeyDownEvent,
new KeyEventArgs { Device = e.Device, Key = e.Key });
new KeyEventArgs { Key = e.Key });
}

public override void OnPreviewKeyUp(KeyEventArgs e)
{
if (e.Key == Key.DeadCharProcessed)
return;
e.Handled = RaiseEventPair(Window, null, KeyUpEvent,
new KeyEventArgs { Device = e.Device, Key = e.Key });
new KeyEventArgs { Key = e.Key });
}
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion src/AvaloniaEdit/CodeCompletion/ICompletionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface ICompletionData
/// <summary>
/// Gets the image.
/// </summary>
IBitmap Image { get; }
Bitmap Image { get; }

/// <summary>
/// Gets the text. This property is used to filter the list of visible elements.
Expand Down
2 changes: 1 addition & 1 deletion src/AvaloniaEdit/Editing/CaretNavigationCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private static void AddBinding(RoutedCommand command, KeyGesture gesture, EventH

static CaretNavigationCommandHandler()
{
var keymap = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>();
var keymap = Application.Current.PlatformSettings.HotkeyConfiguration;

AddBinding(EditingCommands.MoveLeftByCharacter, KeyModifiers.None, Key.Left, OnMoveCaret(CaretMovementType.CharLeft));
AddBinding(EditingCommands.SelectLeftByCharacter, keymap.SelectionModifiers, Key.Left, OnMoveCaretExtendSelection(CaretMovementType.CharLeft));
Expand Down
13 changes: 10 additions & 3 deletions src/AvaloniaEdit/RoutedCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using Avalonia;
using Avalonia.Input;
using Avalonia.Interactivity;

namespace AvaloniaEdit
{
public class RoutedCommand : ICommand
{
private static IInputElement _inputElement;

public string Name { get; }
public KeyGesture Gesture { get; }

Expand All @@ -23,6 +24,7 @@ static RoutedCommand()
{
CanExecuteEvent.AddClassHandler<Interactive>(CanExecuteEventHandler);
ExecutedEvent.AddClassHandler<Interactive>(ExecutedEventHandler);
InputElement.GotFocusEvent.AddClassHandler<Interactive>(GotFocusEventHandler);
}

private static void CanExecuteEventHandler(Interactive control, CanExecuteRoutedEventArgs args)
Expand All @@ -46,6 +48,11 @@ private static void ExecutedEventHandler(Interactive control, ExecutedRoutedEven
}
}

private static void GotFocusEventHandler(Interactive control, GotFocusEventArgs args)
{
_inputElement = control as IInputElement;
}

public static RoutedEvent<CanExecuteRoutedEventArgs> CanExecuteEvent { get; } = RoutedEvent.Register<CanExecuteRoutedEventArgs>(nameof(CanExecuteEvent), RoutingStrategies.Bubble, typeof(RoutedCommand));

public bool CanExecute(object parameter, IInputElement target)
Expand All @@ -60,7 +67,7 @@ public bool CanExecute(object parameter, IInputElement target)

bool ICommand.CanExecute(object parameter)
{
return CanExecute(parameter, Application.Current.FocusManager.Current);
return CanExecute(parameter, _inputElement);
}

public static RoutedEvent<ExecutedRoutedEventArgs> ExecutedEvent { get; } = RoutedEvent.Register<ExecutedRoutedEventArgs>(nameof(ExecutedEvent), RoutingStrategies.Bubble, typeof(RoutedCommand));
Expand All @@ -75,7 +82,7 @@ public void Execute(object parameter, IInputElement target)

void ICommand.Execute(object parameter)
{
Execute(parameter, Application.Current.FocusManager.Current);
Execute(parameter, _inputElement);
}

// TODO
Expand Down
8 changes: 4 additions & 4 deletions test/AvaloniaEdit.Tests/AvaloniaEdit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.999-cibuild0034510-beta" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.999-cibuild0034510-beta" />
<PackageReference Include="Avalonia.Themes.Simple" Version="11.0.999-cibuild0034510-beta" />
<PackageReference Include="Avalonia.Headless.NUnit" Version="11.0.999-cibuild0034510-beta" />
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Headless.NUnit" Version="$(AvaloniaVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NUnit" Version="3.13.2" />
Expand Down

0 comments on commit 33d7342

Please sign in to comment.