forked from dalihub/nui-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloWorld.cs
86 lines (76 loc) · 2.63 KB
/
HelloWorld.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using Tizen.NUI;
using Tizen.NUI.UIComponents;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Constants;
class HelloWorldExample : NUIApplication
{
/// <summary>
/// Override to create the required scene
/// </summary>
protected override void OnCreate()
{
// Up call to the Base class first
base.OnCreate();
// Get the window instance and change background color
Window window = Window.Instance;
window.BackgroundColor = Color.White;
// Create a simple TextLabel
TextLabel title = new TextLabel("Hello World");
// Ensure TextLabel matches its parent's size (i.e. Window size)
// By default, a TextLabel's natural size is the size of the text within it
title.Size2D = new Size2D(window.Size.Width, window.Size.Height);
// By default, text is aligned to the top-left within the TextLabel
// Align it to the center of the TextLabel
title.HorizontalAlignment = HorizontalAlignment.Center;
title.VerticalAlignment = VerticalAlignment.Center;
// Add the text to the window
window.Add(title);
// Respond to key events
window.KeyEvent += OnKeyEvent;
}
/// <summary>
/// Called when any key event is received.
/// Will use this to exit the application if the Back or Escape key is pressed
/// </summary>
private void OnKeyEvent( object sender, Window.KeyEventArgs eventArgs )
{
if( eventArgs.Key.State == Key.StateType.Down )
{
switch( eventArgs.Key.KeyPressedName )
{
case "Escape":
case "Back":
{
Exit();
}
break;
}
}
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread] // Forces app to use one thread to access NUI
static void Main(string[] args)
{
HelloWorldExample example = new HelloWorldExample();
example.Run(args);
}
}