From 17fdde66d94155fc62a034fa6658995bef6fd6e5 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 22 Mar 2016 13:02:25 -0700 Subject: Initial import --- Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml | 7 + .../App.xaml.cs | 134 +++++++++++++++ .../Assets/Logo.scale-240.png | Bin 0 -> 2516 bytes .../Assets/SmallLogo.scale-240.png | Bin 0 -> 753 bytes .../Assets/SplashScreen.scale-240.png | Bin 0 -> 14715 bytes .../Assets/Square71x71Logo.scale-240.png | Bin 0 -> 1122 bytes .../Assets/StoreLogo.scale-240.png | Bin 0 -> 2200 bytes .../Assets/WideLogo.scale-240.png | Bin 0 -> 4530 bytes .../BrokenNativeControl.cs | 65 +++++++ .../MainPage.xaml | 11 ++ .../MainPage.xaml.cs | 108 ++++++++++++ .../Package.appxmanifest | 34 ++++ .../Properties/AssemblyInfo.cs | 29 ++++ .../StringProvider.cs | 15 ++ ...amarin.Forms.ControlGallery.WindowsPhone.csproj | 187 +++++++++++++++++++++ .../app.config | 11 ++ .../toolbar_close.png | Bin 0 -> 463 bytes 17 files changed, 601 insertions(+) create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Assets/Logo.scale-240.png create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Assets/SmallLogo.scale-240.png create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Assets/SplashScreen.scale-240.png create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Assets/Square71x71Logo.scale-240.png create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Assets/StoreLogo.scale-240.png create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Assets/WideLogo.scale-240.png create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/BrokenNativeControl.cs create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/MainPage.xaml create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/MainPage.xaml.cs create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Package.appxmanifest create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Properties/AssemblyInfo.cs create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/StringProvider.cs create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/app.config create mode 100644 Xamarin.Forms.ControlGallery.WindowsPhone/toolbar_close.png (limited to 'Xamarin.Forms.ControlGallery.WindowsPhone') diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml b/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml new file mode 100644 index 00000000..7be404c7 --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs b/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs new file mode 100644 index 00000000..1842bb86 --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Media.Animation; +using Windows.UI.Xaml.Navigation; + +// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=391641 + +namespace Xamarin.Forms.ControlGallery.WindowsPhone +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + public sealed partial class App + { + TransitionCollection _transitions; + + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + InitializeComponent(); + Suspending += OnSuspending; + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// will be used when the application is launched to open a specific file, to display + /// search results, and so forth. + /// + /// Details about the launch request and process. + protected override void OnLaunched(LaunchActivatedEventArgs e) + { +#if DEBUG + if (System.Diagnostics.Debugger.IsAttached) + { + DebugSettings.EnableFrameRateCounter = true; + } +#endif + + var rootFrame = Window.Current.Content as global::Windows.UI.Xaml.Controls.Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new global::Windows.UI.Xaml.Controls.Frame(); + + // TODO: change this value to a cache size that is appropriate for your application + rootFrame.CacheSize = 1; + + Forms.Init (e); + FormsMaps.Init (Controls.App.Secrets["WinPhoneMapsAuthKey"]); + + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + // TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + if (rootFrame.Content == null) + { + // Removes the turnstile navigation for startup. + if (rootFrame.ContentTransitions != null) + { + _transitions = new TransitionCollection(); + foreach (var c in rootFrame.ContentTransitions) + { + _transitions.Add(c); + } + } + + rootFrame.ContentTransitions = null; + rootFrame.Navigated += RootFrame_FirstNavigated; + + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) + { + throw new Exception("Failed to create initial page"); + } + } + + // Ensure the current window is active + Window.Current.Activate(); + } + + /// + /// Restores the content transitions after the app has launched. + /// + /// The object where the handler is attached. + /// Details about the navigation event. + void RootFrame_FirstNavigated(object sender, global::Windows.UI.Xaml.Navigation.NavigationEventArgs e) + { + var rootFrame = sender as global::Windows.UI.Xaml.Controls.Frame; + rootFrame.ContentTransitions = _transitions ?? new TransitionCollection() { new NavigationThemeTransition() }; + rootFrame.Navigated -= RootFrame_FirstNavigated; + } + + /// + /// Invoked when application execution is being suspended. Application state is saved + /// without knowing whether the application will be terminated or resumed with the contents + /// of memory still intact. + /// + /// The source of the suspend request. + /// Details about the suspend request. + void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + + // TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/Logo.scale-240.png b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/Logo.scale-240.png new file mode 100644 index 00000000..76921ca9 Binary files /dev/null and b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/Logo.scale-240.png differ diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/SmallLogo.scale-240.png b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/SmallLogo.scale-240.png new file mode 100644 index 00000000..31663012 Binary files /dev/null and b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/SmallLogo.scale-240.png differ diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/SplashScreen.scale-240.png b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/SplashScreen.scale-240.png new file mode 100644 index 00000000..33f26b33 Binary files /dev/null and b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/SplashScreen.scale-240.png differ diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/Square71x71Logo.scale-240.png b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/Square71x71Logo.scale-240.png new file mode 100644 index 00000000..cfa54bee Binary files /dev/null and b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/Square71x71Logo.scale-240.png differ diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/StoreLogo.scale-240.png b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/StoreLogo.scale-240.png new file mode 100644 index 00000000..47e084b5 Binary files /dev/null and b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/StoreLogo.scale-240.png differ diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/WideLogo.scale-240.png b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/WideLogo.scale-240.png new file mode 100644 index 00000000..6249d29d Binary files /dev/null and b/Xamarin.Forms.ControlGallery.WindowsPhone/Assets/WideLogo.scale-240.png differ diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/BrokenNativeControl.cs b/Xamarin.Forms.ControlGallery.WindowsPhone/BrokenNativeControl.cs new file mode 100644 index 00000000..5be6db25 --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/BrokenNativeControl.cs @@ -0,0 +1,65 @@ +using Windows.Foundation; +using Windows.Graphics.Display; +using Windows.UI; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; +using WSize = Windows.Foundation.Size; + +namespace Xamarin.Forms.ControlGallery.WindowsPhone +{ + internal class BrokenNativeControl : Panel + { + public BrokenNativeControl () + { + _textBlock = new TextBlock { + MinHeight = 0, + MaxHeight = double.PositiveInfinity, + MinWidth = 0, + MaxWidth = double.PositiveInfinity, + FontSize = 24, + HorizontalAlignment = HorizontalAlignment.Center + }; + + Children.Add (_textBlock); + + Background = + new LinearGradientBrush ( + new GradientStopCollection { new GradientStop { Color = Colors.Green, Offset = 0.5}, new GradientStop { Color = Colors.Blue, Offset = 1} }, 0); + } + + public static readonly DependencyProperty TextProperty = DependencyProperty.Register ( + "Text", typeof(string), typeof(BrokenNativeControl), new PropertyMetadata (default(string), PropertyChangedCallback)); + + static void PropertyChangedCallback (DependencyObject dependencyObject, + DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) + { + ((BrokenNativeControl)dependencyObject)._textBlock.Text = (string)dependencyPropertyChangedEventArgs.NewValue; + } + + public string Text + { + get { return (string)GetValue (TextProperty); } + set { SetValue (TextProperty, value); } + } + + readonly TextBlock _textBlock; + + protected override WSize ArrangeOverride(WSize finalSize) + { + _textBlock.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height)); + return finalSize; + } + + protected override WSize MeasureOverride (WSize availableSize) + { + _textBlock.Measure (availableSize); + + // This deliberately does something wrong so we can demo fixing it + var width = Window.Current.Bounds.Width * (int)DisplayProperties.ResolutionScale / 100; + + // This deliberately does something wrong so we can demo fixing it + return new WSize (width, _textBlock.DesiredSize.Height); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/MainPage.xaml b/Xamarin.Forms.ControlGallery.WindowsPhone/MainPage.xaml new file mode 100644 index 00000000..0ce7c4aa --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/MainPage.xaml @@ -0,0 +1,11 @@ + + + diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/MainPage.xaml.cs b/Xamarin.Forms.ControlGallery.WindowsPhone/MainPage.xaml.cs new file mode 100644 index 00000000..1c34efd6 --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/MainPage.xaml.cs @@ -0,0 +1,108 @@ +using System; +using Windows.Foundation; +using Windows.Graphics.Display; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; +using Xamarin.Forms.Controls; +using WControls = Windows.UI.Xaml.Controls; +using Xamarin.Forms.Platform.WinRT; + +// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641 + +namespace Xamarin.Forms.ControlGallery.WindowsPhone +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class MainPage + { + public MainPage () + { + InitializeComponent (); + + var app = new Controls.App (); + + var mdp = app.MainPage as MasterDetailPage; + + var detail = mdp?.Detail as NavigationPage; + if (detail != null) { + detail.Pushed += (sender, args) => { + var nncgPage = args.Page as NestedNativeControlGalleryPage; + + if (nncgPage != null) { + AddNativeControls (nncgPage); + } + }; + } + + LoadApplication (app); + } + + void AddNativeControls (NestedNativeControlGalleryPage page) + { + if (page.NativeControlsAdded) { + return; + } + + StackLayout sl = page.Layout; + + // Create and add a native TextBlock + var originalText = "I am a native TextBlock"; + var textBlock = new TextBlock { + Text = originalText, + FontSize = 14, + FontFamily = new FontFamily ("HelveticaNeue") + }; + + sl?.Children.Add (textBlock); + + // Create and add a native Button + var button = new WControls.Button { Content = "Click to toggle font size", Height = 80 }; + button.Click += (sender, args) => { textBlock.FontSize = textBlock.FontSize == 14 ? 24 : 14; }; + + sl?.Children.Add (button.ToView ()); + + // Create a control which we know doesn't behave correctly with regard to measurement + var difficultControl = new BrokenNativeControl { + Text = "Not Sized/Arranged Properly" + }; + + var difficultControl2 = new BrokenNativeControl { + Text = "Fixed" + }; + + // Add the misbehaving controls, one with a custom delegate for ArrangeOverrideDelegate + sl?.Children.Add (difficultControl); + sl?.Children.Add (difficultControl2, + arrangeOverrideDelegate: (renderer, finalSize) => { + if (finalSize.Width <= 0 || double.IsInfinity (finalSize.Width)) { + return null; + } + + FrameworkElement frameworkElement = renderer.Control; + + frameworkElement.Measure (finalSize); + + // The broken control tries sizes itself to be the width of the screen + var wrongSize = Window.Current.Bounds.Width * (int)DisplayProperties.ResolutionScale / 100; + + // The broken control always sizes itself to be 600 wide + // We can re-center it by offsetting it during the Arrange call + double diff = Math.Abs(finalSize.Width - wrongSize) / -2; + frameworkElement.Arrange (new Rect (diff, 0, finalSize.Width - diff, finalSize.Height)); + + // Arranging the control to the left will make it show up past the edge of the master page + // We can fix that by clipping it manually + var clip = new RectangleGeometry { Rect = new Rect (-diff, 0, finalSize.Width, finalSize.Height) }; + frameworkElement.Clip = clip; + + return finalSize; + } + ); + + page.NativeControlsAdded = true; + } + + } +} diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Package.appxmanifest b/Xamarin.Forms.ControlGallery.WindowsPhone/Package.appxmanifest new file mode 100644 index 00000000..b47c1316 --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/Package.appxmanifest @@ -0,0 +1,34 @@ + + + + + + Xamarin.Forms.ControlGallery.WindowsPhone + Eric + Assets\StoreLogo.png + + + 6.3.1 + 6.3.1 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Properties/AssemblyInfo.cs b/Xamarin.Forms.ControlGallery.WindowsPhone/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7be28e92 --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +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("Xamarin.Forms.ControlGallery.WindowsPhone")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Xamarin.Forms.ControlGallery.WindowsPhone")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/StringProvider.cs b/Xamarin.Forms.ControlGallery.WindowsPhone/StringProvider.cs new file mode 100644 index 00000000..f6baddfa --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/StringProvider.cs @@ -0,0 +1,15 @@ +using Xamarin.Forms; +using Xamarin.Forms.ControlGallery.Windows; +using Xamarin.Forms.Controls; + +[assembly: Dependency (typeof (StringProvider))] + +namespace Xamarin.Forms.ControlGallery.Windows +{ + public class StringProvider : IStringProvider + { + public string CoreGalleryTitle { + get { return "Windows Core Gallery"; } + } + } +} diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj b/Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj new file mode 100644 index 00000000..50c990ce --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj @@ -0,0 +1,187 @@ + + + + + Debug + AnyCPU + {8CDEC974-E6BE-4424-BC77-0B87400A08AF} + AppContainerExe + Properties + Xamarin.Forms.ControlGallery.WindowsPhone + Xamarin.Forms.ControlGallery.WindowsPhone + en-US + 8.1 + 12 + 512 + {76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE;NETFX_CORE;WINDOWS_PHONE_APP + prompt + 4 + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_PHONE_APP + true + ;2008 + pdbonly + ARM + false + prompt + true + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_PHONE_APP + true + ;2008 + pdbonly + x86 + false + prompt + true + + + + + {cb9c96ce-125c-4a68-b6a1-c3ff1fbf93e1} + Xamarin.Forms.Controls + + + {57b8b73d-c3b5-4c42-869e-7b2f17d354ac} + Xamarin.Forms.Core + + + {2633af57-f2cb-442a-ac19-f97bd8a06571} + Xamarin.Forms.Maps.WinRT.Phone + + + {3361d52c-2e74-433e-8285-9c9a5c485977} + Xamarin.Forms.Platform.WinRT.Phone + + + {f3fdd7ac-8899-4e41-bfd7-ec83403e736d} + Xamarin.Forms.Platform.WinRT + + + + + App.xaml + + + + MainPage.xaml + + + + + + + Designer + + + + + bank.png + + + cover1.jpg + + + cover1small.jpg + + + crimson.jpg + + + crimsonsmall.jpg + + + menuIcon.png + + + oasis.jpg + + + oasissmall.jpg + + + photo.jpg + + + seth.png + + + + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + + + 12.0 + + + WindowsPhoneApp + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/app.config b/Xamarin.Forms.ControlGallery.WindowsPhone/app.config new file mode 100644 index 00000000..b1d2a5a3 --- /dev/null +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/toolbar_close.png b/Xamarin.Forms.ControlGallery.WindowsPhone/toolbar_close.png new file mode 100644 index 00000000..12f82abb Binary files /dev/null and b/Xamarin.Forms.ControlGallery.WindowsPhone/toolbar_close.png differ -- cgit v1.2.3