Esempio n. 1
0
        private void SetDellValue(int MeterID, MeterInfo meterInfo)
        {
            if (Settings.Person.Accounts.Count == 0)
            {
                return;
            }

            int currentDay = DateTime.Now.Day;

            if (meterInfo.ValuesCanAdd)
            {
                Label del = new Label();
                del.TextColor               = (Color)Application.Current.Resources["MainColor"];
                del.Text                    = "Удалить";
                del.TextDecorations         = TextDecorations.Underline;
                del.FontAttributes          = FontAttributes.Bold;
                del.VerticalOptions         = LayoutOptions.Center;
                del.VerticalTextAlignment   = TextAlignment.Center;
                del.HorizontalTextAlignment = TextAlignment.Center;
                del.HorizontalOptions       = LayoutOptions.FillAndExpand;
                count1Stack.Children[1]     = del;
                var          dellClick = new TapGestureRecognizer();
                RestClientMP server    = new RestClientMP();
                dellClick.Tapped += async(s, e) =>
                {
                    Configurations.LoadingConfig = new LoadingConfig
                    {
                        IndicatorColor = (Color)Application.Current.Resources["MainColor"],
                        OverlayColor   = Color.Black,
                        Opacity        = 0.8,
                        DefaultMessage = "",
                    };
                    bool displayAlert = await Settings.mainPage.DisplayAlert("", AppResources.DellCouneter,
                                                                             AppResources.Yes, AppResources.Cancel);

                    if (displayAlert)
                    {
                        await Loading.Instance.StartAsync(async progress =>
                        {
                            CommonResult result = await server.DeleteMeterValue(MeterID);
                            if (result.Error == null)
                            {
                                MessagingCenter.Send <Object>(this, "UpdateCounters");
                            }
                            else
                            {
                                await Settings.mainPage.DisplayAlert(AppResources.ErrorTitle, result.Error,
                                                                     "OK");
                            }

                            // });
                        });
                    }
                };
                del.GestureRecognizers.Add(dellClick);
            }
        }