2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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.
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.UIComponents;
22 namespace Tizen.NUI.Examples
24 public class MediaHubPage : ContentPage
26 private Vector2 bezierPointIn1 = new Vector2(0.21f, 2);
27 private Vector2 bezierPointIn2 = new Vector2(0.14f, 1);
28 private Vector2 bezierPointOut1 = new Vector2(0.19f, 1);
29 private Vector2 bezierPointOut2 = new Vector2(0.22f, 1);
30 private Animation scaleInAni = null;
31 private Animation scaleOutAni = null;
32 private TableView contentTable = null;
33 private TableView optionList = null;
35 public MediaHubPage(Window win) : base (win)
37 Root.BackgroundImage = "/home/owner/apps_rw/org.tizen.example.NUIXAMLTestSample/res/images/mc_bg.png";
38 ClearEvent += OnClearEvent;
42 /// To make the ContentPage instance be disposed.
44 protected override void Dispose(DisposeTypes type)
51 if (type == DisposeTypes.Explicit)
54 //Release your own managed resources here.
55 //You should release all of your own disposable objects here.
58 //Release your own unmanaged resources here.
59 //You should not access any managed member here except static instance.
60 //because the execution order of Finalizes is non-deterministic.
61 scaleInAni?.Dispose();
63 scaleOutAni?.Dispose();
65 FocusManager.Instance.PreFocusChange -= OnPreFocusChange;
66 ClearEvent -= OnClearEvent;
71 public override void SetFocus()
75 private void OnClearEvent(object obj, EventArgs e)
77 Root.BackgroundImage = "/home/owner/apps_rw/org.tizen.example.NUIXAMLTestSample/res/images/mc_bg.png";
80 private View OnPreFocusChange(object obj, FocusManager.PreFocusChangeEventArgs e)
82 if (e.CurrentView != null && !e.ProposedView)
84 if (e.Direction == View.FocusDirection.Down)
86 e.ProposedView = optionList;//.GetChildAt(0);
88 if (e.Direction == View.FocusDirection.Up)
90 e.ProposedView = contentTable;//.GetChildAt(0);
92 Tizen.Log.Fatal("NUISamples", "proposed view is null ");
93 // Console.WriteLine("================== Proposed view null");
95 if (!e.ProposedView && !e.CurrentView)
97 e.ProposedView = contentTable;//.GetChildAt(0);
99 return e.ProposedView;
102 private bool OnClicked(object sender, EventArgs e)
104 if (sender is Button)
106 Button button = sender as Button;
107 button.LabelText = "Click Me";
112 private void OnFocusGained(object obj, EventArgs e)
114 View view = obj as View;
116 if (scaleInAni == null)
118 scaleInAni = new Animation();
121 scaleInAni.EndAction = Animation.EndActions.StopFinal;
122 scaleInAni.AnimateTo(view, "Scale", new Vector3(1.2f, 1.2f, 0), 0, 1100, new AlphaFunction(bezierPointIn1, bezierPointIn2));
126 private void OnFocusLost(object obj, EventArgs e)
128 View view = obj as View;
129 if (scaleOutAni == null)
131 scaleOutAni = new Animation();
134 scaleOutAni.EndAction = Animation.EndActions.StopFinal;
135 scaleOutAni.AnimateTo(view, "Scale", new Vector3(1.0f, 1.0f, 0), 0, 850, new AlphaFunction(bezierPointOut1, bezierPointOut2));
139 private void OnOptionsFocusGained(object obj, EventArgs e)
141 ImageView view = obj as ImageView;
142 view.ResourceUrl = "/home/owner/apps_rw/org.tizen.example.NUIXAMLTestSample/res/images/r_highlight_bg_focus_9patch.png";
143 view.Border = new Rectangle(14,14,20,20);
145 if (scaleInAni == null)
147 scaleInAni = new Animation();
150 scaleInAni.EndAction = Animation.EndActions.StopFinal;
151 scaleInAni.AnimateTo(view, "Scale", new Vector3(1.2f, 1.2f, 0), 0, 1100, new AlphaFunction(bezierPointIn1, bezierPointIn2));
155 private void OnOptionsFocusLost(object obj, EventArgs e)
157 ImageView view = obj as ImageView;
158 view.ResourceUrl = "/home/owner/apps_rw/org.tizen.example.NUIXAMLTestSample/res/images/c_basic_button_white_bg_normal.9.png";
159 view.Border = new Rectangle(4,4,5,5);
160 if (scaleOutAni == null)
162 scaleOutAni = new Animation();
165 scaleOutAni.EndAction = Animation.EndActions.StopFinal;
166 scaleOutAni.AnimateTo(view, "Scale", new Vector3(1.0f, 1.0f, 0), 0, 850, new AlphaFunction(bezierPointOut1, bezierPointOut2));