Exemple #1
0
            /// <summary>
            ///		<see cref="MyWatchFaceEngine"/>クラスの新しいインスタンスを生成します。
            /// </summary>
            /// <param name="owner"><see cref="CanvasWatchFaceService"/>クラスを継承したオブジェクトの参照</param>
            public MyWatchFaceEngine(CanvasWatchFaceService owner) : base(owner)
            {
                // CanvasWatchFaceServiceクラスを継承したオブジェクトの参照をセットします。
                this.owner = owner;
                // 時刻を更新した時の処理を構成します。
                updateTimeHandler = new Handler(
                    message =>
                {
//#if DEBUG
//						if( Log.IsLoggable( logTag, LogPriority.Info ) ) {
//							Log.Info( logTag, $"Updating timer: Message = {message.What}" );
//						}
//#endif

                    // Whatプロパティでメッセージを判別します。
                    switch (message.What)
                    {
                    case MessageUpdateTime:
                        // TODO : 時刻の更新のメッセージの時の処理を入れます。
                        // ウォッチフェイスを再描画します。
                        Invalidate();
                        // タイマーを動作させるかどうかを判別します。
                        if (ShouldTimerBeRunning)
                        {
                            /*
                             *                                          Javaでは、System.currentTimeMillisメソッドで世界協定時(ミリ秒)を取得します。
                             *                                          一方C#では、DateTime.UtcNow.Ticksプロパティで世界協定時(100ナノ秒)取得し、
                             *                                          TimeSpan.TicksPerMillisecondフィールドで割って、ミリ秒の値を求めます。
                             */
                            long timeMillseconds = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond;
                            // delayMs = 更新間隔 - ( 現在時刻(ミリ秒) % 更新間隔) -> 更新間隔との差
                            long delayMilliseconds = InteractiveUpdateRateMilliseconds - (timeMillseconds % InteractiveUpdateRateMilliseconds);
                            // UpdateTimeHandlerにメッセージをセットします。
                            // SendEmptyMessageDelayedメソッドは指定した時間後にメッセージを発行します。
                            updateTimeHandler.SendEmptyMessageDelayed(MessageUpdateTime, delayMilliseconds);
                        }
                        break;
                    }
                }
                    );

                // TimeZoneReceiverのインスタンスを生成します。
                timeZoneReceiver = new ActionExecutableBroadcastReceiver(
                    intent =>
                {
                    // TODO : ブロードキャストされた Intent.ActionTimezoneChanged のIntentオブジェクトを受け取った時に実行する処理を入れます。
                    // IntentからタイムゾーンIDを取得して、Timeオブジェクトのタイムゾーンに設定し、現在時刻を取得します。
                    // intent.GetStringExtra( "time-zone" )の戻り値はタイムゾーンのIDです。
                    // Time ( Android )
                    //nowTime.Clear( intent.GetStringExtra( "time-zone" ) );
                    //nowTime.SetToNow();
                    // Calendar ( Java )
                    nowTime = Java.Util.Calendar.GetInstance(Java.Util.TimeZone.GetTimeZone(intent.GetStringExtra("time-zone")));
                    // DateTime ( C# )
                    //nowTime = DateTime.Now;
                },
                    // Intentフィルターに「ActionTimezoneChanged」を指定します。
                    Intent.ActionTimezoneChanged
                    );
            }
Exemple #2
0
            public AnalogEngine(CanvasWatchFaceService self) : base(self)
            {
                _owner = self;
                Init(this);

                _watchHandColor       = Color.White;
                _watchHandShadowColor = Color.Black;
            }
Exemple #3
0
        public WatchNotify(CanvasWatchFaceService owner)
        {
            msgText  = new MessageText();
            msgImage = new MessageImage(owner);

            NotifyStyle = NotifyStyles.Text;
            Message     = Messages.none;
        }
            /// <summary>
            ///		Creates a new instance of <see cref="MyWatchFaceEngine"/> class.
            /// </summary>
            /// <param name="owner">Reference to a <see cref="CanvasWatchFaceService"/> object</param>
            public MyWatchFaceEngine(CanvasWatchFaceService owner) : base(owner)
            {
                // Sets a reference to an object that inherits CanvasWatchFaceService class.
                this.owner = owner;
                // Configures processing when updating time.
                updateTimeHandler = new Handler(
                    message => {
#if DEBUG
                    if (Log.IsLoggable(logTag, LogPriority.Info))
                    {
                        Log.Info(logTag, $"Updating timer: Message = {message.What}");
                    }
#endif

                    // Determines the message ID with the What property.
                    switch (message.What)
                    {
                    case MessageUpdateTime:
                        // TODO: Writes here, the processing at the time of the time update message.
                        // Redraws the watch face.
                        Invalidate();
                        // Determinea whether to activate the timer.
                        if (ShouldTimerBeRunning)
                        {
                            /*
                             *      In Java, gets Universal Time Coordinated (milli-seconds) by System.currentTimeMillis method.
                             *      Meanwhile, in C#, gets Universal Time Coordinated (100 nano-seconds) by DateTime.UtcNow.Ticks property,
                             *      and divides by TimeSpan.TicksPerMillisecond field to calculate the value in milliseconds.
                             */
                            long timeMillseconds = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond;
                            // delayMilliseconds = [Update interval] - ([Current time( milliseconds )] % [Update interval] ) -> Difference from update interval
                            long delayMilliseconds = InteractiveUpdateRateMilliseconds - (timeMillseconds % InteractiveUpdateRateMilliseconds);
                            // Sets the message in UpdateTimeHandler.
                            updateTimeHandler.SendEmptyMessageDelayed(MessageUpdateTime, delayMilliseconds);
                        }
                        break;
                    }
                }
                    );

                // Creates an instance of ActionExecutableBroadcastReceiver.
                timeZoneReceiver = new ActionExecutableBroadcastReceiver(
                    intent => {
                    // TODO: Writes here, process to be executed when receiving Intent object of broadcasted with Intent.ActionTimezoneChanged.
                    // Gets the time zone ID from the Intent, set it as the time zone of the Time object, and get the current time.
                    // Time ( Android )
                    //nowTime.Clear( intent.GetStringExtra( "time-zone" ) );
                    //nowTime.SetToNow();
                    // Calendar ( Java )
                    nowTime = Java.Util.Calendar.GetInstance(Java.Util.TimeZone.GetTimeZone(intent.GetStringExtra("time-zone")));
                    // DateTime ( C# )
                    //nowTime = DateTime.Now;
                },
                    // Specifies "android.intent.action.TIMEZONE_CHANGED" for the Intent filter.
                    Intent.ActionTimezoneChanged
                    );
            }
Exemple #5
0
        // true: PostDelayed の実行
        //bool hasPost;
        //bool mustCharRescaled;      // Rescale をするか
        //bool mustBalloonRescaled;   //  〃

        public MessageImage(CanvasWatchFaceService owner)
        {
            //mustCharRescaled = true;
            //mustBalloonRescaled = true;

            Character = Characters.none;
            Message   = Messages.none;

            //hasPost = false;
            Visible = false;

            paint = new Paint
            {
                FilterBitmap = true
            };

            #region Resource から Bitmap を読み込み、Rescale 前の状態で変数にセット

            //var drawablePlayer = owner.Resources.GetDrawable(Resource.Drawable.CharPlayer);
            //var drawableTemplarDragon = owner.Resources.GetDrawable(Resource.Drawable.CharTemplarDragon);
            //var drawableEileen = owner.Resources.GetDrawable(Resource.Drawable.CharEileen);
            //var drawableShionyan = owner.Resources.GetDrawable(Resource.Drawable.CharShionyan);

            // 'Resources.GetDrawable(int)' は旧形式です('deprecated')
            //bmpPlayer = (owner.Resources.GetDrawable(Resource.Drawable.CharPlayer) as BitmapDrawable).Bitmap;
            //bmpTemplarDragon = (owner.Resources.GetDrawable(Resource.Drawable.CharTemplarDragon) as BitmapDrawable).Bitmap;
            //bmpEileen = (owner.Resources.GetDrawable(Resource.Drawable.CharEileen) as BitmapDrawable).Bitmap;
            //bmpShionyan = (owner.Resources.GetDrawable(Resource.Drawable.CharShionyan) as BitmapDrawable).Bitmap;

            // Resource から Bitmap を読み込み、Rescale 前の状態で変数にセット
            charPlayer = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.CharPlayer, null)
                as BitmapDrawable).Bitmap;
            charTemplarDragon = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.CharTemplarDragon, null)
                as BitmapDrawable).Bitmap;
            charEileen = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.CharEileen, null)
                as BitmapDrawable).Bitmap;
            charShionyan = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.CharShionyan, null)
                as BitmapDrawable).Bitmap;

            //var drawableBefore5min = owner.Resources.GetDrawable(Resource.Drawable.BalloonBefore5min);
            //var drawableBefore1min = owner.Resources.GetDrawable(Resource.Drawable.BalloonBefore1min);
            //var drawableEnded = owner.Resources.GetDrawable(Resource.Drawable.BalloonEnded);

            // 'Resources.GetDrawable(int)' は旧形式です('deprecated')
            //bmpBefore5min = (owner.Resources.GetDrawable(Resource.Drawable.BalloonBefore5min) as BitmapDrawable).Bitmap;
            //bmpBefore1min = (owner.Resources.GetDrawable(Resource.Drawable.BalloonBefore1min) as BitmapDrawable).Bitmap;
            //bmpEnded = (owner.Resources.GetDrawable(Resource.Drawable.BalloonEnded) as BitmapDrawable).Bitmap;

            // Resource から Bitmap を読み込み、Rescale 前の状態で変数にセット
            balloonBefore5min = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.BalloonBefore5min, null)
                as BitmapDrawable).Bitmap;
            balloonBefore1min = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.BalloonBefore1min, null)
                as BitmapDrawable).Bitmap;
            balloonEnded = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.BalloonEnded, null)
                as BitmapDrawable).Bitmap;

            #endregion

            // 遅延実行
            handler = new Handler();
            action  = () => { Visible = false; };
        }
Exemple #6
0
        // Scaled 用 Bitmap
        //private Bitmap backgroundScaledBitmap;
        //private Bitmap backgroundScaledAmbient;

        public WatchBackground(CanvasWatchFaceService owner)
        {
            // 背景色の作成
            backColor = new Color(
                WatchfaceUtility.ConvertARGBToColor(
                    ContextCompat.GetColor(owner, Resource.Color.background)));

            // 背景用 Paint の作成
            backgroundPaint = new Paint()
            {
                // 背景色を設定
                Color = backColor,
                // Scaled された画像をなめらかにする
                FilterBitmap = true
            };

            #region 'Resources.GetDrawable(int)' は旧形式です('deprecated')

            //// リソースから月齢画像を読み込みます
            //var backgroundDrawableFullMoon = owner.Resources.GetDrawable(Resource.Drawable.FullMoon);
            //var backgroundDrawableF7N = owner.Resources.GetDrawable(Resource.Drawable.F7N);
            //var backgroundDrawableF6N = owner.Resources.GetDrawable(Resource.Drawable.F6N);
            //var backgroundDrawableF5N = owner.Resources.GetDrawable(Resource.Drawable.F5N);
            //var backgroundDrawableF4N = owner.Resources.GetDrawable(Resource.Drawable.F4N);
            //var backgroundDrawableF3N = owner.Resources.GetDrawable(Resource.Drawable.F3N);
            //var backgroundDrawableF2N = owner.Resources.GetDrawable(Resource.Drawable.F2N);
            //var backgroundDrawableF1N = owner.Resources.GetDrawable(Resource.Drawable.F1N);
            //var backgroundDrawableNewMoon = owner.Resources.GetDrawable(Resource.Drawable.NewMoon);
            //var backgroundDrawableN1F = owner.Resources.GetDrawable(Resource.Drawable.N1F);
            //var backgroundDrawableN2F = owner.Resources.GetDrawable(Resource.Drawable.N2F);
            //var backgroundDrawableN3F = owner.Resources.GetDrawable(Resource.Drawable.N3F);
            //var backgroundDrawableN4F = owner.Resources.GetDrawable(Resource.Drawable.N4F);
            //var backgroundDrawableN5F = owner.Resources.GetDrawable(Resource.Drawable.N5F);
            //var backgroundDrawableN6F = owner.Resources.GetDrawable(Resource.Drawable.N6F);
            //var backgroundDrawableN7F = owner.Resources.GetDrawable(Resource.Drawable.N7F);
            //var backgroundDrawableDevilSummoner = owner.Resources.GetDrawable(Resource.Drawable.DevilSummoner);
            //var backgroundDrawableDx2 = owner.Resources.GetDrawable(Resource.Drawable.Dx2);
            ////var backgroundDrawableAmbient = owner.Resources.GetDrawable(Resource.Drawable.Ambient);    //

            //// 月齢画像を Bitmap に変換
            //backgroundFullMoon = (backgroundDrawableFullMoon as BitmapDrawable).Bitmap;
            //backgroundF7N = (backgroundDrawableF7N as BitmapDrawable).Bitmap;
            //backgroundF6N = (backgroundDrawableF6N as BitmapDrawable).Bitmap;
            //backgroundF5N = (backgroundDrawableF5N as BitmapDrawable).Bitmap;
            //backgroundF4N = (backgroundDrawableF4N as BitmapDrawable).Bitmap;
            //backgroundF3N = (backgroundDrawableF3N as BitmapDrawable).Bitmap;
            //backgroundF2N = (backgroundDrawableF2N as BitmapDrawable).Bitmap;
            //backgroundF1N = (backgroundDrawableF1N as BitmapDrawable).Bitmap;
            //backgroundNewMoon = (backgroundDrawableNewMoon as BitmapDrawable).Bitmap;
            //backgroundN1F = (backgroundDrawableN1F as BitmapDrawable).Bitmap;
            //backgroundN2F = (backgroundDrawableN2F as BitmapDrawable).Bitmap;
            //backgroundN3F = (backgroundDrawableN3F as BitmapDrawable).Bitmap;
            //backgroundN4F = (backgroundDrawableN4F as BitmapDrawable).Bitmap;
            //backgroundN5F = (backgroundDrawableN5F as BitmapDrawable).Bitmap;
            //backgroundN6F = (backgroundDrawableN6F as BitmapDrawable).Bitmap;
            //backgroundN7F = (backgroundDrawableN7F as BitmapDrawable).Bitmap;
            //backgroundDevilSummoner = (backgroundDrawableDevilSummoner as BitmapDrawable).Bitmap;
            //backgroundDx2 = (backgroundDrawableDx2 as BitmapDrawable).Bitmap;
            ////backgroundAmbient = (backgroundDrawableAmbient as BitmapDrawable).Bitmap;

            #endregion

            #region Resource から Bitmap を読み込み、Rescale 前の状態で変数にセット

            backgroundFullMoon = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.FullMoon, null)
                as BitmapDrawable).Bitmap;
            backgroundF7N = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.F7N, null)
                as BitmapDrawable).Bitmap;
            backgroundF6N = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.F6N, null)
                as BitmapDrawable).Bitmap;
            backgroundF5N = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.F5N, null)
                as BitmapDrawable).Bitmap;
            backgroundF4N = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.F4N, null)
                as BitmapDrawable).Bitmap;
            backgroundF3N = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.F3N, null)
                as BitmapDrawable).Bitmap;
            backgroundF2N = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.F2N, null)
                as BitmapDrawable).Bitmap;
            backgroundF1N = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.F1N, null)
                as BitmapDrawable).Bitmap;
            backgroundNewMoon = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.NewMoon, null)
                as BitmapDrawable).Bitmap;
            backgroundN1F = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.N1F, null)
                as BitmapDrawable).Bitmap;
            backgroundN2F = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.N2F, null)
                as BitmapDrawable).Bitmap;
            backgroundN3F = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.N3F, null)
                as BitmapDrawable).Bitmap;
            backgroundN4F = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.N4F, null)
                as BitmapDrawable).Bitmap;
            backgroundN5F = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.N5F, null)
                as BitmapDrawable).Bitmap;
            backgroundN6F = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.N6F, null)
                as BitmapDrawable).Bitmap;
            backgroundN7F = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.N7F, null)
                as BitmapDrawable).Bitmap;
            backgroundDevilSummoner = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.DevilSummoner, null)
                as BitmapDrawable).Bitmap;
            backgroundDx2 = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.Dx2, null)
                as BitmapDrawable).Bitmap;
            backgroundAmbient = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.Ambient, null)
                as BitmapDrawable).Bitmap;
            backgroundTetregrammaton = (
                ResourcesCompat.GetDrawable(owner.Resources, Resource.Drawable.TETREGRAMMATON, null)
                as BitmapDrawable).Bitmap;

            #endregion
        }
 public SweepWatchFaceEngine(CanvasWatchFaceService owner) : base(owner)
 {
     this.owner = owner;
 }
 public NFLWatchEngine(CanvasWatchFaceService NFLWatchService)
     : base(NFLWatchService)
 {
     this.NFLWatchService = NFLWatchService;
 }
 public XFitWatchfaceEngine(CanvasWatchFaceService owner) : base(owner)
 {
     this.owner = owner;
 }
 public SweepWatchFaceEngine(CanvasWatchFaceService owner)
     : base(owner)
 {
     this.owner = owner;
 }
			public XFitWatchfaceEngine(CanvasWatchFaceService owner) : base(owner)
			{
				this.owner = owner;
			}			
Exemple #12
0
 // Saves a reference to the outer CanvasWatchFaceService
 public MyWatchFaceEngine(CanvasWatchFaceService owner) : base(owner)
 {
     _owner = owner;
 }
Exemple #13
0
 public DigitalWatchFaceEngine(CanvasWatchFaceService owner) : base(owner)
 {
     this.owner = owner;
 }
 public DigitalWatchFaceEngine(CanvasWatchFaceService owner)
     : base(owner)
 {
     this.owner = owner;
 }
Exemple #15
0
        public WatchHands(CanvasWatchFaceService owner)
        {
            var resources = owner.Resources;

            // 時針用のPaintグラフィックスオブジェクトを生成します。
            hourHandPaint = new Paint
            {
                // 時針の色を設定します
                Color =
                    WatchfaceUtility.ConvertARGBToColor(
                        ContextCompat.GetColor(owner, Resource.Color.analog_hands)),
                // 時針の幅を設定します。
                StrokeWidth = resources.GetDimension(Resource.Dimension.hour_hand_stroke),
                // アンチエイリアスを有効にします。
                AntiAlias = true,
                // 線端の形は丸形を指定します。
                StrokeCap = Paint.Cap.Round
            };

            // 時針の縁を準備します
            hourHandBackPaint = new Paint
            {
                Color       = Color.Black,
                StrokeWidth = hourHandPaint.StrokeWidth + 3,
                AntiAlias   = hourHandPaint.AntiAlias,
                StrokeCap   = hourHandPaint.StrokeCap
            };

            // 分針用のPaintグラフィックスオブジェクトを生成します。
            minuteHandPaint = new Paint
            {
                Color       = hourHandPaint.Color,
                StrokeWidth = resources.GetDimension(Resource.Dimension.minute_hand_stroke),
                AntiAlias   = true,
                StrokeCap   = Paint.Cap.Round
            };

            // 分針の縁を準備します
            minuteHandBackPaint = new Paint
            {
                Color       = hourHandBackPaint.Color,
                StrokeWidth = minuteHandPaint.StrokeWidth + 3,
                AntiAlias   = minuteHandPaint.AntiAlias,
                StrokeCap   = minuteHandPaint.StrokeCap
            };

            // 秒針用のPaintグラフィックスオブジェクトを生成します。
            secondHandPaint = new Paint
            {
                Color =
                    WatchfaceUtility.ConvertARGBToColor(
                        ContextCompat.GetColor(owner, Resource.Color.analog_second_hand)),
                StrokeWidth = resources.GetDimension(Resource.Dimension.second_hand_stroke),
                AntiAlias   = true,
                StrokeCap   = Paint.Cap.Round
            };

            // 秒針の縁を準備します
            secondHandBackPaint = new Paint
            {
                Color       = Color.Black,
                StrokeWidth = secondHandPaint.StrokeWidth + 2,
                AntiAlias   = secondHandPaint.AntiAlias,
                StrokeCap   = secondHandPaint.StrokeCap
            };
        }