@ -0,0 +1,84 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
using Avalonia.Platform; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Platform; |
|||
using Avalonia.Markup.Xaml; |
|||
using Avalonia; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class NativeEmbedPage : UserControl |
|||
{ |
|||
public NativeEmbedPage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
public async void ShowPopupDelay(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Task.Delay(3000); |
|||
ShowPopup(sender, args); |
|||
} |
|||
|
|||
public void ShowPopup(object sender, RoutedEventArgs args) |
|||
{ |
|||
new ContextMenu() |
|||
{ |
|||
Items = new List<MenuItem> |
|||
{ |
|||
new MenuItem() { Header = "Test" }, new MenuItem() { Header = "Test" } |
|||
} |
|||
}.Open((Control)sender); |
|||
} |
|||
|
|||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) |
|||
{ |
|||
base.OnPropertyChanged(change); |
|||
|
|||
if (change.Property == BoundsProperty) |
|||
{ |
|||
var isMobile = change.GetNewValue<Rect>().Width < 1200; |
|||
this.Find<DockPanel>("FirstPanel")!.Classes.Set("mobile", isMobile); |
|||
this.Find<DockPanel>("SecondPanel")!.Classes.Set("mobile", isMobile); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class EmbedSample : NativeControlHost |
|||
{ |
|||
public static INativeDemoControl? Implementation { get; set; } |
|||
|
|||
static EmbedSample() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public bool IsSecond { get; set; } |
|||
|
|||
protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle parent) |
|||
{ |
|||
return Implementation?.CreateControl(IsSecond, parent, () => base.CreateNativeControlCore(parent)) |
|||
?? base.CreateNativeControlCore(parent); |
|||
} |
|||
|
|||
protected override void DestroyNativeControlCore(IPlatformHandle control) |
|||
{ |
|||
base.DestroyNativeControlCore(control); |
|||
} |
|||
} |
|||
|
|||
public interface INativeDemoControl |
|||
{ |
|||
/// <param name="isSecond">Used to specify which control should be displayed as a demo</param>
|
|||
IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func<IPlatformHandle> createDefault); |
|||
} |
|||
} |
|||
@ -1,12 +0,0 @@ |
|||
using Android.App; |
|||
using Android.Content.PM; |
|||
|
|||
using Avalonia; |
|||
using Avalonia.Android; |
|||
|
|||
namespace NativeEmbedSample.Android; |
|||
|
|||
[Activity(Label = "NativeEmbedSample", Theme = "@style/MyTheme.NoActionBar", Icon = "@drawable/icon", LaunchMode = LaunchMode.SingleInstance, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize)] |
|||
public class MainActivity : AvaloniaActivity<App> |
|||
{ |
|||
} |
|||
@ -1,50 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0-android</TargetFramework> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<OutputType>Exe</OutputType> |
|||
<Nullable>enable</Nullable> |
|||
<ApplicationId>com.Avalonia.NativeEmbedSample</ApplicationId> |
|||
<ApplicationVersion>1</ApplicationVersion> |
|||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> |
|||
<AndroidPackageFormat>apk</AndroidPackageFormat> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<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>True</RunAOTCompilation> |
|||
<EnableLLVM>True</EnableLLVM> |
|||
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> |
|||
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk> |
|||
<RunAOTCompilation>False</RunAOTCompilation> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)'=='Release'"> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<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" /> |
|||
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> |
|||
<ProjectReference Include="..\NativeEmbedSample\NativeEmbedSample.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\..\build\BuildTargets.targets" /> |
|||
</Project> |
|||
@ -1,4 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<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,44 +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.axml), |
|||
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/ |
|||
icon.png |
|||
|
|||
layout/ |
|||
main.axml |
|||
|
|||
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 "R" |
|||
(this is an Android convention) that contains the tokens for each one of the resources |
|||
included. For example, for the above Resources layout, this is what the R class would expose: |
|||
|
|||
public class R { |
|||
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 R.layout.main |
|||
to reference the layout/main.axml file, or R.strings.first_string to reference the first |
|||
string in the dictionary file values/strings.xml. |
|||
@ -1,13 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
|
|||
<item> |
|||
<color android:color="@color/splash_background"/> |
|||
</item> |
|||
|
|||
<item android:drawable="@drawable/icon" |
|||
android:width="120dp" |
|||
android:height="120dp" |
|||
android:gravity="center" /> |
|||
|
|||
</layer-list> |
|||
@ -1,4 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<resources> |
|||
<color name="splash_background">#FFFFFF</color> |
|||
</resources> |
|||
@ -1,17 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<resources> |
|||
|
|||
<style name="MyTheme"> |
|||
</style> |
|||
|
|||
<style name="MyTheme.NoActionBar" parent="@style/Theme.AppCompat.NoActionBar"> |
|||
<item name="android:windowActionBar">false</item> |
|||
<item name="android:windowNoTitle">true</item> |
|||
</style> |
|||
|
|||
<style name="MyTheme.Splash" parent ="MyTheme.NoActionBar"> |
|||
<item name="android:windowBackground">@drawable/splash_screen</item> |
|||
<item name="android:windowContentOverlay">@null</item> |
|||
</style> |
|||
|
|||
</resources> |
|||
@ -1,16 +0,0 @@ |
|||
using Android.App; |
|||
using Android.Content; |
|||
using Android.OS; |
|||
|
|||
namespace NativeEmbedSample.Android; |
|||
|
|||
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)] |
|||
public class SplashActivity : Activity |
|||
{ |
|||
protected override void OnResume() |
|||
{ |
|||
base.OnResume(); |
|||
|
|||
StartActivity(new Intent(Application.Context, typeof(MainActivity))); |
|||
} |
|||
} |
|||
@ -1,15 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\NativeEmbedSample\NativeEmbedSample.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\..\build\SampleApp.props" /> |
|||
<Import Project="..\..\..\build\BuildTargets.targets" /> |
|||
<Import Project="..\..\..\build\ReferenceCoreLibraries.props" /> |
|||
</Project> |
|||
@ -1,17 +0,0 @@ |
|||
using Avalonia; |
|||
using NativeEmbedSample; |
|||
|
|||
namespace NativeEmbedSample.Desktop; |
|||
|
|||
public class Program |
|||
{ |
|||
static int Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); |
|||
|
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.With(new AvaloniaNativePlatformOptions() |
|||
{ |
|||
}) |
|||
.UsePlatformDetect(); |
|||
|
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
using Avalonia.iOS; |
|||
|
|||
namespace NativeEmbedSample.iOS; |
|||
|
|||
[Register("AppDelegate")] |
|||
public partial class AppDelegate : AvaloniaAppDelegate<App> |
|||
{ |
|||
|
|||
} |
|||
@ -1,117 +0,0 @@ |
|||
{ |
|||
"images": [ |
|||
{ |
|||
"scale": "2x", |
|||
"size": "20x20", |
|||
"idiom": "iphone", |
|||
"filename": "Icon40.png" |
|||
}, |
|||
{ |
|||
"scale": "3x", |
|||
"size": "20x20", |
|||
"idiom": "iphone", |
|||
"filename": "Icon60.png" |
|||
}, |
|||
{ |
|||
"scale": "2x", |
|||
"size": "29x29", |
|||
"idiom": "iphone", |
|||
"filename": "Icon58.png" |
|||
}, |
|||
{ |
|||
"scale": "3x", |
|||
"size": "29x29", |
|||
"idiom": "iphone", |
|||
"filename": "Icon87.png" |
|||
}, |
|||
{ |
|||
"scale": "2x", |
|||
"size": "40x40", |
|||
"idiom": "iphone", |
|||
"filename": "Icon80.png" |
|||
}, |
|||
{ |
|||
"scale": "3x", |
|||
"size": "40x40", |
|||
"idiom": "iphone", |
|||
"filename": "Icon120.png" |
|||
}, |
|||
{ |
|||
"scale": "2x", |
|||
"size": "60x60", |
|||
"idiom": "iphone", |
|||
"filename": "Icon120.png" |
|||
}, |
|||
{ |
|||
"scale": "3x", |
|||
"size": "60x60", |
|||
"idiom": "iphone", |
|||
"filename": "Icon180.png" |
|||
}, |
|||
{ |
|||
"scale": "1x", |
|||
"size": "20x20", |
|||
"idiom": "ipad", |
|||
"filename": "Icon20.png" |
|||
}, |
|||
{ |
|||
"scale": "2x", |
|||
"size": "20x20", |
|||
"idiom": "ipad", |
|||
"filename": "Icon40.png" |
|||
}, |
|||
{ |
|||
"scale": "1x", |
|||
"size": "29x29", |
|||
"idiom": "ipad", |
|||
"filename": "Icon29.png" |
|||
}, |
|||
{ |
|||
"scale": "2x", |
|||
"size": "29x29", |
|||
"idiom": "ipad", |
|||
"filename": "Icon58.png" |
|||
}, |
|||
{ |
|||
"scale": "1x", |
|||
"size": "40x40", |
|||
"idiom": "ipad", |
|||
"filename": "Icon40.png" |
|||
}, |
|||
{ |
|||
"scale": "2x", |
|||
"size": "40x40", |
|||
"idiom": "ipad", |
|||
"filename": "Icon80.png" |
|||
}, |
|||
{ |
|||
"scale": "1x", |
|||
"size": "76x76", |
|||
"idiom": "ipad", |
|||
"filename": "Icon76.png" |
|||
}, |
|||
{ |
|||
"scale": "2x", |
|||
"size": "76x76", |
|||
"idiom": "ipad", |
|||
"filename": "Icon152.png" |
|||
}, |
|||
{ |
|||
"scale": "2x", |
|||
"size": "83.5x83.5", |
|||
"idiom": "ipad", |
|||
"filename": "Icon167.png" |
|||
}, |
|||
{ |
|||
"scale": "1x", |
|||
"size": "1024x1024", |
|||
"idiom": "ios-marketing", |
|||
"filename": "Icon1024.png" |
|||
} |
|||
], |
|||
"properties": {}, |
|||
"info": { |
|||
"version": 1, |
|||
"author": "xcode" |
|||
} |
|||
} |
|||
|
Before Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 845 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
|||
<plist version="1.0"> |
|||
<dict> |
|||
</dict> |
|||
</plist> |
|||
@ -1,42 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
|||
<plist version="1.0"> |
|||
<dict> |
|||
<key>CFBundleDisplayName</key> |
|||
<string>AvaloniaNative</string> |
|||
<key>CFBundleIdentifier</key> |
|||
<string>Avalonia.Native.Sample</string> |
|||
<key>CFBundleShortVersionString</key> |
|||
<string>1.0</string> |
|||
<key>CFBundleVersion</key> |
|||
<string>1.0</string> |
|||
<key>LSRequiresIPhoneOS</key> |
|||
<true/> |
|||
<key>UIDeviceFamily</key> |
|||
<array> |
|||
<integer>1</integer> |
|||
<integer>2</integer> |
|||
</array> |
|||
<key>UILaunchStoryboardName</key> |
|||
<string>LaunchScreen</string> |
|||
<key>UIRequiredDeviceCapabilities</key> |
|||
<array> |
|||
<string>armv7</string> |
|||
</array> |
|||
<key>UISupportedInterfaceOrientations</key> |
|||
<array> |
|||
<string>UIInterfaceOrientationPortrait</string> |
|||
<string>UIInterfaceOrientationLandscapeLeft</string> |
|||
<string>UIInterfaceOrientationLandscapeRight</string> |
|||
</array> |
|||
<key>UISupportedInterfaceOrientations~ipad</key> |
|||
<array> |
|||
<string>UIInterfaceOrientationPortrait</string> |
|||
<string>UIInterfaceOrientationPortraitUpsideDown</string> |
|||
<string>UIInterfaceOrientationLandscapeLeft</string> |
|||
<string>UIInterfaceOrientationLandscapeRight</string> |
|||
</array> |
|||
<key>XSAppIconAssets</key> |
|||
<string>Assets.xcassets/AppIcon.appiconset</string> |
|||
</dict> |
|||
</plist> |
|||
@ -1,6 +0,0 @@ |
|||
using NativeEmbedSample.iOS; |
|||
|
|||
// This is the main entry point of the application.
|
|||
// If you want to use a different Application Delegate class from "AppDelegate"
|
|||
// you can specify it here.
|
|||
UIApplication.Main(args, null, typeof(AppDelegate)); |
|||
@ -1,16 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0-ios</TargetFramework> |
|||
<ProvisioningType>manual</ProvisioningType> |
|||
<OutputType>Exe</OutputType> |
|||
<Nullable>enable</Nullable> |
|||
<ImplicitUsings>true</ImplicitUsings> |
|||
<SupportedOSPlatformVersion>11.2</SupportedOSPlatformVersion> |
|||
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier> |
|||
<!-- <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>--> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj" /> |
|||
<ProjectReference Include="..\NativeEmbedSample\NativeEmbedSample.csproj" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,43 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
|||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES"> |
|||
<dependencies> |
|||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207" /> |
|||
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1" /> |
|||
</dependencies> |
|||
<objects> |
|||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" /> |
|||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder" /> |
|||
<view contentMode="scaleToFill" id="iN0-l3-epB"> |
|||
<rect key="frame" x="0.0" y="0.0" width="480" height="480" /> |
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" /> |
|||
<subviews> |
|||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2017 " textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" |
|||
minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye"> |
|||
<rect key="frame" x="20" y="439" width="441" height="21" /> |
|||
<fontDescription key="fontDescription" type="system" pointSize="17" /> |
|||
<color key="textColor" cocoaTouchSystemColor="darkTextColor" /> |
|||
<nil key="highlightedColor" /> |
|||
</label> |
|||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="NewApp" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" |
|||
minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX"> |
|||
<rect key="frame" x="20" y="140" width="441" height="43" /> |
|||
<fontDescription key="fontDescription" type="boldSystem" pointSize="36" /> |
|||
<color key="textColor" cocoaTouchSystemColor="darkTextColor" /> |
|||
<nil key="highlightedColor" /> |
|||
</label> |
|||
</subviews> |
|||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" /> |
|||
<constraints> |
|||
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC" /> |
|||
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk" /> |
|||
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l" /> |
|||
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0" /> |
|||
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9" /> |
|||
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g" /> |
|||
</constraints> |
|||
<nil key="simulatedStatusBarMetrics" /> |
|||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics" /> |
|||
<point key="canvasLocation" x="548" y="455" /> |
|||
</view> |
|||
</objects> |
|||
</document> |
|||
@ -1,7 +0,0 @@ |
|||
<Application xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="NativeEmbedSample.App"> |
|||
<Application.Styles> |
|||
<FluentTheme /> |
|||
</Application.Styles> |
|||
</Application> |
|||
@ -1,23 +0,0 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace NativeEmbedSample; |
|||
|
|||
public class App : Application |
|||
{ |
|||
public override void Initialize() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
public override void OnFrameworkInitializationCompleted() |
|||
{ |
|||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) |
|||
desktopLifetime.MainWindow = new MainWindow(); |
|||
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime) |
|||
singleViewLifetime.MainView = new MainView(); |
|||
|
|||
base.OnFrameworkInitializationCompleted(); |
|||
} |
|||
} |
|||
@ -1,54 +0,0 @@ |
|||
using System; |
|||
using System.Diagnostics; |
|||
using System.IO; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace NativeEmbedSample |
|||
{ |
|||
public partial class EmbedSample : NativeControlHost |
|||
{ |
|||
public bool IsSecond { get; set; } |
|||
|
|||
protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle parent) |
|||
{ |
|||
#if DESKTOP
|
|||
if (OperatingSystem.IsLinux()) |
|||
return CreateLinux(parent); |
|||
if (OperatingSystem.IsWindows()) |
|||
return CreateWin32(parent); |
|||
if (OperatingSystem.IsMacOS()) |
|||
return CreateOSX(parent); |
|||
#elif __ANDROID__ || ANDROID
|
|||
if (OperatingSystem.IsAndroid()) |
|||
return CreateAndroid(parent); |
|||
#elif IOS
|
|||
if (OperatingSystem.IsIOS()) |
|||
return CreateIOS(parent); |
|||
#endif
|
|||
return base.CreateNativeControlCore(parent); |
|||
} |
|||
|
|||
protected override void DestroyNativeControlCore(IPlatformHandle control) |
|||
{ |
|||
#if DESKTOP
|
|||
if (OperatingSystem.IsLinux()) |
|||
DestroyLinux(control); |
|||
else if (OperatingSystem.IsWindows()) |
|||
DestroyWin32(control); |
|||
else if (OperatingSystem.IsMacOS()) |
|||
DestroyOSX(control); |
|||
#elif __ANDROID__ || ANDROID
|
|||
if (OperatingSystem.IsAndroid()) |
|||
DestroyAndroid(control); |
|||
#elif IOS
|
|||
if (OperatingSystem.IsIOS()) |
|||
DestroyIOS(control); |
|||
#endif
|
|||
else base.DestroyNativeControlCore(control); |
|||
} |
|||
} |
|||
} |
|||
@ -1,45 +0,0 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace NativeEmbedSample; |
|||
|
|||
public class MainView : UserControl |
|||
{ |
|||
public MainView() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
public async void ShowPopupDelay(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Task.Delay(3000); |
|||
ShowPopup(sender, args); |
|||
} |
|||
|
|||
public void ShowPopup(object sender, RoutedEventArgs args) |
|||
{ |
|||
new ContextMenu() |
|||
{ |
|||
Items = new List<MenuItem> |
|||
{ |
|||
new MenuItem() { Header = "Test" }, new MenuItem() { Header = "Test" } |
|||
} |
|||
}.Open((Control)sender); |
|||
} |
|||
|
|||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) |
|||
{ |
|||
base.OnPropertyChanged(change); |
|||
|
|||
if (change.Property == BoundsProperty) |
|||
{ |
|||
var isMobile = change.GetNewValue<Rect>().Width < 1200; |
|||
this.Find<DockPanel>("FirstPanel")!.Classes.Set("mobile", isMobile); |
|||
this.Find<DockPanel>("SecondPanel")!.Classes.Set("mobile", isMobile); |
|||
} |
|||
} |
|||
} |
|||
@ -1,10 +0,0 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:nativeEmbedSample="clr-namespace:NativeEmbedSample" |
|||
x:Class="NativeEmbedSample.MainWindow" |
|||
MinWidth="500" MinHeight="300" |
|||
Width="1024" Height="800" |
|||
Title="Native embedding sample"> |
|||
<nativeEmbedSample:MainView /> |
|||
</Window> |
|||
|
|||
@ -1,17 +0,0 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace NativeEmbedSample; |
|||
|
|||
public class MainWindow : Window |
|||
{ |
|||
public MainWindow() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
#if DEBUG && DESKTOP
|
|||
this.AttachDevTools(); |
|||
#endif
|
|||
} |
|||
} |
|||
|
|||
@ -1,38 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios</TargetFrameworks> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
|
|||
<DefineConstants Condition="'$(TargetFramework)' == 'net6.0'">$(DefineConstants);DESKTOP</DefineConstants> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'"> |
|||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.4" /> |
|||
<ProjectReference Include="..\..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj" /> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" /> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.X11\Avalonia.X11.csproj" /> |
|||
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.0.2020091801" /> |
|||
<None Remove="nodes.mp4" /> |
|||
|
|||
<Compile Include="..\..\..\src\Avalonia.X11\NativeDialogs\Gtk.cs"> |
|||
<Link>Gtk\Gtk.cs</Link> |
|||
</Compile> |
|||
|
|||
<Content Include="Gtk\nodes.mp4"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-android'"> |
|||
<ProjectReference Include="..\..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-ios'"> |
|||
<ProjectReference Include="..\..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\..\build\BuildTargets.targets" /> |
|||
</Project> |
|||