/*
* 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 Tizen.Applications;
using Tizen.Xamarin.Forms.Extension.Renderer;
using Xamarin.Forms;
using TVMediaHub.Tizen.Views;
using TVMediaHub.Tizen.ViewModels;
namespace TVMediaHub.Tizen
{
///
/// TV MediaHub application main entry point
///
class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
{
///
/// Gets or sets the instance of TV MediaHub
///
public static Program Instance
{
get;
private set;
}
///
/// Gets or sets the resource directory path of TV MediaHub
///
public static string ResourceDirectoryPath
{
get;
private set;
}
///
/// An instance of the TV MediaHub application
///
private static App app;
///
/// A method will be called when application is created
///
protected override void OnCreate()
{
base.OnCreate();
// TODO : due to VD's GBM binary issue.
if (DirectoryInfo.Resource == null || DirectoryInfo.Resource.Length < 1)
{
ResourceDirectoryPath = "/home/owner/apps_rw/org.tizen.xamediahub/res/";
}
else
{
ResourceDirectoryPath = DirectoryInfo.Resource;
}
app = new App(MainWindow.ScreenSize.Width,
MainWindow.ScreenSize.Height,
MainWindow.ScreenDpi.X,
ElmSharp.Elementary.GetScale(),
MainWindow);
LoadApplication(app);
}
///
/// A method will be called when application receives app control
///
/// AppControl event argument
protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
{
if (e.ReceivedAppControl != null && e.ReceivedAppControl.ExtraData != null)
{
string mediaId;
if (e.ReceivedAppControl.ExtraData.TryGet("Media Id", out mediaId) == true)
{
VideoTabViewModelLocator.ViewModel.SetCurrentVideo(mediaId);
Program.TransitionTo(new VideoPlayer());
}
}
}
///
/// A method for pushing a specific page to navigation stack.
///
/// A page to be pushed
public static void TransitionTo(ContentPage page)
{
app.TransitionTo(page);
}
///
/// A method for setting the root page as MainPage.
///
/// An index of tab to be set as MainPage. Default value is 0
public static void TransitionToMain(int tabIndex = 0)
{
app.TransitionToMain(tabIndex);
}
///
/// The entry point for the application
///
/// A list of command line arguments
static void Main(string[] args)
{
Instance = new Program();
TizenFormsExtension.Init();
global::Xamarin.Forms.Platform.Tizen.Forms.Init(Instance);
Instance.Run(args);
}
///
/// A method terminates application
///
public void SelfTerminate()
{
Instance.Exit();
}
}
}