Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
Migrated to 11.0.0-preview8
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Jul 19, 2023
1 parent 3ab9f21 commit 0c66691
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions TAS.Avalonia/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://AvaloniaEdit/AvaloniaEdit.xaml" />
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
</Application.Styles>

<Application.Resources>
<FontFamily x:Key="CodeFontFamily">Cascadia Code,Consolas,Menlo,Monospace</FontFamily>
<converters:NativeMenuConverter x:Key="NativeMenuConverter" />
Expand Down
8 changes: 6 additions & 2 deletions TAS.Avalonia/Editing/TASEditingCommandHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Globalization;
using Avalonia;
using Avalonia.Input;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using AvaloniaEdit;
using AvaloniaEdit.Document;
using AvaloniaEdit.Editing;
Expand All @@ -15,6 +17,8 @@ internal class TASEditingCommandHandler {
private static readonly List<RoutedCommandBinding> CommandBindings = new List<RoutedCommandBinding>();
private static readonly List<KeyBinding> KeyBindings = new List<KeyBinding>();

private static Window _window => (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;

public static TextAreaInputHandler Create(TextArea textArea) {
var areaInputHandler = new TextAreaInputHandler(textArea);
areaInputHandler.CommandBindings.AddRange(CommandBindings);
Expand Down Expand Up @@ -291,7 +295,7 @@ private static bool CopySelectedText(TextArea textArea) {

private static void SetClipboardText(string text) {
try {
Application.Current.Clipboard.SetTextAsync(text).GetAwaiter().GetResult();
_window.Clipboard.SetTextAsync(text).GetAwaiter().GetResult();
} catch (Exception) {
}
}
Expand Down Expand Up @@ -321,7 +325,7 @@ private static async void OnPaste(object target, ExecutedRoutedEventArgs args) {
textArea.Document.BeginUpdate();
string text = null;
try {
text = await Application.Current.Clipboard.GetTextAsync();
text = await _window.Clipboard.GetTextAsync();
} catch (Exception) {
textArea.Document.EndUpdate();
textArea = null;
Expand Down
5 changes: 3 additions & 2 deletions TAS.Avalonia/Models/MenuModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public MenuItem ToMenuItem() {
IsVisible = IsVisible,
};

if (Items.Any()) menuItem.Items = Items.ToMenu();
if (Items.Any())
menuItem.ItemsSource = Items.ToMenu();

return menuItem;
}
Expand All @@ -83,6 +84,6 @@ public static IEnumerable<Control> ToMenu(this IEnumerable<MenuModel> self) =>

public static ContextMenu ToContextMenu(this IEnumerable<MenuModel> self) =>
new ContextMenu {
Items = self.ToMenu()
ItemsSource = self.ToMenu()
};
}
22 changes: 10 additions & 12 deletions TAS.Avalonia/TAS.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<NSPrincipalClass>NSApplication</NSPrincipalClass>
<NSHighResolutionCapable>true</NSHighResolutionCapable>
</PropertyGroup>

<ItemGroup>
<Compile Update="**\*.axaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
Expand All @@ -38,23 +38,21 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Xaml.Interactions" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview5" />
<!-- <PackageReference Include="Avalonia.Themes.Simple" Version="11.0.0-preview5" /> -->
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Xaml.Interactions" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview8" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview5" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />

<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.0-preview5" />
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.0-preview6" />
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.0-preview6" />
<PackageReference Include="AvaloniaEdit.TextMate.Grammars" Version="0.10.12" />

<PackageReference Include="ReactiveUI" Version="18.3.1" />

<PackageReference Include="Dialogs.Avalonia" Version="0.1.29" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.5.1" />
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
<PackageReference Include="Dotnet.Bundle" Version="0.9.13" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion TAS.Avalonia/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DockPanel>
<Menu DockPanel.Dock="Top"
IsVisible="{Binding MenuVisible}"
Items="{Binding MainMenu, Converter={StaticResource MenuConverter}}" />
ItemsSource="{Binding MainMenu, Converter={StaticResource MenuConverter}}" />
<controls:EditorControl x:Name="editor" Document="{Binding Document}"
CaretPosition="{Binding CaretPosition, Mode=TwoWay}"
ContextMenu="{Binding EditorContextMenu, Converter={StaticResource ContextMenuConverter}}" />
Expand Down

0 comments on commit 0c66691

Please sign in to comment.