--- /dev/null
+using System.Collections.Generic;
+using Oobe.Common.Interfaces;
+using Oobe.Language;
+using Oobe.Views;
+using Tizen.NUI;
+using Oobe.Region;
+using System;
+
+ namespace Oobe
+ {
+ public class ProcessManager : IProcessNavigation
+ {
+ private MainView ui;
+ private LinkedList<Lazy<ProcessStep>> steps;
+ private LinkedListNode<Lazy<ProcessStep>> current;
+
+ public ProcessManager()
+ {
+ //TODO consider loading this from xaml, xml or something...
+ steps = new LinkedList<Lazy<ProcessStep>>(new List<Lazy<ProcessStep>>{
+ new Lazy<ProcessStep>(() => new LanguageStep()),
+ new Lazy<ProcessStep>(() => new RegionStep())}
+ );
+ }
+
+ public void Start()
+ {
+ ui = new MainView(Window.Instance);
+
+ current = steps.First;
+ current.Value.Value.Initialize();
+ ui.Push(current.Value.Value.CreateView(this));
+ current.Next?.Value.Value.Initialize();
+ }
+
+ /// <summary>
+ /// Next shows next view in the process or finish the process
+ /// </summary>
+ public void Next()
+ {
+ // end process if all steps are done
+ if (current.Next == null)
+ {
+ Exit();
+ return;
+ }
+
+ current = current.Next;
+ ui.Push(current.Value.Value.CreateView(this));
+ current.Next?.Value.Value.Initialize();
+ }
+
+ /// <summary>
+ /// Finishes process and exits application
+ /// </summary>
+ public void Exit()
+ {
+ foreach (Lazy<ProcessStep> step in steps)
+ {
+ step.Value.Shutdown();
+ }
+ NUIApplication.Current.Exit();
+ }
+
+ /// <summary>
+ /// Previous shows previous view in the process
+ /// </summary>
+ public void Previous()
+ {
+ if (current.Previous != null)
+ {
+ current = current.Previous;
+ ui.Pop();
+ }
+ }
+ }
+}
-using System;
-using Tizen.NUI;
-using Tizen.NUI.BaseComponents;
+using Tizen.NUI;
using Tizen.NUI.Components;
-using Oobe.Controls;
-using Oobe.Views;
+using System;
namespace Oobe
{
class Program : NUIApplication
{
- private OobeViewSwitcher switcher;
+ private ProcessManager processManager;
protected override void OnCreate()
{
Initialize();
}
- TextLabel makeLabel(string txt, Color color)
- {
- TextLabel text2 = new TextLabel(txt);
- text2.HorizontalAlignment = HorizontalAlignment.Center;
- text2.VerticalAlignment = VerticalAlignment.Center;
- text2.TextColor = Color.Black;
- text2.PointSize = 12.0f;
- text2.HeightResizePolicy = ResizePolicyType.FillToParent;
- text2.WidthResizePolicy = ResizePolicyType.FillToParent;
-
- return text2;
- }
-
void Initialize()
{
- Window.Instance.KeyEvent += OnKeyEvent;
-
- switcher = new OobeViewSwitcher(Window.Instance);
+ processManager = new ProcessManager();
+ processManager.Start();
Button button = new Button();
- button.Text = "Push";
+ button.Text = "Next";
button.BackgroundColor = Color.Blue;
button.Size2D = new Size2D(100, 80);
button.Position2D.X = 48;
button.Position2D.Y = 720;
- button.ClickEvent += PushClicked;
+ button.ClickEvent += NextClicked;
Window.Instance.GetDefaultLayer().Add(button);
-
+
button = new Button();
- button.Text = "Pop";
+ button.Text = "Previous";
button.Position2D = new Position2D(250, 720);
button.BackgroundColor = Color.White;
button.Size2D = new Size2D(100, 80);
- button.ClickEvent += PopClicked;
+ button.ClickEvent += PrevClicked;
Window.Instance.GetDefaultLayer().Add(button);
-
}
- int current = 0;
- public static Color[] PossibleColors = new Color[]{
- Color.White,
- Color.White,
- Color.White
- };
-
- public void PushClicked(object sender, EventArgs args)
- {
- Tizen.Log.Debug("ViewStack", "Push");
- TextLabel text = makeLabel("More text", PossibleColors[current++ % PossibleColors.Length]);
- switcher.Push(text);
- }
-
- public void PopClicked(object sender, EventArgs args)
+ public void NextClicked(object sender, EventArgs args)
{
- Tizen.Log.Debug("ViewStack", "Pop");
- switcher.Pop();
+ processManager.Next();
}
- public void OnKeyEvent(object sender, Window.KeyEventArgs e)
+ public void PrevClicked(object sender, EventArgs args)
{
- if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
- {
- Exit();
- }
+ processManager.Previous();
}
static void Main(string[] args)
--- /dev/null
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI;
+using Oobe.Controls;
+
+namespace Oobe.Views
+{
+ /// <summary>
+ /// Implementation of OOBE GUI Guideline for IoT Headed
+ /// </summary>
+ public class MainView
+ {
+ private ViewStack stack;
+ private Animation dimEffectAnimation;
+ private const int TransitionTime = 750;
+
+ public MainView(Window win)
+ {
+ View backImage = new View();
+ backImage.BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + "0_BG_dark.svg";
+ backImage.WidthResizePolicy = ResizePolicyType.FillToParent;
+ backImage.HeightResizePolicy = ResizePolicyType.FillToParent;
+
+ stack = new ViewStack();
+ stack.ScrollDuration = TransitionTime;
+ stack.Position2D = new Position2D(48 - 6, 48 - 6); // include shadow
+ stack.Size2D = new Size2D(1184 + 6 + 9, 624 + 6 + 9); // includes surrounding shadow
+ stack.PagesRightPadding = 48;
+ stack.PagesLeftPadding = (int)(0.5f * stack.Size2D.Width);
+ stack.ClippingMode = ClippingModeType.Disabled;
+ dimEffectAnimation = new Animation(TransitionTime);
+
+ win.GetDefaultLayer().Add(backImage);
+ win.GetDefaultLayer().Add(stack);
+ }
+
+ public void Push(View view)
+ {
+ FinishDimAnimation();
+
+ var newView = new Views.Page();
+ newView.HeightResizePolicy = ResizePolicyType.FillToParent;
+ newView.WidthResizePolicy = ResizePolicyType.FillToParent;
+ newView.Content = view;
+ newView.Overlay.Opacity = 0.0f;
+
+ if (stack.Current is Views.Page overlayedView)
+ {
+ StartDimAnimation(overlayedView);
+ }
+
+ stack.Push(newView);
+ }
+
+ public void Pop()
+ {
+ FinishDimAnimation();
+ if (stack.Previous is Views.Page previous)
+ {
+ StartUndimAnimation(previous);
+ }
+ if (stack.Current is Views.Page current)
+ {
+ StartDimAnimation(current);
+ }
+ stack.Pop();
+ }
+
+ private void StartDimAnimation(Views.Page view)
+ {
+ view.Overlay.Opacity = 0.0f;
+ view.Opacity = 1.0f;
+ dimEffectAnimation.AnimateTo(view.Overlay, "Opacity", 0.5f);
+ dimEffectAnimation.AnimateTo(view, "Opacity", 0.0f);
+ dimEffectAnimation.Play();
+ }
+
+ private void StartUndimAnimation(Views.Page view)
+ {
+ view.Overlay.Opacity = 0.5f;
+ view.Opacity = 0.0f;
+ dimEffectAnimation.AnimateTo(view.Overlay, "Opacity", 0.0f);
+ dimEffectAnimation.AnimateTo(view, "Opacity", 1.0f);
+ dimEffectAnimation.Play();
+ }
+
+ private void FinishDimAnimation()
+ {
+ if (dimEffectAnimation.State == Animation.States.Playing)
+ {
+ dimEffectAnimation.Stop(Animation.EndActions.StopFinal);
+ }
+ dimEffectAnimation.Clear();
+ }
+ }
+}
+++ /dev/null
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI;
-using Oobe.Controls;
-
-namespace Oobe.Views
-{
- /// <summary>
- /// Implementation of OOBE GUI Guideline for IoT Headed
- /// </summary>
- public class OobeViewSwitcher
- {
- private ViewStack stack;
- private Animation dimEffectAnimation;
- private const int TransitionTime = 750;
-
- public OobeViewSwitcher(Window win)
- {
- View backImage = new View();
- backImage.BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + "0_BG_dark.svg";
- backImage.WidthResizePolicy = ResizePolicyType.FillToParent;
- backImage.HeightResizePolicy = ResizePolicyType.FillToParent;
-
- stack = new ViewStack();
- stack.ScrollDuration = TransitionTime;
- stack.Position2D = new Position2D(48 - 6, 48 - 6); // include shadow
- stack.Size2D = new Size2D(1184 + 6 + 9, 624 + 6 + 9); // includes surrounding shadow
- stack.PagesRightPadding = 48;
- stack.PagesLeftPadding = (int)(0.5f * stack.Size2D.Width);
- stack.ClippingMode = ClippingModeType.Disabled;
- dimEffectAnimation = new Animation(TransitionTime);
-
- win.GetDefaultLayer().Add(backImage);
- win.GetDefaultLayer().Add(stack);
- }
-
- public void Push(View view)
- {
- FinishDimAnimation();
-
- var newView = new Views.Page();
- newView.HeightResizePolicy = ResizePolicyType.FillToParent;
- newView.WidthResizePolicy = ResizePolicyType.FillToParent;
- newView.Content = view;
- newView.Overlay.Opacity = 0.0f;
-
- if (stack.Current is Views.Page overlayedView)
- {
- StartDimAnimation(overlayedView);
- }
-
- stack.Push(newView);
- }
-
- public void Pop()
- {
- FinishDimAnimation();
- if (stack.Previous is Views.Page previous)
- {
- StartUndimAnimation(previous);
- }
- if (stack.Current is Views.Page current)
- {
- StartDimAnimation(current);
- }
- stack.Pop();
- }
-
- private void StartDimAnimation(Views.Page view)
- {
- view.Overlay.Opacity = 0.0f;
- view.Opacity = 1.0f;
- dimEffectAnimation.AnimateTo(view.Overlay, "Opacity", 0.5f);
- dimEffectAnimation.AnimateTo(view, "Opacity", 0.0f);
- dimEffectAnimation.Play();
- }
-
- private void StartUndimAnimation(Views.Page view)
- {
- view.Overlay.Opacity = 0.5f;
- view.Opacity = 0.0f;
- dimEffectAnimation.AnimateTo(view.Overlay, "Opacity", 0.0f);
- dimEffectAnimation.AnimateTo(view, "Opacity", 1.0f);
- dimEffectAnimation.Play();
- }
-
- private void FinishDimAnimation()
- {
- if (dimEffectAnimation.State == Animation.States.Playing)
- {
- dimEffectAnimation.Stop(Animation.EndActions.StopFinal);
- }
- dimEffectAnimation.Clear();
- }
- }
-}
{
public interface IProcessNavigation
{
+ /// <summary>
+ /// Goto next process step.
+ /// </summary>
void Next();
+
+ /// <summary>
+ /// Goto previous process step.
+ /// </summary>
void Previous();
- ProcessInfo CurrentStep();
}
}
\ No newline at end of file
+++ /dev/null
-using System;
-
-
-namespace Oobe.Common.Interfaces
-{
- public struct ProcessInfo
- {
- int CurrentStep;
- int StepsCount;
- }
-}
\ No newline at end of file
using System;
using Tizen.NUI.BaseComponents;
+using Oobe.Common.Interfaces;
namespace Oobe.Common.Interfaces
{
- public abstract class ProcessStep
- {
+ public abstract class ProcessStep
+ {
protected IProcessNavigation Navigation { get; private set; }
+ private bool initialized;
- protected ProcessStep(IProcessNavigation nav)
+ public void Initialize()
{
- Navigation = nav;
+ if (initialized)
+ return;
+
+ this.OnInitialized();
+ initialized = true;
}
- public virtual void Initialize()
+
+ public virtual void Shutdown()
{
+ if (!initialized)
+ return;
+
+ this.OnShutdown();
+ initialized = false;
}
+
public virtual void Reset()
{
+ OnReset();
}
- public virtual void Shutdown()
- {
+
+ public virtual void OnInitialized()
+ {
+ }
+
+ public virtual void OnShutdown()
+ {
+ }
+
+ public virtual void OnReset()
+ {
+ }
+
+ public virtual View CreateView(IProcessNavigation nav)
+ {
+ return null;
}
- public View View => null;
- }
-}
\ No newline at end of file
+ }
+ }
using System;\r
using Oobe.Common.Interfaces;\r
+using Tizen.NUI;\r
+using Tizen.NUI.BaseComponents;\r
\r
namespace Oobe.Language\r
{\r
- public class LanguageStep : ProcessStep\r
- {\r
- public LanguageStep(IProcessNavigation navi) : base(navi)\r
+ public class LanguageStep : ProcessStep\r
+ {\r
+ public LanguageStep() : base()\r
{\r
+\r
}\r
- }\r
-}
\ No newline at end of file
+\r
+ public override View CreateView(IProcessNavigation nav)\r
+ {\r
+ TextLabel text2 = new TextLabel("Choose Language");\r
+ text2.HorizontalAlignment = HorizontalAlignment.Center;\r
+ text2.VerticalAlignment = VerticalAlignment.Center;\r
+ text2.TextColor = Color.Black;\r
+ text2.PointSize = 12.0f;\r
+ text2.HeightResizePolicy = ResizePolicyType.FillToParent;\r
+ text2.WidthResizePolicy = ResizePolicyType.FillToParent;\r
+ return text2;\r
+ }\r
+ }\r
+}\r
</PackageReference>\r
</ItemGroup>\r
\r
- <ItemGroup>
- <ProjectReference Include="..\OobeCommon\OobeCommon.csproj" />
+ <ItemGroup>\r
+ <ProjectReference Include="..\OobeCommon\OobeCommon.csproj" />\r
</ItemGroup>\r
</Project>\r
+++ /dev/null
-using System;\r
-\r
-namespace OobeRegion\r
-{\r
- public class Class1\r
- {\r
- }\r
-}\r
<ExcludeAssets>Runtime</ExcludeAssets>\r
</PackageReference>\r
</ItemGroup>\r
+ <ItemGroup>\r
+ <ProjectReference Include="..\OobeCommon\OobeCommon.csproj" />\r
+ </ItemGroup>\r
</Project>\r
--- /dev/null
+using System;\r
+using Tizen.NUI;\r
+using Tizen.NUI.BaseComponents;\r
+using Oobe.Common.Interfaces;\r
+\r
+namespace Oobe.Region\r
+{\r
+ public class RegionStep : ProcessStep\r
+ {\r
+ public RegionStep() : base()\r
+ {\r
+\r
+ }\r
+\r
+ public override View CreateView(IProcessNavigation nav)\r
+ {\r
+ TextLabel text2 = new TextLabel("Choose Country");\r
+ text2.HorizontalAlignment = HorizontalAlignment.Center;\r
+ text2.VerticalAlignment = VerticalAlignment.Center;\r
+ text2.TextColor = Color.Black;\r
+ text2.PointSize = 12.0f;\r
+ text2.HeightResizePolicy = ResizePolicyType.FillToParent;\r
+ text2.WidthResizePolicy = ResizePolicyType.FillToParent;\r
+ return text2;\r
+ }\r
+ }\r
+}\r