2 * Copyright (c) 2017 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using Tizen.Applications;
18 using Tizen.Xamarin.Forms.Extension.Renderer;
20 using TVMediaHub.Tizen.Views;
21 using TVMediaHub.Tizen.ViewModels;
23 namespace TVMediaHub.Tizen
26 /// TV MediaHub application main entry point
28 class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
31 /// Gets or sets the instance of TV MediaHub
33 public static Program Instance
40 /// Gets or sets the resource directory path of TV MediaHub
42 public static string ResourceDirectoryPath
49 /// An instance of the TV MediaHub application
51 private static App app;
54 /// A method will be called when application is created
56 protected override void OnCreate()
60 // TODO : due to VD's GBM binary issue.
61 if (DirectoryInfo.Resource == null || DirectoryInfo.Resource.Length < 1)
63 ResourceDirectoryPath = "/home/owner/apps_rw/org.tizen.xamediahub/res/";
67 ResourceDirectoryPath = DirectoryInfo.Resource;
70 app = new App(MainWindow.ScreenSize.Width,
71 MainWindow.ScreenSize.Height,
72 MainWindow.ScreenDpi.X,
73 ElmSharp.Elementary.GetScale(),
79 /// A method will be called when application receives app control
81 /// <param name="e">AppControl event argument</param>
82 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
84 if (e.ReceivedAppControl != null && e.ReceivedAppControl.ExtraData != null)
87 if (e.ReceivedAppControl.ExtraData.TryGet("Media Id", out mediaId) == true)
89 VideoTabViewModelLocator.ViewModel.SetCurrentVideo(mediaId);
90 Program.TransitionTo(new VideoPlayer());
96 /// A method for pushing a specific page to navigation stack.
98 /// <param name="page">A page to be pushed</param>
99 public static void TransitionTo(ContentPage page)
101 app.TransitionTo(page);
105 /// A method for setting the root page as MainPage.
107 /// <param name="tabIndex">An index of tab to be set as MainPage. Default value is 0</param>
108 public static void TransitionToMain(int tabIndex = 0)
110 app.TransitionToMain(tabIndex);
114 /// The entry point for the application
116 /// <param name="args">A list of command line arguments</param>
117 static void Main(string[] args)
119 Instance = new Program();
120 TizenFormsExtension.Init();
121 global::Xamarin.Forms.Platform.Tizen.Forms.Init(Instance);
126 /// A method terminates application
128 public void SelfTerminate()