private async void SaveMatch(object sender, RoutedEventArgs e)
        {
            FolderPicker folderPicker = new FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            folderPicker.FileTypeFilter.Add("*");
            StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            ((Matchimpro)list_of_matches.SelectedItem).Save(folder);

            ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();

            Windows.Data.Xml.Dom.XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(resourceLoader.GetString("ExportTitle")));
            toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(resourceLoader.GetString("ExportMessage")));
            Windows.Data.Xml.Dom.IXmlNode toastNode = toastXml.SelectSingleNode("/toast");

            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = DateTime.Now.AddSeconds(1);
            ToastNotifier.Show(toast);
        }
Beispiel #2
0
        //查询天气
        async void WeatherQuery()
        {
            if (cityName.Text == "")
            {
                return;
            }

            string     url      = "http://api.avatardata.cn/Weather/Query?key=1a2fa02c4cf34aafbb7ff83904a6ac6e&cityname=" + cityName.Text + "&dtype=XML";
            HttpClient client   = new HttpClient();
            string     response = await client.GetStringAsync(url);

            Windows.Data.Xml.Dom.XmlDocument document = new Windows.Data.Xml.Dom.XmlDocument();
            document.LoadXml(response);
            Windows.Data.Xml.Dom.XmlNodeList list = document.GetElementsByTagName("temperature");
            if (list.Length == 0)
            {
                var ii = new MessageDialog("The city is not exit!").ShowAsync();
            }
            else
            {
                IXmlNode node = list.Item(0);
                string   i    = node.InnerText;
                if (i != "")
                {
                    list             = document.GetElementsByTagName("info");
                    node             = list.Item(0);
                    weatherText.Text = "天气: " + node.InnerText;

                    list              = document.GetElementsByTagName("temperature");
                    node              = list.Item(0);
                    weatherText.Text += "   温度: " + node.InnerText + "摄氏度";
                }
                else
                {
                    var ii = new MessageDialog("Error!").ShowAsync();
                }
            }
        }