Example #1
0
	public void AppLaunched(AppBehaviour app)
	{
		var appNameLowerCase = AppNameLowerCase(app);

		DisableMainOS();

		_loadedScene = appNameLowerCase;
		SceneManager.LoadScene(appNameLowerCase, LoadSceneMode.Additive);
	}
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xen.Utils.Timer"/> class.
        /// </summary>
        /// <param name="interval">Interval.</param>
        /// <param name="count">Count.</param>
        /// <param name="behaviour">if set event will be dispatched in main thread.</param>
        public Timer(double interval, int count, AppBehaviour behaviour = null)
        {
            if (interval <= 0)
            {
                throw new ArgumentException("Timer : unable to init timer!");
            }

            this._behaviour = behaviour;

            _timer          = new System.Timers.Timer();
            _timer.Elapsed += _TimerEventHandler;
            _timer.Enabled  = false;

            this._delay       = interval;
            this._repeatCount = count <= 0 ? int.MaxValue : count;
        }
        //a list of requests that waiting for response
//		protected Dictionary<string, IServiceRequest> _requestList;

        //TODO : currently only support using for one time.
        //NOTE : NOT USED!!! it should only be ran in main thread
        public HTTPConnection(string url, AppBehaviour behaviour, double timeOutInterval = -1) : base(null)
        {
            if (String.IsNullOrEmpty(url) || url.IndexOf("http") == -1 || !(behaviour is AppBehaviour))
            {
                throw new ArgumentException("HTTPConnection : expecting url!");
            }

            if (timeOutInterval > 0)
            {
                this._timeOutTimer = new Timer(timeOutInterval, 1, behaviour);
                this._timeOutTimer.AddEventListener(TimerEvent.TIMER_COMPLETE, this._TimerEvnetHandler);
            }


//			this._requestList = new Dictionary<string, IServiceRequest> ();
            this._URL          = url;
            this._behaviour    = behaviour;
            this._isRequesting = false;
        }
Example #4
0
	public void Initialize(AppManager appManager, AppBehaviour installedApp)
	{
		manager = appManager;
		app = installedApp;

		GetComponent<Image>().sprite = app.iconTexture;
		GetComponent<Button>().onClick.AddListener(LaunchApp);

		_appBehaviourInstance = Instantiate(app);

		_appBehaviourInstance.transform.SetParent(appManager.instanceContainer);

		_appBehaviourInstance.On(AppBehaviour.AppEvent.Done, data =>
		{
			_appBehaviourInstance.Cleanup();

			manager.AppDone(app);
		});

		_appBehaviourInstance.On(AppBehaviour.AppEvent.Notification, data =>
		{
			var notificationData = (Notification) data;

			manager.AddAppNotification(app, notificationData);

			ShowNotifications(manager.GetAppNotifications(app));
		});

		_appBehaviourInstance.On(AppBehaviour.AppEvent.DismissNotification, data =>
		{
			var notificationData = (Notification) data;

			manager.DismissAppNotification(app, notificationData);

			ShowNotifications(manager.GetAppNotifications(app));
		});
	}
Example #5
0
	public void Initialize(AppBehaviour app)
	{
		GetComponent<Image>().sprite = app.iconTexture;
	}
Example #6
0
	public void AppDone(AppBehaviour app)
	{
		_loadedScene = null;
		SceneManager.UnloadScene(AppNameLowerCase(app));

		_enableNextFrame = true;
	}
Example #7
0
	public void DismissAppNotification(AppBehaviour app, Notification notificationData)
	{
		var appName = AppNameLowerCase(app);

		var notificationInfo = _appNotifications[appName];

		var numPrevNotifications = notificationInfo.notifications.Count;

		notificationInfo.DismissNotification(notificationData);

		if (numPrevNotifications != 0 && notificationInfo.notifications.Count == 0)
		{
			_trayIcons[appName].gameObject.SetActive(false);
		}
	}
Example #8
0
	private static string AppNameLowerCase(AppBehaviour app)
	{
		return app.name.ToLower();
	}
Example #9
0
	public NotificationInfo GetAppNotifications(AppBehaviour app)
	{
		return _appNotifications[AppNameLowerCase(app)];
	}
Example #10
0
	public void AddAppNotification(AppBehaviour app, Notification notificationData)
	{
		var appName = AppNameLowerCase(app);
		var notificationInfo = _appNotifications[appName];

		var numPrevNotifications = notificationInfo.notifications.Count;

		notificationInfo.AddNotification(notificationData);

		if (numPrevNotifications == 0 && notificationInfo.notifications.Count > 0)
		{
			_trayIcons[appName].gameObject.SetActive(true);
		}
	}