Beispiel #1
0
        private void readDirectory()
        {
            comboCityID.Clear();

            string directory = String.Format(@"{0}xmldata\", AppDomain.CurrentDomain.BaseDirectory);

            string[] path = Directory.GetFiles(directory);

            for (int i = 0; i < path.Length; i++)
            {
                string extension = System.IO.Path.GetExtension(path[i]);

                if (extension == ".xaml")
                {
                    string filename = System.IO.Path.GetFileNameWithoutExtension(path[i]);

                    if (int.TryParse(filename, out _))
                    {
                        int  id   = Convert.ToInt32(filename);
                        City city = new City();

                        city = XamlOperation.readXML(id);

                        comboCityID.Add(id);
                        cb_ID.Items.Add(city.name + " (" + id.ToString() + ")");
                    }
                }
            }
        }
Beispiel #2
0
        private void TakeCity_click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(cb_ID.Text))
            {
                Error = "Вы ничего не выбрали";
                return;
            }

            City city = XamlOperation.readXML(comboCityID[cb_ID.SelectedIndex]);

            city.checkWeatherUpdate();

            mainWindow.setCity(city);
            Hide();
        }