summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-06-16 15:45:09 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-06-16 15:45:09 (GMT)
commitd5be2f0144ca810fdfbf59808d526c26fe86017e (patch)
tree3ad7e4465307cd6d633184e05d85eb3a4df59e01 /Xamarin.Forms.Platform.WinRT
parent04f7bd296ee67af9189ecd7fdfbd2808ca16ce9a (diff)
downloadxamarin-forms-d5be2f0144ca810fdfbf59808d526c26fe86017e.zip
xamarin-forms-d5be2f0144ca810fdfbf59808d526c26fe86017e.tar.gz
xamarin-forms-d5be2f0144ca810fdfbf59808d526c26fe86017e.tar.bz2
Prep Page for removal of InternalsVisibleTo (#150)
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT')
-rw-r--r--Xamarin.Forms.Platform.WinRT/CarouselPageRenderer.cs16
-rw-r--r--Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs12
-rw-r--r--Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs21
-rw-r--r--Xamarin.Forms.Platform.WinRT/PageRenderer.cs17
-rw-r--r--Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs2
-rw-r--r--Xamarin.Forms.Platform.WinRT/VisualElementPackager.cs10
-rw-r--r--Xamarin.Forms.Platform.WinRT/VisualElementRenderer.cs10
7 files changed, 44 insertions, 44 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/CarouselPageRenderer.cs b/Xamarin.Forms.Platform.WinRT/CarouselPageRenderer.cs
index 97733cf..7fe0ba0 100644
--- a/Xamarin.Forms.Platform.WinRT/CarouselPageRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/CarouselPageRenderer.cs
@@ -46,6 +46,8 @@ namespace Xamarin.Forms.Platform.WinRT
get { return Element; }
}
+ IPageController PageController => Element as IPageController;
+
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
@@ -78,7 +80,7 @@ namespace Xamarin.Forms.Platform.WinRT
if (oldPage != null)
{
- oldPage.SendDisappearing();
+ ((IPageController)oldPage).SendDisappearing();
((INotifyCollectionChanged)oldPage.Children).CollectionChanged -= OnChildrenChanged;
oldPage.PropertyChanged -= OnElementPropertyChanged;
}
@@ -103,7 +105,7 @@ namespace Xamarin.Forms.Platform.WinRT
newPage.PropertyChanged += OnElementPropertyChanged;
UpdateCurrentPage();
- newPage.SendAppearing();
+ ((IPageController)newPage).SendAppearing();
}
OnElementChanged(new ElementChangedEventArgs<CarouselPage>(oldPage, newPage));
@@ -124,7 +126,7 @@ namespace Xamarin.Forms.Platform.WinRT
}
_disposed = true;
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
SetElement(null);
}
@@ -150,7 +152,7 @@ namespace Xamarin.Forms.Platform.WinRT
void OnLoaded(object sender, RoutedEventArgs e)
{
- Element?.SendAppearing();
+ PageController?.SendAppearing();
}
void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -162,14 +164,14 @@ namespace Xamarin.Forms.Platform.WinRT
ContentPage currentPage = Element.CurrentPage;
if (currentPage == page)
return;
- currentPage?.SendDisappearing();
+ ((IPageController)currentPage)?.SendDisappearing();
Element.CurrentPage = page;
- page?.SendAppearing();
+ ((IPageController)page)?.SendAppearing();
}
void OnUnloaded(object sender, RoutedEventArgs e)
{
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
}
void UpdateCurrentPage()
diff --git a/Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs
index 87b8cd7..abc614b 100644
--- a/Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs
@@ -40,6 +40,8 @@ namespace Xamarin.Forms.Platform.WinRT
get { return Device.Idiom == TargetIdiom.Phone; }
}
+ IPageController PageController => Element as IPageController;
+
public void Dispose()
{
Dispose(true);
@@ -173,10 +175,7 @@ namespace Xamarin.Forms.Platform.WinRT
void OnLoaded(object sender, RoutedEventArgs args)
{
- if (Element == null)
- return;
-
- Element.SendAppearing();
+ PageController?.SendAppearing();
}
void OnNativeSizeChanged(object sender, SizeChangedEventArgs e)
@@ -186,10 +185,7 @@ namespace Xamarin.Forms.Platform.WinRT
void OnUnloaded(object sender, RoutedEventArgs args)
{
- if (Element == null)
- return;
-
- Element.SendDisappearing();
+ PageController?.SendDisappearing();
}
void OnUserClosedPopover(object sender, EventArgs e)
diff --git a/Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs
index 6e8edf5..b5bf487 100644
--- a/Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs
@@ -86,6 +86,8 @@ namespace Xamarin.Forms.Platform.WinRT
}
}
+ IPageController PageController => Element as IPageController;
+
bool ITitleProvider.ShowTitle
{
get { return _showTitle; }
@@ -158,7 +160,7 @@ namespace Xamarin.Forms.Platform.WinRT
((INavigationPageController)oldElement).PushRequested -= OnPushRequested;
((INavigationPageController)oldElement).PopRequested -= OnPopRequested;
((INavigationPageController)oldElement).PopToRootRequested -= OnPopToRootRequested;
- oldElement.InternalChildren.CollectionChanged -= OnChildrenChanged;
+ ((IPageController)oldElement).InternalChildren.CollectionChanged -= OnChildrenChanged;
oldElement.PropertyChanged -= OnElementPropertyChanged;
}
@@ -189,7 +191,7 @@ namespace Xamarin.Forms.Platform.WinRT
((INavigationPageController)Element).PushRequested += OnPushRequested;
((INavigationPageController)Element).PopRequested += OnPopRequested;
((INavigationPageController)Element).PopToRootRequested += OnPopToRootRequested;
- Element.InternalChildren.CollectionChanged += OnChildrenChanged;
+ PageController.InternalChildren.CollectionChanged += OnChildrenChanged;
if (!string.IsNullOrEmpty(Element.AutomationId))
_container.SetValue(AutomationProperties.AutomationIdProperty, Element.AutomationId);
@@ -204,7 +206,7 @@ namespace Xamarin.Forms.Platform.WinRT
{
if (!disposing || _disposed)
return;
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
_disposed = true;
_container.PointerPressed -= OnPointerPressed;
@@ -344,7 +346,7 @@ namespace Xamarin.Forms.Platform.WinRT
#if WINDOWS_UWP
_navManager = SystemNavigationManager.GetForCurrentView();
#endif
- Element.SendAppearing();
+ PageController.SendAppearing();
UpdateBackButton();
UpdateTitleOnParents();
}
@@ -375,7 +377,7 @@ namespace Xamarin.Forms.Platform.WinRT
void OnPopRequested(object sender, NavigationRequestedEventArgs e)
{
- var newCurrent = (Page)Element.InternalChildren[Element.InternalChildren.Count - 2];
+ var newCurrent = (Page)PageController.InternalChildren[PageController.InternalChildren.Count - 2];
SetPage(newCurrent, e.Animated, true);
}
@@ -391,10 +393,7 @@ namespace Xamarin.Forms.Platform.WinRT
void OnUnloaded(object sender, RoutedEventArgs args)
{
- if (Element == null)
- return;
-
- Element.SendDisappearing();
+ PageController?.SendDisappearing();
}
void PushExistingNavigationStack()
@@ -448,7 +447,7 @@ namespace Xamarin.Forms.Platform.WinRT
void UpdateBackButton()
{
- bool showBackButton = Element.InternalChildren.Count > 1 && NavigationPage.GetHasBackButton(_currentPage);
+ bool showBackButton = PageController.InternalChildren.Count > 1 && NavigationPage.GetHasBackButton(_currentPage);
_container.ShowBackButton = showBackButton;
#if WINDOWS_UWP
@@ -470,7 +469,7 @@ namespace Xamarin.Forms.Platform.WinRT
void UpdateContainerArea()
{
- Element.ContainerArea = new Rectangle(0, 0, _container.ContentWidth, _container.ContentHeight);
+ PageController.ContainerArea = new Rectangle(0, 0, _container.ContentWidth, _container.ContentHeight);
}
void UpdateNavigationBarBackground()
diff --git a/Xamarin.Forms.Platform.WinRT/PageRenderer.cs b/Xamarin.Forms.Platform.WinRT/PageRenderer.cs
index d33ff02..708c13b 100644
--- a/Xamarin.Forms.Platform.WinRT/PageRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/PageRenderer.cs
@@ -15,6 +15,8 @@ namespace Xamarin.Forms.Platform.WinRT
bool _loaded;
+ IPageController PageController => Element as IPageController;
+
protected override void Dispose(bool disposing)
{
if (!disposing || _disposed)
@@ -24,13 +26,13 @@ namespace Xamarin.Forms.Platform.WinRT
if (Element != null)
{
- ReadOnlyCollection<Element> children = Element.LogicalChildren;
+ ReadOnlyCollection<Element> children = ((IElementController)Element).LogicalChildren;
for (var i = 0; i < children.Count; i++)
{
var visualChild = children[i] as VisualElement;
visualChild?.Cleanup();
}
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
}
base.Dispose();
@@ -40,10 +42,7 @@ namespace Xamarin.Forms.Platform.WinRT
{
base.OnElementChanged(e);
- if (e.OldElement != null)
- {
- e.OldElement.SendDisappearing();
- }
+ ((IPageController)e.OldElement)?.SendDisappearing();
if (e.NewElement != null)
{
@@ -56,7 +55,7 @@ namespace Xamarin.Forms.Platform.WinRT
}
if (_loaded)
- e.NewElement.SendAppearing();
+ ((IPageController)e.NewElement).SendAppearing();
}
}
@@ -68,13 +67,13 @@ namespace Xamarin.Forms.Platform.WinRT
return;
}
_loaded = true;
- Element?.SendAppearing();
+ PageController?.SendAppearing();
}
void OnUnloaded(object sender, RoutedEventArgs args)
{
_loaded = false;
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
}
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs b/Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs
index 2d8a4f9..3895052 100644
--- a/Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs
+++ b/Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs
@@ -97,7 +97,7 @@ namespace Xamarin.Forms.Platform.WinRT
var wrapperAwareRenderer = currentRenderer as IWrapperAware;
wrapperAwareRenderer?.NotifyWrapped();
- foreach (Element child in currentView.LogicalChildren)
+ foreach (Element child in ((IElementController)currentView).LogicalChildren)
{
var childView = child as View;
if (childView == null)
diff --git a/Xamarin.Forms.Platform.WinRT/VisualElementPackager.cs b/Xamarin.Forms.Platform.WinRT/VisualElementPackager.cs
index 1c4036e..686da58 100644
--- a/Xamarin.Forms.Platform.WinRT/VisualElementPackager.cs
+++ b/Xamarin.Forms.Platform.WinRT/VisualElementPackager.cs
@@ -42,6 +42,8 @@ namespace Xamarin.Forms.Platform.WinRT
_columnSpan = columnSpan;
}
+ IElementController ElementController => _renderer.Element as IElementController;
+
public void Dispose()
{
if (_disposed)
@@ -66,7 +68,7 @@ namespace Xamarin.Forms.Platform.WinRT
_renderer.Element.ChildAdded += OnChildAdded;
_renderer.Element.ChildRemoved += OnChildRemoved;
- ReadOnlyCollection<Element> children = _renderer.Element.LogicalChildren;
+ ReadOnlyCollection<Element> children = ElementController.LogicalChildren;
for (var i = 0; i < children.Count; i++)
{
OnChildAdded(_renderer.Element, new ElementEventArgs(children[i]));
@@ -75,12 +77,12 @@ namespace Xamarin.Forms.Platform.WinRT
void EnsureZIndex()
{
- if (_renderer.Element.LogicalChildren.Count == 0)
+ if (ElementController.LogicalChildren.Count == 0)
return;
- for (var z = 0; z < _renderer.Element.LogicalChildren.Count; z++)
+ for (var z = 0; z < ElementController.LogicalChildren.Count; z++)
{
- var child = _renderer.Element.LogicalChildren[z] as VisualElement;
+ var child = ElementController.LogicalChildren[z] as VisualElement;
if (child == null)
continue;
diff --git a/Xamarin.Forms.Platform.WinRT/VisualElementRenderer.cs b/Xamarin.Forms.Platform.WinRT/VisualElementRenderer.cs
index 96565d7..3ad826b 100644
--- a/Xamarin.Forms.Platform.WinRT/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/VisualElementRenderer.cs
@@ -28,6 +28,8 @@ namespace Xamarin.Forms.Platform.WinRT
protected bool AutoTrack { get; set; } = true;
+ IElementController ElementController => Element as IElementController;
+
protected VisualElementTracker<TElement, TNativeElement> Tracker
{
get { return _tracker; }
@@ -163,9 +165,9 @@ namespace Xamarin.Forms.Platform.WinRT
Control.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
}
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var child = Element.LogicalChildren[i] as VisualElement;
+ var child = ElementController.LogicalChildren[i] as VisualElement;
if (child == null)
continue;
IVisualElementRenderer renderer = Platform.GetRenderer(child);
@@ -205,9 +207,9 @@ namespace Xamarin.Forms.Platform.WinRT
Element.IsInNativeLayout = true;
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var child = Element.LogicalChildren[i] as VisualElement;
+ var child = ElementController.LogicalChildren[i] as VisualElement;
if (child == null)
continue;
IVisualElementRenderer renderer = Platform.GetRenderer(child);