using System;
using Tizen;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
using Tizen.Applications;
-using ElmSharp;
+using Tizen.Internals.Errors;
namespace WidgetViewerApp
{
- class MyApp : CoreUIApplication
+ class MyApp : NUIApplication
{
- private RemoteView _view;
+ private WidgetViewManager _viewManager;
+ private WidgetView _widgetView = null;
public const string LogTag = "WidgetViewerApp";
public const string WidgetAppiD = "org.tizen.example.WidgetBaseApp.Tizen";
private static Window _win;
Log.Warn(LogTag, "@@@ OnResumed");
}
- private void Exit_Clicked(object sender, EventArgs e)
- {
- try
- {
- _view.Layout.Unrealize();
- }
- catch (Exception ex)
- {
- Log.Warn(LogTag, "exception " + ex);
- }
- }
-
protected override void OnCreate()
{
base.OnCreate();
-
- Elementary.Initialize();
- Elementary.ThemeOverlay();
- EcoreSynchronizationContext.Initialize();
-
try
{
_control = new WidgetControl(WidgetAppiD);
_control.Paused += OnPaused;
_control.Destroyed += OnDestroyed;
- _win = new Window("test");
- _win.Show();
-
- Conformant conformant = new Conformant(_win);
- conformant.Show();
-
- _win.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, false);
- _win.KeyUp += (s, e) =>
+ _win = Window.Instance;
+ _win.KeyEvent += (object source, Window.KeyEventArgs e) =>
{
- if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
+ if (e.Key.State == Key.StateType.Down)
{
- Exit();
+ Tizen.Log.Info("Key", e.Key.KeyPressedName);
+ if (e.Key.KeyPressedName == "XF86Back")
+ {
+ this.Exit();
+ }
}
};
- Layout layout = new Layout(_win);
- layout.Show();
-
- Layout layout2 = new Layout(_win);
- layout2.Show();
+ Bundle bundle = new Bundle();
+ bundle.AddItem("ImageIdx", "1");
- Scroller scroller = new Scroller(conformant)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
- ScrollBlock = ScrollBlock.None,
+ _viewManager = new WidgetViewManager(this, ApplicationInfo.ApplicationId);
+ _widgetView = _viewManager.AddWidget(WidgetAppiD, bundle.Encode(), _win.WindowSize.Width, _win.WindowSize.Height, 0);
+ _widgetView.BackgroundColor = Color.Black;
+ _widgetView.WidgetDeleted += (src, arg) =>
+ {\r
+ Log.Warn(LogTag, "@@@ Widget app has been terminated");\r
+ this.Exit();\r
};
- scroller.Show();
-
- Box box = new Box(scroller)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
+ _widgetView.WidgetFaulted += (src, arg) =>
+ {\r
+ Log.Warn(LogTag, "@@@ Widget app has been faulted");\r
+ this.Exit();\r
};
- box.Show();
- box.SetAlignment(0.0, 0.0);
-
- scroller.SetContent(box);
- conformant.SetContent(scroller);
-
- RemoteViewFactory.Init(_win);
- _view = RemoteViewFactory.Create(_win, WidgetAppiD, null, 0, true, true, true);
- _view.Layout.Resize(_win.ScreenSize.Width, _win.ScreenSize.Height);
- _view.Layout.Show();
- layout.SetContent(_view.Layout);
- box.PackEnd(layout);
+ _win.Add(_widgetView);
}
catch (Exception e)
{
{
Log.Warn(LogTag, "Term");
base.OnTerminate();
- try
- {
- RemoteViewFactory.Shutdown();
- Elementary.Shutdown();
- }
- catch (Exception e)
- {
- Log.Warn(LogTag, "Exception " + e);
- }
}
protected override void OnPause()
Log.Warn(LogTag, "OnPause");
// For WidgetApplication OnResize event check.
- _view.Layout.Resize(_win.ScreenSize.Width, _win.ScreenSize.Height - 100);
+ _widgetView.Size2D = new Size2D(_win.WindowSize.Width, _win.WindowSize.Height - 100);
base.OnPause();
- try
- {
- _view?.Pause();
- }
- catch (Exception e)
- {
- Log.Warn(LogTag, "Exception " + e);
- }
+ bool ret = _widgetView.PauseWidget();
+ if (!ret)
+ Log.Error(LogTag, "Pause Failed.");
}
protected override void OnResume()
Log.Warn(LogTag, "OnResume");
// Restore size
- _view.Layout.Resize(_win.ScreenSize.Width, _win.ScreenSize.Height);
+ _widgetView.Size2D = new Size2D(_win.WindowSize.Width, _win.WindowSize.Height);
base.OnResume();
- try
- {
- _view?.Resume();
- }
- catch (Exception e)
- {
- Log.Warn(LogTag, "Exception " + e);
- }
+ bool ret = _widgetView.ResumeWidget();
+ if (!ret)
+ Log.Error(LogTag, "Resume Failed.");
}
}