218 changed files with 7364 additions and 2674 deletions
@ -0,0 +1,17 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace BindingTest.ViewModels |
|||
{ |
|||
public class DataAnnotationsErrorViewModel |
|||
{ |
|||
[Phone] |
|||
[MaxLength(10)] |
|||
public string PhoneNumber { get; set; } |
|||
|
|||
[Range(0, 9)] |
|||
public int LessThan10 { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using ReactiveUI; |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Collections; |
|||
|
|||
namespace BindingTest.ViewModels |
|||
{ |
|||
public class IndeiErrorViewModel : ReactiveObject, INotifyDataErrorInfo |
|||
{ |
|||
private int _maximum = 10; |
|||
private int _value; |
|||
private string _valueError; |
|||
|
|||
public IndeiErrorViewModel() |
|||
{ |
|||
this.WhenAnyValue(x => x.Maximum, x => x.Value) |
|||
.Subscribe(_ => UpdateErrors()); |
|||
} |
|||
|
|||
public bool HasErrors |
|||
{ |
|||
get { throw new NotImplementedException(); } |
|||
} |
|||
|
|||
public int Maximum |
|||
{ |
|||
get { return _maximum; } |
|||
set { this.RaiseAndSetIfChanged(ref _maximum, value); } |
|||
} |
|||
|
|||
public int Value |
|||
{ |
|||
get { return _value; } |
|||
set { this.RaiseAndSetIfChanged(ref _value, value); } |
|||
} |
|||
|
|||
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged; |
|||
|
|||
public IEnumerable GetErrors(string propertyName) |
|||
{ |
|||
switch (propertyName) |
|||
{ |
|||
case nameof(Value): |
|||
return new[] { _valueError }; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
private void UpdateErrors() |
|||
{ |
|||
if (Value <= Maximum) |
|||
{ |
|||
if (_valueError != null) |
|||
{ |
|||
_valueError = null; |
|||
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Value))); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
if (_valueError == null) |
|||
{ |
|||
_valueError = "Value must be less than Maximum"; |
|||
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Value))); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -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 MainView : UserControl |
|||
{ |
|||
public MainView() |
|||
{ |
|||
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:MainView/> |
|||
</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,160 @@ |
|||
<?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>{BD7F352C-6DC1-4740-BAF2-2D34A038728C}</ProjectGuid> |
|||
<OutputType>WinExe</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>GtkInteropDemo</RootNamespace> |
|||
<AssemblyName>GtkInteropDemo</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> |
|||
<UseVSHostingProcess>false</UseVSHostingProcess> |
|||
</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="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> |
|||
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> |
|||
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> |
|||
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<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.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="MainWindow.cs" /> |
|||
<Compile Include="Program.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<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> |
|||
<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.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj"> |
|||
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project> |
|||
<Name>Avalonia.DotNetFrameworkRuntime</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\Gtk\Avalonia.Cairo\Avalonia.Cairo.csproj"> |
|||
<Project>{fb05ac90-89ba-4f2f-a924-f37875fb547c}</Project> |
|||
<Name>Avalonia.Cairo</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Gtk\Avalonia.Gtk\Avalonia.Gtk.csproj"> |
|||
<Project>{54f237d5-a70a-4752-9656-0c70b1a7b047}</Project> |
|||
<Name>Avalonia.Gtk</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="..\..\ControlCatalog\ControlCatalog.csproj"> |
|||
<Project>{d0a739b9-3c68-4ba6-a328-41606954b6bd}</Project> |
|||
<Name>ControlCatalog</Name> |
|||
</ProjectReference> |
|||
</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> |
|||
@ -0,0 +1,26 @@ |
|||
<ProjectConfiguration> |
|||
<AutoDetectNugetBuildDependencies>true</AutoDetectNugetBuildDependencies> |
|||
<BuildPriority>1000</BuildPriority> |
|||
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace> |
|||
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing> |
|||
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies> |
|||
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking> |
|||
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking> |
|||
<AllowCodeAnalysis>false</AllowCodeAnalysis> |
|||
<IgnoreThisComponentCompletely>true</IgnoreThisComponentCompletely> |
|||
<RunPreBuildEvents>false</RunPreBuildEvents> |
|||
<RunPostBuildEvents>false</RunPostBuildEvents> |
|||
<PreviouslyBuiltSuccessfully>false</PreviouslyBuiltSuccessfully> |
|||
<InstrumentAssembly>true</InstrumentAssembly> |
|||
<PreventSigningOfAssembly>false</PreventSigningOfAssembly> |
|||
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> |
|||
<DetectStackOverflow>true</DetectStackOverflow> |
|||
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> |
|||
<DefaultTestTimeout>60000</DefaultTestTimeout> |
|||
<UseBuildConfiguration /> |
|||
<UseBuildPlatform /> |
|||
<ProxyProcessPath /> |
|||
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> |
|||
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState> |
|||
<BuildProcessArchitecture>x86</BuildProcessArchitecture> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Diagnostics; |
|||
using Avalonia.Gtk.Embedding; |
|||
using ControlCatalog; |
|||
using Gtk; |
|||
|
|||
namespace GtkInteropDemo |
|||
{ |
|||
class MainWindow : Window |
|||
{ |
|||
public MainWindow() : base("Gtk Embedding Demo") |
|||
{ |
|||
var root = new HBox(); |
|||
var left = new VBox(); |
|||
left.Add(new Button("I'm GTK button")); |
|||
left.Add(new Calendar()); |
|||
root.PackEnd(left, false, false, 0); |
|||
var host = new GtkAvaloniaControlHost() {Content = new MainView()}; |
|||
host.SetSizeRequest(600, 600); |
|||
root.PackStart(host, true, true, 0); |
|||
Add(root); |
|||
|
|||
ShowAll(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using ControlCatalog; |
|||
|
|||
namespace GtkInteropDemo |
|||
{ |
|||
static class Program |
|||
{ |
|||
/// <summary>
|
|||
/// The main entry point for the application.
|
|||
/// </summary>
|
|||
[STAThread] |
|||
static void Main() |
|||
{ |
|||
AppBuilder.Configure<App>().UseGtk().UseCairo().SetupWithoutStarting(); |
|||
new MainWindow().Show(); |
|||
Gtk.Application.Run(); |
|||
} |
|||
} |
|||
} |
|||
@ -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("GtkInteropDemo")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("GtkInteropDemo")] |
|||
[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("bd7f352c-6dc1-4740-baf2-2d34a038728c")] |
|||
|
|||
// 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 GtkInteropDemo.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("GtkInteropDemo.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 GtkInteropDemo.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,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.Content = 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,23 @@ |
|||
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(); |
|||
avaloniaHost.Content = new MainView(); |
|||
} |
|||
} |
|||
} |
|||
@ -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.Content = new MainView(); |
|||
} |
|||
} |
|||
} |
|||
@ -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,190 @@ |
|||
<?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.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj"> |
|||
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project> |
|||
<Name>Avalonia.DotNetFrameworkRuntime</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> |
|||
@ -0,0 +1,26 @@ |
|||
<ProjectConfiguration> |
|||
<AutoDetectNugetBuildDependencies>true</AutoDetectNugetBuildDependencies> |
|||
<BuildPriority>1000</BuildPriority> |
|||
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace> |
|||
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing> |
|||
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies> |
|||
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking> |
|||
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking> |
|||
<AllowCodeAnalysis>false</AllowCodeAnalysis> |
|||
<IgnoreThisComponentCompletely>true</IgnoreThisComponentCompletely> |
|||
<RunPreBuildEvents>false</RunPreBuildEvents> |
|||
<RunPostBuildEvents>false</RunPostBuildEvents> |
|||
<PreviouslyBuiltSuccessfully>false</PreviouslyBuiltSuccessfully> |
|||
<InstrumentAssembly>true</InstrumentAssembly> |
|||
<PreventSigningOfAssembly>false</PreventSigningOfAssembly> |
|||
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> |
|||
<DetectStackOverflow>true</DetectStackOverflow> |
|||
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> |
|||
<DefaultTestTimeout>60000</DefaultTestTimeout> |
|||
<UseBuildConfiguration /> |
|||
<UseBuildPlatform /> |
|||
<ProxyProcessPath /> |
|||
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> |
|||
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState> |
|||
<BuildProcessArchitecture>x86</BuildProcessArchitecture> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,85 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Data |
|||
{ |
|||
/// <summary>
|
|||
/// An exception returned through <see cref="BindingNotification"/> signalling that a
|
|||
/// requested binding expression could not be evaluated because of a null in one of the links
|
|||
/// of the binding chain.
|
|||
/// </summary>
|
|||
public class BindingChainNullException : Exception |
|||
{ |
|||
private string _message; |
|||
|
|||
/// <summary>
|
|||
/// Initalizes a new instance of the <see cref="BindingChainNullException"/> class.
|
|||
/// </summary>
|
|||
public BindingChainNullException() |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initalizes a new instance of the <see cref="BindingChainNullException"/> class.
|
|||
/// </summary>
|
|||
public BindingChainNullException(string message) |
|||
{ |
|||
_message = message; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initalizes a new instance of the <see cref="BindingChainNullException"/> class.
|
|||
/// </summary>
|
|||
/// <param name="expression">The expression.</param>
|
|||
/// <param name="expressionNullPoint">
|
|||
/// The point in the expression at which the null was encountered.
|
|||
/// </param>
|
|||
public BindingChainNullException(string expression, string expressionNullPoint) |
|||
{ |
|||
Expression = expression; |
|||
ExpressionNullPoint = expressionNullPoint; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the expression that could not be evaluated.
|
|||
/// </summary>
|
|||
public string Expression { get; protected set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the point in the expression at which the null was encountered.
|
|||
/// </summary>
|
|||
public string ExpressionNullPoint { get; protected set; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public override string Message |
|||
{ |
|||
get |
|||
{ |
|||
if (_message == null) |
|||
{ |
|||
_message = BuildMessage(); |
|||
} |
|||
|
|||
return _message; |
|||
} |
|||
} |
|||
|
|||
private string BuildMessage() |
|||
{ |
|||
if (Expression != null && ExpressionNullPoint != null) |
|||
{ |
|||
return $"'{ExpressionNullPoint}' is null in expression '{Expression}'."; |
|||
} |
|||
else if (ExpressionNullPoint != null) |
|||
{ |
|||
return $"'{ExpressionNullPoint}' is null in expression."; |
|||
} |
|||
else |
|||
{ |
|||
return "Null encountered in binding expression."; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,59 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Data |
|||
{ |
|||
/// <summary>
|
|||
/// Represents a recoverable binding error.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// When produced by a binding source observable, informs the binding system that an error
|
|||
/// occurred. It can also provide an optional fallback value to be pushed to the binding
|
|||
/// target.
|
|||
///
|
|||
/// Instead of using <see cref="BindingError"/>, one could simply not push a value (in the
|
|||
/// case of a no fallback value) or push a fallback value, but BindingError also causes an
|
|||
/// error to be logged with the correct binding target.
|
|||
/// </remarks>
|
|||
public class BindingError |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="BindingError"/> class.
|
|||
/// </summary>
|
|||
/// <param name="exception">An exception describing the binding error.</param>
|
|||
public BindingError(Exception exception) |
|||
{ |
|||
Exception = exception; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="BindingError"/> class.
|
|||
/// </summary>
|
|||
/// <param name="exception">An exception describing the binding error.</param>
|
|||
/// <param name="fallbackValue">The fallback value.</param>
|
|||
public BindingError(Exception exception, object fallbackValue) |
|||
{ |
|||
Exception = exception; |
|||
FallbackValue = fallbackValue; |
|||
UseFallbackValue = true; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the exception describing the binding error.
|
|||
/// </summary>
|
|||
public Exception Exception { get; } |
|||
|
|||
/// <summary>
|
|||
/// Get the fallback value.
|
|||
/// </summary>
|
|||
public object FallbackValue { get; } |
|||
|
|||
/// <summary>
|
|||
/// Get a value indicating whether the fallback value should be pushed to the binding
|
|||
/// target.
|
|||
/// </summary>
|
|||
public bool UseFallbackValue { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,282 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Data |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the types of binding errors for a <see cref="BindingNotification"/>.
|
|||
/// </summary>
|
|||
public enum BindingErrorType |
|||
{ |
|||
/// <summary>
|
|||
/// There was no error.
|
|||
/// </summary>
|
|||
None, |
|||
|
|||
/// <summary>
|
|||
/// There was a binding error.
|
|||
/// </summary>
|
|||
Error, |
|||
|
|||
/// <summary>
|
|||
/// There was a data validation error.
|
|||
/// </summary>
|
|||
DataValidationError, |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Represents a binding notification that can be a valid binding value, or a binding or
|
|||
/// data validation error.
|
|||
/// </summary>
|
|||
public class BindingNotification |
|||
{ |
|||
/// <summary>
|
|||
/// A binding notification representing the null value.
|
|||
/// </summary>
|
|||
public static readonly BindingNotification Null = |
|||
new BindingNotification(null); |
|||
|
|||
/// <summary>
|
|||
/// A binding notification representing <see cref="AvaloniaProperty.UnsetValue"/>.
|
|||
/// </summary>
|
|||
public static readonly BindingNotification UnsetValue = |
|||
new BindingNotification(AvaloniaProperty.UnsetValue); |
|||
|
|||
// Null cannot be held in WeakReference as it's indistinguishable from an expired value so
|
|||
// use this value in its place.
|
|||
private static readonly object NullValue = new object(); |
|||
|
|||
private WeakReference<object> _value; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="BindingNotification"/> class.
|
|||
/// </summary>
|
|||
/// <param name="value">The binding value.</param>
|
|||
public BindingNotification(object value) |
|||
{ |
|||
_value = new WeakReference<object>(value ?? NullValue); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="BindingNotification"/> class.
|
|||
/// </summary>
|
|||
/// <param name="error">The binding error.</param>
|
|||
/// <param name="errorType">The type of the binding error.</param>
|
|||
public BindingNotification(Exception error, BindingErrorType errorType) |
|||
{ |
|||
if (errorType == BindingErrorType.None) |
|||
{ |
|||
throw new ArgumentException($"'errorType' may not be None"); |
|||
} |
|||
|
|||
Error = error; |
|||
ErrorType = errorType; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="BindingNotification"/> class.
|
|||
/// </summary>
|
|||
/// <param name="error">The binding error.</param>
|
|||
/// <param name="errorType">The type of the binding error.</param>
|
|||
/// <param name="fallbackValue">The fallback value.</param>
|
|||
public BindingNotification(Exception error, BindingErrorType errorType, object fallbackValue) |
|||
: this(error, errorType) |
|||
{ |
|||
_value = new WeakReference<object>(fallbackValue ?? NullValue); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the value that should be passed to the target when <see cref="HasValue"/>
|
|||
/// is true.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// If this property is read when <see cref="HasValue"/> is false then it will return
|
|||
/// <see cref="AvaloniaProperty.UnsetValue"/>.
|
|||
/// </remarks>
|
|||
public object Value |
|||
{ |
|||
get |
|||
{ |
|||
if (_value != null) |
|||
{ |
|||
object result; |
|||
|
|||
if (_value.TryGetTarget(out result)) |
|||
{ |
|||
return result == NullValue ? null : result; |
|||
} |
|||
} |
|||
|
|||
// There's the possibility of a race condition in that HasValue can return true,
|
|||
// and then the value is GC'd before Value is read. We should be ok though as
|
|||
// we return UnsetValue which should be a safe alternative.
|
|||
return AvaloniaProperty.UnsetValue; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets a value indicating whether <see cref="Value"/> should be pushed to the target.
|
|||
/// </summary>
|
|||
public bool HasValue => _value != null; |
|||
|
|||
/// <summary>
|
|||
/// Gets the error that occurred on the source, if any.
|
|||
/// </summary>
|
|||
public Exception Error { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the type of error that <see cref="Error"/> represents, if any.
|
|||
/// </summary>
|
|||
public BindingErrorType ErrorType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Compares two instances of <see cref="BindingNotification"/> for equality.
|
|||
/// </summary>
|
|||
/// <param name="a">The first instance.</param>
|
|||
/// <param name="b">The second instance.</param>
|
|||
/// <returns>true if the two instances are equal; otherwise false.</returns>
|
|||
public static bool operator ==(BindingNotification a, BindingNotification b) |
|||
{ |
|||
if (object.ReferenceEquals(a, b)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
if ((object)a == null || (object)b == null) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return a.HasValue == b.HasValue && |
|||
a.ErrorType == b.ErrorType && |
|||
(!a.HasValue || object.Equals(a.Value, b.Value)) && |
|||
(a.ErrorType == BindingErrorType.None || ExceptionEquals(a.Error, b.Error)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Compares two instances of <see cref="BindingNotification"/> for inequality.
|
|||
/// </summary>
|
|||
/// <param name="a">The first instance.</param>
|
|||
/// <param name="b">The second instance.</param>
|
|||
/// <returns>true if the two instances are unequal; otherwise false.</returns>
|
|||
public static bool operator !=(BindingNotification a, BindingNotification b) |
|||
{ |
|||
return !(a == b); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets a value from an object that may be a <see cref="BindingNotification"/>.
|
|||
/// </summary>
|
|||
/// <param name="o">The object.</param>
|
|||
/// <returns>The value.</returns>
|
|||
/// <remarks>
|
|||
/// If <paramref name="o"/> is a <see cref="BindingNotification"/> then returns the binding
|
|||
/// notification's <see cref="Value"/>. If not, returns the object unchanged.
|
|||
/// </remarks>
|
|||
public static object ExtractValue(object o) |
|||
{ |
|||
var notification = o as BindingNotification; |
|||
return notification != null ? notification.Value : o; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets an exception from an object that may be a <see cref="BindingNotification"/>.
|
|||
/// </summary>
|
|||
/// <param name="o">The object.</param>
|
|||
/// <returns>The value.</returns>
|
|||
/// <remarks>
|
|||
/// If <paramref name="o"/> is a <see cref="BindingNotification"/> then returns the binding
|
|||
/// notification's <see cref="Error"/>. If not, returns the object unchanged.
|
|||
/// </remarks>
|
|||
public static object ExtractError(object o) |
|||
{ |
|||
var notification = o as BindingNotification; |
|||
return notification != null ? notification.Error : o; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Compares an object to an instance of <see cref="BindingNotification"/> for equality.
|
|||
/// </summary>
|
|||
/// <param name="obj">The object to compare.</param>
|
|||
/// <returns>true if the two instances are equal; otherwise false.</returns>
|
|||
public override bool Equals(object obj) |
|||
{ |
|||
return Equals(obj as BindingNotification); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Compares a value to an instance of <see cref="BindingNotification"/> for equality.
|
|||
/// </summary>
|
|||
/// <param name="other">The value to compare.</param>
|
|||
/// <returns>true if the two instances are equal; otherwise false.</returns>
|
|||
public bool Equals(BindingNotification other) |
|||
{ |
|||
return this == other; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the hash code for this instance of <see cref="BindingNotification"/>.
|
|||
/// </summary>
|
|||
/// <returns>A hash code.</returns>
|
|||
public override int GetHashCode() |
|||
{ |
|||
return base.GetHashCode(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Adds an error to the <see cref="BindingNotification"/>.
|
|||
/// </summary>
|
|||
/// <param name="e">The error to add.</param>
|
|||
/// <param name="type">The error type.</param>
|
|||
public void AddError(Exception e, BindingErrorType type) |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(e != null); |
|||
Contract.Requires<ArgumentException>(type != BindingErrorType.None); |
|||
|
|||
Error = Error != null ? new AggregateException(Error, e) : e; |
|||
|
|||
if (type == BindingErrorType.Error || ErrorType == BindingErrorType.Error) |
|||
{ |
|||
ErrorType = BindingErrorType.Error; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Removes the <see cref="Value"/> and makes <see cref="HasValue"/> return null.
|
|||
/// </summary>
|
|||
public void ClearValue() |
|||
{ |
|||
_value = null; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Sets the <see cref="Value"/>.
|
|||
/// </summary>
|
|||
public void SetValue(object value) |
|||
{ |
|||
_value = new WeakReference<object>(value ?? NullValue); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public override string ToString() |
|||
{ |
|||
switch (ErrorType) |
|||
{ |
|||
case BindingErrorType.None: |
|||
return $"{{Value: {Value}}}"; |
|||
default: |
|||
return HasValue ? |
|||
$"{{{ErrorType}: {Error}, Fallback: {Value}}}" : |
|||
$"{{{ErrorType}: {Error}}}"; |
|||
} |
|||
} |
|||
|
|||
private static bool ExceptionEquals(Exception a, Exception b) |
|||
{ |
|||
return a?.GetType() == b?.GetType() && |
|||
a?.Message == b?.Message; |
|||
} |
|||
} |
|||
} |
|||
@ -1,17 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia.Data |
|||
{ |
|||
/// <summary>
|
|||
/// Contains information on if the current object passed validation.
|
|||
/// Subclasses of this class contain additional information depending on the method of validation checking.
|
|||
/// </summary>
|
|||
public interface IValidationStatus |
|||
{ |
|||
/// <summary>
|
|||
/// True when the data passes validation; otherwise, false.
|
|||
/// </summary>
|
|||
bool IsValid { get; } |
|||
} |
|||
} |
|||
@ -1,44 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace Avalonia.Data |
|||
{ |
|||
/// <summary>
|
|||
/// An immutable struct that contains validation information for a <see cref="AvaloniaObject"/> that validates a single property.
|
|||
/// </summary>
|
|||
public struct ObjectValidationStatus : IValidationStatus |
|||
{ |
|||
private Dictionary<Type, IValidationStatus> currentValidationStatus; |
|||
|
|||
public bool IsValid => currentValidationStatus?.Values.All(status => status.IsValid) ?? true; |
|||
|
|||
/// <summary>
|
|||
/// Constructs the structure with the given validation information.
|
|||
/// </summary>
|
|||
/// <param name="validations">The validation information</param>
|
|||
public ObjectValidationStatus(Dictionary<Type, IValidationStatus> validations) |
|||
:this() |
|||
{ |
|||
currentValidationStatus = validations; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates a new status with the updated information.
|
|||
/// </summary>
|
|||
/// <param name="status">The updated status information.</param>
|
|||
/// <returns>The new validation status.</returns>
|
|||
public ObjectValidationStatus UpdateValidationStatus(IValidationStatus status) |
|||
{ |
|||
var newStatus = new Dictionary<Type, IValidationStatus>(currentValidationStatus ?? |
|||
new Dictionary<Type, IValidationStatus>()); |
|||
newStatus[status.GetType()] = status; |
|||
return new ObjectValidationStatus(newStatus); |
|||
} |
|||
|
|||
public IEnumerable<IValidationStatus> StatusInformation => currentValidationStatus.Values; |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Avalonia.Utilities |
|||
{ |
|||
internal static class ExceptionUtilities |
|||
{ |
|||
public static string GetMessage(Exception e) |
|||
{ |
|||
var aggregate = e as AggregateException; |
|||
|
|||
if (aggregate != null) |
|||
{ |
|||
return string.Join(" | ", aggregate.InnerExceptions.Select(x => x.Message)); |
|||
} |
|||
|
|||
return e.Message; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive; |
|||
using System.Reactive.Linq; |
|||
|
|||
namespace Avalonia.Utilities |
|||
{ |
|||
/// <summary>
|
|||
/// Provides extension methods for working with weak event handlers.
|
|||
/// </summary>
|
|||
public static class WeakObservable |
|||
{ |
|||
/// <summary>
|
|||
/// Converts a .NET event conforming to the standard .NET event pattern into an observable
|
|||
/// sequence, subscribing weakly.
|
|||
/// </summary>
|
|||
/// <typeparam name="TEventArgs">The type of the event args.</typeparam>
|
|||
/// <param name="target">Object instance that exposes the event to convert.</param>
|
|||
/// <param name="eventName">Name of the event to convert.</param>
|
|||
/// <returns></returns>
|
|||
public static IObservable<EventPattern<object, TEventArgs>> FromEventPattern<TEventArgs>( |
|||
object target, |
|||
string eventName) |
|||
where TEventArgs : EventArgs |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(target != null); |
|||
Contract.Requires<ArgumentNullException>(eventName != null); |
|||
|
|||
return Observable.Create<EventPattern<object, TEventArgs>>(observer => |
|||
{ |
|||
var handler = new Handler<TEventArgs>(observer); |
|||
WeakSubscriptionManager.Subscribe(target, eventName, handler); |
|||
return () => WeakSubscriptionManager.Unsubscribe(target, eventName, handler); |
|||
}).Publish().RefCount(); |
|||
} |
|||
|
|||
private class Handler<TEventArgs> : IWeakSubscriber<TEventArgs> where TEventArgs : EventArgs |
|||
{ |
|||
private IObserver<EventPattern<object, TEventArgs>> _observer; |
|||
|
|||
public Handler(IObserver<EventPattern<object, TEventArgs>> observer) |
|||
{ |
|||
_observer = observer; |
|||
} |
|||
|
|||
public void OnEvent(object sender, TEventArgs e) |
|||
{ |
|||
_observer.OnNext(new EventPattern<object, TEventArgs>(sender, e)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
using System; |
|||
using Avalonia.Controls.Platform; |
|||
using Avalonia.Input; |
|||
using Avalonia.Layout; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Styling; |
|||
|
|||
namespace Avalonia.Controls.Embedding |
|||
{ |
|||
public class EmbeddableControlRoot : TopLevel, IStyleable, IFocusScope, INameScope, IDisposable |
|||
{ |
|||
public EmbeddableControlRoot(IEmbeddableWindowImpl impl) : base(impl) |
|||
{ |
|||
PlatformImpl.Show(); |
|||
} |
|||
|
|||
public EmbeddableControlRoot() : base(PlatformManager.CreateEmbeddableWindow()) |
|||
{ |
|||
PlatformImpl.Show(); |
|||
} |
|||
|
|||
public new IEmbeddableWindowImpl PlatformImpl => (IEmbeddableWindowImpl) base.PlatformImpl; |
|||
|
|||
public void Prepare() |
|||
{ |
|||
EnsureInitialized(); |
|||
ApplyTemplate(); |
|||
PlatformImpl.Show(); |
|||
LayoutManager.Instance.ExecuteInitialLayoutPass(this); |
|||
} |
|||
|
|||
private void EnsureInitialized() |
|||
{ |
|||
if (!this.IsInitialized) |
|||
{ |
|||
var init = (ISupportInitialize)this; |
|||
init.BeginInit(); |
|||
init.EndInit(); |
|||
} |
|||
} |
|||
|
|||
protected override Size MeasureOverride(Size availableSize) |
|||
{ |
|||
base.MeasureOverride(PlatformImpl.ClientSize); |
|||
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(EmbeddableControlRoot); |
|||
public void Dispose() |
|||
{ |
|||
PlatformImpl.Dispose(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
/// <summary>
|
|||
/// Defines a platform-specific embeddable window implementation.
|
|||
/// </summary>
|
|||
public interface IEmbeddableWindowImpl : IWindowImpl |
|||
{ |
|||
event Action LostFocus; |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
<ProjectConfiguration> |
|||
<AutoDetectNugetBuildDependencies>true</AutoDetectNugetBuildDependencies> |
|||
<BuildPriority>1000</BuildPriority> |
|||
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace> |
|||
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing> |
|||
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies> |
|||
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking> |
|||
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking> |
|||
<AllowCodeAnalysis>false</AllowCodeAnalysis> |
|||
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely> |
|||
<RunPreBuildEvents>false</RunPreBuildEvents> |
|||
<RunPostBuildEvents>false</RunPostBuildEvents> |
|||
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully> |
|||
<InstrumentAssembly>true</InstrumentAssembly> |
|||
<PreventSigningOfAssembly>false</PreventSigningOfAssembly> |
|||
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> |
|||
<DetectStackOverflow>true</DetectStackOverflow> |
|||
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> |
|||
<DefaultTestTimeout>60000</DefaultTestTimeout> |
|||
<UseBuildConfiguration /> |
|||
<UseBuildPlatform /> |
|||
<ProxyProcessPath /> |
|||
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> |
|||
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState> |
|||
<BuildProcessArchitecture>x86</BuildProcessArchitecture> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,17 @@ |
|||
<Style xmlns="https://github.com/avaloniaui" Selector="EmbeddableControlRoot"> |
|||
<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> |
|||
@ -0,0 +1,70 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Reactive.Disposables; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Platform; |
|||
using Gdk; |
|||
using Gtk; |
|||
using Action = System.Action; |
|||
using WindowEdge = Avalonia.Controls.WindowEdge; |
|||
|
|||
namespace Avalonia.Gtk |
|||
{ |
|||
class EmbeddableImpl : WindowImplBase, IEmbeddableWindowImpl |
|||
{ |
|||
public event Action LostFocus; |
|||
|
|||
public EmbeddableImpl(DrawingArea area) : base(area) |
|||
{ |
|||
area.Events = EventMask.AllEventsMask; |
|||
area.SizeAllocated += Plug_SizeAllocated; |
|||
} |
|||
|
|||
public EmbeddableImpl() : this(new PlatformHandleAwareDrawingArea()) |
|||
{ |
|||
} |
|||
|
|||
private void Plug_SizeAllocated(object o, SizeAllocatedArgs args) |
|||
{ |
|||
Resized?.Invoke(new Size(args.Allocation.Width, args.Allocation.Height)); |
|||
} |
|||
|
|||
public override Size ClientSize |
|||
{ |
|||
get { return new Size(Widget.Allocation.Width, Widget.Allocation.Height); } |
|||
set {} |
|||
} |
|||
|
|||
|
|||
//Stubs are needed for future GTK designer embedding support
|
|||
public override void SetTitle(string title) |
|||
{ |
|||
} |
|||
|
|||
public override IDisposable ShowDialog() => Disposable.Create(() => { }); |
|||
|
|||
public override void SetSystemDecorations(bool enabled) |
|||
{ |
|||
} |
|||
|
|||
public override void SetIcon(IWindowIconImpl icon) |
|||
{ |
|||
} |
|||
|
|||
public override void BeginMoveDrag() |
|||
{ |
|||
} |
|||
|
|||
public override void BeginResizeDrag(WindowEdge edge) |
|||
{ |
|||
} |
|||
|
|||
public override Point Position |
|||
{ |
|||
get { return new Point(); } |
|||
set {} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Embedding; |
|||
using Avalonia.Diagnostics; |
|||
using Avalonia.Input; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Layout; |
|||
using Avalonia.Platform; |
|||
using Avalonia.VisualTree; |
|||
using Gdk; |
|||
using Gtk; |
|||
|
|||
namespace Avalonia.Gtk.Embedding |
|||
{ |
|||
public class GtkAvaloniaControlHost : DrawingArea, IPlatformHandle |
|||
{ |
|||
private EmbeddableControlRoot _root; |
|||
|
|||
public GtkAvaloniaControlHost() |
|||
{ |
|||
_root = new EmbeddableControlRoot(new EmbeddableImpl(this)); |
|||
_root.Prepare(); |
|||
if (_root.IsFocused) |
|||
Unfocus(); |
|||
_root.GotFocus += RootGotFocus; |
|||
CanFocus = true; |
|||
} |
|||
|
|||
void Unfocus() |
|||
{ |
|||
var focused = (IVisual)FocusManager.Instance.Current; |
|||
if (focused == null) |
|||
return; |
|||
while (focused.VisualParent != null) |
|||
focused = focused.VisualParent; |
|||
|
|||
if (focused == _root) |
|||
KeyboardDevice.Instance.SetFocusedElement(null, NavigationMethod.Unspecified, InputModifiers.None); |
|||
} |
|||
|
|||
protected override bool OnFocusOutEvent(EventFocus evnt) |
|||
{ |
|||
Unfocus(); |
|||
return false; |
|||
} |
|||
|
|||
private void RootGotFocus(object sender, RoutedEventArgs e) |
|||
{ |
|||
this.HasFocus = true; |
|||
GdkWindow.Focus(0); |
|||
} |
|||
|
|||
private Control _content; |
|||
|
|||
public Control Content |
|||
{ |
|||
get { return _content; } |
|||
set |
|||
{ |
|||
_content = value; |
|||
if (_root != null) |
|||
{ |
|||
_root.Content = value; |
|||
_root.Prepare(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
IntPtr IPlatformHandle.Handle => PlatformHandleAwareWindow.GetNativeWindow(GdkWindow); |
|||
|
|||
string IPlatformHandle.HandleDescriptor => "HWND"; |
|||
} |
|||
} |
|||
@ -1,404 +1,118 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive.Disposables; |
|||
using System.Runtime.InteropServices; |
|||
using Gdk; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Input.Raw; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Input; |
|||
using Avalonia.Threading; |
|||
using Action = System.Action; |
|||
using WindowEdge = Avalonia.Controls.WindowEdge; |
|||
using Gdk; |
|||
|
|||
namespace Avalonia.Gtk |
|||
{ |
|||
using Gtk = global::Gtk; |
|||
|
|||
public class WindowImpl : Gtk.Window, IWindowImpl, IPlatformHandle |
|||
public class WindowImpl : WindowImplBase |
|||
{ |
|||
private IInputRoot _inputRoot; |
|||
private Gtk.Window _window; |
|||
private Gtk.Window Window => _window ?? (_window = (Gtk.Window) Widget); |
|||
|
|||
private Size _lastClientSize; |
|||
|
|||
private Gtk.IMContext _imContext; |
|||
|
|||
private uint _lastKeyEventTimestamp; |
|||
|
|||
private static readonly Gdk.Cursor DefaultCursor = new Gdk.Cursor(CursorType.LeftPtr); |
|||
|
|||
public WindowImpl() |
|||
: base(Gtk.WindowType.Toplevel) |
|||
public WindowImpl(Gtk.WindowType type) : base(new PlatformHandleAwareWindow(type)) |
|||
{ |
|||
DefaultSize = new Gdk.Size(900, 480); |
|||
Init(); |
|||
} |
|||
|
|||
public WindowImpl(Gtk.WindowType type) |
|||
: base(type) |
|||
public WindowImpl() |
|||
: base(new PlatformHandleAwareWindow(Gtk.WindowType.Toplevel) {DefaultSize = new Gdk.Size(900, 480)}) |
|||
{ |
|||
Init(); |
|||
} |
|||
|
|||
private void Init() |
|||
void Init() |
|||
{ |
|||
Events = EventMask.PointerMotionMask | |
|||
EventMask.ButtonPressMask | |
|||
EventMask.ButtonReleaseMask; |
|||
_imContext = new Gtk.IMMulticontext(); |
|||
_imContext.Commit += ImContext_Commit; |
|||
DoubleBuffered = false; |
|||
Realize(); |
|||
Window.FocusActivated += OnFocusActivated; |
|||
Window.ConfigureEvent += OnConfigureEvent; |
|||
_lastClientSize = ClientSize; |
|||
} |
|||
|
|||
protected override void OnRealized () |
|||
{ |
|||
base.OnRealized (); |
|||
_imContext.ClientWindow = this.GdkWindow; |
|||
} |
|||
|
|||
public Size ClientSize |
|||
private Size _lastClientSize; |
|||
void OnConfigureEvent(object o, Gtk.ConfigureEventArgs args) |
|||
{ |
|||
get |
|||
{ |
|||
int width; |
|||
int height; |
|||
GetSize(out width, out height); |
|||
return new Size(width, height); |
|||
} |
|||
|
|||
set |
|||
{ |
|||
Resize((int)value.Width, (int)value.Height); |
|||
} |
|||
} |
|||
var evnt = args.Event; |
|||
args.RetVal = true; |
|||
var newSize = new Size(evnt.Width, evnt.Height); |
|||
|
|||
public Size MaxClientSize |
|||
{ |
|||
get |
|||
if (newSize != _lastClientSize) |
|||
{ |
|||
// TODO: This should take into account things such as taskbar and window border
|
|||
// thickness etc.
|
|||
return new Size(Screen.Width, Screen.Height); |
|||
Resized(newSize); |
|||
_lastClientSize = newSize; |
|||
} |
|||
} |
|||
|
|||
public Avalonia.Controls.WindowState WindowState |
|||
public override Size ClientSize |
|||
{ |
|||
get |
|||
{ |
|||
switch (GdkWindow.State) |
|||
{ |
|||
case Gdk.WindowState.Iconified: |
|||
return Controls.WindowState.Minimized; |
|||
case Gdk.WindowState.Maximized: |
|||
return Controls.WindowState.Maximized; |
|||
default: |
|||
return Controls.WindowState.Normal; |
|||
} |
|||
int width; |
|||
int height; |
|||
Window.GetSize(out width, out height); |
|||
return new Size(width, height); |
|||
} |
|||
|
|||
set |
|||
{ |
|||
switch (value) |
|||
{ |
|||
case Controls.WindowState.Minimized: |
|||
GdkWindow.Iconify(); |
|||
break; |
|||
case Controls.WindowState.Maximized: |
|||
GdkWindow.Maximize(); |
|||
break; |
|||
case Controls.WindowState.Normal: |
|||
GdkWindow.Deiconify(); |
|||
GdkWindow.Unmaximize(); |
|||
break; |
|||
} |
|||
Window.Resize((int)value.Width, (int)value.Height); |
|||
} |
|||
} |
|||
|
|||
public double Scaling => 1; |
|||
|
|||
IPlatformHandle ITopLevelImpl.Handle => this; |
|||
|
|||
[DllImport("libgdk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] |
|||
extern static IntPtr gdk_win32_drawable_get_handle(IntPtr gdkWindow); |
|||
|
|||
[DllImport("libgtk-x11-2.0.so.0", CallingConvention = CallingConvention.Cdecl)] |
|||
extern static IntPtr gdk_x11_drawable_get_xid(IntPtr gdkWindow); |
|||
|
|||
[DllImport("libgdk-quartz-2.0-0.dylib", CallingConvention = CallingConvention.Cdecl)] |
|||
extern static IntPtr gdk_quartz_window_get_nswindow(IntPtr gdkWindow); |
|||
|
|||
IntPtr _nativeWindow; |
|||
|
|||
IntPtr GetNativeWindow() |
|||
public override void SetTitle(string title) |
|||
{ |
|||
IntPtr h = GdkWindow.Handle; |
|||
if (_nativeWindow != IntPtr.Zero) |
|||
return _nativeWindow; |
|||
//Try whatever backend that works
|
|||
try |
|||
{ |
|||
return _nativeWindow = gdk_quartz_window_get_nswindow(h); |
|||
} |
|||
catch |
|||
{ |
|||
} |
|||
try |
|||
{ |
|||
return _nativeWindow = gdk_x11_drawable_get_xid(h); |
|||
} |
|||
catch |
|||
{ |
|||
} |
|||
return _nativeWindow = gdk_win32_drawable_get_handle(h); |
|||
Window.Title = title; |
|||
} |
|||
|
|||
|
|||
IntPtr IPlatformHandle.Handle => GetNativeWindow(); |
|||
public string HandleDescriptor => "HWND"; |
|||
|
|||
public Action Activated { get; set; } |
|||
|
|||
public Action Closed { get; set; } |
|||
|
|||
public Action Deactivated { get; set; } |
|||
|
|||
public Action<RawInputEventArgs> Input { get; set; } |
|||
|
|||
public Action<Rect> Paint { get; set; } |
|||
|
|||
public Action<Size> Resized { get; set; } |
|||
|
|||
public Action<double> ScalingChanged { get; set; } |
|||
|
|||
public IPopupImpl CreatePopup() |
|||
{ |
|||
return new PopupImpl(); |
|||
} |
|||
|
|||
public void Invalidate(Rect rect) |
|||
{ |
|||
if (base.GdkWindow != null) |
|||
base.GdkWindow.InvalidateRect( |
|||
new Rectangle((int) rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height), true); |
|||
} |
|||
|
|||
public Point PointToClient(Point point) |
|||
void OnFocusActivated(object sender, EventArgs eventArgs) |
|||
{ |
|||
int x, y; |
|||
GdkWindow.GetDeskrelativeOrigin(out x, out y); |
|||
|
|||
return new Point(point.X - x, point.Y - y); |
|||
} |
|||
|
|||
public Point PointToScreen(Point point) |
|||
{ |
|||
int x, y; |
|||
GdkWindow.GetDeskrelativeOrigin(out x, out y); |
|||
|
|||
return new Point(point.X + x, point.Y + y); |
|||
} |
|||
|
|||
public void SetInputRoot(IInputRoot inputRoot) |
|||
{ |
|||
_inputRoot = inputRoot; |
|||
} |
|||
|
|||
public void SetTitle(string title) |
|||
{ |
|||
Title = title; |
|||
} |
|||
|
|||
|
|||
public void SetCursor(IPlatformHandle cursor) |
|||
{ |
|||
GdkWindow.Cursor = cursor != null ? new Gdk.Cursor(cursor.Handle) : DefaultCursor; |
|||
Activated(); |
|||
} |
|||
|
|||
public void BeginMoveDrag() |
|||
public override void BeginMoveDrag() |
|||
{ |
|||
int x, y; |
|||
ModifierType mod; |
|||
Screen.RootWindow.GetPointer(out x, out y, out mod); |
|||
BeginMoveDrag(1, x, y, 0); |
|||
Window.Screen.RootWindow.GetPointer(out x, out y, out mod); |
|||
Window.BeginMoveDrag(1, x, y, 0); |
|||
} |
|||
|
|||
public void BeginResizeDrag(WindowEdge edge) |
|||
public override void BeginResizeDrag(Controls.WindowEdge edge) |
|||
{ |
|||
int x, y; |
|||
ModifierType mod; |
|||
Screen.RootWindow.GetPointer(out x, out y, out mod); |
|||
BeginResizeDrag((Gdk.WindowEdge) (int) edge, 1, x, y, 0); |
|||
Window.Screen.RootWindow.GetPointer(out x, out y, out mod); |
|||
Window.BeginResizeDrag((Gdk.WindowEdge)(int)edge, 1, x, y, 0); |
|||
} |
|||
|
|||
public Point Position |
|||
public override Point Position |
|||
{ |
|||
get |
|||
{ |
|||
int x, y; |
|||
GetPosition(out x, out y); |
|||
Window.GetPosition(out x, out y); |
|||
return new Point(x, y); |
|||
} |
|||
set |
|||
{ |
|||
Move((int)value.X, (int)value.Y); |
|||
Window.Move((int)value.X, (int)value.Y); |
|||
} |
|||
} |
|||
|
|||
public IDisposable ShowDialog() |
|||
public override IDisposable ShowDialog() |
|||
{ |
|||
Modal = true; |
|||
Show(); |
|||
Window.Modal = true; |
|||
Window.Show(); |
|||
|
|||
return Disposable.Empty; |
|||
} |
|||
|
|||
public void SetSystemDecorations(bool enabled) => Decorated = enabled; |
|||
|
|||
void ITopLevelImpl.Activate() |
|||
{ |
|||
Activate(); |
|||
} |
|||
|
|||
private static InputModifiers GetModifierKeys(ModifierType state) |
|||
{ |
|||
var rv = InputModifiers.None; |
|||
if (state.HasFlag(ModifierType.ControlMask)) |
|||
rv |= InputModifiers.Control; |
|||
if (state.HasFlag(ModifierType.ShiftMask)) |
|||
rv |= InputModifiers.Shift; |
|||
if (state.HasFlag(ModifierType.Mod1Mask)) |
|||
rv |= InputModifiers.Control; |
|||
if(state.HasFlag(ModifierType.Button1Mask)) |
|||
rv |= InputModifiers.LeftMouseButton; |
|||
if (state.HasFlag(ModifierType.Button2Mask)) |
|||
rv |= InputModifiers.RightMouseButton; |
|||
if (state.HasFlag(ModifierType.Button3Mask)) |
|||
rv |= InputModifiers.MiddleMouseButton; |
|||
return rv; |
|||
} |
|||
|
|||
protected override bool OnButtonPressEvent(EventButton evnt) |
|||
{ |
|||
|
|||
var e = new RawMouseEventArgs( |
|||
GtkMouseDevice.Instance, |
|||
evnt.Time, |
|||
_inputRoot, |
|||
evnt.Button == 1 |
|||
? RawMouseEventType.LeftButtonDown |
|||
: evnt.Button == 3 ? RawMouseEventType.RightButtonDown : RawMouseEventType.MiddleButtonDown, |
|||
new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
return true; |
|||
} |
|||
|
|||
protected override bool OnScrollEvent(EventScroll evnt) |
|||
{ |
|||
double step = 1; |
|||
var delta = new Vector(); |
|||
if (evnt.Direction == ScrollDirection.Down) |
|||
delta = new Vector(0, -step); |
|||
else if (evnt.Direction == ScrollDirection.Up) |
|||
delta = new Vector(0, step); |
|||
else if (evnt.Direction == ScrollDirection.Right) |
|||
delta = new Vector(-step, 0); |
|||
if (evnt.Direction == ScrollDirection.Left) |
|||
delta = new Vector(step, 0); |
|||
var e = new RawMouseWheelEventArgs(GtkMouseDevice.Instance, evnt.Time, _inputRoot, new Point(evnt.X, evnt.Y), delta, GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
return base.OnScrollEvent(evnt); |
|||
} |
|||
|
|||
protected override bool OnButtonReleaseEvent(EventButton evnt) |
|||
{ |
|||
var e = new RawMouseEventArgs( |
|||
GtkMouseDevice.Instance, |
|||
evnt.Time, |
|||
_inputRoot, |
|||
evnt.Button == 1 |
|||
? RawMouseEventType.LeftButtonUp |
|||
: evnt.Button == 3 ? RawMouseEventType.RightButtonUp : RawMouseEventType.MiddleButtonUp, |
|||
new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
return true; |
|||
} |
|||
|
|||
protected override bool OnConfigureEvent(EventConfigure evnt) |
|||
{ |
|||
var newSize = new Size(evnt.Width, evnt.Height); |
|||
|
|||
if (newSize != _lastClientSize) |
|||
{ |
|||
Resized(newSize); |
|||
_lastClientSize = newSize; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
protected override void OnDestroyed() |
|||
{ |
|||
Closed(); |
|||
} |
|||
|
|||
private bool ProcessKeyEvent(EventKey evnt) |
|||
{ |
|||
_lastKeyEventTimestamp = evnt.Time; |
|||
if (_imContext.FilterKeypress(evnt)) |
|||
return true; |
|||
var e = new RawKeyEventArgs( |
|||
GtkKeyboardDevice.Instance, |
|||
evnt.Time, |
|||
evnt.Type == EventType.KeyPress ? RawKeyEventType.KeyDown : RawKeyEventType.KeyUp, |
|||
GtkKeyboardDevice.ConvertKey(evnt.Key), GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
return true; |
|||
} |
|||
|
|||
protected override bool OnKeyPressEvent(EventKey evnt) => ProcessKeyEvent(evnt); |
|||
|
|||
protected override bool OnKeyReleaseEvent(EventKey evnt) => ProcessKeyEvent(evnt); |
|||
|
|||
private void ImContext_Commit(object o, Gtk.CommitArgs args) |
|||
{ |
|||
Input(new RawTextInputEventArgs(GtkKeyboardDevice.Instance, _lastKeyEventTimestamp, args.Str)); |
|||
} |
|||
|
|||
protected override bool OnExposeEvent(EventExpose evnt) |
|||
{ |
|||
Paint(evnt.Area.ToAvalonia()); |
|||
return true; |
|||
} |
|||
|
|||
protected override void OnFocusActivated() |
|||
{ |
|||
Activated(); |
|||
} |
|||
|
|||
protected override bool OnMotionNotifyEvent(EventMotion evnt) |
|||
{ |
|||
var position = new Point(evnt.X, evnt.Y); |
|||
|
|||
GtkMouseDevice.Instance.SetClientPosition(position); |
|||
|
|||
var e = new RawMouseEventArgs( |
|||
GtkMouseDevice.Instance, |
|||
evnt.Time, |
|||
_inputRoot, |
|||
RawMouseEventType.Move, |
|||
position, GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
return true; |
|||
} |
|||
public override void SetSystemDecorations(bool enabled) => Window.Decorated = enabled; |
|||
|
|||
public void SetIcon(IWindowIconImpl icon) |
|||
public override void SetIcon(IWindowIconImpl icon) |
|||
{ |
|||
Icon = ((IconImpl)icon).Pixbuf; |
|||
Window.Icon = ((IconImpl)icon).Pixbuf; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,310 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive.Disposables; |
|||
using System.Runtime.InteropServices; |
|||
using Gdk; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Input.Raw; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Input; |
|||
using Avalonia.Threading; |
|||
using Action = System.Action; |
|||
using WindowEdge = Avalonia.Controls.WindowEdge; |
|||
|
|||
namespace Avalonia.Gtk |
|||
{ |
|||
using Gtk = global::Gtk; |
|||
|
|||
public abstract class WindowImplBase : IWindowImpl |
|||
{ |
|||
private IInputRoot _inputRoot; |
|||
protected Gtk.Widget _window; |
|||
public Gtk.Widget Widget => _window; |
|||
|
|||
|
|||
private Gtk.IMContext _imContext; |
|||
|
|||
private uint _lastKeyEventTimestamp; |
|||
|
|||
private static readonly Gdk.Cursor DefaultCursor = new Gdk.Cursor(CursorType.LeftPtr); |
|||
|
|||
protected WindowImplBase(Gtk.Widget window) |
|||
{ |
|||
_window = window; |
|||
Init(); |
|||
} |
|||
|
|||
void Init() |
|||
{ |
|||
Handle = _window as IPlatformHandle; |
|||
_window.Events = EventMask.AllEventsMask; |
|||
_imContext = new Gtk.IMMulticontext(); |
|||
_imContext.Commit += ImContext_Commit; |
|||
_window.Realized += OnRealized; |
|||
_window.DoubleBuffered = false; |
|||
_window.Realize(); |
|||
_window.ButtonPressEvent += OnButtonPressEvent; |
|||
_window.ButtonReleaseEvent += OnButtonReleaseEvent; |
|||
_window.ScrollEvent += OnScrollEvent; |
|||
_window.Destroyed += OnDestroyed; |
|||
_window.KeyPressEvent += OnKeyPressEvent; |
|||
_window.KeyReleaseEvent += OnKeyReleaseEvent; |
|||
_window.ExposeEvent += OnExposeEvent; |
|||
_window.MotionNotifyEvent += OnMotionNotifyEvent; |
|||
|
|||
} |
|||
|
|||
public IPlatformHandle Handle { get; private set; } |
|||
|
|||
void OnRealized (object sender, EventArgs eventArgs) |
|||
{ |
|||
_imContext.ClientWindow = _window.GdkWindow; |
|||
} |
|||
|
|||
public abstract Size ClientSize { get; set; } |
|||
|
|||
|
|||
public Size MaxClientSize |
|||
{ |
|||
get |
|||
{ |
|||
// TODO: This should take into account things such as taskbar and window border
|
|||
// thickness etc.
|
|||
return new Size(_window.Screen.Width, _window.Screen.Height); |
|||
} |
|||
} |
|||
|
|||
public Avalonia.Controls.WindowState WindowState |
|||
{ |
|||
get |
|||
{ |
|||
switch (_window.GdkWindow.State) |
|||
{ |
|||
case Gdk.WindowState.Iconified: |
|||
return Controls.WindowState.Minimized; |
|||
case Gdk.WindowState.Maximized: |
|||
return Controls.WindowState.Maximized; |
|||
default: |
|||
return Controls.WindowState.Normal; |
|||
} |
|||
} |
|||
|
|||
set |
|||
{ |
|||
switch (value) |
|||
{ |
|||
case Controls.WindowState.Minimized: |
|||
_window.GdkWindow.Iconify(); |
|||
break; |
|||
case Controls.WindowState.Maximized: |
|||
_window.GdkWindow.Maximize(); |
|||
break; |
|||
case Controls.WindowState.Normal: |
|||
_window.GdkWindow.Deiconify(); |
|||
_window.GdkWindow.Unmaximize(); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public double Scaling => 1; |
|||
|
|||
public Action Activated { get; set; } |
|||
|
|||
public Action Closed { get; set; } |
|||
|
|||
public Action Deactivated { get; set; } |
|||
|
|||
public Action<RawInputEventArgs> Input { get; set; } |
|||
|
|||
public Action<Rect> Paint { get; set; } |
|||
|
|||
public Action<Size> Resized { get; set; } |
|||
|
|||
public Action<double> ScalingChanged { get; set; } |
|||
|
|||
public IPopupImpl CreatePopup() |
|||
{ |
|||
return new PopupImpl(); |
|||
} |
|||
|
|||
public void Invalidate(Rect rect) |
|||
{ |
|||
if (_window.GdkWindow != null) |
|||
_window.GdkWindow.InvalidateRect( |
|||
new Rectangle((int) rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height), true); |
|||
} |
|||
|
|||
public Point PointToClient(Point point) |
|||
{ |
|||
int x, y; |
|||
_window.GdkWindow.GetDeskrelativeOrigin(out x, out y); |
|||
|
|||
return new Point(point.X - x, point.Y - y); |
|||
} |
|||
|
|||
public Point PointToScreen(Point point) |
|||
{ |
|||
int x, y; |
|||
_window.GdkWindow.GetDeskrelativeOrigin(out x, out y); |
|||
return new Point(point.X + x, point.Y + y); |
|||
} |
|||
|
|||
public void SetInputRoot(IInputRoot inputRoot) |
|||
{ |
|||
_inputRoot = inputRoot; |
|||
} |
|||
|
|||
public abstract void SetTitle(string title); |
|||
public abstract IDisposable ShowDialog(); |
|||
public abstract void SetSystemDecorations(bool enabled); |
|||
public abstract void SetIcon(IWindowIconImpl icon); |
|||
|
|||
|
|||
public void SetCursor(IPlatformHandle cursor) |
|||
{ |
|||
_window.GdkWindow.Cursor = cursor != null ? new Gdk.Cursor(cursor.Handle) : DefaultCursor; |
|||
} |
|||
|
|||
public void Show() => _window.Show(); |
|||
|
|||
public void Hide() => _window.Hide(); |
|||
public abstract void BeginMoveDrag(); |
|||
public abstract void BeginResizeDrag(WindowEdge edge); |
|||
public abstract Point Position { get; set; } |
|||
|
|||
void ITopLevelImpl.Activate() |
|||
{ |
|||
_window.Activate(); |
|||
} |
|||
|
|||
private static InputModifiers GetModifierKeys(ModifierType state) |
|||
{ |
|||
var rv = InputModifiers.None; |
|||
if (state.HasFlag(ModifierType.ControlMask)) |
|||
rv |= InputModifiers.Control; |
|||
if (state.HasFlag(ModifierType.ShiftMask)) |
|||
rv |= InputModifiers.Shift; |
|||
if (state.HasFlag(ModifierType.Mod1Mask)) |
|||
rv |= InputModifiers.Control; |
|||
if(state.HasFlag(ModifierType.Button1Mask)) |
|||
rv |= InputModifiers.LeftMouseButton; |
|||
if (state.HasFlag(ModifierType.Button2Mask)) |
|||
rv |= InputModifiers.RightMouseButton; |
|||
if (state.HasFlag(ModifierType.Button3Mask)) |
|||
rv |= InputModifiers.MiddleMouseButton; |
|||
return rv; |
|||
} |
|||
|
|||
void OnButtonPressEvent(object o, Gtk.ButtonPressEventArgs args) |
|||
{ |
|||
var evnt = args.Event; |
|||
var e = new RawMouseEventArgs( |
|||
GtkMouseDevice.Instance, |
|||
evnt.Time, |
|||
_inputRoot, |
|||
evnt.Button == 1 |
|||
? RawMouseEventType.LeftButtonDown |
|||
: evnt.Button == 3 ? RawMouseEventType.RightButtonDown : RawMouseEventType.MiddleButtonDown, |
|||
new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
} |
|||
|
|||
void OnScrollEvent(object o, Gtk.ScrollEventArgs args) |
|||
{ |
|||
var evnt = args.Event; |
|||
double step = 1; |
|||
var delta = new Vector(); |
|||
if (evnt.Direction == ScrollDirection.Down) |
|||
delta = new Vector(0, -step); |
|||
else if (evnt.Direction == ScrollDirection.Up) |
|||
delta = new Vector(0, step); |
|||
else if (evnt.Direction == ScrollDirection.Right) |
|||
delta = new Vector(-step, 0); |
|||
if (evnt.Direction == ScrollDirection.Left) |
|||
delta = new Vector(step, 0); |
|||
var e = new RawMouseWheelEventArgs(GtkMouseDevice.Instance, evnt.Time, _inputRoot, new Point(evnt.X, evnt.Y), delta, GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
} |
|||
|
|||
protected void OnButtonReleaseEvent(object o, Gtk.ButtonReleaseEventArgs args) |
|||
{ |
|||
var evnt = args.Event; |
|||
var e = new RawMouseEventArgs( |
|||
GtkMouseDevice.Instance, |
|||
evnt.Time, |
|||
_inputRoot, |
|||
evnt.Button == 1 |
|||
? RawMouseEventType.LeftButtonUp |
|||
: evnt.Button == 3 ? RawMouseEventType.RightButtonUp : RawMouseEventType.MiddleButtonUp, |
|||
new Point(evnt.X, evnt.Y), GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
} |
|||
|
|||
void OnDestroyed(object sender, EventArgs eventArgs) |
|||
{ |
|||
Closed(); |
|||
} |
|||
|
|||
private void ProcessKeyEvent(EventKey evnt) |
|||
{ |
|||
|
|||
_lastKeyEventTimestamp = evnt.Time; |
|||
if (_imContext.FilterKeypress(evnt)) |
|||
return; |
|||
var e = new RawKeyEventArgs( |
|||
GtkKeyboardDevice.Instance, |
|||
evnt.Time, |
|||
evnt.Type == EventType.KeyPress ? RawKeyEventType.KeyDown : RawKeyEventType.KeyUp, |
|||
GtkKeyboardDevice.ConvertKey(evnt.Key), GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
} |
|||
|
|||
void OnKeyPressEvent(object o, Gtk.KeyPressEventArgs args) |
|||
{ |
|||
args.RetVal = true; |
|||
ProcessKeyEvent(args.Event); |
|||
} |
|||
|
|||
void OnKeyReleaseEvent(object o, Gtk.KeyReleaseEventArgs args) |
|||
{ |
|||
args.RetVal = true; |
|||
ProcessKeyEvent(args.Event); |
|||
} |
|||
|
|||
private void ImContext_Commit(object o, Gtk.CommitArgs args) |
|||
{ |
|||
Input(new RawTextInputEventArgs(GtkKeyboardDevice.Instance, _lastKeyEventTimestamp, args.Str)); |
|||
} |
|||
|
|||
void OnExposeEvent(object o, Gtk.ExposeEventArgs args) |
|||
{ |
|||
Paint(args.Event.Area.ToAvalonia()); |
|||
args.RetVal = true; |
|||
} |
|||
|
|||
void OnMotionNotifyEvent(object o, Gtk.MotionNotifyEventArgs args) |
|||
{ |
|||
var evnt = args.Event; |
|||
var position = new Point(evnt.X, evnt.Y); |
|||
|
|||
GtkMouseDevice.Instance.SetClientPosition(position); |
|||
|
|||
var e = new RawMouseEventArgs( |
|||
GtkMouseDevice.Instance, |
|||
evnt.Time, |
|||
_inputRoot, |
|||
RawMouseEventType.Move, |
|||
position, GetModifierKeys(evnt.State)); |
|||
Input(e); |
|||
args.RetVal = true; |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
_window.Dispose(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,91 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Platform; |
|||
using Gdk; |
|||
using Gtk; |
|||
using Window = Gtk.Window; |
|||
using WindowType = Gtk.WindowType; |
|||
|
|||
namespace Avalonia.Gtk |
|||
{ |
|||
class PlatformHandleAwareWindow : Window, IPlatformHandle |
|||
{ |
|||
public PlatformHandleAwareWindow(WindowType type) : base(type) |
|||
{ |
|||
Events = EventMask.AllEventsMask; |
|||
} |
|||
|
|||
IntPtr IPlatformHandle.Handle => GetNativeWindow(); |
|||
public string HandleDescriptor => "HWND"; |
|||
|
|||
|
|||
[DllImport("libgdk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] |
|||
static extern IntPtr gdk_win32_drawable_get_handle(IntPtr gdkWindow); |
|||
|
|||
[DllImport("libgtk-x11-2.0.so.0", CallingConvention = CallingConvention.Cdecl)] |
|||
static extern IntPtr gdk_x11_drawable_get_xid(IntPtr gdkWindow); |
|||
|
|||
[DllImport("libgdk-quartz-2.0-0.dylib", CallingConvention = CallingConvention.Cdecl)] |
|||
static extern IntPtr gdk_quartz_window_get_nswindow(IntPtr gdkWindow); |
|||
|
|||
IntPtr _nativeWindow; |
|||
|
|||
IntPtr GetNativeWindow() |
|||
{ |
|||
if (_nativeWindow != IntPtr.Zero) |
|||
return _nativeWindow; |
|||
return _nativeWindow = GetNativeWindow(GdkWindow); |
|||
} |
|||
|
|||
public static IntPtr GetNativeWindow(Gdk.Window window) |
|||
{ |
|||
IntPtr h = window.Handle; |
|||
|
|||
//Try whatever backend that works
|
|||
try |
|||
{ |
|||
return gdk_quartz_window_get_nswindow(h); |
|||
} |
|||
catch |
|||
{ |
|||
} |
|||
try |
|||
{ |
|||
return gdk_x11_drawable_get_xid(h); |
|||
} |
|||
catch |
|||
{ |
|||
} |
|||
return gdk_win32_drawable_get_handle(h); |
|||
} |
|||
|
|||
protected override bool OnConfigureEvent(EventConfigure evnt) |
|||
{ |
|||
base.OnConfigureEvent(evnt); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
class PlatformHandleAwareDrawingArea : DrawingArea, IPlatformHandle |
|||
{ |
|||
|
|||
|
|||
|
|||
IntPtr IPlatformHandle.Handle => GetNativeWindow(); |
|||
public string HandleDescriptor => "HWND"; |
|||
IntPtr _nativeWindow; |
|||
|
|||
IntPtr GetNativeWindow() |
|||
{ |
|||
|
|||
if (_nativeWindow != IntPtr.Zero) |
|||
return _nativeWindow; |
|||
Realize(); |
|||
return _nativeWindow = PlatformHandleAwareWindow.GetNativeWindow(GdkWindow); |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue