-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHelloWorldExample.cs
More file actions
123 lines (104 loc) · 4 KB
/
HelloWorldExample.cs
File metadata and controls
123 lines (104 loc) · 4 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Copyright (c) 2020 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.BaseComponents;
using Tizen.NUI.Components;
public class NUISampleApplication : NUIApplication
{
protected override void OnCreate()
{
base.OnCreate();
Initialize();
}
Theme themeBlack, themeGreen;
int clickCount = 0;
void Initialize()
{
var root = NUIApplication.GetDefaultWindow();
var resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
// Load and apply theme from xaml file.
themeBlack = new Theme(resourcePath + "Theme/Black.xaml");
themeGreen = new Theme(resourcePath + "Theme/Green.xaml");
ThemeManager.ApplyTheme(themeBlack);
var themeChangeButton = new Button() {
WidthResizePolicy = ResizePolicyType.FillToParent,
SizeHeight = 70,
Text = "Click to change theme",
};
themeChangeButton.Clicked += OnClicked;
root.Add(themeChangeButton);
root.BackgroundColor = Color.White;
// [Sample 1]
// Set style name you want to apply.
root.Add(new TextLabel() {
StyleName = "TextLabelTypeA",
Position = new Position(30, 120),
Text = "Hello World!",
});
// [Sample 2]
// You can also set style name using constructor.
// Note that, BaseComponents(e.g. TextLabel) does not provide this way.
root.Add(new Button("ButtonDefault") {
Position = new Position(30, 180),
Text = "Button",
});
// [Sample 3-1]
root.Add(new Switch("SwitchFancy") {
Position = new Position(30, 280),
});
// [Sample 3-2]
// Set ThemeChangedSensitive to false if you don't want this view to be affected by theme changes.
// Note that the ThemeChangedSensitive is "false" by default, but turned to true when setting StyleName explitcitly.
// (Either by setting StyleName property or by using constructor with style name)
root.Add(new Switch("SwitchFancy") {
Position = new Position(200, 280),
ThemeChangeSensitive = false,
});
// [Sample 4-1][Advanced]
// The view without style name uses a style named its type name. ("Tizen.NUI.Components.CheckBox" in this case)
// Note that, because the style name was not set explicitly, the ThemeChangedSensitive is false,
// which means it is not affected by theme changes.
root.Add(new CheckBox() {
Position = new Position(30, 380),
});
// [Sample 4-2][Advanced]
// Set ThemeChangedSensitive to true if you want this view to be affected by theme changes.
root.Add(new CheckBox() {
Position = new Position(200, 380),
ThemeChangeSensitive = true,
});
}
private void OnClicked(object target, ClickedEventArgs args)
{
clickCount++;
if ((clickCount) % 2 == 0) ThemeManager.ApplyTheme(themeBlack);
else ThemeManager.ApplyTheme(themeGreen);
}
public void OnKeyEvent(object sender, Window.KeyEventArgs e)
{
if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
{
Exit();
}
}
static void Main(string[] args)
{
NUISampleApplication example = new NUISampleApplication();
example.Run(args);
}
}