Skip to content

Commit 0ef5862

Browse files
Jay ChoJoonghyunCho
authored andcommitted
Migrate WindowSystem Sample
1 parent 282c546 commit 0ef5862

16 files changed

+1205
-1
lines changed

test/Tizen.NUI.WindowSystem.InputGesture/tizen-manifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@
1313
<icon>Tizen.NUI.WindowSystem.InputGesture.png</icon>
1414
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
1515
</ui-application>
16+
<privileges>
17+
<privilege>http://tizen.org/privilege/gesturegrab</privilege>
18+
<privilege>http://tizen.org/privilege/inputgenerator</privilege>
19+
</privileges>
1620
</manifest>

test/Tizen.NUI.WindowSystem.InputGesture/tizen_dotnet_project.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ files:
66
- Tizen.NUI.WindowSystem.InputGesture.csproj
77
- Tizen.NUI.WindowSystem.InputGesture.cs
88
- tizen-manifest.xml
9-
- shared/res/Tizen.NUI.WindowSystem.InputGesture.png
9+
- shared/res/Tizen.NUI.WindowSystem.InputGesture.png
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/*
2+
* Copyright(c) 2024 Samsung Electronics Co., Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using System;
19+
using Tizen;
20+
using Tizen.NUI;
21+
using Tizen.NUI.BaseComponents;
22+
using Tizen.WindowSystem;
23+
24+
namespace Tizen.WindowSystem.InputGeneratorTest
25+
{
26+
class Program : NUIApplication
27+
{
28+
protected override void OnCreate()
29+
{
30+
base.OnCreate();
31+
Initialize();
32+
}
33+
34+
void Initialize()
35+
{
36+
Window win = Window.Default;
37+
inputGen = new InputGenerator();
38+
39+
win.WindowSize = new Size2D(500, 500);
40+
win.KeyEvent += OnKeyEvent;
41+
win.BackgroundColor = Color.White;
42+
43+
// Root layout
44+
View rootView = new View();
45+
rootView.Size2D = new Size2D(500, 500);
46+
rootView.Layout = new LinearLayout()
47+
{
48+
LinearOrientation = LinearLayout.Orientation.Vertical,
49+
};
50+
win.Add(rootView);
51+
52+
// Upper area: touch to generate SendKey
53+
View touchView = new View();
54+
touchView.SizeWidth = 500;
55+
touchView.Weight = 1.0f;
56+
touchView.SizeHeight = 400;
57+
touchView.BackgroundColor = Color.White;
58+
touchView.TouchEvent += OnTouchView;
59+
rootView.Add(touchView);
60+
61+
centerLabel = new TextLabel("Touch upper area: SendKey test\nTouch counter: 0 / Key counter: 0");
62+
centerLabel.HorizontalAlignment = HorizontalAlignment.Center;
63+
centerLabel.VerticalAlignment = VerticalAlignment.Center;
64+
centerLabel.TextColor = Color.Black;
65+
centerLabel.PointSize = 12.0f;
66+
centerLabel.MultiLine = true;
67+
centerLabel.HeightResizePolicy = ResizePolicyType.FillToParent;
68+
centerLabel.WidthResizePolicy = ResizePolicyType.FillToParent;
69+
touchView.Add(centerLabel);
70+
71+
// Lower area: button to generate SendPointer
72+
var sendPointerBtn = new Tizen.NUI.Components.Button()
73+
{
74+
Text = "SendPointer (generate touch at upper area)",
75+
SizeWidth = 500,
76+
SizeHeight = 80,
77+
PointSize = 10.0f,
78+
PositionY = 300f
79+
};
80+
sendPointerBtn.Clicked += OnSendPointerClicked;
81+
rootView.Add(sendPointerBtn);
82+
}
83+
84+
private void OnKeyEvent(object sender, Window.KeyEventArgs e)
85+
{
86+
if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
87+
{
88+
Exit();
89+
}
90+
if (e.Key.State == Key.StateType.Down && e.Key.KeyPressedName == "Return")
91+
{
92+
keyCounter++;
93+
UpdateLabel();
94+
}
95+
}
96+
97+
/// <summary>
98+
/// Touch on upper area → SendKey("Return") test
99+
/// </summary>
100+
private bool OnTouchView(object sender, View.TouchEventArgs e)
101+
{
102+
if (e.Touch.GetState(0) == PointStateType.Down)
103+
{
104+
touchCounter++;
105+
UpdateLabel();
106+
107+
inputGen.SendKey("Return", true);
108+
inputGen.SendKey("Return", false);
109+
110+
return true;
111+
}
112+
return false;
113+
}
114+
115+
/// <summary>
116+
/// Button click → SendPointer() generates a touch at (250, 150) which lands on the upper touchView.
117+
/// This triggers OnTouchView, proving SendPointer works.
118+
/// </summary>
119+
private void OnSendPointerClicked(object sender, Tizen.NUI.Components.ClickedEventArgs e)
120+
{
121+
inputGen.SendPointer(0, PointerAction.Down, 250, 150, InputGeneratorDevices.Touchscreen);
122+
inputGen.SendPointer(0, PointerAction.Up, 250, 150, InputGeneratorDevices.Touchscreen);
123+
}
124+
125+
private void UpdateLabel()
126+
{
127+
centerLabel.Text = $"Touch counter: {touchCounter} / Key counter: {keyCounter}";
128+
}
129+
130+
static void Main(string[] args)
131+
{
132+
var app = new Program();
133+
app.Run(args);
134+
}
135+
136+
private InputGenerator inputGen;
137+
private TextLabel centerLabel;
138+
int touchCounter = 0;
139+
int keyCounter = 0;
140+
}
141+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0-tizen10.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
9+
<DebugType>portable</DebugType>
10+
</PropertyGroup>
11+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
12+
<DebugType>None</DebugType>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="../../src/Tizen/Tizen.csproj" />
17+
<ProjectReference Include="../../src/Tizen.NUI.Components/Tizen.NUI.Components.csproj" />
18+
<ProjectReference Include="../../src/Tizen.NUI/Tizen.NUI.csproj" />
19+
<ProjectReference Include="../../src/Tizen.WindowSystem/Tizen.WindowSystem.csproj" />
20+
</ItemGroup>
21+
22+
<PropertyGroup>
23+
<NeedInjection>True</NeedInjection>
24+
</PropertyGroup>
25+
26+
</Project>
9.86 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns="http://tizen.org/ns/packages" api-version="10" package="org.tizen.example.WS.InputGenerator" version="1.0.0">
3+
<profile name="common" />
4+
<ui-application appid="org.tizen.example.WS.InputGenerator"
5+
exec="Tizen.WindowSystem.InputGenerator.dll"
6+
type="dotnet-nui"
7+
multiple="false"
8+
taskmanage="true"
9+
nodisplay="false"
10+
launch_mode="single">
11+
<label>Tizen.WindowSystem.InputGenerator</label>
12+
<icon>Tizen.WindowSystem.InputGenerator.png</icon>
13+
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
14+
</ui-application>
15+
<privileges>
16+
<privilege>http://tizen.org/privilege/inputgenerator</privilege>
17+
</privileges>
18+
</manifest>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# csproj file path
2+
csproj_file: Tizen.WindowSystem.InputGenerator.csproj
3+
4+
# files monitored for dirty/modified status
5+
files:
6+
- Tizen.WindowSystem.InputGenerator.csproj
7+
- Tizen.WindowSystem.InputGenerator.cs
8+
- tizen-manifest.xml
9+
- shared/res/Tizen.WindowSystem.InputGenerator.png

0 commit comments

Comments
 (0)