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);
22 SetContentInfo(contentInfo);
24 window.BackgroundColor = Color.White;
25 _textLabel = new TextLabel("Hello Widget");
26 _textLabel.TextColor = Color.Black;
27 _textLabel.Size2D = new Size2D(360, 130);
28 _textLabel.ParentOrigin = ParentOrigin.TopLeft;
29 _textLabel.PivotPoint = PivotPoint.TopLeft;
30 _textLabel.HorizontalAlignment = HorizontalAlignment.Center;
31 _textLabel.VerticalAlignment = VerticalAlignment.Center;
32 _textLabel.PositionUsesPivotPoint = true;
33 _textLabel.PointSize = _pointSize;
34 _textLabel.Position2D = new Position2D(0, 0);
35 window.Add(_textLabel);
36 Tizen.Log.Fatal("NUIWidget", "text width: " + _textLabel.NaturalSize2D.Width + ", height: " + _textLabel.NaturalSize2D.Height);
38 _animation = new Animation(2000);
39 _animation.AnimateTo(_textLabel, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.Y), 0, 500);
40 _animation.AnimateTo(_textLabel, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.Y), 500, 1000);
41 _animation.Looping = true;
42 _animation.EndAction = Animation.EndActions.Discard;
43 Log.Error("TCT", "[TestCase][OnCreate][Widget] Pass");
44 base.OnCreate(contentInfo, window);
47 private bool IsEmulator()
50 var result = Tizen.System.Information.TryGetValue("tizen.org/system/model_name", out value);
51 if (result && value.Equals("Emulator"))
59 protected override void OnPause()
61 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnPause!");
63 Log.Error("TCT", "[TestCase][OnPause][Widget] Pass");
67 protected override void OnResume()
69 OnUpdate(_content.Encode(), 1);
70 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnResume!");
71 Log.Error("TCT", "[TestCase][OnResume][Widget] Pass");
75 protected override void OnResize(Window window)
77 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnResize!");
78 Log.Error("TCT", "[TestCase][OnResize][Widget] Pass");
79 base.OnResize(window);
82 protected override void OnTerminate(string contentInfo, TerminationType type)
84 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnTerminate!");
85 Log.Error("TCT", "[TestCase][OnTerminate][Widget] Pass");
86 base.OnTerminate(contentInfo, type);
89 protected override void OnUpdate(string contentInfo, int force)
91 Tizen.Log.Fatal("NUIWidget", "Widget Instance OnUpdate! " + contentInfo);
92 Bundle content = Bundle.Decode(contentInfo);
93 string imageIdx = Convert.ToString(content.GetItem("ImageIdx"));
95 Tizen.Log.Fatal("NUIWidget", "Widget Instance content info is " + imageIdx);
96 Log.Error("TCT", "[TestCase][OnUpdate][Widget] Pass");
97 base.OnUpdate(contentInfo, force);
101 class Program : NUIWidgetApplication
103 public Program(System.Type type) : base(type)
107 protected override void OnCreate()
110 Log.Error("TCT", "[TestCase][OnCreate][NUIWidgetApplication] Pass");
113 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
115 Log.Error("TCT", "NUIWidgetApplication::OnLocaleChanged()");
116 if (e.Locale != null)
118 Log.Error("TCT", "[Test_Properties] Locale properties is not null");
119 Log.Error("TCT", "[Test_Properties] Current value of Locale : " + e.Locale);
120 Log.Error("TCT", "[Test_Properties] Locale type: " + e.Locale.GetType());
123 Log.Error("TCT", "[TestCase][OnLocaleChanged][NUIWidgetApplication] Pass");
124 base.OnLocaleChanged(e);
127 protected override void OnLowBattery(LowBatteryEventArgs e)
129 Log.Error("TCT", "NUIWidgetApplication::OnLowBattery()");
130 if (e.LowBatteryStatus != LowBatteryStatus.None)
132 Log.Error("TCT", "[Test_Properties] LowBatteryStatus properties is not null");
133 Log.Error("TCT", "[Test_Properties] Current value of LowBatteryStatus : " + e.LowBatteryStatus.ToString());
134 Log.Error("TCT", "[Test_Properties] LowBatteryStatus type: " + e.LowBatteryStatus.GetType());
137 Log.Error("TCT", "[TestCase][OnLowBattery][NUIWidgetApplication] Pass");
139 base.OnLowBattery(e);
142 protected override void OnLowMemory(LowMemoryEventArgs e)
144 Log.Error("TCT", "NUIWidgetApplication::OnLowMemory()");
145 if (e.LowMemoryStatus != LowMemoryStatus.None)
147 Log.Error("TCT", "[Test_Properties] LowMemoryStatus properties is not null");
148 Log.Error("TCT", "[Test_Properties] Current value of LowMemoryStatus : " + e.LowMemoryStatus.ToString());
149 Log.Error("TCT", "[Test_Properties] LowMemoryStatus type: " + e.LowMemoryStatus.GetType());
151 //logBuilder.AppendLine("TCT [TestCase][OnLowMemory] Pass");
152 Log.Error("TCT", "[TestCase][OnLowMemory][NUIWidgetApplication] Pass");
157 protected override void OnPreCreate()
159 Log.Error("TCT", "[TestCase][OnPreCreate][NUIWidgetApplication] Pass");
163 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
165 Log.Error("TCT", "NUIWidgetApplication::OnRegionFormatChanged()");
168 Log.Error("TCT", "[Test_Properties] Region properties is not null");
169 Log.Error("TCT", "[Test_Properties] Current value of Region : " + e.Region);
170 Log.Error("TCT", "[Test_Properties] Region type: " + e.Region.GetType());
173 Log.Error("TCT", "[TestCase][OnRegionFormatChanged][NUIWidgetApplication] Pass");
174 base.OnRegionFormatChanged(e);
177 protected override void OnTerminate()
179 Log.Error("TCT", "NUIWidgetApplication::OnTerminate()");
180 Log.Error("TCT", "[TestCase][OnTerminate][NUIWidgetApplication] Pass");
185 public override void Run(string[] args)
187 //Created += Created_Event_Test;
188 //AppControlReceived += AppControlReceived_Event_Test;
189 //LocaleChanged += LocaleChanged_Event_Test;
190 //LowMemory += LowMemory_Event_Test;
191 //LowBattery += LowBattery_Event_Test;
192 //Terminated += Terminated_Event_Test;
193 //Paused += EventHandlerPaused;
194 //Resumed += EventHandlerResumed;
195 //DeviceOrientationChanged += DeviceOrientationCHanged_Event_Test;
196 //RegionFormatChanged += RegionFormatChanged_Event_Test;
198 Log.Error("TCT", "[TestCase][Run][NUIWidgetApplication] Pass");
202 public override void Exit()
204 Log.Error("TCT", "[TestCase][Exit][NUIWidgetApplication] Pass");
208 public void OnKeyEvent(object sender, Window.KeyEventArgs e)
210 if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
216 static void Main(string[] args)
218 var app = new Program(typeof(MyWidget));