Ejemplo n.º 1
0
        public void Run(string[] args)
        {
            TizenSynchronizationContext.Initialize();

            Interop.Widget.ErrorCode err = Interop.Widget.ErrorCode.None;
            err = Interop.Widget.AddEventHandler(out _lowMemoryEventHandle, Interop.Widget.AppEventType.LowMemory, _lowMemoryCallback, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to add event handler for LowMemory event. Err = " + err);
            }
            err = Interop.Widget.AddEventHandler(out _lowBatteryEventHandle, Interop.Widget.AppEventType.LowBattery, _lowBatteryCallback, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to add event handler for LowBattery event. Err = " + err);
            }

            err = Interop.Widget.AddEventHandler(out _localeChangedEventHandle, Interop.Widget.AppEventType.LanguageChanged, _localeChangedCallback, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to add event handler for LocaleChanged event. Err = " + err);
            }

            err = Interop.Widget.AddEventHandler(out _regionChangedEventHandle, Interop.Widget.AppEventType.RegionFormatChanged, _regionChangedCallback, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err);
            }

            err = Interop.Widget.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to run the application. Err = " + err);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finishes the context for the widget instance.
        /// </summary>
        /// <exception cref="NotSupportedException">Thrown when the API is not supported in this device.</exception>
        /// <exception cref="InvalidOperationException">Thrown in case of an unrecoverable error.</exception>
        /// <since_tizen> 3 </since_tizen>
        public void Exit()
        {
            Interop.Widget.ErrorCode err = Interop.Widget.TerminateContext(Handle);

            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to terminate context. Err = " + err);

                switch (err)
                {
                case Interop.Widget.ErrorCode.NotSupported:
                    throw new NotSupportedException();

                case Interop.Widget.ErrorCode.InvalidParameter:
                case Interop.Widget.ErrorCode.Fault:
                    throw new InvalidOperationException();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the content information to the widget.
        /// </summary>
        /// <param name="info">The data set to save.</param>
        /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
        /// <exception cref="NotSupportedException">Thrown when the API is not supported in this device.</exception>
        /// <exception cref="InvalidOperationException">Thrown in case of an unrecoverable error.</exception>
        /// <since_tizen> 3 </since_tizen>
        public void SetContent(Bundle info)
        {
            Interop.Widget.ErrorCode err = Interop.Widget.SetContent(Handle, info.SafeBundleHandle);

            if (err != Interop.Widget.ErrorCode.None)
            {
                Log.Error(LogTag, "Failed to set content. Err = " + err);

                switch (err)
                {
                case Interop.Widget.ErrorCode.InvalidParameter:
                    throw new ArgumentException("Invalid parameter of SetContent()");

                case Interop.Widget.ErrorCode.NotSupported:
                    throw new NotSupportedException();

                case Interop.Widget.ErrorCode.OutOfMemory:
                case Interop.Widget.ErrorCode.Fault:
                    throw new InvalidOperationException();
                }
            }
        }