示例#1
0
        void ReleaseDesignerOutlets()
        {
            if (ImagePuzzle != null)
            {
                ImagePuzzle.Dispose();
                ImagePuzzle = null;
            }

            if (LabelTitle != null)
            {
                LabelTitle.Dispose();
                LabelTitle = null;
            }

            if (LabelSize != null)
            {
                LabelSize.Dispose();
                LabelSize = null;
            }

            if (LabelTime != null)
            {
                LabelTime.Dispose();
                LabelTime = null;
            }

            if (ButtonPlay != null)
            {
                ButtonPlay.Dispose();
                ButtonPlay = null;
            }
        }
示例#2
0
        void ReleaseDesignerOutlets()
        {
            if (ButtonPause != null)
            {
                ButtonPause.Dispose();
                ButtonPause = null;
            }

            if (LabelTime != null)
            {
                LabelTime.Dispose();
                LabelTime = null;
            }

            if (ScrollViewGame != null)
            {
                ScrollViewGame.Dispose();
                ScrollViewGame = null;
            }

            if (ButtonDebug != null)
            {
                ButtonDebug.Dispose();
                ButtonDebug = null;
            }
        }
 void ReleaseDesignerOutlets()
 {
     if (LabelTime != null)
     {
         LabelTime.Dispose();
         LabelTime = null;
     }
     if (NearablePicker != null)
     {
         NearablePicker.Dispose();
         NearablePicker = null;
     }
     if (SwitchEnable != null)
     {
         SwitchEnable.Dispose();
         SwitchEnable = null;
     }
 }
 private void UpdateTimer()
 {
     LabelTime.Content = _stopwatch.Elapsed.ToString(@"m\:ss\:fff");
     LabelTime.InvalidateVisual();
     LabelTime.UpdateLayout();
 }
        private void DisplayCurrentTime()
        {
            var time = String.Format("{0:HH:mm:ss}", DateTime.Now);

            LabelTime.SetText(time);
        }
        private async void CommitShakeAnimation()
        {
            uint timeout = 50;
            await Task.WhenAll(new List <Task> {
                BGSymbolImage.TranslateTo(-15, 0, timeout), HeroImage1.TranslateTo(-15, 0, timeout), LabelDate.TranslateTo(-15, 0, timeout), LabelTime.TranslateTo(-15, 0, timeout), HeroImage3.TranslateTo(-15, 0, timeout)
            });

            await Task.WhenAll(new List <Task> {
                BGSymbolImage.TranslateTo(15, 0, timeout), HeroImage1.TranslateTo(15, 0, timeout), LabelDate.TranslateTo(15, 0, timeout), LabelTime.TranslateTo(15, 0, timeout), HeroImage3.TranslateTo(15, 0, timeout)
            });

            await Task.WhenAll(new List <Task> {
                BGSymbolImage.TranslateTo(-9, 0, timeout), HeroImage1.TranslateTo(-9, 0, timeout), LabelDate.TranslateTo(-9, 0, timeout), LabelTime.TranslateTo(-9, 0, timeout), HeroImage3.TranslateTo(-9, 0, timeout)
            });

            await Task.WhenAll(new List <Task> {
                BGSymbolImage.TranslateTo(9, 0, timeout), HeroImage1.TranslateTo(9, 0, timeout), LabelDate.TranslateTo(9, 0, timeout), LabelTime.TranslateTo(9, 0, timeout), HeroImage3.TranslateTo(9, 0, timeout)
            });

            await Task.WhenAll(new List <Task> {
                BGSymbolImage.TranslateTo(-5, 0, timeout), HeroImage1.TranslateTo(-5, 0, timeout), LabelDate.TranslateTo(-5, 0, timeout), LabelTime.TranslateTo(-5, 0, timeout), HeroImage3.TranslateTo(-5, 0, timeout)
            });

            await Task.WhenAll(new List <Task> {
                BGSymbolImage.TranslateTo(5, 0, timeout), HeroImage1.TranslateTo(5, 0, timeout), LabelDate.TranslateTo(5, 0, timeout), LabelTime.TranslateTo(5, 0, timeout), HeroImage3.TranslateTo(5, 0, timeout)
            });

            await Task.WhenAll(new List <Task> {
                BGSymbolImage.TranslateTo(-2, 0, timeout), HeroImage1.TranslateTo(-2, 0, timeout), LabelDate.TranslateTo(-2, 0, timeout), LabelTime.TranslateTo(-2, 0, timeout), HeroImage3.TranslateTo(-2, 0, timeout)
            });

            await Task.WhenAll(new List <Task> {
                BGSymbolImage.TranslateTo(2, 0, timeout), HeroImage1.TranslateTo(2, 0, timeout), LabelDate.TranslateTo(2, 0, timeout), LabelTime.TranslateTo(2, 0, timeout), HeroImage3.TranslateTo(2, 0, timeout)
            });

            BGSymbolImage.TranslationX = 0;
            LabelDate.TranslationX     = 0;
            LabelTime.TranslationX     = 0;
            HeroImage1.TranslationX    = 0;
            HeroImage3.TranslationX    = 0;
        }
 private Timer timer;

        #endregion

        #region Constructor

        protected InterfaceController(IntPtr handle) : base(handle)
        {
            // Note: this .ctor should not contain any initialization logic.
        }

        #endregion

        #region Lifecycle

        public override void Awake(NSObject context)
        {
            base.Awake(context);

            SetTitle("Hello, watch!");

            ConfigureTimer();

            DisplayInfo("Awake");
        }

        public override void WillActivate()
        {
            UpdateTimer();

            DisplayInfo("WillActivate");
        }

        public override void DidDeactivate()
        {
            UpdateTimer(false);

            DisplayInfo("DidDeactivate");
        }

        public override void DidAppear()
        {
            DisplayInfo("DidAppear");
        }

        public override void WillDisappear()
        {
            DisplayInfo("WillDisappear");
        }

        #endregion

        #region Timer

        private void ConfigureTimer()
        {
            if (timer == null)
            {
                timer = new Timer();

                timer.Elapsed += (sender, e) =>
                {
                    DisplayCurrentTime();
                };

                timer.Interval = 1000;
            }
        }

        private void DisplayCurrentTime()
        {
            var time = String.Format("{0:HH:mm:ss}", DateTime.Now);

            LabelTime.SetText(time);
        }

        private void UpdateTimer(bool start = true)
        {
            if (start)
            {
                DisplayCurrentTime();
                timer.Start();
            }
            else
            {
                timer.Stop();
            }
        }

        #endregion

        #region Text input

        partial void ButtonInput_Activated()
        {
            var colors = new string[]
            {
                "Red", "Green", "Blue", "Orange", "Purple"
            };

            PresentTextInputController(colors,
                WKTextInputMode.AllowEmoji, DisplayUserResponse);
        }

        private void DisplayUserResponse(NSArray result)
        {
            var answer = "No answer";

            if (result != null)
            {
                if (result.Count > 0)
                {
                    answer = result.GetItem<NSObject>(0).ToString();
                }
            }

            LabelAnswer.SetText(answer);

            ComplicationHelper.Answer = answer;
            ComplicationHelper.UpdateComplications();
        }

        #endregion

        #region Menu

        partial void NewYorkItem_Tapped()
        {
            DisplayCityGeolocationController(City.NewYork);
        }