Exemplo n.º 1
0
        public async Task GetStation()
        {
            if (StationSetting != null)
            {
                SplashScreenManager.ShowDefaultWaitForm(_localization.LoadText(3700), _localization.LoadText(1055));
                StationObject = await FireBase.GetStation(StationSetting?.Id ?? 0);

                SplashScreenManager.CloseDefaultWaitForm();
                await UpdateUi();
            }
        }
Exemplo n.º 2
0
        private async void simpleButton1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textEdit1.Text) || string.IsNullOrEmpty(textEdit2.Text) ||
                string.IsNullOrEmpty(textEdit3.Text) || string.IsNullOrEmpty(textEdit4.Text) ||
                string.IsNullOrEmpty(textEdit5.Text) || string.IsNullOrEmpty(textEdit6.Text) ||
                string.IsNullOrEmpty(textEdit7.Text))
            {
                XtraMessageBox.Show(_localization.LoadText(1036), _localization.LoadText(1037), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            var station = new Station()
            {
                Id        = textEdit1.Text.ToInteger(),
                Name      = textEdit2.Text,
                City      = textEdit3.Text,
                Country   = textEdit4.Text,
                Latitude  = textEdit5.Text,
                Longitude = textEdit6.Text,
                Altitude  = textEdit7.Text,
                IsPublic  = checkEdit1.Checked
            };

            var fileName = $"{station.Id}_{station.Name}.png";

            //if (!string.IsNullOrEmpty(StationObject.Object.ImageName) && !string.Equals(fileName, StationObject.Object.ImageName))
            //{
            //    await FireBase.AddImage(StationObject.Object.ImageName);
            //}

            if (!FormulaLib.IsNumeric(station.Id))
            {
                XtraMessageBox.Show(_localization.LoadText(1060),
                                    _localization.LoadText(3738), MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                if (_imageChanged)
                {
                    pictureEdit1.Image.Save(fileName, ImageFormat.Png);

                    var pictureUrl = await FireBase.AddImage(fileName);

                    File.Delete(fileName);
                    if (!string.IsNullOrEmpty(pictureUrl))
                    {
                        station.ImageName = fileName;
                        station.ImageUrl  = pictureUrl;
                    }
                }
                else
                {
                    station.ImageName = StationObject.Object.ImageName;
                    station.ImageUrl  = StationObject.Object.ImageUrl;
                }

                if (StationObject != null && StationObject.Object.Id.Equals(station.Id))
                {
                    SplashScreenManager.ShowDefaultWaitForm(_localization.LoadText(3700), _localization.LoadText(1056));
                    var r = await FireBase.ChangeStation(station, StationObject.Key);

                    SplashScreenManager.CloseDefaultWaitForm();
                }
                else
                {
                    SplashScreenManager.ShowDefaultWaitForm(_localization.LoadText(3700), _localization.LoadText(1057));
                    var result = await FireBase.AddStation(station);

                    SplashScreenManager.CloseDefaultWaitForm();
                    if (!result)
                    {
                        XtraMessageBox.Show(_localization.LoadText(1046) + " " + FireBase.ErrorText, _localization.LoadText(1037), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                }
                SplashScreenManager.ShowDefaultWaitForm(_localization.LoadText(3700), _localization.LoadText(1058));
                var s = await FireBase.GetStation(station.Id);

                SplashScreenManager.CloseDefaultWaitForm();
                if (s != null)
                {
                    XtraMessageBox.Show(_localization.LoadText(1561) + " " + s.Object.Name + " " + _localization.LoadText(1059), _localization.LoadText(3841), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }