Exemple #1
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            User.Password += (sender as Button)?.Text;
            if (User.Password.Length == 4)
            {
                if (await ApiWorker.Auth(User))
                {
                    await Navigation.PushModalAsync(new MainScreenPage());
                }
                else
                {
                    await DisplayAlert("Error", "Password or email incorrect", "Ok");

                    await Navigation.PopModalAsync();
                }
                User.Password = "";
            }
            else
            {
                var numberRandom = new Random();
                for (int i = 0; i < 10; i++)
                {
                    Buttons.Move(numberRandom.Next(0, 9), numberRandom.Next(0, 9));
                }
            }
        }
        private async void SignUp(object sender, EventArgs e)
        {
            User.Email          = Email.Text;
            User.Password       = Code.Text;
            User.RepeatPassword = RepeatCode.Text;

            if (User.Validation(out string stringResult) && await ApiWorker.Registration(User))
            {
                await Navigation.PushModalAsync(new MainScreenPage());
            }
		private async void Window_Loaded(object sender, RoutedEventArgs e)
		{
			List<KeyValuePair<string, string>> logindata = new List<KeyValuePair<string, string>>();
			logindata.Add(new KeyValuePair<string, string>("email", m_UN));
			logindata.Add(new KeyValuePair<string, string>("password", m_PW));

			m_ApiWorker = new ApiWorker();
			object o = await m_ApiWorker.SendApi("login", logindata);

			Models.Api.Rat r = JsonConvert.DeserializeObject<Models.Api.Rat>(o.ToString());
		}
Exemple #4
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            List <KeyValuePair <string, string> > logindata = new List <KeyValuePair <string, string> >();

            logindata.Add(new KeyValuePair <string, string>("email", m_UN));
            logindata.Add(new KeyValuePair <string, string>("password", m_PW));

            m_ApiWorker = new ApiWorker();
            object o = await m_ApiWorker.SendApi("login", logindata);

            Models.Api.Rat r = JsonConvert.DeserializeObject <Models.Api.Rat>(o.ToString());
        }
Exemple #5
0
        private void StartParse()
        {
            string url = ConfigurationManager.AppSettings.Get("JsonOWM").Replace("Region", WeatherSett.Region);

            _apiWorker             = new ApiWorker <Weather>(new ApiWeatherJson(), new WeatherOWMSetting(url));
            _apiWorker.EventStart += Show;

            int millisec = Convert.ToInt16(WeatherSett.TimeParse) * 1000;

            if (millisec < 1000)
            {
                millisec = 1000;
            }

            _apiWorker.Start(millisec);
        }
        private async void buttonGetWeather_Click(object sender, EventArgs e)
        {
            if (textBoxCity.Text == "")
            {
                MessageBox.Show("Ошибка! Введите город");
                return;
            }

            string dataCoordFromYa = await ApiWorker.GetCoord(this);

            JObject jsonDataCoord = JObject.Parse(dataCoordFromYa);

            CoordData coord = JsonConvert.DeserializeObject <CoordData>(jsonDataCoord["response"]["GeoObjectCollection"]["featureMember"][0]["GeoObject"]["Point"].ToString());

            string[] coordArray = coord.Pos.Split(new char[] { ' ' });

            labelLon.Text = coordArray[0];
            labelLat.Text = coordArray[1];


            string dataWeatherFromYa = await ApiWorker.GetWeather(this);

            JObject jsonDataWeather = JObject.Parse(dataWeatherFromYa);

            WeatherData weatherData = JsonConvert.DeserializeObject <WeatherData>(jsonDataWeather["fact"].ToString());

            WebClient webClient = new WebClient();

            webClient.Encoding = Encoding.UTF8;

            webClient.DownloadFile($"https://yastatic.net/weather/i/icons/blueye/color/svg/{weatherData.Icon}.svg", "icon.svg");

            labelTemp.Text      = weatherData.Temp;
            labelFeelsLike.Text = weatherData.FeelsLike;

            SvgDocument svg = SvgDocument.Open("icon.svg");

            pictureIcon.Image = svg.Draw();

            labelCondition.Text = ApiHelper.WeatherConditions[weatherData.Condition];

            labelWindSpeed.Text = weatherData.WindSpeed;

            labelWindDir.Text = ApiHelper.WeatherWindDir[weatherData.WindDir];

            labelPressureMM.Text = weatherData.PressureMM;
        }