예제 #1
0
            // Called when the engine is created for the first time:
            public override void OnCreate(ISurfaceHolder holder)
            {
                base.OnCreate(holder);

                // Configure the system UI. Instantiates a WatchFaceStyle object that causes
                // notifications to appear as small peek cards that are shown only briefly
                // when interruptive. Also disables the system-style UI time from being drawn:
                SetWatchFaceStyle(new WatchFaceStyle.Builder(_owner)
                                  .SetCardPeekMode(WatchFaceStyle
                                                   .PeekModeShort)                            // This method is deprecated. Wear 2.0 doesn't have peeking cards
                                  .SetBackgroundVisibility(WatchFaceStyle
                                                           .BackgroundVisibilityInterruptive) // This method is deprecated. Wear 2.0 doesn't have peeking cards
                                  .SetShowSystemUiTime(false)                                 //  this will be removed in a future version of the Wear platform
                                  .SetStatusBarGravity(Resource.Id.bottom | Resource.Id.right)
                                  .Build());


                // Configure the background image:
                var backgroundDrawable = Application.Context.Resources.GetDrawable(
                    Resource.Drawable.mind_the_gap);

                backgroundBitmap = (backgroundDrawable as BitmapDrawable)?.Bitmap;

                var AOD_backgroundDrawable = Application.Context.Resources.GetDrawable(
                    Resource.Drawable.Underground);

                aodBackgroundBitmap = (AOD_backgroundDrawable as BitmapDrawable)?.Bitmap;

                // configure a foreground image for use later (bullet hole)
                var foregroundDrawable =
                    Application.Context.Resources.GetDrawable(
                        Resource.Drawable.BSN_Chevron_Red);

                hubBitmap = (foregroundDrawable as BitmapDrawable)?.Bitmap;

                // Initialize paint objects for drawing the clock hands and tick marks:

                // Hand paints:
                hourPaint   = WatchFaceFactory.GetHourHand(Color.Blue, false);
                minutePaint = WatchFaceFactory.GetMinuteHand(Color.White, false);
                secondPaint = WatchFaceFactory.GetSecondHand(Color.White, false);

                // Ticks:
                hTickPaint = new Paint {
                    AntiAlias = true, StrokeWidth = 3.0f
                };
                hTickPaint.SetARGB(NORMAL_ALPHA, 255, 0, 0);
                //hTickPaint.SetShadowLayer(1.1f, .5f, .5f, Color.Argb(MUTE_ALPHA, 50, 50, 50));

                mTickPaint = new Paint {
                    AntiAlias = true, StrokeWidth = 1.5f
                };
                mTickPaint.SetARGB(NORMAL_ALPHA, 255, 0, 0);
                // mTickPaint.SetShadowLayer(1.1f, .5f, .5f, Color.Argb(MUTE_ALPHA, 50, 50, 50));

                // Instantiate the time object:
                _calendar = Calendar.GetInstance(Locale.Default);

                // Start a timer for redrawing the click face (second hand) every second.
                // How to stop the timer? It shouldn't run in ambient mode...
                _updateRate  = NORMAL_UPDATE_RATE_MS;
                timerSeconds = new Timer(state => { Invalidate(); },
                                         null, TimeSpan.FromMilliseconds(_updateRate),
                                         TimeSpan.FromMilliseconds(_updateRate));
            }
예제 #2
0
            // Called when the engine is created for the first time:
            public override void OnCreate(ISurfaceHolder holder)
            {
                base.OnCreate(holder);
                var Res = Application.Context.Resources;

                // CONFIG THE UI
                // configure the system UI
                SetWatchFaceStyle(new WatchFaceStyle.Builder(_owner)
                                  .SetBackgroundVisibility(WatchFaceStyle.BackgroundVisibilityInterruptive)
                                  .SetShowSystemUiTime(false)
                                  .Build());

                // load the background image(s)
                _backgroundBitmap    = BitmapFactory.DecodeResource(Res, Resource.Drawable.gwg_background);
                _aodBackgroundBitmap = BitmapFactory.DecodeResource(Res, Resource.Drawable.gwg_aod);

                // dynamically update the watchhand colors based on the background image


                // configure a foreground image for use later (bullet hole)
                _hubBitmap = BitmapFactory.DecodeResource(Res, Resource.Drawable.bullet_hole);


                // create graphic styles


                // Initialize paint objects for drawing the clock hands and tick marks:
                _facePaint = new Paint {
                    AntiAlias = false, Alpha = 255
                };

                // Hand paints:
                _hourPaint = WatchFaceFactory.GetHourHand(Color.White);

                // change the style on the minute hand
                _minutePaint = new Paint
                {
                    AntiAlias   = true,
                    Color       = Color.White,
                    StrokeWidth = 4f
                };
                _minutePaint.SetShadowLayer(SHADOW_RADIUS, 0, 0, Color.Black);
                _minutePaint.SetStyle(Paint.Style.Stroke);

                _secondPaint = WatchFaceFactory.GetSecondHand(Color.Red);

                // Ticks:
                _tickPaint = new Paint {
                    AntiAlias = true, StrokeWidth = 3.0f
                };
                _tickPaint.SetARGB(255, 210, 0, 0);
                _tickPaint.SetShadowLayer(1.1f, .5f, .5f, Color.Argb(120, 50, 50, 50));

                _minuteTickPaint = new Paint {
                    AntiAlias = true, StrokeWidth = 1.5f
                };
                _minuteTickPaint.SetARGB(255, 159, 191, 255);
                _minuteTickPaint.SetShadowLayer(1.1f, .5f, .5f, Color.Argb(120, 50, 50, 50));

                _datePaint = new Paint {
                    Alpha = 255, AntiAlias = true,
                };

                // allocate a Calendar to calculate local time using the UTC time and time zone
                _calendar = Java.Util.Calendar.GetInstance(Java.Util.Locale.Default);
            }