diff options
-rw-r--r--[-rwxr-xr-x] | Xamarin.Forms.Platform.Tizen/FormsApplication.cs | 54 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Native/DisplayOrientations.cs | 36 | ||||
-rw-r--r--[-rwxr-xr-x] | Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs | 6 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Native/Window.cs | 140 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Platform.cs | 2 |
5 files changed, 38 insertions, 200 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs index b725443f..ba01268d 100755..100644 --- a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs +++ b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs @@ -7,6 +7,7 @@ using Tizen.Applications; using Xamarin.Forms.Internals; using EButton = ElmSharp.Button; using EColor = ElmSharp.Color; +using ELayout = ElmSharp.Layout; using EProgressBar = ElmSharp.ProgressBar; namespace Xamarin.Forms.Platform.Tizen @@ -19,7 +20,7 @@ namespace Xamarin.Forms.Platform.Tizen bool _isInitialStart; int _pageBusyCount; Native.Dialog _pageBusyDialog; - Native.Window _window; + Window _window; protected FormsApplication() { @@ -31,24 +32,29 @@ namespace Xamarin.Forms.Platform.Tizen /// Gets the main window or <c>null</c> if it's not set. /// </summary> /// <value>The main window or <c>null</c>.</value> - public Native.Window MainWindow + public Window MainWindow { get { return _window; } - protected set { _window = value; + InitializeWindow(); } } + public ELayout BaseLayout + { + get; protected set; + } + protected override void OnPreCreate() { base.OnPreCreate(); Application.ClearCurrent(); - CreateWindow(); + MainWindow = new Window("FormsWindow"); } protected override void OnTerminate() @@ -283,43 +289,51 @@ namespace Xamarin.Forms.Platform.Tizen _platform.SetPage(page); } - void CreateWindow() + void InitializeWindow() { - Debug.Assert(null == MainWindow); + Debug.Assert(MainWindow != null, "Window cannot be null"); + + MainWindow.Active(); + MainWindow.Show(); + var conformant = new Conformant(MainWindow); + conformant.Show(); + + // Create the base (default) layout for the application + var layout = new ELayout(conformant); + layout.SetTheme("layout", "application", "default"); + layout.Show(); - var window = new Native.Window(); - window.Closed += (s, e) => + conformant.SetContent(layout); + BaseLayout = layout; + MainWindow.AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_90 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270; + + MainWindow.Deleted += (s, e) => { Exit(); }; - window.RotationChanged += (sender, e) => + MainWindow.RotationChanged += (sender, e) => { - switch (_window.CurrentOrientation) + switch (MainWindow.Rotation) { - case Native.DisplayOrientations.None: - Device.Info.CurrentOrientation = Internals.DeviceOrientation.Other; - break; - - case Native.DisplayOrientations.Portrait: + case 0: Device.Info.CurrentOrientation = Internals.DeviceOrientation.PortraitUp; break; - case Native.DisplayOrientations.Landscape: + case 90: Device.Info.CurrentOrientation = Internals.DeviceOrientation.LandscapeLeft; break; - case Native.DisplayOrientations.PortraitFlipped: + case 180: Device.Info.CurrentOrientation = Internals.DeviceOrientation.PortraitDown; break; - case Native.DisplayOrientations.LandscapeFlipped: + case 270: Device.Info.CurrentOrientation = Internals.DeviceOrientation.LandscapeRight; break; } }; - - MainWindow = window; } + public void Run() { Run(System.Environment.GetCommandLineArgs()); diff --git a/Xamarin.Forms.Platform.Tizen/Native/DisplayOrientations.cs b/Xamarin.Forms.Platform.Tizen/Native/DisplayOrientations.cs deleted file mode 100644 index efb09529..00000000 --- a/Xamarin.Forms.Platform.Tizen/Native/DisplayOrientations.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace Xamarin.Forms.Platform.Tizen.Native -{ - /// <summary> - /// Enumeration for the orientation of a rectangular screen. - /// </summary> - [Flags] - public enum DisplayOrientations - { - /// <summary> - /// No display orientation is specified. - /// </summary> - None = 0, - - /// <summary> - /// The display is oriented in a natural position. - /// </summary> - Portrait = 1, - - /// <summary> - /// The display's left side is at the top. - /// </summary> - Landscape = 2, - - /// <summary> - /// The display is upside down. - /// </summary> - PortraitFlipped = 4, - - /// <summary> - /// The display's right side is at the top. - /// </summary> - LandscapeFlipped = 8 - } -} diff --git a/Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs b/Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs index e7e1f243..68260732 100755..100644 --- a/Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs @@ -295,10 +295,10 @@ namespace Xamarin.Forms.Platform.Tizen.Native if (behavior == MasterBehavior.SplitOnLandscape || behavior == MasterBehavior.SplitOnPortrait) { - var orientation = Forms.Context.MainWindow.CurrentOrientation; + var rotation = Forms.Context.MainWindow.Rotation; - if (((orientation == DisplayOrientations.Landscape || orientation == DisplayOrientations.LandscapeFlipped) && behavior == MasterBehavior.SplitOnLandscape) || - ((orientation == DisplayOrientations.Portrait || orientation == DisplayOrientations.PortraitFlipped) && behavior == MasterBehavior.SplitOnPortrait)) + if (((rotation == 90 || rotation == 270) && behavior == MasterBehavior.SplitOnLandscape) || + ((rotation == 0 || rotation == 90) && behavior == MasterBehavior.SplitOnPortrait)) { behavior = MasterBehavior.Split; } diff --git a/Xamarin.Forms.Platform.Tizen/Native/Window.cs b/Xamarin.Forms.Platform.Tizen/Native/Window.cs deleted file mode 100644 index 3e982ae5..00000000 --- a/Xamarin.Forms.Platform.Tizen/Native/Window.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using ElmSharp; -using EWindow = ElmSharp.Window; -using ELayout = ElmSharp.Layout; - -namespace Xamarin.Forms.Platform.Tizen.Native -{ - public class Window : EWindow - { - ELayout _layout; - Conformant _conformant; - - /// <summary> - /// Initializes a new instance of the Window class. - /// </summary> - public Window() : base("FormsWindow") - { - Initialize(); - } - - /// <summary> - /// Notifies that the window has been closed. - /// </summary> - public event EventHandler Closed; - - /// <summary> - /// Gets the current orientation. - /// </summary> - public DisplayOrientations CurrentOrientation - { - get - { - if (IsRotationSupported) - { - return GetDisplayOrientation(); - } - else - { - return DisplayOrientations.None; - } - } - } - - /// <summary> - /// Gets or sets the orientation of a rectangular screen. - /// </summary> - public DisplayOrientations AvailableOrientations - { - get - { - if (IsRotationSupported) - { - return (DisplayOrientations)AvailableRotations; - } - else - { - return DisplayOrientations.None; - } - } - set - { - if (IsRotationSupported) - { - AvailableRotations = (DisplayRotation)value; - } - } - } - - public ELayout BaseLayout - { - get - { - return _layout; - } - - private set - { - _layout = value; - } - } - - /// <summary> - /// Sets the main page of Window. - /// </summary> - /// <param name="content">ElmSharp.EvasObject type page to be set.</param> - public void SetMainPage(EvasObject content) - { - _layout.SetContent(content); - } - - void Initialize() - { - // events - Deleted += (sender, e) => - { - Closed?.Invoke(this, EventArgs.Empty); - }; - CloseRequested += (sender, e) => - { - Unrealize(); - }; - - Active(); - AutoDeletion = false; - Show(); - - _conformant = new Conformant(this); - _conformant.Show(); - - // Create the base (default) layout for the application - _layout = new ELayout(_conformant); - _layout.SetTheme("layout", "application", "default"); - _layout.Show(); - - _conformant.SetContent(_layout); - BaseLayout = _layout; - AvailableOrientations = DisplayOrientations.Portrait | DisplayOrientations.Landscape | DisplayOrientations.PortraitFlipped | DisplayOrientations.LandscapeFlipped; - } - DisplayOrientations GetDisplayOrientation() - { - switch (Rotation) - { - case 0: - return Native.DisplayOrientations.Portrait; - - case 90: - return Native.DisplayOrientations.Landscape; - - case 180: - return Native.DisplayOrientations.PortraitFlipped; - - case 270: - return Native.DisplayOrientations.LandscapeFlipped; - - default: - return Native.DisplayOrientations.None; - } - } - } -} diff --git a/Xamarin.Forms.Platform.Tizen/Platform.cs b/Xamarin.Forms.Platform.Tizen/Platform.cs index 8111a832..b3cd88af 100644 --- a/Xamarin.Forms.Platform.Tizen/Platform.cs +++ b/Xamarin.Forms.Platform.Tizen/Platform.cs @@ -49,7 +49,7 @@ namespace Xamarin.Forms.Platform.Tizen _naviframe.SetWeight(1.0, 1.0); _naviframe.Show(); _naviframe.AnimationFinished += NaviAnimationFinished; - Forms.Context.MainWindow.SetMainPage(_naviframe); + Forms.Context.BaseLayout.SetContent(_naviframe); } ~Platform() |