Skip to content

Commit

Permalink
refactor: Remove WpfIslandsHost
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jun 2, 2022
1 parent 2a5740e commit 6771870
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 350 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows;
using WUX = Windows.UI.Xaml;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void UpdateUnoSize()
{
if (IsXamlContentLoaded())
{
if (_xamlSource.Content.VisualTree.RootElement is WUX.FrameworkElement element)
if (_xamlSource.Content.VisualTreeCache.RootElement is WUX.FrameworkElement element)
{
var width = ActualWidth;
var height = ActualHeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ static UnoXamlHostBase()
MetadataProviderDiscovery.MetadataProviderFactory = type =>
{
WUX.Application application = null;
var host = new WpfIslandsHost(
System.Windows.Application.Current.MainWindow.Dispatcher,
() => application = (WUX.Application)Activator.CreateInstance(type),
null);
var provider = (WUX.Markup.IXamlMetadataProvider)application;
return provider;

WUX.Application.Start(_ =>
{
application = (WUX.Application)Activator.CreateInstance(type);
});

return (WUX.Markup.IXamlMetadataProvider)application;
};
}

Expand Down
17 changes: 4 additions & 13 deletions src/Uno.UI.Runtime.Skia.Wpf/Hosting/XamlRootMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@
namespace Uno.UI.Runtime.Skia.Wpf.Hosting
{
internal static class XamlRootMap
{
{
private static Dictionary<XamlRoot, IWpfHost> _map = new Dictionary<XamlRoot, IWpfHost>();

public static void Register(XamlRoot xamlRoot, IWpfHost host)
{
_map[xamlRoot] = host;
}
public static void Register(XamlRoot xamlRoot, IWpfHost host) => _map[xamlRoot] = host;

public static void Unregister(XamlRoot xamlRoot)
{
_map.Remove(xamlRoot);
}
public static void Unregister(XamlRoot xamlRoot) => _map.Remove(xamlRoot);

public static IWpfHost GetHostForRoot(XamlRoot xamlRoot)
{
return _map[xamlRoot];
}
public static IWpfHost GetHostForRoot(XamlRoot xamlRoot) => _map[xamlRoot];
}
}
279 changes: 0 additions & 279 deletions src/Uno.UI.Runtime.Skia.Wpf/Islands/WpfIslandsHost.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static partial class DependencyObjectExtensions
//TODO:MZ: This should work for non-UIElement as well!
if (dependencyObject is UIElement uiElement)
{
return uiElement.VisualTree;
return uiElement.VisualTreeCache;
}

return null;
Expand All @@ -27,7 +27,7 @@ internal static void SetVisualTree(this DependencyObject dependencyObject, Visua
//TODO:MZ: This should work for non-UIElement as well!
if (dependencyObject is UIElement uiElement)
{
uiElement.VisualTree = visualTree;
uiElement.VisualTreeCache = visualTree;
}
}
}
Expand Down
22 changes: 2 additions & 20 deletions src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml/XamlRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,10 @@ namespace Windows.UI.Xaml
public partial class XamlRoot
{
// Skipping already declared property Content
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsHostVisible
{
get
{
throw new global::System.NotImplementedException("The member bool XamlRoot.IsHostVisible is not implemented in Uno.");
}
}
#endif
// Skipping already declared property IsHostVisible
// Skipping already declared property RasterizationScale
// Skipping already declared property Size
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.UI.UIContext UIContext
{
get
{
throw new global::System.NotImplementedException("The member UIContext XamlRoot.UIContext is not implemented in Uno.");
}
}
#endif
// Skipping already declared property UIContext
// Forced skipping of method Windows.UI.Xaml.XamlRoot.Content.get
// Forced skipping of method Windows.UI.Xaml.XamlRoot.Size.get
// Forced skipping of method Windows.UI.Xaml.XamlRoot.RasterizationScale.get
Expand Down
Loading

0 comments on commit 6771870

Please sign in to comment.