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);
23 window.BackgroundColor = Color.White;
24 _textLabel = new TextLabel("Hello Widget");
25 _textLabel.TextColor = Color.Black;
26 _textLabel.Size2D = new Size2D(360, 130);
27 _textLabel.ParentOrigin = ParentOrigin.TopLeft;
28 _textLabel.PivotPoint = PivotPoint.TopLeft;
29 _textLabel.HorizontalAlignment = HorizontalAlignment.Center;
30 _textLabel.VerticalAlignment = VerticalAlignment.Center;
31 _textLabel.PositionUsesPivotPoint = true;
32 _textLabel.PointSize = _pointSize;
33 _textLabel.Position2D = new Position2D(0, 0);
34 window.Add(_textLabel);
35 Tizen.Log.Fatal("NUIWidget", "text width: " + _textLabel.NaturalSize2D.Width + ", height: " + _textLabel.NaturalSize2D.Height);
37 _animation = new Animation(2000);
38 _animation.AnimateTo(_textLabel, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.Y), 0, 500);
39 _animation.AnimateTo(_textLabel, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.Y), 500, 1000);
40 _animation.Looping = true;
41 _animation.EndAction = Animation.EndActions.Discard;
42 Log.Debug("TCT", "[TestCase][OnCreate][Widget] Pass");
43 base.OnCreate(contentInfo, window);
46 private bool IsEmulator()
49 var result = Tizen.System.Information.TryGetValue("tizen.org/system/model_name", out value);
50 if (result && value.Equals("Emulator"))
58 protected override void OnPause()
60 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnPause!");
62 Log.Debug("TCT", "[TestCase][OnPause][Widget] Pass");
66 protected override void OnResume()
68 OnUpdate(_content.Encode(), 1);
69 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnResume!");
70 Log.Debug("TCT", "[TestCase][OnResume][Widget] Pass");
74 protected override void OnResize(Window window)
76 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnResize!");
77 Log.Debug("TCT", "[TestCase][OnResize][Widget] Pass");
78 base.OnResize(window);
81 protected override void OnTerminate(string contentInfo, TerminationType type)
83 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnTerminate!");
84 Log.Debug("TCT", "[TestCase][OnTerminate][Widget] Pass");
85 base.OnTerminate(contentInfo, type);
88 protected override void OnUpdate(string contentInfo, int force)
90 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnUpdate! " + contentInfo);
91 Bundle content = Bundle.Decode(contentInfo);
92 string imageIdx = Convert.ToString(content.GetItem("ImageIdx"));
94 Tizen.Log.Fatal("NUIWidget", "Widget Instance content info is " + imageIdx);
95 Log.Debug("TCT", "[TestCase][OnUpdate][Widget] Pass");
96 base.OnUpdate(contentInfo, force);
100 class Program : NUIWidgetApplication
102 public Program(System.Type type) : base(type)
106 protected override void OnCreate()
109 Log.Debug("TCT", "[TestCase][OnCreate][NUIWidgetApplication] Pass");
112 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
114 Log.Debug("TCT", "NUIWidgetApplication::OnLocaleChanged()");
115 if (e.Locale != null)
117 Log.Debug("TCT", "[Test_Properties] Locale properties is not null");
118 Log.Debug("TCT", "[Test_Properties] Current value of Locale : " + e.Locale);
119 Log.Debug("TCT", "[Test_Properties] Locale type: " + e.Locale.GetType());
122 Log.Debug("TCT", "[TestCase][OnLocaleChanged][NUIWidgetApplication] Pass");
123 base.OnLocaleChanged(e);
126 protected override void OnLowBattery(LowBatteryEventArgs e)
128 Log.Debug("TCT", "NUIWidgetApplication::OnLowBattery()");
129 if (e.LowBatteryStatus != LowBatteryStatus.None)
131 Log.Debug("TCT", "[Test_Properties] LowBatteryStatus properties is not null");
132 Log.Debug("TCT", "[Test_Properties] Current value of LowBatteryStatus : " + e.LowBatteryStatus.ToString());
133 Log.Debug("TCT", "[Test_Properties] LowBatteryStatus type: " + e.LowBatteryStatus.GetType());
136 Log.Debug("TCT", "[TestCase][OnLowBattery][NUIWidgetApplication] Pass");
138 base.OnLowBattery(e);
141 protected override void OnLowMemory(LowMemoryEventArgs e)
143 Log.Debug("TCT", "NUIWidgetApplication::OnLowMemory()");
144 if (e.LowMemoryStatus != LowMemoryStatus.None)
146 Log.Debug("TCT", "[Test_Properties] LowMemoryStatus properties is not null");
147 Log.Debug("TCT", "[Test_Properties] Current value of LowMemoryStatus : " + e.LowMemoryStatus.ToString());
148 Log.Debug("TCT", "[Test_Properties] LowMemoryStatus type: " + e.LowMemoryStatus.GetType());
150 //logBuilder.AppendLine("TCT [TestCase][OnLowMemory] Pass");
151 Log.Debug("TCT", "[TestCase][OnLowMemory][NUIWidgetApplication] Pass");
156 protected override void OnPreCreate()
158 Log.Debug("TCT", "[TestCase][OnPreCreate][NUIWidgetApplication] Pass");
162 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
164 Log.Debug("TCT", "NUIWidgetApplication::OnRegionFormatChanged()");
167 Log.Debug("TCT", "[Test_Properties] Region properties is not null");
168 Log.Debug("TCT", "[Test_Properties] Current value of Region : " + e.Region);
169 Log.Debug("TCT", "[Test_Properties] Region type: " + e.Region.GetType());
172 Log.Debug("TCT", "[TestCase][OnRegionFormatChanged][NUIWidgetApplication] Pass");
173 base.OnRegionFormatChanged(e);
176 protected override void OnTerminate()
178 Log.Debug("TCT", "NUIWidgetApplication::OnTerminate()");
179 Log.Debug("TCT", "[TestCase][OnTerminate][NUIWidgetApplication] Pass");
183 public override void Run(string[] args)
185 //Created += Created_Event_Test;
186 //AppControlReceived += AppControlReceived_Event_Test;
187 //LocaleChanged += LocaleChanged_Event_Test;
188 //LowMemory += LowMemory_Event_Test;
189 //LowBattery += LowBattery_Event_Test;
190 //Terminated += Terminated_Event_Test;
191 //Paused += EventHandlerPaused;
192 //Resumed += EventHandlerResumed;
193 //DeviceOrientationChanged += DeviceOrientationCHanged_Event_Test;
194 //RegionFormatChanged += RegionFormatChanged_Event_Test;
196 Log.Debug("TCT", "[TestCase][Run][NUIWidgetApplication] Pass");
200 public override void Exit()
202 Log.Debug("TCT", "[TestCase][Exit][NUIWidgetApplication] Pass");
206 public void OnKeyEvent(object sender, Window.KeyEventArgs e)
208 if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
214 static void Main(string[] args)
216 var app = new Program(typeof(MyWidget));