Example #1
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            splash = (SplashScreen)e.Parameter;
            OnResize();

            var weatherData = await WeatherService.GetWeatherData();

            WeekDays            = new ObservableCollection <WeekDay>(weatherData.WeekDay);
            TodaysWeather       = new ObservableCollection <Today>(weatherData.Today);
            NowButton.IsChecked = true;
            WeatherController.SetView(WeatherController.ViewMode.TodayCloseUp);
            WeatherController.AssetsLoaded += WeatherController_AssetsLoaded;
        }
Example #2
0
        private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
        {
            var messageDeferral = args.GetDeferral();

            ValueSet message    = args.Request.Message;
            ValueSet returnData = new ValueSet();

            if (message.ContainsKey("Command"))
            {
                string command = message["Command"] as string;
                // ... //
                if (command == "CurrentWeather")
                {
                    string resultJson = string.Empty;

                    var weatherData = await WeatherService.GetWeatherData();

                    var index = DateTime.Now.Hour / 6;

                    returnData.Add("Temperature", weatherData.Today[index].Temperature);
                    returnData.Add("State", weatherData.Today[index].Weather);
                    returnData.Add("Status", "OK");
                }
                else
                {
                    returnData.Add("Status", "Fail: Unknown command");
                }
            }
            else
            {
                returnData.Add("Status", "Fail: Missing command");
            }

            await args.Request.SendResponseAsync(returnData); // Return the data to the caller.

            messageDeferral.Complete();                       // Complete the deferral so that the platform knows that we're done responding to the app service call.
        }