105 changed files with 2075 additions and 1125 deletions
@ -1,16 +0,0 @@ |
|||
<Project> |
|||
<ItemGroup Condition="'$(AndroidApplication)' == 'true'"> |
|||
<!-- WORKAROUND: The packages below are transitively referenced by System.Memory, |
|||
but Xamarin.Android applications need the newest versions directly referenced for the linker. --> |
|||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.6.0" /> |
|||
<PackageReference Include="System.Buffers" Version="4.5.0" /> |
|||
</ItemGroup> |
|||
<Target Name="_RemoveNonExistingResgenFile" BeforeTargets="CoreCompile" Condition="'$(_SdkSetAndroidResgenFile)' == 'true' And '$(AndroidResgenFile)' != '' And !Exists('$(AndroidResgenFile)')"> |
|||
<ItemGroup> |
|||
<Compile Remove="$(AndroidResgenFile)"/> |
|||
</ItemGroup> |
|||
</Target> |
|||
<PropertyGroup> |
|||
<DesignTimeBuild>false</DesignTimeBuild> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -1,19 +0,0 @@ |
|||
Any raw assets you want to be deployed with your application can be placed in |
|||
this directory (and child directories) and given a Build Action of "AndroidAsset". |
|||
|
|||
These files will be deployed with your package and will be accessible using Android's |
|||
AssetManager, like this: |
|||
|
|||
public class ReadAsset : Activity |
|||
{ |
|||
protected override void OnCreate (Bundle bundle) |
|||
{ |
|||
base.OnCreate (bundle); |
|||
|
|||
InputStream input = Assets.Open ("my_asset.txt"); |
|||
} |
|||
} |
|||
|
|||
Additionally, some Android functions will automatically load asset files: |
|||
|
|||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
|||
@ -1,165 +1,46 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProductVersion>8.0.30703</ProductVersion> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
<ProjectGuid>{29132311-1848-4FD6-AE0C-4FF841151BD3}</ProjectGuid> |
|||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>ControlCatalog.Android</RootNamespace> |
|||
<AssemblyName>ControlCatalog.Android</AssemblyName> |
|||
<FileAlignment>512</FileAlignment> |
|||
<AndroidApplication>true</AndroidApplication> |
|||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> |
|||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> |
|||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> |
|||
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion> |
|||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> |
|||
<TargetFramework>net6.0-android</TargetFramework> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<OutputType>Exe</OutputType> |
|||
<Nullable>enable</Nullable> |
|||
<ApplicationId>com.Avalonia.ControlCatalog</ApplicationId> |
|||
<ApplicationVersion>1</ApplicationVersion> |
|||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> |
|||
<AndroidPackageFormat>apk</AndroidPackageFormat> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> |
|||
<AndroidLinkMode>None</AndroidLinkMode> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
<BundleAssemblies>False</BundleAssemblies> |
|||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> |
|||
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64</AndroidSupportedAbis> |
|||
<Debugger>Xamarin</Debugger> |
|||
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> |
|||
<AotAssemblies>False</AotAssemblies> |
|||
<EnableLLVM>False</EnableLLVM> |
|||
<EnableProguard>False</EnableProguard> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> |
|||
<AndroidLinkMode>Full</AndroidLinkMode> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
<BundleAssemblies>False</BundleAssemblies> |
|||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> |
|||
<AndroidSupportedAbis>armeabi-v7a,x86;x86_64</AndroidSupportedAbis> |
|||
<Debugger>Xamarin</Debugger> |
|||
<AotAssemblies>False</AotAssemblies> |
|||
<EnableLLVM>False</EnableLLVM> |
|||
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> |
|||
<EnableProguard>False</EnableProguard> |
|||
<DebugSymbols>False</DebugSymbols> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="Mono.Android" /> |
|||
<Reference Include="mscorlib" /> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="MainActivity.cs" /> |
|||
<Compile Include="Resources\Resource.Designer.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<Compile Include="SplashActivity.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="Resources\AboutResources.txt" /> |
|||
<None Include="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<AndroidResource Include="Resources\drawable\splash_screen.xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<AndroidResource Include="Resources\values\colors.xml" /> |
|||
<AndroidResource Include="Resources\values\styles.xml" /> |
|||
<None Remove="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<AndroidResource Include="..\..\build\Assets\Icon.png"> |
|||
<Link>Resources\drawable\Icon.png</Link> |
|||
</AndroidResource> |
|||
</ItemGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''"> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<RunAOTCompilation>False</RunAOTCompilation> |
|||
<EnableLLVM>True</EnableLLVM> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk> |
|||
<RunAOTCompilation>False</RunAOTCompilation> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Include="Properties\AndroidManifest.xml" /> |
|||
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.3" /> |
|||
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel" Version="2.3.1.3" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj"> |
|||
<Project>{7B92AF71-6287-4693-9DCB-BD5B6E927E23}</Project> |
|||
<Name>Avalonia.Android</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj"> |
|||
<Project>{c42d2fc1-a531-4ed4-84b9-89aec7c962fc}</Project> |
|||
<Name>Avalonia.Themes.Fluent</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|||
<Name>Avalonia.Themes.Default</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|||
<Name>Avalonia.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj"> |
|||
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project> |
|||
<Name>Avalonia.Markup</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Skia\Avalonia.Skia\Avalonia.Skia.csproj"> |
|||
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project> |
|||
<Name>Avalonia.Skia</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj"> |
|||
<Project>{d0a739b9-3c68-4ba6-a328-41606954b6bd}</Project> |
|||
<Name>ControlCatalog</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj" /> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\build\Rx.props" /> |
|||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> |
|||
<Import Project="..\..\build\AndroidWorkarounds.props" /> |
|||
<Import Project="..\..\build\LegacyProject.targets" /> |
|||
</Project> |
|||
|
|||
@ -1,5 +1,4 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ControlCatalog.Android" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"> |
|||
<uses-sdk android:targetSdkVersion="30" /> |
|||
<application android:label="ControlCatalog.Android"></application> |
|||
</manifest> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto"> |
|||
<application android:label="ControlCatalog.Android" android:icon="@drawable/Icon"></application> |
|||
</manifest> |
|||
|
|||
@ -1,30 +0,0 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
using Android.App; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("ControlCatalog.Android")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("ControlCatalog.Android")] |
|||
[assembly: AssemblyCopyright("Copyright © 2016")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
[assembly: ComVisible(false)] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -1,101 +0,0 @@ |
|||
#pragma warning disable 1591
|
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
[assembly: global::Android.Runtime.ResourceDesignerAttribute("ControlCatalog.Android.Resource", IsApplication=true)] |
|||
|
|||
namespace ControlCatalog.Android |
|||
{ |
|||
|
|||
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.99.62")] |
|||
public partial class Resource |
|||
{ |
|||
|
|||
static Resource() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
public static void UpdateIdValues() |
|||
{ |
|||
} |
|||
|
|||
public partial class Attribute |
|||
{ |
|||
|
|||
static Attribute() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Attribute() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class Color |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F010000
|
|||
public const int splash_background = 2130771968; |
|||
|
|||
static Color() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Color() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class Drawable |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F020000
|
|||
public const int Icon = 2130837504; |
|||
|
|||
// aapt resource value: 0x7F020001
|
|||
public const int splash_screen = 2130837505; |
|||
|
|||
static Drawable() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Drawable() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class Style |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F030000
|
|||
public const int MyTheme = 2130903040; |
|||
|
|||
// aapt resource value: 0x7F030001
|
|||
public const int MyTheme_NoActionBar = 2130903041; |
|||
|
|||
// aapt resource value: 0x7F030002
|
|||
public const int MyTheme_Splash = 2130903042; |
|||
|
|||
static Style() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Style() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
#pragma warning restore 1591
|
|||
@ -0,0 +1,7 @@ |
|||
<Directives> |
|||
<Application> |
|||
<Assembly Name="ControlCatalog" Dynamic="Required All"></Assembly> |
|||
<Assembly Name="Avalonia.Themes.Default" Dynamic="Required All"></Assembly> |
|||
<Assembly Name="Avalonia.Themes.Fluent" Dynamic="Required All"></Assembly> |
|||
</Application> |
|||
</Directives> |
|||
@ -0,0 +1,23 @@ |
|||
<UserControl x:Class="ControlCatalog.Pages.ClipboardPage" |
|||
xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h2">Example of ClipboardPage capabilities</TextBlock> |
|||
|
|||
<Button Click="CopyText" Content="Copy text to clipboard" /> |
|||
<Button Click="PasteText" Content="Paste text from clipboard" /> |
|||
<Button Click="CopyTextDataObject" Content="Copy text to clipboard (data object)" /> |
|||
<Button Click="PasteTextDataObject" Content="Paste text from clipboard (data object)" /> |
|||
|
|||
<Button Click="CopyFilesDataObject" Content="Copy files to clipboard (data object)" /> |
|||
<Button Click="PasteFilesDataObject" Content="Paste files from clipboard (data object)" /> |
|||
|
|||
<Button Click="GetFormats" Content="Get clipboard formats" /> |
|||
<Button Click="Clear" Content="Clear clipboard" /> |
|||
|
|||
<TextBox x:Name="ClipboardContent" |
|||
MinHeight="100" |
|||
AcceptsReturn="True" |
|||
Watermark="Text to copy of file names per line" /> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,77 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Input; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public partial class ClipboardPage : UserControl |
|||
{ |
|||
public ClipboardPage() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private TextBox ClipboardContent => this.Get<TextBox>("ClipboardContent"); |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
private async void CopyText(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Application.Current.Clipboard.SetTextAsync(ClipboardContent.Text); |
|||
} |
|||
|
|||
private async void PasteText(object sender, RoutedEventArgs args) |
|||
{ |
|||
ClipboardContent.Text = await Application.Current.Clipboard.GetTextAsync(); |
|||
} |
|||
|
|||
private async void CopyTextDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var dataObject = new DataObject(); |
|||
dataObject.Set(DataFormats.Text, ClipboardContent.Text ?? string.Empty); |
|||
await Application.Current.Clipboard.SetDataObjectAsync(dataObject); |
|||
} |
|||
|
|||
private async void PasteTextDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
ClipboardContent.Text = await Application.Current.Clipboard.GetDataAsync(DataFormats.Text) as string ?? string.Empty; |
|||
} |
|||
|
|||
private async void CopyFilesDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var files = ClipboardContent.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); |
|||
if (files.Length == 0) |
|||
{ |
|||
return; |
|||
} |
|||
var dataObject = new DataObject(); |
|||
dataObject.Set(DataFormats.FileNames, files); |
|||
await Application.Current.Clipboard.SetDataObjectAsync(dataObject); |
|||
} |
|||
|
|||
private async void PasteFilesDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var fiels = await Application.Current.Clipboard.GetDataAsync(DataFormats.FileNames) as IEnumerable<string>; |
|||
ClipboardContent.Text = fiels != null ? string.Join(Environment.NewLine, fiels) : string.Empty; |
|||
} |
|||
|
|||
private async void GetFormats(object sender, RoutedEventArgs args) |
|||
{ |
|||
var formats = await Application.Current.Clipboard.GetFormatsAsync(); |
|||
ClipboardContent.Text = string.Join(Environment.NewLine, formats); |
|||
} |
|||
|
|||
private async void Clear(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Application.Current.Clipboard.ClearAsync(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,14 +0,0 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.PlatformSupport; |
|||
|
|||
namespace Avalonia |
|||
{ |
|||
public sealed class AppBuilder : AppBuilderBase<AppBuilder> |
|||
{ |
|||
public AppBuilder() : base(new StandardRuntimePlatform(), |
|||
builder => StandardRuntimePlatformServices.Register(builder.Instance?.GetType()?.Assembly)) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,15 +1,18 @@ |
|||
<Project Sdk="MSBuild.Sdk.Extras"> |
|||
<Project Sdk="Xamarin.Legacy.Sdk"> |
|||
<PropertyGroup> |
|||
<TargetFramework>monoandroid11.0</TargetFramework> |
|||
<TargetFrameworks>net6.0-android;monoandroid11.0</TargetFrameworks> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
<DebugType>portable</DebugType> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> |
|||
<ProjectReference Include="..\..\Avalonia.PlatformSupport\Avalonia.PlatformSupport.csproj"> |
|||
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework> |
|||
</ProjectReference> |
|||
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.3" /> |
|||
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel" Version="2.3.1.3" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj" /> |
|||
<ProjectReference Include="..\..\Skia\Avalonia.Skia\Avalonia.Skia.csproj" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\..\build\Rx.props" /> |
|||
<Import Project="..\..\..\build\AndroidWorkarounds.props" /> |
|||
</Project> |
|||
|
|||
@ -1,35 +1,55 @@ |
|||
using Android.App; |
|||
using Android.OS; |
|||
using Android.Views; |
|||
using Android.Content.PM; |
|||
using AndroidX.AppCompat.App; |
|||
using Android.Content.Res; |
|||
using AndroidX.Lifecycle; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaActivity : Activity |
|||
public abstract class AvaloniaActivity : AppCompatActivity |
|||
{ |
|||
internal AvaloniaView View; |
|||
object _content; |
|||
|
|||
internal AvaloniaViewModel _viewModel; |
|||
protected override void OnCreate(Bundle savedInstanceState) |
|||
{ |
|||
View = new AvaloniaView(this); |
|||
if (_content != null) |
|||
View.Content = _content; |
|||
SetContentView(View); |
|||
|
|||
_viewModel = new ViewModelProvider(this).Get(Java.Lang.Class.FromType(typeof(AvaloniaViewModel))) as AvaloniaViewModel; |
|||
|
|||
if (_viewModel.Content != null) |
|||
{ |
|||
View.Content = _viewModel.Content; |
|||
} |
|||
|
|||
base.OnCreate(savedInstanceState); |
|||
} |
|||
|
|||
public object Content |
|||
{ |
|||
get |
|||
{ |
|||
return _content; |
|||
return _viewModel.Content; |
|||
} |
|||
set |
|||
{ |
|||
_content = value; |
|||
_viewModel.Content = value; |
|||
if (View != null) |
|||
View.Content = value; |
|||
} |
|||
} |
|||
|
|||
public override void OnConfigurationChanged(Configuration newConfig) |
|||
{ |
|||
base.OnConfigurationChanged(newConfig); |
|||
} |
|||
|
|||
protected override void OnDestroy() |
|||
{ |
|||
View.Content = null; |
|||
|
|||
base.OnDestroy(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
internal class AvaloniaViewModel : AndroidX.Lifecycle.ViewModel |
|||
{ |
|||
public object Content { get; set; } |
|||
} |
|||
} |
|||
@ -1,50 +0,0 @@ |
|||
Images, layout descriptions, binary blobs and string dictionaries can be included |
|||
in your application as resource files. Various Android APIs are designed to |
|||
operate on the resource IDs instead of dealing with images, strings or binary blobs |
|||
directly. |
|||
|
|||
For example, a sample Android app that contains a user interface layout (main.xml), |
|||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) |
|||
would keep its resources in the "Resources" directory of the application: |
|||
|
|||
Resources/ |
|||
drawable-hdpi/ |
|||
icon.png |
|||
|
|||
drawable-ldpi/ |
|||
icon.png |
|||
|
|||
drawable-mdpi/ |
|||
icon.png |
|||
|
|||
layout/ |
|||
main.xml |
|||
|
|||
values/ |
|||
strings.xml |
|||
|
|||
In order to get the build system to recognize Android resources, set the build action to |
|||
"AndroidResource". The native Android APIs do not operate directly with filenames, but |
|||
instead operate on resource IDs. When you compile an Android application that uses resources, |
|||
the build system will package the resources for distribution and generate a class called |
|||
"Resource" that contains the tokens for each one of the resources included. For example, |
|||
for the above Resources layout, this is what the Resource class would expose: |
|||
|
|||
public class Resource { |
|||
public class drawable { |
|||
public const int icon = 0x123; |
|||
} |
|||
|
|||
public class layout { |
|||
public const int main = 0x456; |
|||
} |
|||
|
|||
public class strings { |
|||
public const int first_string = 0xabc; |
|||
public const int second_string = 0xbcd; |
|||
} |
|||
} |
|||
|
|||
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main |
|||
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first |
|||
string in the dictionary file values/strings.xml. |
|||
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
|
|||
<resources> |
|||
<string name="Hello">Hello World, Click Me!</string> |
|||
<string name="ApplicationName">$projectname$</string> |
|||
</resources> |
|||
@ -1,19 +0,0 @@ |
|||
Any raw assets you want to be deployed with your application can be placed in |
|||
this directory (and child directories) and given a Build Action of "AndroidAsset". |
|||
|
|||
These files will be deployed with you package and will be accessible using Android's |
|||
AssetManager, like this: |
|||
|
|||
public class ReadAsset : Activity |
|||
{ |
|||
protected override void OnCreate (Bundle bundle) |
|||
{ |
|||
base.OnCreate (bundle); |
|||
|
|||
InputStream input = Assets.Open ("my_asset.txt"); |
|||
} |
|||
} |
|||
|
|||
Additionally, some Android functions will automatically load asset files: |
|||
|
|||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
|||
@ -1,153 +1,37 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProductVersion>8.0.30703</ProductVersion> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
<ProjectGuid>{FF69B927-C545-49AE-8E16-3D14D621AA12}</ProjectGuid> |
|||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Avalonia.AndroidTestApplication</RootNamespace> |
|||
<AssemblyName>Avalonia.AndroidTestApplication</AssemblyName> |
|||
<FileAlignment>512</FileAlignment> |
|||
<AndroidApplication>true</AndroidApplication> |
|||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> |
|||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> |
|||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> |
|||
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion> |
|||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> |
|||
<TargetFramework>net6.0-android</TargetFramework> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<OutputType>Exe</OutputType> |
|||
<Nullable>enable</Nullable> |
|||
<ApplicationId>com.Avalonia.AndroidTestApplication</ApplicationId> |
|||
<ApplicationVersion>1</ApplicationVersion> |
|||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> |
|||
<AndroidPackageFormat>apk</AndroidPackageFormat> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
<DebugType>portable</DebugType> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''"> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> |
|||
<AndroidLinkMode>None</AndroidLinkMode> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
<BundleAssemblies>False</BundleAssemblies> |
|||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> |
|||
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis> |
|||
<Debugger>Xamarin</Debugger> |
|||
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> |
|||
<DevInstrumentationEnabled>True</DevInstrumentationEnabled> |
|||
<AotAssemblies>False</AotAssemblies> |
|||
<EnableLLVM>False</EnableLLVM> |
|||
<EnableProguard>False</EnableProguard> |
|||
<RunAOTCompilation>True</RunAOTCompilation> |
|||
<EnableLLVM>True</EnableLLVM> |
|||
<!--<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>--> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> |
|||
<AndroidLinkMode>Full</AndroidLinkMode> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
<BundleAssemblies>False</BundleAssemblies> |
|||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> |
|||
<AndroidSupportedAbis>armeabi-v7a,x86</AndroidSupportedAbis> |
|||
<Debugger>Xamarin</Debugger> |
|||
<AotAssemblies>False</AotAssemblies> |
|||
<EnableLLVM>False</EnableLLVM> |
|||
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> |
|||
<EnableProguard>False</EnableProguard> |
|||
<DevInstrumentationEnabled>False</DevInstrumentationEnabled> |
|||
<DebugSymbols>False</DebugSymbols> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="Mono.Android" /> |
|||
<Reference Include="mscorlib" /> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="MainActivity.cs" /> |
|||
<Compile Include="Resources\Resource.Designer.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="app.config" /> |
|||
<None Include="Resources\AboutResources.txt" /> |
|||
<None Include="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<AndroidResource Include="Resources\values\Strings.xml"> |
|||
<SubType>Designer</SubType> |
|||
</AndroidResource> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<AndroidResource Include="Resources\drawable\Icon.png" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="Properties\AndroidManifest.xml" /> |
|||
<None Remove="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<BundleAssemblies>True</BundleAssemblies> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
|||
<BundleAssemblies>True</BundleAssemblies> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj"> |
|||
<Project>{7b92af71-6287-4693-9dcb-bd5b6e927e23}</Project> |
|||
<Name>Avalonia.Android</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|||
<Name>Avalonia.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|||
<Name>Avalonia.Themes.Default</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Skia\Avalonia.Skia\Avalonia.Skia.csproj"> |
|||
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project> |
|||
<Name>Avalonia.Skia</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> |
|||
<ProjectReference Include="..\Avalonia.Android\Avalonia.Android.csproj" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> |
|||
<Import Project="..\..\..\build\Base.props" /> |
|||
<Import Project="..\..\..\build\Rx.props" /> |
|||
<Import Project="..\..\..\build\System.Memory.props" /> |
|||
<Import Project="..\..\..\build\AndroidWorkarounds.props" /> |
|||
<Import Project="..\..\..\build\LegacyProject.targets" /> |
|||
</Project> |
|||
|
|||
@ -1,6 +1,4 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Avalonia.AndroidTestApplication" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"> |
|||
<uses-sdk android:targetSdkVersion="30" /> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<application android:label="Avalonia.AndroidTestApplication" android:icon="@drawable/Icon" android:hardwareAccelerated="true"></application> |
|||
<uses-permission android:name="android.permission.INTERNET" /> |
|||
</manifest> |
|||
</manifest> |
|||
|
|||
@ -1,30 +0,0 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
|
|||
[assembly: AssemblyTitle("Avalonia.AndroidTestApplication")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("Avalonia.AndroidTestApplication")] |
|||
[assembly: AssemblyCopyright("Copyright © 2015")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
[assembly: ComVisible(false)] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -1,79 +0,0 @@ |
|||
#pragma warning disable 1591
|
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
[assembly: global::Android.Runtime.ResourceDesignerAttribute("Avalonia.AndroidTestApplication.Resource", IsApplication=true)] |
|||
|
|||
namespace Avalonia.AndroidTestApplication |
|||
{ |
|||
|
|||
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.99.62")] |
|||
public partial class Resource |
|||
{ |
|||
|
|||
static Resource() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
public static void UpdateIdValues() |
|||
{ |
|||
} |
|||
|
|||
public partial class Attribute |
|||
{ |
|||
|
|||
static Attribute() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Attribute() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class Drawable |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F010000
|
|||
public const int Icon = 2130771968; |
|||
|
|||
static Drawable() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Drawable() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class String |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F020000
|
|||
public const int ApplicationName = 2130837504; |
|||
|
|||
// aapt resource value: 0x7F020001
|
|||
public const int Hello = 2130837505; |
|||
|
|||
static String() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private String() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
#pragma warning restore 1591
|
|||
@ -1,11 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="System.Runtime.InteropServices.WindowsRuntime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
@ -0,0 +1,37 @@ |
|||
using Avalonia.Interactivity; |
|||
|
|||
namespace Avalonia.Controls.Primitives |
|||
{ |
|||
/// <summary>
|
|||
/// Allows to customize text searching in <see cref="SelectingItemsControl"/>.
|
|||
/// </summary>
|
|||
public static class TextSearch |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the Text attached property.
|
|||
/// This text will be considered during text search in <see cref="SelectingItemsControl"/> (such as <see cref="ComboBox"/>)
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> TextProperty |
|||
= AvaloniaProperty.RegisterAttached<Interactive, string>("Text", typeof(TextSearch)); |
|||
|
|||
/// <summary>
|
|||
/// Sets the <see cref="TextProperty"/> for a control.
|
|||
/// </summary>
|
|||
/// <param name="control">The control</param>
|
|||
/// <param name="text">The search text to set</param>
|
|||
public static void SetText(Control control, string text) |
|||
{ |
|||
control.SetValue(TextProperty, text); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="TextProperty"/> of a control.
|
|||
/// </summary>
|
|||
/// <param name="control">The control</param>
|
|||
/// <returns>The property value</returns>
|
|||
public static string GetText(Control control) |
|||
{ |
|||
return control.GetValue(TextProperty); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
using System; |
|||
using System.Threading; |
|||
using Avalonia.Animation; |
|||
using Avalonia.Controls.Templates; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.Controls; |
|||
|
|||
/// <summary>
|
|||
/// Displays <see cref="ContentControl.Content"/> according to a <see cref="FuncDataTemplate"/>.
|
|||
/// Uses <see cref="PageTransition"/> to move between the old and new content values.
|
|||
/// </summary>
|
|||
public class TransitioningContentControl : ContentControl |
|||
{ |
|||
private CancellationTokenSource? _lastTransitionCts; |
|||
private object? _currentContent; |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="PageTransition"/> property.
|
|||
/// </summary>
|
|||
public static readonly StyledProperty<IPageTransition?> PageTransitionProperty = |
|||
AvaloniaProperty.Register<TransitioningContentControl, IPageTransition?>(nameof(PageTransition), |
|||
new CrossFade(TimeSpan.FromSeconds(0.125))); |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="CurrentContent"/> property.
|
|||
/// </summary>
|
|||
public static readonly DirectProperty<TransitioningContentControl, object?> CurrentContentProperty = |
|||
AvaloniaProperty.RegisterDirect<TransitioningContentControl, object?>(nameof(CurrentContent), |
|||
o => o.CurrentContent); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the animation played when content appears and disappears.
|
|||
/// </summary>
|
|||
public IPageTransition? PageTransition |
|||
{ |
|||
get => GetValue(PageTransitionProperty); |
|||
set => SetValue(PageTransitionProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the content currently displayed on the screen.
|
|||
/// </summary>
|
|||
public object? CurrentContent |
|||
{ |
|||
get => _currentContent; |
|||
private set => SetAndRaise(CurrentContentProperty, ref _currentContent, value); |
|||
} |
|||
|
|||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnAttachedToVisualTree(e); |
|||
|
|||
Dispatcher.UIThread.Post(() => UpdateContentWithTransition(Content)); |
|||
} |
|||
|
|||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnDetachedFromVisualTree(e); |
|||
|
|||
_lastTransitionCts?.Cancel(); |
|||
} |
|||
|
|||
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change) |
|||
{ |
|||
base.OnPropertyChanged(change); |
|||
|
|||
if (change.Property == ContentProperty) |
|||
{ |
|||
Dispatcher.UIThread.Post(() => UpdateContentWithTransition(Content)); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Updates the content with transitions.
|
|||
/// </summary>
|
|||
/// <param name="content">New content to set.</param>
|
|||
private async void UpdateContentWithTransition(object? content) |
|||
{ |
|||
if (VisualRoot is null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
_lastTransitionCts?.Cancel(); |
|||
_lastTransitionCts = new CancellationTokenSource(); |
|||
|
|||
if (PageTransition != null) |
|||
await PageTransition.Start(this, null, true, _lastTransitionCts.Token); |
|||
|
|||
CurrentContent = content; |
|||
|
|||
if (PageTransition != null) |
|||
await PageTransition.Start(null, this, true, _lastTransitionCts.Token); |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
namespace Avalonia.MicroCom |
|||
{ |
|||
public abstract class CallbackBase : IUnknown, IMicroComShadowContainer |
|||
{ |
|||
private readonly object _lock = new object(); |
|||
private bool _referencedFromManaged = true; |
|||
private bool _referencedFromNative = false; |
|||
private bool _destroyed; |
|||
|
|||
public bool IsDestroyed => _destroyed; |
|||
|
|||
protected virtual void Destroyed() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
lock (_lock) |
|||
{ |
|||
_referencedFromManaged = false; |
|||
DestroyIfNeeded(); |
|||
} |
|||
} |
|||
|
|||
void DestroyIfNeeded() |
|||
{ |
|||
if(_destroyed) |
|||
return; |
|||
if (_referencedFromManaged == false && _referencedFromNative == false) |
|||
{ |
|||
_destroyed = true; |
|||
Destroyed(); |
|||
} |
|||
} |
|||
|
|||
public MicroComShadow Shadow { get; set; } |
|||
public void OnReferencedFromNative() |
|||
{ |
|||
lock (_lock) |
|||
_referencedFromNative = true; |
|||
} |
|||
|
|||
public void OnUnreferencedFromNative() |
|||
{ |
|||
lock (_lock) |
|||
{ |
|||
_referencedFromNative = false; |
|||
DestroyIfNeeded(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Style Selector="TransitioningContentControl"> |
|||
<!-- Set Defaults --> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding CurrentContent}" |
|||
Padding="{TemplateBinding Padding}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,20 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Style Selector="TransitioningContentControl"> |
|||
<!-- Set Defaults --> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding CurrentContent}" |
|||
Padding="{TemplateBinding Padding}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,116 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.Text; |
|||
using XamlX.Emit; |
|||
using XamlX.IL; |
|||
using XamlX.TypeSystem; |
|||
using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; |
|||
using System.Reflection.Emit; |
|||
|
|||
namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions |
|||
{ |
|||
internal class XamlIlTrampolineBuilder |
|||
{ |
|||
private IXamlTypeBuilder<IXamlILEmitter> _builder; |
|||
private Dictionary<string, IXamlMethod> _trampolines = new(); |
|||
|
|||
public XamlIlTrampolineBuilder(IXamlTypeBuilder<IXamlILEmitter> builder) |
|||
{ |
|||
_builder = builder; |
|||
} |
|||
|
|||
public IXamlMethod EmitCommandExecuteTrampoline(XamlEmitContext<IXamlILEmitter, XamlILNodeEmitResult> context, IXamlMethod executeMethod) |
|||
{ |
|||
Debug.Assert(!executeMethod.IsStatic); |
|||
string methodName = $"{executeMethod.DeclaringType.GetFqn()}+{executeMethod.Name}_{executeMethod.Parameters.Count}!CommandExecuteTrampoline"; |
|||
if (_trampolines.TryGetValue(methodName, out var method)) |
|||
{ |
|||
return method; |
|||
} |
|||
var trampoline = _builder.DefineMethod( |
|||
context.Configuration.WellKnownTypes.Void, |
|||
new[] { context.Configuration.WellKnownTypes.Object, context.Configuration.WellKnownTypes.Object }, |
|||
methodName, |
|||
true, |
|||
true, |
|||
false); |
|||
var gen = trampoline.Generator; |
|||
if (executeMethod.DeclaringType.IsValueType) |
|||
{ |
|||
gen.Ldarg_0() |
|||
.Unbox(executeMethod.DeclaringType); |
|||
} |
|||
else |
|||
{ |
|||
gen.Ldarg_0() |
|||
.Castclass(executeMethod.DeclaringType); |
|||
} |
|||
if (executeMethod.Parameters.Count != 0) |
|||
{ |
|||
Debug.Assert(executeMethod.Parameters.Count == 1); |
|||
if (executeMethod.Parameters[0] != context.Configuration.WellKnownTypes.Object) |
|||
{ |
|||
var convertedValue = gen.DefineLocal(context.Configuration.WellKnownTypes.Object); |
|||
gen.Ldtype(executeMethod.Parameters[0]) |
|||
.Ldarg(1) |
|||
.EmitCall(context.Configuration.WellKnownTypes.CultureInfo.FindMethod(m => m.Name == "get_CurrentCulture")) |
|||
.Ldloca(convertedValue) |
|||
.EmitCall( |
|||
context.GetAvaloniaTypes().TypeUtilities.FindMethod(m => m.Name == "TryConvert"), |
|||
swallowResult: true) |
|||
.Ldloc(convertedValue) |
|||
.Unbox_Any(executeMethod.Parameters[0]); |
|||
} |
|||
else |
|||
{ |
|||
gen.Ldarg(1); |
|||
} |
|||
} |
|||
gen.EmitCall(executeMethod, swallowResult: true); |
|||
gen.Ret(); |
|||
|
|||
_trampolines.Add(methodName, trampoline); |
|||
return trampoline; |
|||
} |
|||
|
|||
public IXamlMethod EmitCommandCanExecuteTrampoline(XamlEmitContext<IXamlILEmitter, XamlILNodeEmitResult> context, IXamlMethod canExecuteMethod) |
|||
{ |
|||
Debug.Assert(!canExecuteMethod.IsStatic); |
|||
Debug.Assert(canExecuteMethod.Parameters.Count == 1); |
|||
Debug.Assert(canExecuteMethod.ReturnType == context.Configuration.WellKnownTypes.Boolean); |
|||
string methodName = $"{canExecuteMethod.DeclaringType.GetFqn()}+{canExecuteMethod.Name}!CommandCanExecuteTrampoline"; |
|||
if (_trampolines.TryGetValue(methodName, out var method)) |
|||
{ |
|||
return method; |
|||
} |
|||
var trampoline = _builder.DefineMethod( |
|||
context.Configuration.WellKnownTypes.Boolean, |
|||
new[] { context.Configuration.WellKnownTypes.Object, context.Configuration.WellKnownTypes.Object }, |
|||
methodName, |
|||
true, |
|||
true, |
|||
false); |
|||
if (canExecuteMethod.DeclaringType.IsValueType) |
|||
{ |
|||
trampoline.Generator |
|||
.Ldarg_0() |
|||
.Unbox(canExecuteMethod.DeclaringType); |
|||
} |
|||
else |
|||
{ |
|||
trampoline.Generator |
|||
.Ldarg_0() |
|||
.Castclass(canExecuteMethod.DeclaringType); |
|||
} |
|||
trampoline.Generator |
|||
.Ldarg(1) |
|||
.Emit(OpCodes.Tailcall) |
|||
.EmitCall(canExecuteMethod) |
|||
.Ret(); |
|||
|
|||
_trampolines.Add(methodName, trampoline); |
|||
return trampoline; |
|||
} |
|||
} |
|||
} |
|||
@ -1 +1 @@ |
|||
Subproject commit 8e20d65eb5f1efbae08e49b18f39bfdce32df7b3 |
|||
Subproject commit daaac590e078967b78045f74c38ef046d00d8582 |
|||
@ -0,0 +1,156 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
using System.Reflection; |
|||
using System.Text; |
|||
using System.Windows.Input; |
|||
using Avalonia.Data; |
|||
using Avalonia.Data.Core.Plugins; |
|||
using Avalonia.Utilities; |
|||
|
|||
namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings |
|||
{ |
|||
internal class CommandAccessorPlugin : IPropertyAccessorPlugin |
|||
{ |
|||
private readonly Action<object, object> _execute; |
|||
private readonly Func<object, object, bool> _canExecute; |
|||
private readonly ISet<string> _dependsOnProperties; |
|||
|
|||
public CommandAccessorPlugin(Action<object, object> execute, Func<object, object, bool> canExecute, ISet<string> dependsOnProperties) |
|||
{ |
|||
_execute = execute; |
|||
_canExecute = canExecute; |
|||
_dependsOnProperties = dependsOnProperties; |
|||
} |
|||
|
|||
public bool Match(object obj, string propertyName) |
|||
{ |
|||
throw new InvalidOperationException("The CommandAccessorPlugin does not support dynamic matching"); |
|||
} |
|||
|
|||
public IPropertyAccessor Start(WeakReference<object> reference, string propertyName) |
|||
{ |
|||
return new CommandAccessor(reference, _execute, _canExecute, _dependsOnProperties); |
|||
} |
|||
|
|||
private sealed class CommandAccessor : PropertyAccessorBase |
|||
{ |
|||
private readonly WeakReference<object> _reference; |
|||
private Command _command; |
|||
private readonly ISet<string> _dependsOnProperties; |
|||
|
|||
public CommandAccessor(WeakReference<object> reference, Action<object, object> execute, Func<object, object, bool> canExecute, ISet<string> dependsOnProperties) |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(reference != null); |
|||
|
|||
_reference = reference; |
|||
_dependsOnProperties = dependsOnProperties; |
|||
_command = new Command(reference, execute, canExecute); |
|||
|
|||
} |
|||
|
|||
public override object Value => _reference.TryGetTarget(out var _) ? _command : null; |
|||
|
|||
private void RaiseCanExecuteChanged() |
|||
{ |
|||
_command.RaiseCanExecuteChanged(); |
|||
} |
|||
|
|||
private sealed class Command : ICommand |
|||
{ |
|||
private readonly WeakReference<object> _target; |
|||
private readonly Action<object, object> _execute; |
|||
private readonly Func<object, object, bool> _canExecute; |
|||
|
|||
public event EventHandler CanExecuteChanged; |
|||
|
|||
public Command(WeakReference<object> target, Action<object, object> execute, Func<object, object, bool> canExecute) |
|||
{ |
|||
_target = target; |
|||
_execute = execute; |
|||
_canExecute = canExecute; |
|||
} |
|||
|
|||
public void RaiseCanExecuteChanged() |
|||
{ |
|||
Threading.Dispatcher.UIThread.Post(() => CanExecuteChanged?.Invoke(this, EventArgs.Empty) |
|||
, Threading.DispatcherPriority.Input); |
|||
} |
|||
|
|||
public bool CanExecute(object parameter) |
|||
{ |
|||
if (_target.TryGetTarget(out var target)) |
|||
{ |
|||
if (_canExecute == null) |
|||
{ |
|||
return true; |
|||
} |
|||
return _canExecute(target, parameter); |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
public void Execute(object parameter) |
|||
{ |
|||
if (_target.TryGetTarget(out var target)) |
|||
{ |
|||
_execute(target, parameter); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override Type PropertyType => typeof(ICommand); |
|||
|
|||
public override bool SetValue(object value, BindingPriority priority) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
void OnNotifyPropertyChanged(object sender, PropertyChangedEventArgs e) |
|||
{ |
|||
if (string.IsNullOrEmpty(e.PropertyName) || _dependsOnProperties.Contains(e.PropertyName)) |
|||
{ |
|||
RaiseCanExecuteChanged(); |
|||
} |
|||
} |
|||
|
|||
protected override void SubscribeCore() |
|||
{ |
|||
SendCurrentValue(); |
|||
SubscribeToChanges(); |
|||
} |
|||
|
|||
protected override void UnsubscribeCore() |
|||
{ |
|||
if (_dependsOnProperties is { Count: > 0 } && _reference.TryGetTarget(out var o) && o is INotifyPropertyChanged inpc) |
|||
{ |
|||
WeakEventHandlerManager.Unsubscribe<PropertyChangedEventArgs, InpcPropertyAccessor>( |
|||
inpc, |
|||
nameof(INotifyPropertyChanged.PropertyChanged), |
|||
OnNotifyPropertyChanged); |
|||
} |
|||
} |
|||
|
|||
private void SendCurrentValue() |
|||
{ |
|||
try |
|||
{ |
|||
var value = Value; |
|||
PublishValue(value); |
|||
} |
|||
catch { } |
|||
} |
|||
|
|||
private void SubscribeToChanges() |
|||
{ |
|||
if (_dependsOnProperties is { Count:>0 } && _reference.TryGetTarget(out var o) && o is INotifyPropertyChanged inpc) |
|||
{ |
|||
WeakEventHandlerManager.Subscribe<INotifyPropertyChanged, PropertyChangedEventArgs, InpcPropertyAccessor>( |
|||
inpc, |
|||
nameof(INotifyPropertyChanged.PropertyChanged), |
|||
OnNotifyPropertyChanged); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.Reflection; |
|||
using System.Text; |
|||
using Avalonia.Data; |
|||
using Avalonia.Data.Core.Plugins; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings |
|||
{ |
|||
internal class MethodAccessorPlugin : IPropertyAccessorPlugin |
|||
{ |
|||
private MethodInfo _method; |
|||
private readonly Type _delegateType; |
|||
|
|||
public MethodAccessorPlugin(MethodInfo method, Type delegateType) |
|||
{ |
|||
_method = method; |
|||
_delegateType = delegateType; |
|||
} |
|||
|
|||
public bool Match(object obj, string propertyName) |
|||
{ |
|||
throw new InvalidOperationException("The MethodAccessorPlugin does not support dynamic matching"); |
|||
} |
|||
|
|||
public IPropertyAccessor Start(WeakReference<object?> reference, string propertyName) |
|||
{ |
|||
Debug.Assert(_method.Name == propertyName); |
|||
return new Accessor(reference, _method, _delegateType); |
|||
} |
|||
|
|||
private sealed class Accessor : PropertyAccessorBase |
|||
{ |
|||
public Accessor(WeakReference<object?> reference, MethodInfo method, Type delegateType) |
|||
{ |
|||
_ = reference ?? throw new ArgumentNullException(nameof(reference)); |
|||
_ = method ?? throw new ArgumentNullException(nameof(method)); |
|||
|
|||
PropertyType = delegateType; |
|||
|
|||
if (method.IsStatic) |
|||
{ |
|||
Value = method.CreateDelegate(PropertyType); |
|||
} |
|||
else if (reference.TryGetTarget(out var target)) |
|||
{ |
|||
Value = method.CreateDelegate(PropertyType, target); |
|||
} |
|||
} |
|||
|
|||
public override Type? PropertyType { get; } |
|||
|
|||
public override object? Value { get; } |
|||
|
|||
public override bool SetValue(object? value, BindingPriority priority) => false; |
|||
|
|||
protected override void SubscribeCore() |
|||
{ |
|||
try |
|||
{ |
|||
PublishValue(Value); |
|||
} |
|||
catch { } |
|||
} |
|||
|
|||
protected override void UnsubscribeCore() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue