Initial import
This commit is contained in:
Родитель
ce26f49f71
Коммит
5e48cc84d6
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaloniaWhatKey", "AvaloniaWhatKey\AvaloniaWhatKey.csproj", "{C5D03CA1-1F8C-42DB-BE50-9573D3FF8EE1}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{C5D03CA1-1F8C-42DB-BE50-9573D3FF8EE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C5D03CA1-1F8C-42DB-BE50-9573D3FF8EE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C5D03CA1-1F8C-42DB-BE50-9573D3FF8EE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C5D03CA1-1F8C-42DB-BE50-9573D3FF8EE1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,7 @@
|
||||||
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="AvaloniaWhatKey.App">
|
||||||
|
<Application.Styles>
|
||||||
|
<FluentTheme Mode="Light"/>
|
||||||
|
</Application.Styles>
|
||||||
|
</Application>
|
|
@ -0,0 +1,24 @@
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace AvaloniaWhatKey
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnFrameworkInitializationCompleted()
|
||||||
|
{
|
||||||
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
|
{
|
||||||
|
desktop.MainWindow = new MainWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<!--Avalonia doesen't support TrimMode=link currently,but we are working on that https://github.com/AvaloniaUI/Avalonia/issues/6892 -->
|
||||||
|
<TrimMode>copyused</TrimMode>
|
||||||
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove=".gitignore"/>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<!--This helps with theme dll-s trimming.
|
||||||
|
If you will publish your application in self-contained mode with p:PublishTrimmed=true and it will use Fluent theme Default theme will be trimmed from the output and vice versa.
|
||||||
|
https://github.com/AvaloniaUI/Avalonia/issues/5593 -->
|
||||||
|
<TrimmableAssembly Include="Avalonia.Themes.Fluent"/>
|
||||||
|
<TrimmableAssembly Include="Avalonia.Themes.Default"/>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="0.10.18"/>
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="0.10.18"/>
|
||||||
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18"/>
|
||||||
|
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4"/>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,35 @@
|
||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="500"
|
||||||
|
MinWidth="500" MinHeight="400"
|
||||||
|
Width="900" Height="500"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
x:Class="AvaloniaWhatKey.MainWindow"
|
||||||
|
Title="AvaloniaWhatKey">
|
||||||
|
<DockPanel>
|
||||||
|
<TextBlock Text="Press any key to see Key enum value."
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="14"
|
||||||
|
Margin="12"
|
||||||
|
Opacity="0.6"
|
||||||
|
DockPanel.Dock="Bottom" />
|
||||||
|
<Button Content="Copy"
|
||||||
|
Click="CopyButton_OnClick"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="14"
|
||||||
|
Margin="12"
|
||||||
|
Opacity="0.6"
|
||||||
|
IsVisible="{Binding !!#GestureText.Text.Length}"
|
||||||
|
DockPanel.Dock="Bottom" />
|
||||||
|
<TextBlock x:Name="GestureText"
|
||||||
|
Text=""
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="48"
|
||||||
|
Margin="12"/>
|
||||||
|
</DockPanel>
|
||||||
|
</Window>
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
|
||||||
|
namespace AvaloniaWhatKey
|
||||||
|
{
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
AddHandler(KeyDownEvent, OnKeyDown, RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnKeyDown(object? sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
var gesture =
|
||||||
|
(e.KeyModifiers != KeyModifiers.None
|
||||||
|
? e.KeyModifiers.ToString().Replace(", ", "+") + "+"
|
||||||
|
: "")
|
||||||
|
+ "Key."
|
||||||
|
+ e.Key;
|
||||||
|
GestureText.Text = gesture;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CopyButton_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (Application.Current?.Clipboard is { } clipboard)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await clipboard.SetTextAsync(GestureText.Text);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using Avalonia;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AvaloniaWhatKey
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||||
|
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||||
|
// yet and stuff might break.
|
||||||
|
[STAThread]
|
||||||
|
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||||
|
.StartWithClassicDesktopLifetime(args);
|
||||||
|
|
||||||
|
// Avalonia configuration, don't remove; also used by visual designer.
|
||||||
|
public static AppBuilder BuildAvaloniaApp()
|
||||||
|
=> AppBuilder.Configure<App>()
|
||||||
|
.UsePlatformDetect()
|
||||||
|
.LogToTrace();
|
||||||
|
}
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче