Esempio n. 1
0
        public void Run(string[] args)
        {
            Interop.Watch.ErrorCode err = Interop.Watch.ErrorCode.None;

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

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

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

            err = Interop.Watch.AddEventHandler(out _regionChnagedEventHandle, Interop.Watch.AppEventType.RegionFormatChanged, _regionChnagedCallback, IntPtr.Zero);
            if (err != Interop.Watch.ErrorCode.None)
            {
                Log.Error(LOGTAG, "Failed to add event handler for RegionFormatChanged event, Err = " + err);
            }

            err = Interop.Watch.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
            if (err != Interop.Watch.ErrorCode.None)
            {
                Log.Error(LOGTAG, "Failed to run the Watch application, Err = " + err);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the frequency of the time tick.
        /// </summary>
        /// <param name="ticks">Ticks the number of ticks per given resolution type.</param>
        /// <param name="type">Type of the resolution type.</param>
        /// <feature>http://tizen.org/feature/watch_app</feature>
        /// <exception cref="InvalidOperationException">Thrown when failed to get the time tick frequency.</exception>
        /// <exception cref="NotSupportedException">Thrown when the method is not supported.</exception>
        /// <example>
        /// <code>
        /// class MyApp : WatchApplication
        /// {
        ///     ...
        ///     public void TestMethod()
        ///     {
        ///         int tick;
        ///         TimeTickResolution tType;
        ///         try
        ///         {
        ///             GetTimeTickFrequency(out tick, out tType);
        ///         }
        ///         catch
        ///         {
        ///         }
        ///     }
        /// }
        /// </code>
        /// </example>
        /// <since_tizen> 4 </since_tizen>
        protected void GetTimeTickFrequency(out int ticks, out TimeTickResolution type)
        {
            Interop.Watch.ErrorCode err = Interop.Watch.GetTimeTickFrequency(out ticks, out type);

            if (err != Interop.Watch.ErrorCode.None)
            {
                if (err == Interop.Watch.ErrorCode.NotSupported)
                {
                    throw new NotSupportedException("Failed to get time tick frequency. err : " + err);
                }
                else
                {
                    throw new InvalidOperationException("Failed to get time tick frequency. err : " + err);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the type of the periodic ambient tick.
        /// OnAmbientTick will be called for the following settings.
        /// If the SetAmbientTickType is not called, the OnAmbientTick will be called every minute.
        /// </summary>
        /// <param name="ambientTickType">The type of the ambient tick.</param>
        /// <feature>http://tizen.org/feature/watch_app</feature>
        /// <exception cref="InvalidOperationException">Thrown when failed to set the ambient tick type.</exception>
        /// <exception cref="NotSupportedException">Thrown when the method is not supported.</exception>
        /// <example>
        /// <code>
        /// class MyApp : WatchApplication
        /// {
        ///     ...
        ///     public void TestMethod()
        ///     {
        ///         try
        ///         {
        ///             SetAmbientTickType(AmbientTickType.EveryMinute);
        ///         }
        ///         catch
        ///         {
        ///         }
        ///     }
        /// }
        /// </code>
        /// </example>
        /// <since_tizen> 4 </since_tizen>
        protected void SetAmbientTickType(AmbientTickType ambientTickType)
        {
            Interop.Watch.ErrorCode err = Interop.Watch.SetAmbientTickType(ambientTickType);

            if (err != Interop.Watch.ErrorCode.None)
            {
                if (err == Interop.Watch.ErrorCode.NotSupported)
                {
                    throw new NotSupportedException("Failed to set ambient tick type. err : " + err);
                }
                else
                {
                    throw new InvalidOperationException("Failed to set ambient tick type. err : " + err);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the type of the periodic ambient tick.
        /// </summary>
        /// <returns>AmbientTickType</returns>
        /// <feature>http://tizen.org/feature/watch_app</feature>
        /// <exception cref="InvalidOperationException">Thrown when failed to get the ambient tick type.</exception>
        /// <exception cref="NotSupportedException">Thrown when the method is not supported.</exception>
        /// <example>
        /// <code>
        /// class MyApp : WatchApplication
        /// {
        ///     ...
        ///     public void TestMethod()
        ///     {
        ///         AmbientTickType atType;
        ///         try
        ///         {
        ///             atType = GetAmbientTickType();
        ///         }
        ///         catch
        ///         {
        ///         }
        ///     }
        /// }
        /// </code>
        /// </example>
        /// <since_tizen> 4 </since_tizen>
        protected AmbientTickType GetAmbientTickType()
        {
            AmbientTickType ambientTickType;

            Interop.Watch.ErrorCode err = Interop.Watch.GetAmbientTickType(out ambientTickType);

            if (err != Interop.Watch.ErrorCode.None)
            {
                if (err == Interop.Watch.ErrorCode.NotSupported)
                {
                    throw new NotSupportedException("Failed to get ambient tick type. err : " + err);
                }
                else
                {
                    throw new InvalidOperationException("Failed to get ambient tick type. err : " + err);
                }
            }

            return(ambientTickType);
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the current time.
        /// </summary>
        /// <returns>WatchTime</returns>
        /// <feature>http://tizen.org/feature/watch_app</feature>
        /// <exception cref="InvalidOperationException">Thrown when failed to get the current time because of an invalid parameter.</exception>
        /// <exception cref="OutOfMemoryException">Thrown when failed to get the current time because the memory is not enough.</exception>
        /// <exception cref="NotSupportedException">Thrown when the method is not supported.</exception>
        /// <example>
        /// <code>
        /// class MyApp : WatchApplication
        /// {
        ///     ...
        ///     public void TestMethod()
        ///     {
        ///         WatchTime wt;
        ///         try
        ///         {
        ///             wt = GetCurrentTime();
        ///         }
        ///         catch
        ///         {
        ///         }
        ///     }
        /// }
        /// </code>
        /// </example>
        /// <since_tizen> 4 </since_tizen>
        protected WatchTime GetCurrentTime()
        {
            SafeWatchTimeHandle handle;

            Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetCurrentTime(out handle);
            if (err != Interop.Watch.ErrorCode.None)
            {
                if (err == Interop.Watch.ErrorCode.InvalidParameter)
                {
                    throw new InvalidOperationException("Failed to get current time. err : " + err);
                }
                else if (err == Interop.Watch.ErrorCode.OutOfMemory)
                {
                    throw new OutOfMemoryException("Failed to get current time. err : " + err);
                }
                else if (err == Interop.Watch.ErrorCode.NotSupported)
                {
                    throw new NotSupportedException("Failed to get current time. err : " + err);
                }
            }
            return(new WatchTime(handle));
        }