3 using Tizen.NUI.BaseComponents;
4 using Tizen.Applications;
7 namespace WidgetApplicationSample
9 class MyWidget : Widget
11 private TextLabel _textLabel;
12 private Animation _animation;
13 private float _pointSize = 5.0f;
14 private Bundle _content;
16 protected override void OnCreate(string contentInfo, Window window)
18 Tizen.Log.Fatal("NUIWidget", "Widget Instance is OnCreate! " + contentInfo);
19 _content = Bundle.Decode(contentInfo);
20 string imageIdx = Convert.ToString(_content.GetItem("ImageIdx"));
21 Tizen.Log.Fatal("NUIWidget", "Widget Instance content info is " + imageIdx);
24 if (window.Size.Width > 1000)
29 window.BackgroundColor = Color.Yellow;
30 _textLabel = new TextLabel("Hello Widget");
31 _textLabel.TextColor = Color.Black;
32 _textLabel.Size2D = new Size2D(270, 60);
33 _textLabel.ParentOrigin = ParentOrigin.Center;
34 _textLabel.PivotPoint = PivotPoint.Center;
35 _textLabel.PositionUsesPivotPoint = true;
36 _textLabel.PointSize = _pointSize;
37 window.Add(_textLabel);
38 Tizen.Log.Fatal("NUIWidget", "text width: " + _textLabel.NaturalSize2D.Width + ", height: " + _textLabel.NaturalSize2D.Height);
40 _animation = new Animation(2000);
41 _animation.AnimateTo(_textLabel, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.Y), 0, 500);
42 _animation.AnimateTo(_textLabel, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.Y), 500, 1000);
43 _animation.Looping = true;
44 _animation.EndAction = Animation.EndActions.Discard;
45 Log.Debug("TCT", "[TestCase][OnCreate][Widget] Pass");
46 base.OnCreate(contentInfo, window);
49 private bool IsEmulator()
52 var result = Tizen.System.Information.TryGetValue("tizen.org/system/model_name", out value);
53 if (result && value.Equals("Emulator"))
61 protected override void OnPause()
63 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnPause!");
65 Log.Debug("TCT", "[TestCase][OnPause][Widget] Pass");
69 protected override void OnResume()
71 OnUpdate(_content.Encode(), 1);
72 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnResume!");
73 Log.Debug("TCT", "[TestCase][OnResume][Widget] Pass");
77 protected override void OnResize(Window window)
79 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnResize!");
80 Log.Debug("TCT", "[TestCase][OnResize][Widget] Pass");
81 base.OnResize(window);
84 protected override void OnTerminate(string contentInfo, TerminationType type)
86 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnTerminate!");
87 Log.Debug("TCT", "[TestCase][OnTerminate][Widget] Pass");
88 base.OnTerminate(contentInfo, type);
91 protected override void OnUpdate(string contentInfo, int force)
93 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnUpdate! " + contentInfo);
94 Bundle content = Bundle.Decode(contentInfo);
95 string imageIdx = Convert.ToString(content.GetItem("ImageIdx"));
97 Tizen.Log.Fatal("NUIWidget", "Widget Instance content info is " + imageIdx);
98 Log.Debug("TCT", "[TestCase][OnUpdate][Widget] Pass");
99 base.OnUpdate(contentInfo, force);
103 class Program : NUIWidgetApplication
105 public Program(System.Type type) : base(type)
109 protected override void OnCreate()
112 Log.Debug("TCT", "[TestCase][OnCreate][NUIWidgetApplication] Pass");
115 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
117 Log.Debug("TCT", "NUIWidgetApplication::OnLocaleChanged()");
118 if (e.Locale != null)
120 Log.Debug("TCT", "[Test_Properties] Locale properties is not null");
121 Log.Debug("TCT", "[Test_Properties] Current value of Locale : " + e.Locale);
122 Log.Debug("TCT", "[Test_Properties] Locale type: " + e.Locale.GetType());
125 Log.Debug("TCT", "[TestCase][OnLocaleChanged][NUIWidgetApplication] Pass");
126 base.OnLocaleChanged(e);
129 protected override void OnLowBattery(LowBatteryEventArgs e)
131 Log.Debug("TCT", "NUIWidgetApplication::OnLowBattery()");
132 if (e.LowBatteryStatus != LowBatteryStatus.None)
134 Log.Debug("TCT", "[Test_Properties] LowBatteryStatus properties is not null");
135 Log.Debug("TCT", "[Test_Properties] Current value of LowBatteryStatus : " + e.LowBatteryStatus.ToString());
136 Log.Debug("TCT", "[Test_Properties] LowBatteryStatus type: " + e.LowBatteryStatus.GetType());
139 Log.Debug("TCT", "[TestCase][OnLowBattery][NUIWidgetApplication] Pass");
141 base.OnLowBattery(e);
144 protected override void OnLowMemory(LowMemoryEventArgs e)
146 Log.Debug("TCT", "NUIWidgetApplication::OnLowMemory()");
147 if (e.LowMemoryStatus != LowMemoryStatus.None)
149 Log.Debug("TCT", "[Test_Properties] LowMemoryStatus properties is not null");
150 Log.Debug("TCT", "[Test_Properties] Current value of LowMemoryStatus : " + e.LowMemoryStatus.ToString());
151 Log.Debug("TCT", "[Test_Properties] LowMemoryStatus type: " + e.LowMemoryStatus.GetType());
153 //logBuilder.AppendLine("TCT [TestCase][OnLowMemory] Pass");
154 Log.Debug("TCT", "[TestCase][OnLowMemory][NUIWidgetApplication] Pass");
159 protected override void OnPreCreate()
161 Log.Debug("TCT", "[TestCase][OnPreCreate][NUIWidgetApplication] Pass");
165 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
167 Log.Debug("TCT", "NUIWidgetApplication::OnRegionFormatChanged()");
170 Log.Debug("TCT", "[Test_Properties] Region properties is not null");
171 Log.Debug("TCT", "[Test_Properties] Current value of Region : " + e.Region);
172 Log.Debug("TCT", "[Test_Properties] Region type: " + e.Region.GetType());
175 Log.Debug("TCT", "[TestCase][OnRegionFormatChanged][NUIWidgetApplication] Pass");
176 base.OnRegionFormatChanged(e);
179 protected override void OnTerminate()
181 Log.Debug("TCT", "NUIWidgetApplication::OnTerminate()");
182 Log.Debug("TCT", "[TestCase][OnTerminate][NUIWidgetApplication] Pass");
186 public override void Run(string[] args)
188 //Created += Created_Event_Test;
189 //AppControlReceived += AppControlReceived_Event_Test;
190 //LocaleChanged += LocaleChanged_Event_Test;
191 //LowMemory += LowMemory_Event_Test;
192 //LowBattery += LowBattery_Event_Test;
193 //Terminated += Terminated_Event_Test;
194 //Paused += EventHandlerPaused;
195 //Resumed += EventHandlerResumed;
196 //DeviceOrientationChanged += DeviceOrientationCHanged_Event_Test;
197 //RegionFormatChanged += RegionFormatChanged_Event_Test;
199 Log.Debug("TCT", "[TestCase][Run][NUIWidgetApplication] Pass");
203 public override void Exit()
205 Log.Debug("TCT", "[TestCase][Exit][NUIWidgetApplication] Pass");
209 public void OnKeyEvent(object sender, Window.KeyEventArgs e)
211 if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
217 static void Main(string[] args)
219 var app = new Program(typeof(MyWidget));