示例#1
0
        public StatsPage()
        {
            try
            {
                this.Title = "Статистика";
                sumLbl     = new Label
                {
                    TextColor         = Color.Green,
                    HorizontalOptions = LayoutOptions.EndAndExpand
                };
                _reportImg = new Image {
                    IsEnabled = false, Source = "email.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                listView              = new ListView();
                _rentList             = new ObservableCollection <RentStringFormats>(); LoadStats(DateTime.Now.Date);
                listView.ItemsSource  = _rentList;
                listView.ItemTemplate = new DataTemplate(typeof(RentItemCell));
                listView.RowHeight    = 60;
                listView.ItemTapped  += async(sender, e) =>
                {
                    RentStringFormats item = (RentStringFormats)e.Item;
                    await DisplayAlert("Информация", $"{item.ClientName}\nВ прокате {item.RentTime}\nПолучено {item.Payment:c}\n", "OK");

                    ((ListView)sender).SelectedItem = null;
                };
                var dateLbl = new Label {
                    Text = "Дата: ", FontSize = 18, VerticalTextAlignment = TextAlignment.Center
                };
                _date = new DatePicker {
                    Format = @"dd-MM-yyyy"
                };
                _date.DateSelected  += _date_DateSelected;
                _date.Date           = DateTime.Now.Date;
                _reportImg.IsVisible = _date.Date == DateTime.Now.Date ? false : true;
                _reportImg.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    TappedCallback = async(v, o) =>
                    {
                        try
                        {
                            var ans = await DisplayAlert("Подтвердите", $"Отправить отчет за {_date.Date.ToString("D")}", "Да", "Нет");
                            if (ans == true)
                            {
                                var report = new EmailReport(_date.Date);
                                report.SendAsync(false);
                            }
                            else
                            {
                                App.Toast("Отмена");
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                });
                var dateLayout = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Padding           = new Thickness(5, 0, 5, 0),
                    Children          = { dateLbl, _date, _reportImg }
                };

                StackLayout viewLayout = new StackLayout()
                {
                    Orientation = StackOrientation.Vertical,
                    Padding     = new Thickness(10, 10, 10, 0),
                    Children    = { dateLayout, listView, sumLbl }
                };

                Content = viewLayout;
            }
            catch (Exception ex)
            {
                App.Database.SaveError(new Mob.Dto.Error {
                    Date = DateTime.Now, Invoker = this.GetType().Name, Message = ex.Message
                });
            }
        }
示例#2
0
文件: Menu.cs 项目: bpasha7/GyroHero
        public Menu(NavigationPage cur)
        {
            try
            {
                Title          = "Меню";
                _cur           = cur;
                Detail         = _cur;
                _timersInfoImg = new Image {
                    Source = "time.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                _timersLbl = new Label {
                    TextColor = Color.Black, Text = "Таймеры", FontSize = 16, VerticalTextAlignment = TextAlignment.Center
                };
                _timersLbl.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    TappedCallback = (v, o) =>
                    {
                        try
                        {
                            Detail = _cur;
                            this.IsGestureEnabled = false;
                            this.IsGestureEnabled = true;
                        }
                        catch (Exception ex)
                        {
                            App.Database.SaveError(new Error {
                                Date = DateTime.Now, Invoker = $"{this.GetType().Name}->Timers", Message = ex.Message
                            });
                        }
                    }
                });
                ///
                _statInfoImg = new Image {
                    Source = "barchart.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                _StatLbl = new Label {
                    TextColor = Color.Black, Text = "Статистика ", FontSize = 16, VerticalTextAlignment = TextAlignment.Center
                };
                _StatLbl.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    TappedCallback = (v, o) =>
                    {
                        try
                        {
                            Detail = new NavigationPage(new StatsPage() /*{ SetGestureState = SetGesture }*/);
                            this.IsGestureEnabled = false;
                            this.IsGestureEnabled = true;
                        }
                        catch (Exception ex)
                        {
                            App.Database.SaveError(new Error {
                                Date = DateTime.Now, Invoker = $"{this.GetType().Name}->Stats", Message = ex.Message
                            });
                        }
                    }
                });
                ///
                _reportImg = new Image {
                    Source = "email.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                _reportLbl = new Label {
                    TextColor = Color.Black, Text = "Отчитаться ", FontSize = 16, VerticalTextAlignment = TextAlignment.Center
                };
                _reportLbl.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    TappedCallback = (v, o) =>
                    {
                        try
                        {
                            var report = new EmailReport(DateTime.Now);
                            report.SendAsync(false);
                            this.IsGestureEnabled = false;
                            this.IsGestureEnabled = true;
                        }
                        catch (Exception ex)
                        {
                            App.Database.SaveError(new Error {
                                Date = DateTime.Now, Invoker = $"{this.GetType().Name}->Reports", Message = ex.Message
                            });
                        }
                    }
                });

                ///
                //_pricesImg = new Image { Source = "ruble.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center };
                //_pricesLbl = new Label { TextColor = Color.Black, Text = "Цены ", FontSize = 16, VerticalTextAlignment = TextAlignment.Center };
                ///
                _settingsImg = new Image {
                    Source = "user.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                _settingsLbl = new Label {
                    TextColor = Color.Black, Text = "Профиль ", FontSize = 16, VerticalTextAlignment = TextAlignment.Center
                };
                _settingsLbl.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    TappedCallback = (v, o) =>
                    {
                        try
                        {
                            Detail = new NavigationPage(new UserPage());
                            this.IsGestureEnabled = false;
                            this.IsGestureEnabled = true;
                        }
                        catch (Exception ex)
                        {
                            App.Database.SaveError(new Error {
                                Date = DateTime.Now, Invoker = $"{this.GetType().Name}->Settings", Message = ex.Message
                            });
                        }
                    }
                });

                ///
                _bugReportImg = new Image {
                    Source = "bug.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                _bugReportLbl = new Label {
                    TextColor = Color.Black, /*Text = $"Отправить ошибки программы({App.Database.ErrorCount()}) ",*/ FontSize = 16, VerticalTextAlignment = TextAlignment.Center
                };
                _bugReportLbl.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    TappedCallback = (v, o) =>
                    {
                        try
                        {
                            var report = new EmailReport(DateTime.Now);
                            App.Toast("Отправляется");
                            report.SendAsync(true);
                            this.IsGestureEnabled = false;
                            this.IsGestureEnabled = true;
                        }
                        catch (Exception ex)
                        {
                            App.Database.SaveError(new Error {
                                Date = DateTime.Now, Invoker = $"{this.GetType().Name}->Reports", Message = ex.Message
                            });
                        }
                    }
                });

                StackLayout TimersLayout = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation       = StackOrientation.Horizontal,
                    Padding           = new Thickness(30, 80, 20, 0),
                    Children          = { _timersInfoImg, _timersLbl }
                };

                StackLayout StatLayout = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation       = StackOrientation.Horizontal,
                    Padding           = new Thickness(30, 20, 20, 0),
                    Children          = { _statInfoImg, _StatLbl }
                };
                StackLayout ReportLayout = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation       = StackOrientation.Horizontal,
                    Padding           = new Thickness(30, 20, 20, 0),
                    Children          = { _reportImg, _reportLbl }
                };

                StackLayout SettingsLayout = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation       = StackOrientation.Horizontal,
                    Padding           = new Thickness(30, 20, 20, 0),
                    Children          = { _settingsImg, _settingsLbl }
                };

                StackLayout BugReportLayout = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation       = StackOrientation.Horizontal,
                    Padding           = new Thickness(30, 40, 20, 0),
                    Children          = { _bugReportImg, _bugReportLbl }
                };
                var content = new StackLayout
                {
                    Children =
                    {
                        TimersLayout,
                        StatLayout,
                        ReportLayout,
                        //PriceLayout,
                        SettingsLayout,
                        BugReportLayout
                    }
                };
                this.Master = new ContentPage
                {
                    Title   = "Options",
                    Content = content,
                    Icon    = "hamburger.png"
                };
            }
            catch (Exception ex)
            {
                App.Database.SaveError(new Error {
                    Date = DateTime.Now, Invoker = this.GetType().Name, Message = ex.Message
                });
            }
        }