private void CreateSubList() { Tizen.Log.Fatal("NUI.ChannelList", "CreateSubList..."); // Create sublist. subListView = new List(); subListView.BackgroundColor = new Vector4(8.0f / 255.0f, 12.0f / 255.0f, 15.0f / 255.0f, 0.95f); subListView.Name = "Sub_List"; subListView.SizeWidth = windowSize.Width * 0.207812f; subListView.SizeHeight = windowSize.Height * 0.887962f; subListView.PreloadFrontItemSize = 1; subListView.PreloadBackItemSize = 1; //Initial sublist data set. List <object> dataList = new List <object>(); int num = (new SubListData(0)).Num; for (int i = 0; i < num; i++) { SubListData data = new SubListData(i); dataList.Add(data); } //Crate sublist adapter. SubListAdapter mAdapter = new SubListAdapter(dataList); mAdapter.SelectedIndex = 0; subListView.SetAdapter(mAdapter); subListView.Focusable = true; subListView.KeyEvent += OnKeyPressed; //Add key event handler. listContentLayout.AddChild(subListView, new TableView.CellPosition(0, 1)); // Add shadow image for sublist area. ImageView shadow = new ImageView(subListShadow); shadow.SizeWidth = windowSize.Width * 0.021875f; shadow.SizeHeight = windowSize.Height * 0.887962f; subListView.Add(shadow); }
private bool OnKeyPressed(object source, View.KeyEventArgs e) { Tizen.Log.Fatal("NUI.ChannelList", "OnKeyPressed...KeyPressedName: " + e.Key.KeyPressedName); List listview = source as List; if (e.Key.State == Key.StateType.Down) { if (e.Key.KeyPressedName == "Up") { // Handle up key event. listview.MoveFocus(MoveDirection.Up); } else if (e.Key.KeyPressedName == "Down") { // Handle up key event. listview.MoveFocus(MoveDirection.Down); } else if (e.Key.KeyPressedName == "Right") { // Handle right key event. Tizen.Log.Fatal("NUI.ChannelList", "RightKeyPressed"); if (listview == listView) { Tizen.Log.Fatal("NUI.ChannelList", "RightKeyPressed listview == listView"); FocusManager.Instance.SetCurrentFocusView(subListView); editBackGround1.Show(); Animation animation = new Animation(500); animation.AnimateTo(contentLayout, "Position", new Position(0, 0, 0)); animation.Play(); animation.Finished += (obj, ee) => { FocusManager.Instance.SetCurrentFocusView(subListView); }; SubListAdapter mAdapter = subListView.GetAdapter() as SubListAdapter; mAdapter.Open = false; for (int i = 0; i < mAdapter.GetCount(); i++) { if ((subListView.GetLoadedItemView(i) as SubListItem) != null) { (subListView.GetLoadedItemView(i) as SubListItem).IconOpacity(true); } } } } else if (e.Key.KeyPressedName == "Left" || e.Key.KeyPressedName == "BackSpace") { // Handle left key or BackSpace key event. if (listview == subListView) { // if sublist focused. FocusManager.Instance.SetCurrentFocusView(listView); Animation animation = new Animation(500); animation.AnimateTo(contentLayout, "Position", new Position(windowSize.Width * 0.145833f, 0, 0)); animation.Play(); animation.Finished += (obj, ee) => { editBackGround1.Hide(); FocusManager.Instance.SetCurrentFocusView(listView); }; SubListAdapter mAdapter = subListView.GetAdapter() as SubListAdapter; mAdapter.Open = true; for (int i = 0; i < mAdapter.GetCount(); i++) { if (i == subSelectedIndex) { if ((listview.GetLoadedItemView(i) as SubListItem) != null) { (listview.GetLoadedItemView(i) as SubListItem).IconOpacity(true); } } else { if ((listview.GetLoadedItemView(i) as SubListItem) != null) { (listview.GetLoadedItemView(i) as SubListItem).IconOpacity(false); } } } } else if (listview == selectListView || listview == genreListView) { //if favorite list or genre list focused if (subListView.GetLoadedItemView(subSelectedIndex) != null) { (subListView.GetLoadedItemView(subSelectedIndex) as SubListItem).SelectedText(false); (subListView.GetLoadedItemView(subSelectedIndex) as SubListItem).IconUrl = ((subListView.GetAdapter().GetData(subSelectedIndex)) as SubListData).IconN; } subSelectedIndex = preSubSelectIndex; (subListView.GetLoadedItemView(subSelectedIndex) as SubListItem).SelectedText(true); (subListView.GetLoadedItemView(subSelectedIndex) as SubListItem).IconUrl = ((subListView.GetAdapter().GetData(subSelectedIndex)) as SubListData).IconS; (subListView.GetAdapter() as SubListAdapter).SelectedIndex = subSelectedIndex; Animation animation = new Animation(); animation.AnimateTo(contentLayout, "colorAlpha", 1.0f, 0, 334); animation.AnimateTo(selectContentLayout, "PositionX", windowSize.Width * 0.344270f, 0, 500); animation.Play(); animation.Finished += (obj, ee) => { FocusManager.Instance.SetCurrentFocusView(listView); }; } } else if (e.Key.KeyPressedName == "Return") { //Handle Return event. if (listview == listView && playIndex != listview.FocusItemIndex) { Tizen.Log.Fatal("NUI.ChannelList", "listview selected..."); if (listview.GetLoadedItemView(playIndex) != null) { (listview.GetLoadedItemView(playIndex) as ListItem).Play(false); } playIndex = listview.FocusItemIndex; playProgramIndex = (listview.GetLoadedItemView(listview.FocusItemIndex) as ListItem).ProgramIndex; (listview.GetLoadedItemView(listview.FocusItemIndex) as ListItem).Play(true); (listview.GetAdapter() as SampleListAdapter).PlayProgramIndex = playProgramIndex; } else if (listview == subListView) { Tizen.Log.Fatal("NUI.ChannelList", "sublistview selected..."); Tizen.Log.Fatal("NUI.ChannelList", "subSelectedIndex: " + subSelectedIndex + ", FocusItemIndex: " + listview.FocusItemIndex); if (subSelectedIndex != listview.FocusItemIndex) { if (listview.GetLoadedItemView(subSelectedIndex) != null) { (listview.GetLoadedItemView(subSelectedIndex) as SubListItem).SelectedText(false); (listview.GetLoadedItemView(subSelectedIndex) as SubListItem).IconUrl = ((listview.GetAdapter().GetData(subSelectedIndex)) as SubListData).IconN; } subSelectedIndex = listview.FocusItemIndex; (listview.GetLoadedItemView(subSelectedIndex) as SubListItem).SelectedText(true); (listview.GetLoadedItemView(subSelectedIndex) as SubListItem).IconUrl = ((listview.GetAdapter().GetData(subSelectedIndex)) as SubListData).IconS; (listview.GetAdapter() as SubListAdapter).SelectedIndex = subSelectedIndex; } SubListSelecteChanged(subSelectedIndex); } else if (listview == selectListView) { Tizen.Log.Fatal("NUI.ChannelList", "favoratelistview selected..."); //FavoriteSelect(); } else if (listview == genreListView) { Tizen.Log.Fatal("NUI.ChannelList", "genrelistview selected..."); //GenreSelect(); } } else if (e.Key.KeyPressedName == "XF86Back") { return(false); } } return(true); }