using System; using System.Reflection; using Tizen.Applications; using ElmSharp; namespace Xamarin.Forms.Platform.Tizen { public static class Forms { class TizenDeviceInfo : DeviceInfo { readonly Size pixelScreenSize; readonly Size scaledScreenSize; readonly double scalingFactor; public override Size PixelScreenSize { get { return this.pixelScreenSize; } } public override Size ScaledScreenSize { get { return this.scaledScreenSize; } } public override double ScalingFactor { get { return this.scalingFactor; } } public TizenDeviceInfo(FormsApplication formsApplication) { // TODO: obtain screen data from device pixelScreenSize = new Size(); scaledScreenSize = new Size(); scalingFactor = 0.0; } } public static event EventHandler ViewInitialized; public static FormsApplication Context { get; internal set; } public static bool IsInitialized { get; private set; } internal static TizenTitleBarVisibility TitleBarVisibility { get; private set; } internal static void SendViewInitialized(this VisualElement self, EvasObject nativeView) { EventHandler viewInitialized = Forms.ViewInitialized; if (viewInitialized != null) { viewInitialized.Invoke(self, new ViewInitializedEventArgs { View = self, NativeView = nativeView }); } } public static void SetTitleBarVisibility(TizenTitleBarVisibility visibility) { TitleBarVisibility = visibility; } public static void Init(FormsApplication application) { SetupInit(application); } static void SetupInit(FormsApplication application) { Color.Accent = GetAccentColor(); Context = application; if (!IsInitialized) { Xamarin.Forms.Log.Listeners.Add(new XamarinLogListener()); if (System.Threading.SynchronizationContext.Current == null) { TizenSynchronizationContext.Initialize(); } Elementary.Initialize(); Elementary.ThemeOverlay(); } //TO-DO: Need to change to Tizen. Device.OS = TargetPlatform.Other; #if !NET45 // In .NETCore, AppDomain feature is not supported. // The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually. // The assembly of the executing application and referenced assemblies of it are added into the list here. Assembly asm = application.GetType().GetTypeInfo().Assembly; TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssembly(asm); foreach (var refName in asm.GetReferencedAssemblies()) { if (!refName.Name.StartsWith("System.") && !refName.Name.StartsWith("Microsoft.")) { try { Assembly refAsm = Assembly.Load(refName); TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssembly(refAsm); } catch { Log.Warn("Reference Assembly can not be loaded. {0}", refName.FullName); } } } #endif Device.PlatformServices = new TizenPlatformServices(); ; if (Device.info != null) { ((TizenDeviceInfo)Device.info).Dispose(); Device.info = null; } Device.Info = new Forms.TizenDeviceInfo(application); if (!Forms.IsInitialized) { Registrar.RegisterAll(new Type[] { typeof(ExportRendererAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportCellAttribute), }); } // FIXME: We should consider TV and Common (Desktop) profiles also. Device.Idiom = TargetIdiom.Phone; IsInitialized = true; } static Color GetAccentColor() { // On Windows Phone, this is the complementary color chosen by the user. // Good Windows Phone applications use this as part of their styling to provide a native look and feel. // On iOS and Android this instance is set to a contrasting color that is visible on the default // background but is not the same as the default text color. // TODO: implement me return Color.Black; } } }