diff --git a/Xamarin.Forms.ControlGallery.GTK/Program.cs b/Xamarin.Forms.ControlGallery.GTK/Program.cs index 4632c95c6..81fc61da1 100644 --- a/Xamarin.Forms.ControlGallery.GTK/Program.cs +++ b/Xamarin.Forms.ControlGallery.GTK/Program.cs @@ -21,6 +21,7 @@ namespace Xamarin.Forms.ControlGallery.GTK GtkOpenGL.Init(); GtkThemes.Init(); Gtk.Application.Init(); + Forms.SetFlags("CarouselView_Experimental"); FormsMaps.Init(string.Empty); Forms.Init(); var app = new App(); diff --git a/Xamarin.Forms.ControlGallery.WPF/MainWindow.xaml.cs b/Xamarin.Forms.ControlGallery.WPF/MainWindow.xaml.cs index bffffa728..84b741655 100644 --- a/Xamarin.Forms.ControlGallery.WPF/MainWindow.xaml.cs +++ b/Xamarin.Forms.ControlGallery.WPF/MainWindow.xaml.cs @@ -10,6 +10,7 @@ namespace Xamarin.Forms.ControlGallery.WPF public MainWindow() { InitializeComponent(); + Forms.SetFlags("CarouselView_Experimental"); Xamarin.Forms.Forms.Init(); FormsMaps.Init(""); LoadApplication(new Controls.App()); diff --git a/Xamarin.Forms.Platform.GTK/Forms.cs b/Xamarin.Forms.Platform.GTK/Forms.cs index 52e2afcf5..7f298d874 100644 --- a/Xamarin.Forms.Platform.GTK/Forms.cs +++ b/Xamarin.Forms.Platform.GTK/Forms.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; @@ -15,6 +16,10 @@ namespace Xamarin.Forms const string LogFormat = "[{0}] {1}"; public static bool IsInitialized { get; private set; } + static bool FlagsSet { get; set; } + + static IReadOnlyList s_flags; + public static IReadOnlyList Flags => s_flags ?? (s_flags = new List().AsReadOnly()); public static void Init(IEnumerable rendererAssemblies = null) { @@ -25,9 +30,8 @@ namespace Xamarin.Forms Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); - IsInitialized = true; - Device.SetIdiom(TargetIdiom.Desktop); + Device.SetFlags(s_flags); Device.PlatformServices = new GtkPlatformServices(); Device.Info = new GtkDeviceInfo(); Color.SetAccent(Color.FromHex("#3498DB")); @@ -39,6 +43,24 @@ namespace Xamarin.Forms typeof(ExportImageSourceHandlerAttribute), typeof(ExportRendererAttribute) }); + + IsInitialized = true; + } + + public static void SetFlags(params string[] flags) + { + if (FlagsSet) + { + return; + } + + if (IsInitialized) + { + throw new InvalidOperationException($"{nameof(SetFlags)} must be called before {nameof(Init)}"); + } + + s_flags = flags.ToList().AsReadOnly(); + FlagsSet = true; } } } diff --git a/Xamarin.Forms.Platform.WPF/Forms.cs b/Xamarin.Forms.Platform.WPF/Forms.cs index fc75afdad..c5e4d89e7 100644 --- a/Xamarin.Forms.Platform.WPF/Forms.cs +++ b/Xamarin.Forms.Platform.WPF/Forms.cs @@ -12,6 +12,11 @@ namespace Xamarin.Forms { public static bool IsInitialized { get; private set; } + static bool FlagsSet { get; set; } + + static IReadOnlyList s_flags; + public static IReadOnlyList Flags => s_flags ?? (s_flags = new List().AsReadOnly()); + public static void Init(IEnumerable rendererAssemblies = null) { if (IsInitialized) @@ -36,11 +41,28 @@ namespace Xamarin.Forms ExpressionSearch.Default = new WPFExpressionSearch(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); - + Ticker.SetDefault(new WPFTicker()); Device.SetIdiom(TargetIdiom.Desktop); + Device.SetFlags(s_flags); IsInitialized = true; } + + public static void SetFlags(params string[] flags) + { + if (FlagsSet) + { + return; + } + + if (IsInitialized) + { + throw new InvalidOperationException($"{nameof(SetFlags)} must be called before {nameof(Init)}"); + } + + s_flags = flags.ToList().AsReadOnly(); + FlagsSet = true; + } } }