Exemplo n.º 1
0
        public MainMenu(NSMenu menu)
        {
            Menu = menu;
            TemperatureService = new TemperatureService();

            Swimmer    = MenuItemFactory(SwimmerText);
            NonSwimmer = MenuItemFactory(NonSwimmerText);
            Kids       = MenuItemFactory(KidsText);
            LastUpdate = MenuItemFactory(LastUpdateText);

            Menu.AddItem(Swimmer);
            Menu.AddItem(NonSwimmer);
            Menu.AddItem(Kids);
            Menu.AddItem(LastUpdate);

            Menu.AddItem(NSMenuItem.SeparatorItem);
            Menu.AddItem(new NSMenuItem(Translation.Quit.ToString(), (a, b) => Environment.Exit(0)));

            // fill with data
            UpdateLastTemperature();

            // update every 15 minutes
            UpdateTimer          = new Timer(TemperatureUpdateInterval);
            UpdateTimer.Elapsed += (sender, e) => {
                menu.InvokeOnMainThread(UpdateLastTemperature);
            };
            UpdateTimer.Start();

            // update the timestamp every minute
            TimestampTimer          = new Timer(TimestampUpdateInterval);
            TimestampTimer.Elapsed += (sender, e) => {
                menu.InvokeOnMainThread(UpdateTimestampUI);
            };
            TimestampTimer.Start();
        }