/* * Copyright (c) 2017 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://floralicense.org/license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using ElmSharp; using System; using TVMediaHub.Tizen.Utils; using TVMediaHub.Tizen.Views; using Xamarin.Forms; namespace TVMediaHub { /// /// A class that represents TV MediaHub application /// public class App : Application { /// /// Gets or sets the window of TV MediaHub /// public static Window MainWindow { get; private set; } /// /// Gets or sets the NavigationPage of TV MediaHub /// public static NavigationPage AppMainPage { get; private set; } /// /// A constructor /// Sets main page to MainPage instance /// /// /// Screen Width /// Screen Height /// Screen DPI /// Scale ratio /// Window public App(int screenWidth, int screenHeight, int dpi, double scaleRatio, Window window) { SizeUtils.ScreenWidth = screenWidth; SizeUtils.ScreenHeight = screenHeight; SizeUtils.Dpi = dpi; SizeUtils.ScaleRatio = scaleRatio; try { string modelName; if (SystemSettingsPort.GetSystemModelName(out modelName)) { SizeUtils.SetModelName(modelName); } } catch (Exception e) { DbgPort.E("Cant get model name!!!, " + e.Message); } MainWindow = window; TransitionToMain(); } /// /// A method for pushing a specific page to navigation stack. /// /// A page to be pushed public void TransitionTo(ContentPage page) { //MainPage = page; AppMainPage.PushAsync(page); } /// /// A method for setting the root page as MainPage. /// /// An index of tab to be set as MainPage. Default value is 0 public void TransitionToMain(int tabIndex = 0) { /* MainPage = new NavigationPage(new MediaHubMainPage(tabIndex)); MainPage.Opacity = 0; AppMainPage = MainPage as NavigationPage; */ if (AppMainPage == null) { MainPage = new NavigationPage(new MediaHubMainPage(tabIndex)); MainPage.Opacity = 0; AppMainPage = MainPage as NavigationPage; } else { AppMainPage.PopToRootAsync(); } } /// /// A method for running hide animation /// public void RunHideAnimation() { MainPage.FadeTo(0.0, 667); } /// /// A method for running show animation /// public void RunShowAnimation() { MainPage.FadeTo(0.99, 667); } } }