Esempio n. 1
0
        private void DeleteConfirmation_Click(object sender, RoutedEventArgs e)
        {
            Flyout f = FlyoutService.GetFlyout(Control1) as Flyout;

            if (f != null)
            {
                f.Hide();
            }
        }
Esempio n. 2
0
        private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            Flyout f = FlyoutService.GetFlyout(LocationIPButton) as Flyout;

            if (f != null)
            {
                f.Hide();
            }

            Mouse.OverrideCursor = Cursors.Wait;
            using (WebClient client = new WebClient())
            {
                client.Headers.Add("user-agent", "request");

                client.DownloadStringCompleted += (senderW, eW) =>
                {
                    var xmlDoc = new XmlDocument();
                    try
                    {
                        xmlDoc.LoadXml(eW.Result);
                        XmlNodeList LatValue  = xmlDoc.GetElementsByTagName("lat");
                        XmlNodeList LongValue = xmlDoc.GetElementsByTagName("lon");

                        double.TryParse(LatValue[0].InnerText, NumberStyles.Any, CultureInfo.InvariantCulture, out double LatValueResult);
                        LatitudeBox.Value = LatValueResult;

                        double.TryParse(LongValue[0].InnerText, NumberStyles.Any, CultureInfo.InvariantCulture, out double LongValueResult);
                        LongitudeBox.Value = LongValueResult;
                    }
                    catch { MessageBox.Show("Error while getting location.", "tinyBrightness", MessageBoxButton.OK, MessageBoxImage.Error); }
                    Mouse.OverrideCursor = null;
                };

                client.DownloadStringAsync(new Uri("http://ip-api.com/xml/"));
            }
        }