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.
18 using System.Collections;
19 using System.Collections.Generic;
20 using System.ComponentModel;
21 using System.Windows.Input;
22 using System.Threading.Tasks;
23 using LibTVRefCommonPortable.DataModels;
24 using LibTVRefCommonPortable.Utils;
27 namespace TVHome.ViewModels
29 public class MainPageViewModel : INotifyPropertyChanged
31 public IEnumerable<ShortcutInfo> MainList { get; set; }
32 public IEnumerable<ShortcutInfo> RecentList { get; set; }
33 public IEnumerable<ShortcutInfo> AppList { get; set; }
34 public IEnumerable<ShortcutInfo> SettingsList { get; set; }
36 public event PropertyChangedEventHandler PropertyChanged;
37 protected void OnPropertyChanged(string name)
39 PropertyChangedEventHandler handler = PropertyChanged;
42 handler(this, new PropertyChangedEventArgs(name));
46 public MainPageViewModel()
48 string[] AppName = { "Recent", "Apps", "Settings" };
49 // TODO : Revert this before release
50 //string[] AppControlID = { "org.tizen.settings", "org.tizen.apps", "org.tizen.settings" };
51 string[] AppControlID = { "org.tizen.settings", "org.tizen.example.TVApps.TizenTV", "org.tizen.settings" };
52 string[] AppIconPath = { "ic_tizen_home_menu_recent_normal.png", "ic_tizen_home_menu_apps_normal.png", "ic_tizen_home_menu_settings_normal.png" };
54 List<ShortcutInfo> TempList = new List<ShortcutInfo>();
55 for (int i = 0; i < 3; i++)
57 ShortcutInfo shortcutInfo = new HomeMenuAppShortcutInfo()
66 IconPath = AppIconPath[i],
67 Action = new AppControlAction()
69 AppID = AppControlID[i]
75 shortcutInfo.UpdateState();
76 TempList.Add(shortcutInfo);
80 OnPropertyChanged("MainList");
84 DebuggingUtils.Dbg("Reading Apps list");
85 AppList = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsWithDefaultShortcuts();
86 OnPropertyChanged("AppList");
88 //SettingsList = TVHomeImpl.GetInstance.AppShortcutControllerInstnace.ReadFromFile();
89 SettingsList = TVHomeImpl.GetInstance.SettingShortcutControllerInstance.GetList();
90 OnPropertyChanged("SettingsList");
92 TVHomeImpl.GetInstance.AppShortcutControllerInstance.AddFileSystemChangedListener(TestFunction);
96 private void TestFunction(object sender, EventArgs e)
98 AppList = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsWithDefaultShortcuts();
99 OnPropertyChanged("AppList");
102 private void MakeRecentButtons()
104 RecentList = TVHomeImpl.GetInstance.RecentShortcutControllerInstance.GetList();
105 if (RecentList != null)
107 OnPropertyChanged("RecentList");