Browse Source
Conflicts: src/Avalonia.Controls/TextBox.cs tests/Avalonia.Controls.UnitTests/TextBoxTests.cspull/691/head
148 changed files with 2090 additions and 2214 deletions
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -1,55 +1,89 @@ |
|||||
# Building Avalonia |
# Building Avalonia |
||||
|
|
||||
## Windows |
## Windows |
||||
|
|
||||
Avalonia requires Visual Studio 2015 to build on Windows. |
Avalonia requires at least Visual Studio 2015 to build on Windows. |
||||
|
|
||||
### Install GTK Sharp |
### Install GTK Sharp |
||||
|
|
||||
For the moment under windows, you must have [gtk-sharp](http://www.mono-project.com/download/#download-win) installed. Note that after installing the package your machine may require a restart before GTK# is added to your path. We hope to remove or make this dependency optional at some point in the future. |
For the moment under windows, you must have [gtk-sharp](http://www.mono-project.com/download/#download-win) |
||||
|
installed. Note that after installing the package your machine may require a restart before GTK# is |
||||
|
added to your path. We hope to remove or make this dependency optional at some point in the future. |
||||
|
|
||||
### Clone the Avalonia repository |
### Clone the Avalonia repository |
||||
|
|
||||
git clone https://github.com/AvaloniaUI/Avalonia.git |
``` |
||||
|
git clone https://github.com/AvaloniaUI/Avalonia.git |
||||
|
git submodule update --init |
||||
|
``` |
||||
|
|
||||
We currently need to build our own private version of some libraries. These are linked as submodules in the git repository, so run: |
### Open in Visual Studio |
||||
|
|
||||
|
Open the `Avalonia.sln` solution in Visual Studio 2015 or newer. The free Visual Studio Community |
||||
|
edition works fine. Run the `Samples\ControlCatalog.Desktop` project to see the sample application. |
||||
|
|
||||
git submodule update --init |
|
||||
|
|
||||
## Linux |
## Linux |
||||
|
|
||||
This guide Written for Ubuntu 15.04 - I'm not sure how well it applies to other distributions, but |
### Install the latest version of Mono |
||||
please submit a PR if you have anything to add. |
|
||||
|
To build Avalonia under Linux, you need to have a recent version of Mono installed. Mono is a cross- |
||||
|
platform, open source .Net platform. There is a very good chance that the version of Mono that came |
||||
|
with your Linux distribution is too old, so you want to install a more up-to-date version. The most |
||||
|
convenient way to to this is through your package manager. The Mono project has great [installation |
||||
|
instructions for many popular Linux distros](http://www.mono-project.com/docs/getting-started/install/linux). |
||||
|
|
||||
### Install Latest Mono |
This will make the most up-to-date Mono release available through your package manager, and offer |
||||
|
you updates as they become available. |
||||
|
|
||||
That the time of writing, mono 4.2 aplha was needed to build. Add mono package sources by following |
Once you have your package manager configured for the Mono repository, install the `mono-devel` |
||||
instructions below for the stable channel and then add the alpha channel as well. |
package, for example on ubuntu: |
||||
|
|
||||
http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives |
``` |
||||
|
sudo apt-get install mono-devel |
||||
|
``` |
||||
|
|
||||
Then install the needed packages: |
Once installed, check the version of mono to ensure it's at least 4.4.2: |
||||
|
|
||||
sudo apt-get install git mono-devel referenceassemblies-pcl monodevelop |
``` |
||||
|
mono --version |
||||
|
``` |
||||
|
|
||||
### Clone the Avalonia repository |
### Clone the Avalonia repository |
||||
|
|
||||
git clone https://github.com/AvaloniaUI/Avalonia.git |
``` |
||||
|
git clone https://github.com/AvaloniaUI/Avalonia.git |
||||
|
git submodule update --init |
||||
|
``` |
||||
|
|
||||
|
### Restore nuget packages |
||||
|
|
||||
|
``` |
||||
|
cd Avalonia |
||||
|
mkdir -p .nuget |
||||
|
wget -O .nuget/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe |
||||
|
mono .nuget/nuget.exe restore Avalonia.sln |
||||
|
``` |
||||
|
|
||||
|
### Build and Run Avalonia |
||||
|
|
||||
|
To build Avalonia in the `Debug` configuration: |
||||
|
|
||||
We currently need to build our own private version of ReactiveUI as it doesn't work on mono. This |
``` |
||||
is linked as a submodule in the git repository, so run: |
xbuild /p:Platform=Mono /p:Configuration=Debug Avalonia.sln |
||||
|
``` |
||||
|
|
||||
git submodule update --init |
You should now be able to run the ControlCatalog.Desktop sample: |
||||
|
|
||||
The next step is to download the Skia native libraries. Run ```getnatives.sh``` script which can be found under the folder ```src\Skia\```. |
|
||||
|
|
||||
### Load the Project in MonoDevelop |
|
||||
|
|
||||
Start MonoDevelop and open the `Avalonia.sln` solution. Wait for MonoDevelop to install the |
``` |
||||
project's NuGet packages. |
mono ./samples/ControlCatalog.Desktop/bin/Debug/ControlCatalog.Desktop.exe |
||||
|
``` |
||||
|
|
||||
Set the TestApplication project as the startup project and click Run. |
### Building Avalonia in MonoDevelop |
||||
|
|
||||
There will be some compile errors in the tests, but ignore them for now. |
Unless you have a very current version of monodevelop (6.1.x or newer), it is necessary to manually |
||||
|
restore the Nuget depdendencies as [mentioned above](#restore-nuget-packages). You must then |
||||
|
disable MonoDevelop's inbuilt NuGet package manager add-in by going to `Tools -> Add-in Manager` or |
||||
|
it will complain that a newer version of NuGet is needed. |
||||
|
|
||||
You can track the Linux version's progress in the [Linux issue](https://github.com/AvaloniaUI/Avalonia/issues/78). |
Finally, select the `Debug | Mono` or `Release | Mono` build configuration and you should be good to |
||||
|
go! |
||||
|
|||||
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 233 KiB |
@ -1 +1 @@ |
|||||
.\build-version.ps1 0.2.0-alpha3 |
.\build-version.ps1 0.4.1 |
||||
@ -1,14 +1,14 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||
<configuration> |
<configuration> |
||||
<startup> |
<startup> |
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /> |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> |
||||
</startup> |
</startup> |
||||
<runtime> |
<runtime> |
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
||||
<dependentAssembly> |
<dependentAssembly> |
||||
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral" /> |
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral"/> |
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> |
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/> |
||||
</dependentAssembly> |
</dependentAssembly> |
||||
</assemblyBinding> |
</assemblyBinding> |
||||
</runtime> |
</runtime> |
||||
</configuration> |
</configuration> |
||||
|
|||||
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,19 @@ |
|||||
|
<UserControl xmlns="https://github.com/avaloniaui"> |
||||
|
<StackPanel Orientation="Vertical" Gap="4"> |
||||
|
<TextBlock Classes="h1">TreeView</TextBlock> |
||||
|
<TextBlock Classes="h2">Displays a hierachical tree of data.</TextBlock> |
||||
|
|
||||
|
<StackPanel Orientation="Horizontal" |
||||
|
Margin="0,16,0,0" |
||||
|
HorizontalAlignment="Center" |
||||
|
Gap="16"> |
||||
|
<TreeView Items="{Binding}" Width="250" Height="350"> |
||||
|
<TreeView.ItemTemplate> |
||||
|
<TreeDataTemplate ItemsSource="{Binding Children}"> |
||||
|
<TextBlock Text="{Binding Header}"/> |
||||
|
</TreeDataTemplate> |
||||
|
</TreeView.ItemTemplate> |
||||
|
</TreeView> |
||||
|
</StackPanel> |
||||
|
</StackPanel> |
||||
|
</UserControl> |
||||
@ -0,0 +1,37 @@ |
|||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace ControlCatalog.Pages |
||||
|
{ |
||||
|
public class TreeViewPage : UserControl |
||||
|
{ |
||||
|
public TreeViewPage() |
||||
|
{ |
||||
|
this.InitializeComponent(); |
||||
|
DataContext = CreateNodes(0); |
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
|
||||
|
private IList<Node> CreateNodes(int level) |
||||
|
{ |
||||
|
return Enumerable.Range(0, 10).Select(x => new Node |
||||
|
{ |
||||
|
Header = $"Item {x}", |
||||
|
Children = level < 5 ? CreateNodes(level + 1) : null, |
||||
|
}).ToList(); |
||||
|
} |
||||
|
|
||||
|
private class Node |
||||
|
{ |
||||
|
public string Header { get; set; } |
||||
|
public IList<Node> Children { get; set; } |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,6 +1,14 @@ |
|||||
<?xml version="1.0" encoding="utf-8" ?> |
<?xml version="1.0" encoding="utf-8"?> |
||||
<configuration> |
<configuration> |
||||
<startup> |
<startup> |
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> |
||||
</startup> |
</startup> |
||||
</configuration> |
<runtime> |
||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
||||
|
<dependentAssembly> |
||||
|
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral"/> |
||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/> |
||||
|
</dependentAssembly> |
||||
|
</assemblyBinding> |
||||
|
</runtime> |
||||
|
</configuration> |
||||
|
|||||
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -0,0 +1,17 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Avalonia.Media.Imaging; |
||||
|
|
||||
|
namespace Avalonia.Platform |
||||
|
{ |
||||
|
public interface IPlatformIconLoader |
||||
|
{ |
||||
|
IWindowIconImpl LoadIcon(string fileName); |
||||
|
IWindowIconImpl LoadIcon(Stream stream); |
||||
|
IWindowIconImpl LoadIcon(IBitmapImpl bitmap); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
// 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.Platform |
||||
|
{ |
||||
|
public interface IWindowIconImpl |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
using Avalonia.Platform; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Avalonia.Media.Imaging; |
||||
|
|
||||
|
namespace Avalonia.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents an icon for a window.
|
||||
|
/// </summary>
|
||||
|
public class WindowIcon |
||||
|
{ |
||||
|
public WindowIcon(IBitmap bitmap) |
||||
|
{ |
||||
|
PlatformImpl = AvaloniaLocator.Current.GetService<IPlatformIconLoader>().LoadIcon(bitmap.PlatformImpl); |
||||
|
} |
||||
|
|
||||
|
public WindowIcon(string fileName) |
||||
|
{ |
||||
|
PlatformImpl = AvaloniaLocator.Current.GetService<IPlatformIconLoader>().LoadIcon(fileName); |
||||
|
} |
||||
|
|
||||
|
public WindowIcon(Stream stream) |
||||
|
{ |
||||
|
PlatformImpl = AvaloniaLocator.Current.GetService<IPlatformIconLoader>().LoadIcon(stream); |
||||
|
} |
||||
|
|
||||
|
public IWindowIconImpl PlatformImpl { get; } |
||||
|
} |
||||
|
} |
||||
@ -1,19 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Linq" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.1.30214.0" newVersion="2.1.30214.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,19 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Linq" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.1.30214.0" newVersion="2.1.30214.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Avalonia |
||||
|
{ |
||||
|
public class RenderTargetCorruptedException : Exception |
||||
|
{ |
||||
|
public RenderTargetCorruptedException() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public RenderTargetCorruptedException(string message) |
||||
|
: base(message) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public RenderTargetCorruptedException(Exception innerException) |
||||
|
: base(null, innerException) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public RenderTargetCorruptedException(string message, Exception innerException) |
||||
|
: base(message, innerException) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -0,0 +1,20 @@ |
|||||
|
using Avalonia.Platform; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Gdk; |
||||
|
|
||||
|
namespace Avalonia.Gtk |
||||
|
{ |
||||
|
class IconImpl : IWindowIconImpl |
||||
|
{ |
||||
|
public IconImpl(Pixbuf pixbuf) |
||||
|
{ |
||||
|
Pixbuf = pixbuf; |
||||
|
} |
||||
|
|
||||
|
public Pixbuf Pixbuf { get; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,70 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
using System.Linq; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Media.Imaging; |
||||
|
using Avalonia.Platform; |
||||
|
using OmniXaml.TypeConversion; |
||||
|
|
||||
|
namespace Avalonia.Markup.Xaml.Converters |
||||
|
{ |
||||
|
class IconTypeConverter : ITypeConverter |
||||
|
{ |
||||
|
public bool CanConvertFrom(IValueContext context, Type sourceType) |
||||
|
{ |
||||
|
return sourceType == typeof(string) || typeof(IBitmap).GetTypeInfo().IsAssignableFrom(sourceType.GetTypeInfo()); |
||||
|
} |
||||
|
|
||||
|
public bool CanConvertTo(IValueContext context, Type destinationType) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
public object ConvertFrom(IValueContext context, CultureInfo culture, object value) |
||||
|
{ |
||||
|
var path = value as string; |
||||
|
if (path != null) |
||||
|
{ |
||||
|
return CreateIconFromPath(context, path); |
||||
|
} |
||||
|
var bitmap = value as IBitmap; |
||||
|
if (bitmap != null) |
||||
|
{ |
||||
|
return new WindowIcon(bitmap); |
||||
|
} |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
private WindowIcon CreateIconFromPath(IValueContext context, string path) |
||||
|
{ |
||||
|
var uri = new Uri(path, UriKind.RelativeOrAbsolute); |
||||
|
var baseUri = GetBaseUri(context); |
||||
|
var scheme = uri.IsAbsoluteUri ? uri.Scheme : "file"; |
||||
|
|
||||
|
switch (scheme) |
||||
|
{ |
||||
|
case "file": |
||||
|
return new WindowIcon(path); |
||||
|
default: |
||||
|
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>(); |
||||
|
return new WindowIcon(assets.Open(uri, baseUri)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public object ConvertTo(IValueContext context, CultureInfo culture, object value, Type destinationType) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
private Uri GetBaseUri(IValueContext context) |
||||
|
{ |
||||
|
object result; |
||||
|
context.ParsingDictionary.TryGetValue("Uri", out result); |
||||
|
return result as Uri; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,86 @@ |
|||||
|
// 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.Linq; |
||||
|
using System.Reflection; |
||||
|
using OmniXaml; |
||||
|
using Glass.Core; |
||||
|
|
||||
|
namespace Avalonia.Markup.Xaml.MarkupExtensions.Standard |
||||
|
{ |
||||
|
public class StaticExtension : MarkupExtension |
||||
|
{ |
||||
|
public StaticExtension() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public StaticExtension(string identifier) |
||||
|
{ |
||||
|
Identifier = identifier; |
||||
|
} |
||||
|
|
||||
|
public string Identifier { get; set; } |
||||
|
|
||||
|
public override object ProvideValue(MarkupExtensionContext markupExtensionContext) |
||||
|
{ |
||||
|
var typeRepository = markupExtensionContext.ValueContext.TypeRepository; |
||||
|
var typeAndMember = GetTypeAndMember(Identifier); |
||||
|
var prefixAndType = GetPrefixAndType(typeAndMember.Item1); |
||||
|
var xamlType = typeRepository.GetByPrefix(prefixAndType.Item1, prefixAndType.Item2); |
||||
|
return GetValue(xamlType.UnderlyingType, typeAndMember.Item2); |
||||
|
} |
||||
|
|
||||
|
private static Tuple<string, string> GetTypeAndMember(string s) |
||||
|
{ |
||||
|
var parts = s.Split('.'); |
||||
|
|
||||
|
if (parts.Length != 2) |
||||
|
{ |
||||
|
throw new ArgumentException("Static member must be in the form Type.Member."); |
||||
|
} |
||||
|
|
||||
|
return Tuple.Create(parts[0], parts[1]); |
||||
|
} |
||||
|
|
||||
|
private static Tuple<string, string> GetPrefixAndType(string s) |
||||
|
{ |
||||
|
if (s.Contains(":")) |
||||
|
{ |
||||
|
return s.Dicotomize(':'); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return new Tuple<string, string>(string.Empty, s); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private object GetValue(Type type, string name) |
||||
|
{ |
||||
|
var t = type; |
||||
|
|
||||
|
while (t != null) |
||||
|
{ |
||||
|
var result = t.GetTypeInfo().DeclaredMembers.FirstOrDefault(x => x.Name == name); |
||||
|
|
||||
|
if (result is PropertyInfo) |
||||
|
{ |
||||
|
var property = ((PropertyInfo)result); |
||||
|
|
||||
|
if (property.GetMethod.IsStatic) |
||||
|
{ |
||||
|
return ((PropertyInfo)result).GetValue(null); |
||||
|
} |
||||
|
} |
||||
|
else if (result is FieldInfo) |
||||
|
{ |
||||
|
return ((FieldInfo)result).GetValue(null); |
||||
|
} |
||||
|
|
||||
|
t = t.GetTypeInfo().BaseType; |
||||
|
} |
||||
|
|
||||
|
throw new ArgumentException($"Static member '{type}.{name}' not found."); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,49 @@ |
|||||
|
// 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 OmniXaml; |
||||
|
using OmniXaml.Attributes; |
||||
|
using OmniXaml.Typing; |
||||
|
using Glass.Core; |
||||
|
|
||||
|
namespace Avalonia.Markup.Xaml.MarkupExtensions.Standard |
||||
|
{ |
||||
|
[ContentProperty("TargetType")] |
||||
|
public class TypeExtension : MarkupExtension |
||||
|
{ |
||||
|
public Type Type { get; set; } |
||||
|
|
||||
|
public TypeExtension() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public TypeExtension(Type type) |
||||
|
{ |
||||
|
Type = type; |
||||
|
} |
||||
|
|
||||
|
public string TypeName { get; set; } |
||||
|
|
||||
|
private Type ResolveFromString(string type, ITypeRepository typeRepository) |
||||
|
{ |
||||
|
Guard.ThrowIfNull(type, nameof(type)); |
||||
|
|
||||
|
var split = type.Split(':'); |
||||
|
var prefix = split.Length == 1 ? split[0] : null; |
||||
|
var typeName = split.Length == 1 ? split[1] : split[0]; |
||||
|
var xamlType = typeRepository.GetByPrefix(prefix, typeName); |
||||
|
return xamlType.UnderlyingType; |
||||
|
} |
||||
|
|
||||
|
public override object ProvideValue(MarkupExtensionContext markupExtensionContext) |
||||
|
{ |
||||
|
if (Type != null) |
||||
|
{ |
||||
|
return Type; |
||||
|
} |
||||
|
|
||||
|
return ResolveFromString(TypeName, markupExtensionContext.ValueContext.TypeRepository); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,11 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.3.0.0" newVersion="2.3.0.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,4 +1,4 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||
<packages> |
<packages> |
||||
<package id="SkiaSharp" version="1.49.4-beta" targetFramework="monoandroid44" /> |
<package id="SkiaSharp" version="1.53.0" targetFramework="monoandroid44" /> |
||||
</packages> |
</packages> |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue