Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 22 additions & 34 deletions workload/src/Samsung.Tizen.Templates/tizen/Main.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,33 @@
using System;

using Tizen.NUI;
using Tizen.NUI.BaseComponents;
using Tizen.UI;
using Tizen.UI.Components;
using Tizen.UI.Components.Material;

namespace TizenApp1
{
class Program : NUIApplication
class Program : MaterialApplication
{
protected override void OnCreate()
{
base.OnCreate();
Initialize();
}

void Initialize()
{
Window.Default.KeyEvent += OnKeyEvent;

TextLabel text = new TextLabel("Hello Tizen") {
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
TextColor = Color.Blue,
PointSize = 12.0f,
HeightResizePolicy = ResizePolicyType.FillToParent,
WidthResizePolicy = ResizePolicyType.FillToParent
};
Window.Default.GetDefaultLayer().Add(text);

Animation animation = new Animation(2000);
animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
animation.Looping = true;
animation.Play();
}

public void OnKeyEvent(object sender, Window.KeyEventArgs e)
{
if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
FocusManager.Instance.EnableDefaultFocusAlgorithm(true);
Window.Default.AddAvailableOrientation(WindowOrientation.Portrait);
Window.Default.AddAvailableOrientation(WindowOrientation.Landscape);
Window.Default.AddAvailableOrientation(WindowOrientation.PortraitInverse);
Window.Default.AddAvailableOrientation(WindowOrientation.LandscapeInverse);
Window.Default.KeyEvent += (s, e) =>
{
Exit();
}
if (e.KeyEvent.State == KeyState.Up && (e.KeyEvent.KeyPressedName == "BackSpace" || e.KeyEvent.KeyPressedName == "XF86Back"))
{
if (!RootNavigateBack())
{
Window.Default.Dispose();
Exit();
}
}
};
var navigator = new Navigator();
Window.Default.DefaultLayer.Add(navigator);
navigator.PushAsync(new MainView());
}

static void Main(string[] args)
Expand Down
40 changes: 40 additions & 0 deletions workload/src/Samsung.Tizen.Templates/tizen/MainView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Tizen.UI;
using Tizen.UI.Components.Material;
using Tizen.UI.Layouts;

namespace TizenApp1
{
public class MainView : Scaffold
{
public MainView() : base()
{
int count = 0;

AppBar = new AppBar
{
BackgroundColor = MaterialColor.PrimaryContainer,
Title = "TizenApp1",
};

Content = new VStack
{
Children =
{
new Label
{
Text = $"Current Count: {count}",
FontSize = 40f,
}
.Self(out var label)
.Expand()
.Center(),
}
};

FloatingActionButton = new IconButton(MaterialIcon.Add, IconButtonVariables.FAB)
{
ClickedCommand = (_, _) => label.Text = $"Current Count: {++count}"
};
}
}
}
4 changes: 4 additions & 0 deletions workload/src/Samsung.Tizen.Templates/tizen/TizenApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">TizenApp1</RootNamespace>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Tizen.UI.Components.Material" Version="1.0.0-*" />
</ItemGroup>
</Project>