From 17fdde66d94155fc62a034fa6658995bef6fd6e5 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 22 Mar 2016 13:02:25 -0700 Subject: Initial import --- .../ActivityIndicatorRenderer.cs | 68 ++ .../AlignmentExtensions.cs | 39 ++ Xamarin.Forms.Platform.WinRT/AsyncValue.cs | 95 +++ Xamarin.Forms.Platform.WinRT/BackgroundTracker.cs | 82 +++ .../BoolToVisibilityConverter.cs | 30 + Xamarin.Forms.Platform.WinRT/BoxViewRenderer.cs | 31 + Xamarin.Forms.Platform.WinRT/ButtonRenderer.cs | 160 +++++ .../CarouselPageRenderer.cs | 180 +++++ .../CarouselViewRenderer.cs | 220 +++++++ Xamarin.Forms.Platform.WinRT/CaseConverter.cs | 29 + Xamarin.Forms.Platform.WinRT/CellControl.cs | 342 ++++++++++ .../CollapseWhenEmptyConverter.cs | 33 + Xamarin.Forms.Platform.WinRT/ColorConverter.cs | 30 + Xamarin.Forms.Platform.WinRT/ConvertExtensions.cs | 23 + Xamarin.Forms.Platform.WinRT/DatePickerRenderer.cs | 97 +++ Xamarin.Forms.Platform.WinRT/DefaultRenderer.cs | 14 + Xamarin.Forms.Platform.WinRT/EditorRenderer.cs | 155 +++++ Xamarin.Forms.Platform.WinRT/EntryCellTextBox.cs | 30 + Xamarin.Forms.Platform.WinRT/EntryRenderer.cs | 212 ++++++ .../ExportRendererAttribute.cs | 34 + Xamarin.Forms.Platform.WinRT/Extensions.cs | 46 ++ .../FileImageSourceHandler.cs | 29 + .../FileImageSourcePathConverter.cs | 26 + Xamarin.Forms.Platform.WinRT/FontExtensions.cs | 75 +++ Xamarin.Forms.Platform.WinRT/FormsButton.cs | 46 ++ Xamarin.Forms.Platform.WinRT/FormsComboBox.cs | 68 ++ Xamarin.Forms.Platform.WinRT/FormsDatePicker.cs | 76 +++ Xamarin.Forms.Platform.WinRT/FormsTextBox.cs | 332 ++++++++++ Xamarin.Forms.Platform.WinRT/FormsTimePicker.cs | 76 +++ Xamarin.Forms.Platform.WinRT/FrameRenderer.cs | 71 ++ .../FrameworkElementExtensions.cs | 114 ++++ Xamarin.Forms.Platform.WinRT/HeightConverter.cs | 32 + .../HorizontalTextAlignmentConverter.cs | 24 + Xamarin.Forms.Platform.WinRT/ICellRenderer.cs | 14 + .../IImageSourceHandler.cs | 16 + Xamarin.Forms.Platform.WinRT/ITitleProvider.cs | 21 + Xamarin.Forms.Platform.WinRT/IToolbarProvider.cs | 16 + .../IVisualElementRenderer.cs | 23 + Xamarin.Forms.Platform.WinRT/IWrapperAware.cs | 14 + Xamarin.Forms.Platform.WinRT/ImageConverter.cs | 33 + .../ImageLoaderSourceHandler.cs | 52 ++ Xamarin.Forms.Platform.WinRT/ImageRenderer.cs | 132 ++++ Xamarin.Forms.Platform.WinRT/KeyboardConverter.cs | 27 + Xamarin.Forms.Platform.WinRT/KeyboardExtensions.cs | 57 ++ Xamarin.Forms.Platform.WinRT/LabelRenderer.cs | 202 ++++++ Xamarin.Forms.Platform.WinRT/LayoutExtensions.cs | 33 + Xamarin.Forms.Platform.WinRT/LayoutRenderer.cs | 55 ++ .../ListGroupHeaderPresenter.cs | 46 ++ .../ListViewGroupStyleSelector.cs | 18 + Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs | 634 ++++++++++++++++++ .../MasterBackgroundConverter.cs | 75 +++ .../MasterDetailControl.cs | 168 +++++ .../MasterDetailPageRenderer.cs | 291 +++++++++ Xamarin.Forms.Platform.WinRT/MenuItemCommand.cs | 48 ++ Xamarin.Forms.Platform.WinRT/NativeViewWrapper.cs | 30 + .../NativeViewWrapperRenderer.cs | 74 +++ .../NavigationPageRenderer.cs | 554 ++++++++++++++++ Xamarin.Forms.Platform.WinRT/PageControl.xaml | 10 + Xamarin.Forms.Platform.WinRT/PageControl.xaml.cs | 166 +++++ Xamarin.Forms.Platform.WinRT/PageRenderer.cs | 80 +++ .../PageToRenderedElementConverter.cs | 31 + Xamarin.Forms.Platform.WinRT/PickerRenderer.cs | 147 +++++ Xamarin.Forms.Platform.WinRT/Platform.cs | 721 +++++++++++++++++++++ Xamarin.Forms.Platform.WinRT/PlatformEffect.cs | 14 + .../ProgressBarRenderer.cs | 59 ++ .../Properties/AssemblyInfo.cs | 57 ++ Xamarin.Forms.Platform.WinRT/RendererFactory.cs | 19 + Xamarin.Forms.Platform.WinRT/Resources.xaml | 87 +++ Xamarin.Forms.Platform.WinRT/ScrollViewRenderer.cs | 194 ++++++ Xamarin.Forms.Platform.WinRT/SliderRenderer.cs | 59 ++ Xamarin.Forms.Platform.WinRT/StepperControl.xaml | 90 +++ .../StepperControl.xaml.cs | 94 +++ Xamarin.Forms.Platform.WinRT/StepperRenderer.cs | 72 ++ .../StreamImagesourceHandler.cs | 36 + Xamarin.Forms.Platform.WinRT/SwitchRenderer.cs | 50 ++ Xamarin.Forms.Platform.WinRT/TableViewRenderer.cs | 85 +++ Xamarin.Forms.Platform.WinRT/TaskExtensions.cs | 40 ++ .../TextAlignmentToHorizontalAlignmentConverter.cs | 48 ++ Xamarin.Forms.Platform.WinRT/TextCellRenderer.cs | 79 +++ Xamarin.Forms.Platform.WinRT/TimePickerRenderer.cs | 75 +++ Xamarin.Forms.Platform.WinRT/ViewExtensions.cs | 26 + Xamarin.Forms.Platform.WinRT/ViewRenderer.cs | 37 ++ .../ViewToRendererConverter.cs | 113 ++++ .../VisualElementChangedEventArgs.cs | 30 + .../VisualElementExtensions.cs | 56 ++ .../VisualElementPackager.cs | 147 +++++ .../VisualElementRenderer.cs | 401 ++++++++++++ .../VisualElementTracker.cs | 534 +++++++++++++++ Xamarin.Forms.Platform.WinRT/WebViewRenderer.cs | 174 +++++ Xamarin.Forms.Platform.WinRT/WindowsBasePage.cs | 56 ++ .../WindowsBasePlatformServices.cs | 179 +++++ Xamarin.Forms.Platform.WinRT/WindowsDeviceInfo.cs | 110 ++++ .../WindowsExpressionSearch.cs | 170 +++++ .../WindowsIsolatedStorage.cs | 119 ++++ Xamarin.Forms.Platform.WinRT/WindowsSerializer.cs | 60 ++ Xamarin.Forms.Platform.WinRT/WindowsTicker.cs | 32 + .../Xamarin.Forms.Platform.WinRT.csproj | 179 +++++ 97 files changed, 10288 insertions(+) create mode 100644 Xamarin.Forms.Platform.WinRT/ActivityIndicatorRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/AlignmentExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/AsyncValue.cs create mode 100644 Xamarin.Forms.Platform.WinRT/BackgroundTracker.cs create mode 100644 Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/BoxViewRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ButtonRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/CarouselPageRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/CarouselViewRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/CaseConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/CellControl.cs create mode 100644 Xamarin.Forms.Platform.WinRT/CollapseWhenEmptyConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ColorConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ConvertExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/DatePickerRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/DefaultRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/EditorRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/EntryCellTextBox.cs create mode 100644 Xamarin.Forms.Platform.WinRT/EntryRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ExportRendererAttribute.cs create mode 100644 Xamarin.Forms.Platform.WinRT/Extensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FileImageSourceHandler.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FileImageSourcePathConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FontExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FormsButton.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FormsComboBox.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FormsDatePicker.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FormsTextBox.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FormsTimePicker.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FrameRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/FrameworkElementExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/HeightConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/HorizontalTextAlignmentConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ICellRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/IImageSourceHandler.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ITitleProvider.cs create mode 100644 Xamarin.Forms.Platform.WinRT/IToolbarProvider.cs create mode 100644 Xamarin.Forms.Platform.WinRT/IVisualElementRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/IWrapperAware.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ImageConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ImageLoaderSourceHandler.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ImageRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/KeyboardConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/KeyboardExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/LabelRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/LayoutExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/LayoutRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ListGroupHeaderPresenter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ListViewGroupStyleSelector.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/MasterBackgroundConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/MasterDetailControl.cs create mode 100644 Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/MenuItemCommand.cs create mode 100644 Xamarin.Forms.Platform.WinRT/NativeViewWrapper.cs create mode 100644 Xamarin.Forms.Platform.WinRT/NativeViewWrapperRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/PageControl.xaml create mode 100644 Xamarin.Forms.Platform.WinRT/PageControl.xaml.cs create mode 100644 Xamarin.Forms.Platform.WinRT/PageRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/PageToRenderedElementConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/PickerRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/Platform.cs create mode 100644 Xamarin.Forms.Platform.WinRT/PlatformEffect.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/Properties/AssemblyInfo.cs create mode 100644 Xamarin.Forms.Platform.WinRT/RendererFactory.cs create mode 100644 Xamarin.Forms.Platform.WinRT/Resources.xaml create mode 100644 Xamarin.Forms.Platform.WinRT/ScrollViewRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/SliderRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/StepperControl.xaml create mode 100644 Xamarin.Forms.Platform.WinRT/StepperControl.xaml.cs create mode 100644 Xamarin.Forms.Platform.WinRT/StepperRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/StreamImagesourceHandler.cs create mode 100644 Xamarin.Forms.Platform.WinRT/SwitchRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/TableViewRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/TaskExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/TextAlignmentToHorizontalAlignmentConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/TextCellRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/TimePickerRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ViewExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ViewRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs create mode 100644 Xamarin.Forms.Platform.WinRT/VisualElementChangedEventArgs.cs create mode 100644 Xamarin.Forms.Platform.WinRT/VisualElementExtensions.cs create mode 100644 Xamarin.Forms.Platform.WinRT/VisualElementPackager.cs create mode 100644 Xamarin.Forms.Platform.WinRT/VisualElementRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/VisualElementTracker.cs create mode 100644 Xamarin.Forms.Platform.WinRT/WebViewRenderer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/WindowsBasePage.cs create mode 100644 Xamarin.Forms.Platform.WinRT/WindowsBasePlatformServices.cs create mode 100644 Xamarin.Forms.Platform.WinRT/WindowsDeviceInfo.cs create mode 100644 Xamarin.Forms.Platform.WinRT/WindowsExpressionSearch.cs create mode 100644 Xamarin.Forms.Platform.WinRT/WindowsIsolatedStorage.cs create mode 100644 Xamarin.Forms.Platform.WinRT/WindowsSerializer.cs create mode 100644 Xamarin.Forms.Platform.WinRT/WindowsTicker.cs create mode 100644 Xamarin.Forms.Platform.WinRT/Xamarin.Forms.Platform.WinRT.csproj (limited to 'Xamarin.Forms.Platform.WinRT') diff --git a/Xamarin.Forms.Platform.WinRT/ActivityIndicatorRenderer.cs b/Xamarin.Forms.Platform.WinRT/ActivityIndicatorRenderer.cs new file mode 100644 index 00000000..5c36afda --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/ActivityIndicatorRenderer.cs @@ -0,0 +1,68 @@ +using System.ComponentModel; +using Windows.UI.Xaml; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + public class ActivityIndicatorRenderer : ViewRenderer + { + object _foregroundDefault; + + protected override void OnElementChanged(ElementChangedEventArgs e) + { + base.OnElementChanged(e); + + if (e.NewElement != null) + { + if (Control == null) + { + SetNativeControl(new Windows.UI.Xaml.Controls.ProgressBar { IsIndeterminate = true }); + + Control.Loaded += OnControlLoaded; + } + + // UpdateColor() called when loaded to ensure we can cache dynamic default colors + UpdateIsRunning(); + } + } + + protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + { + base.OnElementPropertyChanged(sender, e); + + if (e.PropertyName == ActivityIndicator.IsRunningProperty.PropertyName) + UpdateIsRunning(); + else if (e.PropertyName == ActivityIndicator.ColorProperty.PropertyName) + UpdateColor(); + } + + void OnControlLoaded(object sender, RoutedEventArgs routedEventArgs) + { + _foregroundDefault = Control.GetForegroundCache(); + UpdateColor(); + } + + void UpdateColor() + { + Color color = Element.Color; + if (color.IsDefault) + { + Control.RestoreForegroundCache(_foregroundDefault); + } + else + { + Control.Foreground = color.ToBrush(); + } + } + + void UpdateIsRunning() + { + Opacity = Element.IsRunning ? 1 : 0; + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT/AlignmentExtensions.cs b/Xamarin.Forms.Platform.WinRT/AlignmentExtensions.cs new file mode 100644 index 00000000..aa6f926a --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/AlignmentExtensions.cs @@ -0,0 +1,39 @@ +using Windows.UI.Xaml; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + internal static class AlignmentExtensions + { + internal static Windows.UI.Xaml.TextAlignment ToNativeTextAlignment(this TextAlignment alignment) + { + switch (alignment) + { + case TextAlignment.Center: + return Windows.UI.Xaml.TextAlignment.Center; + case TextAlignment.End: + return Windows.UI.Xaml.TextAlignment.Right; + default: + return Windows.UI.Xaml.TextAlignment.Left; + } + } + + internal static VerticalAlignment ToNativeVerticalAlignment(this TextAlignment alignment) + { + switch (alignment) + { + case TextAlignment.Center: + return VerticalAlignment.Center; + case TextAlignment.End: + return VerticalAlignment.Bottom; + default: + return VerticalAlignment.Top; + } + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT/AsyncValue.cs b/Xamarin.Forms.Platform.WinRT/AsyncValue.cs new file mode 100644 index 00000000..4cfbb833 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/AsyncValue.cs @@ -0,0 +1,95 @@ +// +// AsyncValue.cs +// +// Author: +// Eric Maupin +// +// Copyright (c) 2013-2014 Xamarin, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + internal sealed class AsyncValue : INotifyPropertyChanged + { + readonly T _defaultValue; + readonly Task _valueTask; + bool _isRunning = true; + + public AsyncValue(Task valueTask, T defaultValue) + { + if (valueTask == null) + throw new ArgumentNullException("valueTask"); + + _valueTask = valueTask; + _defaultValue = defaultValue; + + TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext(); + + _valueTask.ContinueWith(t => { IsRunning = false; }, scheduler); + + _valueTask.ContinueWith(t => { OnPropertyChanged("Value"); }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, scheduler); + } + + public bool IsRunning + { + get { return _isRunning; } + set + { + if (_isRunning == value) + return; + + _isRunning = value; + OnPropertyChanged(); + } + } + + public T Value + { + get + { + if (_valueTask.Status != TaskStatus.RanToCompletion) + return _defaultValue; + + return _valueTask.Result; + } + } + + public event PropertyChangedEventHandler PropertyChanged; + + void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (handler != null) + handler(this, new PropertyChangedEventArgs(propertyName)); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT/BackgroundTracker.cs b/Xamarin.Forms.Platform.WinRT/BackgroundTracker.cs new file mode 100644 index 00000000..c7474015 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/BackgroundTracker.cs @@ -0,0 +1,82 @@ +using System; +using System.ComponentModel; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Media.Imaging; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + internal sealed class BackgroundTracker : VisualElementTracker where T : FrameworkElement + { + readonly DependencyProperty _backgroundProperty; + bool _backgroundNeedsUpdate = true; + + public BackgroundTracker(DependencyProperty backgroundProperty) + { + if (backgroundProperty == null) + throw new ArgumentNullException("backgroundProperty"); + + _backgroundProperty = backgroundProperty; + } + + protected override void OnPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName || e.PropertyName == Page.BackgroundImageProperty.PropertyName) + { + UpdateBackground(); + } + + base.OnPropertyChanged(sender, e); + } + + protected override void UpdateNativeControl() + { + base.UpdateNativeControl(); + + if (_backgroundNeedsUpdate) + UpdateBackground(); + } + + void UpdateBackground() + { + if (Element == null) + return; + + FrameworkElement element = Control ?? Container; + if (element == null) + return; + + string backgroundImage = Element.BackgroundImage; + if (backgroundImage != null) + { + Uri uri; + if (!Uri.TryCreate(backgroundImage, UriKind.RelativeOrAbsolute, out uri) || !uri.IsAbsoluteUri) + uri = new Uri("ms-appx:///" + backgroundImage); + + element.SetValue(_backgroundProperty, new ImageBrush { ImageSource = new BitmapImage(uri) }); + } + else + { + Color backgroundColor = Element.BackgroundColor; + if (!backgroundColor.IsDefault) + { + element.SetValue(_backgroundProperty, backgroundColor.ToBrush()); + } + else + { + object localBackground = element.ReadLocalValue(_backgroundProperty); + if (localBackground != null && localBackground != DependencyProperty.UnsetValue) + element.ClearValue(_backgroundProperty); + } + } + + _backgroundNeedsUpdate = false; + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs b/Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs new file mode 100644 index 00000000..357cba3f --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using Windows.UI.Xaml; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + public sealed class BoolToVisibilityConverter : Windows.UI.Xaml.Data.IValueConverter + { + public bool FalseIsVisible { get; set; } + + public object Convert(object value, Type targetType, object parameter, string language) + { + var v = (bool)value; + if (FalseIsVisible) + v = !v; + + return v ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT/BoxViewRenderer.cs b/Xamarin.Forms.Platform.WinRT/BoxViewRenderer.cs new file mode 100644 index 00000000..2e77c89d --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/BoxViewRenderer.cs @@ -0,0 +1,31 @@ +using Windows.UI.Xaml; +using Windows.UI.Xaml.Shapes; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + public class BoxViewRenderer : ViewRenderer + { + protected override void OnElementChanged(ElementChangedEventArgs e) + { + base.OnElementChanged(e); + + if (e.NewElement != null) + { + if (Control == null) + { + var rect = new Windows.UI.Xaml.Shapes.Rectangle(); + rect.DataContext = Element; + rect.SetBinding(Shape.FillProperty, new Windows.UI.Xaml.Data.Binding { Converter = new ColorConverter(), Path = new PropertyPath("Color") }); + + SetNativeControl(rect); + } + } + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.WinRT/ButtonRenderer.cs b/Xamarin.Forms.Platform.WinRT/ButtonRenderer.cs new file mode 100644 index 00000000..60ee6418 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/ButtonRenderer.cs @@ -0,0 +1,160 @@ +using System; +using System.ComponentModel; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Media.Imaging; +using WThickness = Windows.UI.Xaml.Thickness; +using WButton = Windows.UI.Xaml.Controls.Button; +using WImage = Windows.UI.Xaml.Controls.Image; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + public class ButtonRenderer : ViewRenderer + { + bool _fontApplied; + + protected override void OnElementChanged(ElementChangedEventArgs