зеркало из https://github.com/AvaloniaUI/Avalonia.git
Implemented embedding to WPF and WinForms
This commit is contained in:
Родитель
06cd5c15f1
Коммит
b89d334147
46
Avalonia.sln
46
Avalonia.sln
|
@ -163,6 +163,10 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Avalonia.RenderTests", "tes
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualizationTest", "samples\VirtualizationTest\VirtualizationTest.csproj", "{FBCAF3D0-2808-4934-8E96-3F607594517B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Interop", "Interop", "{A0CC0258-D18C-4AB3-854F-7101680FC3F9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsInteropTest", "samples\interop\WindowsInteropTest\WindowsInteropTest.csproj", "{C7A69145-60B6-4882-97D6-A3921DD43978}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13
|
||||
|
@ -2242,6 +2246,46 @@ Global
|
|||
{FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|Mono.Build.0 = Release|Any CPU
|
||||
{FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|x86.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|Mono.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|Mono.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Ad-Hoc|x86.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|Any CPU.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|iPhone.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|iPhone.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|Mono.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|Mono.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|x86.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.AppStore|x86.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|Mono.ActiveCfg = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|Mono.Build.0 = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|iPhone.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|Mono.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|Mono.Build.0 = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -2294,5 +2338,7 @@ Global
|
|||
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
|
||||
{48840EDD-24BF-495D-911E-2EB12AE75D3B} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
|
||||
{FBCAF3D0-2808-4934-8E96-3F607594517B} = {9B9E3891-2366-4253-A952-D08BCEB71098}
|
||||
{A0CC0258-D18C-4AB3-854F-7101680FC3F9} = {9B9E3891-2366-4253-A952-D08BCEB71098}
|
||||
{C7A69145-60B6-4882-97D6-A3921DD43978} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<EmbeddedResource Include="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MainWindow.xaml">
|
||||
<EmbeddedResource Include="ControlCatalogControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Pages\BorderPage.xaml">
|
||||
|
@ -88,6 +88,9 @@
|
|||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ControlCatalogControl.xaml.cs">
|
||||
<DependentUpon>ControlCatalogControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -215,6 +218,13 @@
|
|||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>
|
||||
</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:pages="clr-namespace:ControlCatalog.Pages;assembly=ControlCatalog"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<TabControl Classes="sidebar">
|
||||
<TabControl.Transition>
|
||||
<CrossFade Duration="0.25"/>
|
||||
</TabControl.Transition>
|
||||
<TabItem Header="Border"><pages:BorderPage/></TabItem>
|
||||
<TabItem Header="Button"><pages:ButtonPage/></TabItem>
|
||||
<TabItem Header="Canvas"><pages:CanvasPage/></TabItem>
|
||||
<TabItem Header="Carousel"><pages:CarouselPage/></TabItem>
|
||||
<TabItem Header="CheckBox"><pages:CheckBoxPage/></TabItem>
|
||||
<TabItem Header="DropDown"><pages:DropDownPage/></TabItem>
|
||||
<TabItem Header="Expander"><pages:ExpanderPage/></TabItem>
|
||||
<TabItem Header="Image"><pages:ImagePage/></TabItem>
|
||||
<TabItem Header="LayoutTransformControl"><pages:LayoutTransformControlPage/></TabItem>
|
||||
<TabItem Header="Menu"><pages:MenuPage/></TabItem>
|
||||
<TabItem Header="RadioButton"><pages:RadioButtonPage/></TabItem>
|
||||
<TabItem Header="Slider"><pages:SliderPage/></TabItem>
|
||||
<TabItem Header="TextBox"><pages:TextBoxPage/></TabItem>
|
||||
<TabItem Header="ToolTip"><pages:ToolTipPage/></TabItem>
|
||||
<TabItem Header="TreeView"><pages:TreeViewPage/></TabItem>
|
||||
</TabControl>
|
||||
</UserControl>
|
|
@ -0,0 +1,19 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog
|
||||
{
|
||||
public class ControlCatalogControl : UserControl
|
||||
{
|
||||
public ControlCatalogControl()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +1,6 @@
|
|||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:pages="clr-namespace:ControlCatalog.Pages;assembly=ControlCatalog"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
<Window xmlns="https://github.com/avaloniaui" MinWidth="500" MinHeight="300"
|
||||
Title="Avalonia Control Gallery"
|
||||
Icon="resm:ControlCatalog.Assets.test_icon.ico?assembly=ControlCatalog">
|
||||
<TabControl Classes="sidebar">
|
||||
<TabControl.Transition>
|
||||
<CrossFade Duration="0.25"/>
|
||||
</TabControl.Transition>
|
||||
<TabItem Header="Border"><pages:BorderPage/></TabItem>
|
||||
<TabItem Header="Button"><pages:ButtonPage/></TabItem>
|
||||
<TabItem Header="Canvas"><pages:CanvasPage/></TabItem>
|
||||
<TabItem Header="Carousel"><pages:CarouselPage/></TabItem>
|
||||
<TabItem Header="CheckBox"><pages:CheckBoxPage/></TabItem>
|
||||
<TabItem Header="DropDown"><pages:DropDownPage/></TabItem>
|
||||
<TabItem Header="Expander"><pages:ExpanderPage/></TabItem>
|
||||
<TabItem Header="Image"><pages:ImagePage/></TabItem>
|
||||
<TabItem Header="LayoutTransformControl"><pages:LayoutTransformControlPage/></TabItem>
|
||||
<TabItem Header="Menu"><pages:MenuPage/></TabItem>
|
||||
<TabItem Header="RadioButton"><pages:RadioButtonPage/></TabItem>
|
||||
<TabItem Header="Slider"><pages:SliderPage/></TabItem>
|
||||
<TabItem Header="TextBox"><pages:TextBoxPage/></TabItem>
|
||||
<TabItem Header="ToolTip"><pages:ToolTipPage/></TabItem>
|
||||
<TabItem Header="TreeView"><pages:TreeViewPage/></TabItem>
|
||||
</TabControl>
|
||||
Icon="resm:ControlCatalog.Assets.test_icon.ico?assembly=ControlCatalog"
|
||||
xmlns:local="clr-namespace:ControlCatalog;assembly=ControlCatalog">
|
||||
<local:ControlCatalogControl/>
|
||||
</Window>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,119 @@
|
|||
using Avalonia.Win32.Embedding;
|
||||
|
||||
namespace WindowsInteropTest
|
||||
{
|
||||
partial class EmbedToWinFormsDemo
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.monthCalendar1 = new System.Windows.Forms.MonthCalendar();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.avaloniaHost = new WinFormsAvaloniaControlHost();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(28, 29);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(164, 73);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "button1";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// monthCalendar1
|
||||
//
|
||||
this.monthCalendar1.Location = new System.Drawing.Point(28, 114);
|
||||
this.monthCalendar1.Name = "monthCalendar1";
|
||||
this.monthCalendar1.TabIndex = 1;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.groupBox1.Controls.Add(this.button1);
|
||||
this.groupBox1.Controls.Add(this.monthCalendar1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(227, 418);
|
||||
this.groupBox1.TabIndex = 2;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "WinForms";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox2.Controls.Add(this.avaloniaHost);
|
||||
this.groupBox2.Location = new System.Drawing.Point(245, 12);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(501, 418);
|
||||
this.groupBox2.TabIndex = 3;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Avalonia";
|
||||
//
|
||||
// avaloniaHost
|
||||
//
|
||||
this.avaloniaHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.avaloniaHost.Child = null;
|
||||
this.avaloniaHost.Location = new System.Drawing.Point(6, 19);
|
||||
this.avaloniaHost.Name = "avaloniaHost";
|
||||
this.avaloniaHost.Size = new System.Drawing.Size(489, 393);
|
||||
this.avaloniaHost.TabIndex = 0;
|
||||
this.avaloniaHost.Text = "avaloniaHost";
|
||||
//
|
||||
// EmbedToWinFormsDemo
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(758, 442);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.MinimumSize = new System.Drawing.Size(600, 400);
|
||||
this.Name = "EmbedToWinFormsDemo";
|
||||
this.Text = "EmbedToWinFormsDemo";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.MonthCalendar monthCalendar1;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private WinFormsAvaloniaControlHost avaloniaHost;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Avalonia.Controls;
|
||||
using ControlCatalog;
|
||||
|
||||
namespace WindowsInteropTest
|
||||
{
|
||||
public partial class EmbedToWinFormsDemo : Form
|
||||
{
|
||||
public EmbedToWinFormsDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
var ctrl = new EmbeddableControl();
|
||||
ctrl.Content = new ControlCatalogControl();
|
||||
ctrl.ApplyTemplate();
|
||||
avaloniaHost.Child = ctrl;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,21 @@
|
|||
<Window x:Class="WindowsInteropTest.EmbedToWpfDemo"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WindowsInteropTest"
|
||||
xmlns:embedding="clr-namespace:Avalonia.Win32.Embedding;assembly=Avalonia.Win32"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400" d:DesignWidth="400" MinWidth="500" MinHeight="400">
|
||||
<DockPanel>
|
||||
<GroupBox DockPanel.Dock="Left" Header="WPF">
|
||||
<StackPanel>
|
||||
<Slider/>
|
||||
<Calendar/>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Avalonia">
|
||||
<embedding:WpfAvaloniaControlHost x:Name="Host"/>
|
||||
</GroupBox>
|
||||
</DockPanel>
|
||||
</Window>
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Avalonia.Controls;
|
||||
using ControlCatalog;
|
||||
using Window = System.Windows.Window;
|
||||
|
||||
namespace WindowsInteropTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EmbedToWpfDemo.xaml
|
||||
/// </summary>
|
||||
public partial class EmbedToWpfDemo : Window
|
||||
{
|
||||
public EmbedToWpfDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
Host.Child = new EmbeddableControl {Content = new ControlCatalogControl()};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using Avalonia.Controls;
|
||||
using ControlCatalog;
|
||||
using Avalonia;
|
||||
|
||||
namespace WindowsInteropTest
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
System.Windows.Forms.Application.EnableVisualStyles();
|
||||
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
|
||||
AppBuilder.Configure<App>().UseWin32().UseSkia().SetupWithoutStarting();
|
||||
System.Windows.Forms.Application.Run(new SelectorForm());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
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("WindowsInteropTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("WindowsInteropTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("c7a69145-60b6-4882-97d6-a3921dd43978")]
|
||||
|
||||
// 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")]
|
|
@ -0,0 +1,71 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WindowsInteropTest.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsInteropTest.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,30 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WindowsInteropTest.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,76 @@
|
|||
namespace WindowsInteropTest
|
||||
{
|
||||
partial class SelectorForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnEmbedToWinForms = new System.Windows.Forms.Button();
|
||||
this.btnEmbedToWpf = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnEmbedToWinForms
|
||||
//
|
||||
this.btnEmbedToWinForms.Location = new System.Drawing.Point(12, 12);
|
||||
this.btnEmbedToWinForms.Name = "btnEmbedToWinForms";
|
||||
this.btnEmbedToWinForms.Size = new System.Drawing.Size(201, 86);
|
||||
this.btnEmbedToWinForms.TabIndex = 0;
|
||||
this.btnEmbedToWinForms.Text = "Embed to WinForms";
|
||||
this.btnEmbedToWinForms.UseVisualStyleBackColor = true;
|
||||
this.btnEmbedToWinForms.Click += new System.EventHandler(this.btnEmbedToWinForms_Click);
|
||||
//
|
||||
// btnEmbedToWpf
|
||||
//
|
||||
this.btnEmbedToWpf.Location = new System.Drawing.Point(219, 12);
|
||||
this.btnEmbedToWpf.Name = "btnEmbedToWpf";
|
||||
this.btnEmbedToWpf.Size = new System.Drawing.Size(201, 86);
|
||||
this.btnEmbedToWpf.TabIndex = 1;
|
||||
this.btnEmbedToWpf.Text = "Embed to WPF";
|
||||
this.btnEmbedToWpf.UseVisualStyleBackColor = true;
|
||||
this.btnEmbedToWpf.Click += new System.EventHandler(this.btnEmbedToWpf_Click);
|
||||
//
|
||||
// SelectorForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(432, 284);
|
||||
this.Controls.Add(this.btnEmbedToWpf);
|
||||
this.Controls.Add(this.btnEmbedToWinForms);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "SelectorForm";
|
||||
this.Text = "Interop";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnEmbedToWinForms;
|
||||
private System.Windows.Forms.Button btnEmbedToWpf;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WindowsInteropTest
|
||||
{
|
||||
public partial class SelectorForm : Form
|
||||
{
|
||||
public SelectorForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnEmbedToWinForms_Click(object sender, EventArgs e)
|
||||
{
|
||||
new EmbedToWinFormsDemo().ShowDialog(this);
|
||||
}
|
||||
|
||||
private void btnEmbedToWpf_Click(object sender, EventArgs e)
|
||||
{
|
||||
new EmbedToWpfDemo().ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,186 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{C7A69145-60B6-4882-97D6-A3921DD43978}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WindowsInteropTest</RootNamespace>
|
||||
<AssemblyName>WindowsInteropTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EmbedToWinFormsDemo.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="EmbedToWinFormsDemo.Designer.cs">
|
||||
<DependentUpon>EmbedToWinFormsDemo.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EmbedToWpfDemo.xaml.cs">
|
||||
<DependentUpon>EmbedToWpfDemo.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SelectorForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SelectorForm.Designer.cs">
|
||||
<DependentUpon>SelectorForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="EmbedToWinFormsDemo.resx">
|
||||
<DependentUpon>EmbedToWinFormsDemo.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="SelectorForm.resx">
|
||||
<DependentUpon>SelectorForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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.DesignerSupport\Avalonia.DesignerSupport.csproj">
|
||||
<Project>{799a7bb5-3c2c-48b6-85a7-406a12c420da}</Project>
|
||||
<Name>Avalonia.DesignerSupport</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.ReactiveUI\Avalonia.ReactiveUI.csproj">
|
||||
<Project>{6417b24e-49c2-4985-8db2-3ab9d898ec91}</Project>
|
||||
<Name>Avalonia.ReactiveUI</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.SceneGraph\Avalonia.SceneGraph.csproj">
|
||||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
|
||||
<Name>Avalonia.SceneGraph</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.Desktop\Avalonia.Skia.Desktop.csproj">
|
||||
<Project>{925dd807-b651-475f-9f7c-cbeb974ce43d}</Project>
|
||||
<Name>Avalonia.Skia.Desktop</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj">
|
||||
<Project>{3e908f67-5543-4879-a1dc-08eace79b3cd}</Project>
|
||||
<Name>Avalonia.Direct2D1</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Windows\Avalonia.Win32\Avalonia.Win32.csproj">
|
||||
<Project>{811a76cf-1cf6-440f-963b-bbe31bd72a82}</Project>
|
||||
<Name>Avalonia.Win32</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\ControlCatalog\ControlCatalog.csproj">
|
||||
<Project>{d0a739b9-3c68-4ba6-a328-41606954b6bd}</Project>
|
||||
<Name>ControlCatalog</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="EmbedToWpfDemo.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -56,6 +56,7 @@
|
|||
<Compile Include="HotkeyManager.cs" />
|
||||
<Compile Include="IApplicationLifecycle.cs" />
|
||||
<Compile Include="IScrollable.cs" />
|
||||
<Compile Include="EmbeddableControl.cs" />
|
||||
<Compile Include="WindowIcon.cs" />
|
||||
<Compile Include="IPseudoClasses.cs" />
|
||||
<Compile Include="DropDownItem.cs" />
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls.Platform;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Styling;
|
||||
|
||||
namespace Avalonia.Controls
|
||||
{
|
||||
public class EmbeddableControl : TopLevel, IStyleable, IFocusScope, ILayoutRoot, INameScope
|
||||
{
|
||||
public EmbeddableControl() : base(PlatformManager.CreateEmbeddableWindow())
|
||||
{
|
||||
PlatformImpl.Show();
|
||||
}
|
||||
|
||||
public void Prepare()
|
||||
{
|
||||
EnsureInitialized();
|
||||
ApplyTemplate();
|
||||
LayoutManager.Instance.ExecuteInitialLayoutPass(this);
|
||||
PlatformImpl.Show();
|
||||
}
|
||||
|
||||
|
||||
private void EnsureInitialized()
|
||||
{
|
||||
if (!this.IsInitialized)
|
||||
{
|
||||
var init = (ISupportInitialize)this;
|
||||
init.BeginInit();
|
||||
init.EndInit();
|
||||
}
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
return PlatformImpl.ClientSize;
|
||||
}
|
||||
|
||||
private readonly NameScope _nameScope = new NameScope();
|
||||
public event EventHandler<NameScopeEventArgs> Registered
|
||||
{
|
||||
add { _nameScope.Registered += value; }
|
||||
remove { _nameScope.Registered -= value; }
|
||||
}
|
||||
|
||||
public event EventHandler<NameScopeEventArgs> Unregistered
|
||||
{
|
||||
add { _nameScope.Unregistered += value; }
|
||||
remove { _nameScope.Unregistered -= value; }
|
||||
}
|
||||
|
||||
public void Register(string name, object element) => _nameScope.Register(name, element);
|
||||
|
||||
public object Find(string name) => _nameScope.Find(name);
|
||||
|
||||
public void Unregister(string name) => _nameScope.Unregister(name);
|
||||
|
||||
Type IStyleable.StyleKey => typeof(EmbeddableControl);
|
||||
}
|
||||
}
|
|
@ -43,6 +43,14 @@ namespace Avalonia.Controls.Platform
|
|||
return s_designerMode ? platform.CreateEmbeddableWindow() : platform.CreateWindow();
|
||||
}
|
||||
|
||||
public static IWindowImpl CreateEmbeddableWindow()
|
||||
{
|
||||
var platform = AvaloniaLocator.Current.GetService<IWindowingPlatform>();
|
||||
if (platform == null)
|
||||
throw new Exception("Could not CreateEmbeddableWindow(): IWindowingPlatform is not registered.");
|
||||
return platform.CreateEmbeddableWindow();
|
||||
}
|
||||
|
||||
public static IPopupImpl CreatePopup()
|
||||
{
|
||||
return AvaloniaLocator.Current.GetService<IWindowingPlatform>().CreatePopup();
|
||||
|
|
|
@ -208,6 +208,11 @@
|
|||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="EmbeddableControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -32,4 +32,5 @@
|
|||
<StyleInclude Source="resm:Avalonia.Themes.Default.TreeView.xaml?assembly=Avalonia.Themes.Default"/>
|
||||
<StyleInclude Source="resm:Avalonia.Themes.Default.TreeViewItem.xaml?assembly=Avalonia.Themes.Default"/>
|
||||
<StyleInclude Source="resm:Avalonia.Themes.Default.Window.xaml?assembly=Avalonia.Themes.Default"/>
|
||||
<StyleInclude Source="resm:Avalonia.Themes.Default.EmbeddableControl.xaml?assembly=Avalonia.Themes.Default"/>
|
||||
</Styles>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<Style xmlns="https://github.com/avaloniaui" Selector="EmbeddableControl">
|
||||
<Setter Property="Background" Value="{StyleResource ThemeBackgroundBrush}"/>
|
||||
<Setter Property="FontFamily" Value="Segoe UI"/>
|
||||
<Setter Property="FontSize" Value="{StyleResource FontSizeNormal}"/>
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border Background="{TemplateBinding Background}">
|
||||
<AdornerDecorator>
|
||||
<ContentPresenter Name="PART_ContentPresenter"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Margin="{TemplateBinding Padding}"/>
|
||||
</AdornerDecorator>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</Style>
|
|
@ -38,6 +38,8 @@
|
|||
<NoWarn>CS1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
|
@ -53,12 +55,19 @@
|
|||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="WindowsFormsIntegration" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ClipboardImpl.cs" />
|
||||
<Compile Include="Embedding\WinFormsAvaloniaControlHost.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Embedding\WpfAvaloniaControlHost.cs" />
|
||||
<Compile Include="IconImpl.cs" />
|
||||
<Compile Include="SystemDialogImpl.cs" />
|
||||
<Compile Include="CursorFactory.cs" />
|
||||
|
|
|
@ -6,10 +6,12 @@ using Avalonia.Win32.Interop;
|
|||
|
||||
namespace Avalonia.Win32
|
||||
{
|
||||
public class EmbeddedWindowImpl : WindowImpl
|
||||
class EmbeddedWindowImpl : WindowImpl
|
||||
{
|
||||
private static readonly System.Windows.Forms.UserControl WinFormsControl = new System.Windows.Forms.UserControl();
|
||||
|
||||
public static IntPtr DefaultParentWindow => WinFormsControl.Handle;
|
||||
|
||||
protected override IntPtr CreateWindowOverride(ushort atom)
|
||||
{
|
||||
var hWnd = UnmanagedMethods.CreateWindowEx(
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Win32.Interop;
|
||||
using Control = System.Windows.Forms.Control;
|
||||
|
||||
namespace Avalonia.Win32.Embedding
|
||||
{
|
||||
[ToolboxItem(true)]
|
||||
public class WinFormsAvaloniaControlHost : Control
|
||||
{
|
||||
private EmbeddableControl _child;
|
||||
|
||||
public EmbeddableControl Child
|
||||
{
|
||||
get { return _child; }
|
||||
set
|
||||
{
|
||||
if (value !=null && value.PlatformImpl.Handle.HandleDescriptor != PlatformConstants.WindowHandleType)
|
||||
throw new ArgumentException("Invalid widget for embedding, don't know what to do with " +
|
||||
value.PlatformImpl.Handle.HandleDescriptor);
|
||||
if (_child != null)
|
||||
{
|
||||
_child.PlatformImpl.Hide();
|
||||
UnmanagedMethods.SetParent(_child.PlatformImpl.Handle.Handle, EmbeddedWindowImpl.DefaultParentWindow);
|
||||
}
|
||||
_child = value;
|
||||
if (_child != null)
|
||||
{
|
||||
UnmanagedMethods.SetParent(_child.PlatformImpl.Handle.Handle, Handle);
|
||||
_child.Prepare();
|
||||
FixPosition();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FixPosition()
|
||||
{
|
||||
if (_child != null && Width > 0 && Height > 0)
|
||||
UnmanagedMethods.MoveWindow(_child.PlatformImpl.Handle.Handle, 0, 0, Width, Height, true);
|
||||
}
|
||||
|
||||
public WinFormsAvaloniaControlHost()
|
||||
{
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
FixPosition();
|
||||
base.OnResize(e);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
if (Child == null)
|
||||
base.OnPaint(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms.Integration;
|
||||
using System.Windows.Interop;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Win32.Interop;
|
||||
|
||||
namespace Avalonia.Win32.Embedding
|
||||
{
|
||||
public class WpfAvaloniaControlHost : HwndHost
|
||||
{
|
||||
private WinFormsAvaloniaControlHost _host;
|
||||
private EmbeddableControl _child;
|
||||
|
||||
public EmbeddableControl Child
|
||||
{
|
||||
get { return _child; }
|
||||
set
|
||||
{
|
||||
if (_host != null)
|
||||
_host.Child = value;
|
||||
_child = value;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyHost()
|
||||
{
|
||||
_host?.Dispose();
|
||||
_host = null;
|
||||
}
|
||||
|
||||
protected override HandleRef BuildWindowCore(HandleRef hwndParent)
|
||||
{
|
||||
DestroyHost();
|
||||
_host = new WinFormsAvaloniaControlHost {Child = _child};
|
||||
UnmanagedMethods.SetParent(_host.Handle, hwndParent.Handle);
|
||||
return new HandleRef(this, _host.Handle);
|
||||
}
|
||||
|
||||
protected override void DestroyWindowCore(HandleRef hwnd)
|
||||
{
|
||||
DestroyHost();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ using Avalonia.Win32.Interop;
|
|||
|
||||
namespace Avalonia.Win32.Input
|
||||
{
|
||||
public static class KeyInterop
|
||||
static class KeyInterop
|
||||
{
|
||||
private static readonly Dictionary<Key, int> s_virtualKeyFromKey = new Dictionary<Key, int>
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ using Avalonia.Win32.Interop;
|
|||
|
||||
namespace Avalonia.Win32.Input
|
||||
{
|
||||
public class WindowsKeyboardDevice : KeyboardDevice
|
||||
class WindowsKeyboardDevice : KeyboardDevice
|
||||
{
|
||||
private readonly byte[] _keyStates = new byte[256];
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ using Avalonia.Win32.Interop;
|
|||
|
||||
namespace Avalonia.Win32.Input
|
||||
{
|
||||
public class WindowsMouseDevice : MouseDevice
|
||||
class WindowsMouseDevice : MouseDevice
|
||||
{
|
||||
public new static WindowsMouseDevice Instance { get; } = new WindowsMouseDevice();
|
||||
|
||||
|
|
|
@ -727,7 +727,8 @@ namespace Avalonia.Win32.Interop
|
|||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags uFlags);
|
||||
[DllImport("user32.dll")]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace Avalonia.Win32
|
||||
{
|
||||
public static class PlatformConstants
|
||||
static class PlatformConstants
|
||||
{
|
||||
public const string WindowHandleType = "HWND";
|
||||
public const string CursorHandleType = "HCURSOR";
|
||||
|
|
|
@ -7,7 +7,7 @@ using Avalonia.Win32.Interop;
|
|||
|
||||
namespace Avalonia.Win32
|
||||
{
|
||||
public class PopupImpl : WindowImpl, IPopupImpl
|
||||
class PopupImpl : WindowImpl, IPopupImpl
|
||||
{
|
||||
public override void Show()
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Avalonia
|
|||
|
||||
namespace Avalonia.Win32
|
||||
{
|
||||
public class Win32Platform : IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform, IPlatformIconLoader
|
||||
class Win32Platform : IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform, IPlatformIconLoader
|
||||
{
|
||||
private static readonly Win32Platform s_instance = new Win32Platform();
|
||||
private static Thread _uiThread;
|
||||
|
|
|
@ -18,7 +18,7 @@ using Avalonia.Win32.Interop;
|
|||
|
||||
namespace Avalonia.Win32
|
||||
{
|
||||
public class WindowImpl : IWindowImpl
|
||||
class WindowImpl : IWindowImpl
|
||||
{
|
||||
private static readonly List<WindowImpl> s_instances = new List<WindowImpl>();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче