示例#1
0
        async void OpenFullPhoto(object sender, ItemTappedEventArgs e)
        {
            Pages.FullImagePage fullImagePage = new Pages.FullImagePage((Photo)e.Item);
            await Navigation.PushAsync(fullImagePage);

            ((ListView)sender).SelectedItem = null;
        }
示例#2
0
        public FinalPage(MainModel mainModel)
        {
            _MainModel = mainModel;
            BindingContext = _MainModel;

            Title = "Итоговое обращение";

            var photosCount = _MainModel.selectedPhotos.Count();
            var rows = new RowDefinitionCollection() { };

            for (var i = 0; i < photosCount; i += 3)
                rows.Add(new RowDefinition { Height = 80 });

            Grid photoGrid = new Grid
            {
                RowDefinitions = rows,
                ColumnDefinitions =
                {
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }
                }
            };
                

            var photosId = 0;
            for (var i = 0; i < photoGrid.RowDefinitions.Count(); i++)
                for (var j = 0; j < photoGrid.ColumnDefinitions.Count(); j++)
                {
                    var tapGestureRecognizer = new TapGestureRecognizer();
                    tapGestureRecognizer.Tapped += async (s, e) => {
                        Pages.FullImagePage fullImagePage = new Pages.FullImagePage(new Photo() { Image = ((Image)s).Source });
                        await Navigation.PushAsync(fullImagePage);
                    };

                    Image image = new Image { Source = _MainModel.selectedPhotos[photosId].Image };
                    image.GestureRecognizers.Add(tapGestureRecognizer);

                    photoGrid.Children.Add(new Frame { Content = image, BorderColor = Color.FromRgb(10, 10, 10), Padding = 1 }, j, i );
                    photosId++;
                    if (photosId == photosCount) break;
                }

            photoGrid.RowSpacing = 0;
            photoGrid.ColumnSpacing = 0;

            Button finalButton = new Button() { Text = "Сохранить и продолжить" };
            finalButton.Clicked += FinalButtonClicked;

            Content = new StackLayout
            {
                Children =
                {
                    new ScrollView
                    {
                        Content = new StackLayout
                        {
                            Children =
                            {
                                new Label { Text = "ФИО:", Margin = 0, Padding = 0, FontSize = 22, TextColor = Color.Black },
                                new Label { Text = "Имя: " + _MainModel.selectedProfile.Name, Margin = 0, Padding = 0, FontSize = 22 },
                                new Label { Text = "Фамилия: " + _MainModel.selectedProfile.Surname, Margin = 0, Padding = 0, FontSize = 22 },
                                new Label { Text = "Отчество: " + _MainModel.selectedProfile.Patronymic, Margin = new Thickness(0, 0, 0, 15), Padding = 0, FontSize = 22 },
                                new Label { Text = "Контактная информация:", Margin = 0, Padding = 0, FontSize = 22, TextColor = Color.Black },
                                new Label { Text = "Email: " + _MainModel.selectedProfile.Email, Margin = 0, Padding = 0, FontSize = 18 },
                                new Label { Text = "Телефон: " + _MainModel.selectedProfile.Phone, Margin = new Thickness(0, 0, 0, 10), Padding = 0, FontSize = 18 },
                                new Label { Text = "Регион: " + _MainModel.selectedProfile.Region, Margin = 0, Padding = 0, FontSize = 18 },
                                new Label { Text = "Отделение: " + _MainModel.selectedProfile.Division, Margin = 0, Padding = 0, FontSize = 18 },
                                new Label { Text = "Регион происшествия: " + _MainModel.selectedProfile.EvsRegion, Margin = 0, Padding = 0, FontSize = 18 },
                                new Label { Text = "Текст обращения:", Margin = new Thickness(0, 15, 0, 0), Padding = 0, FontSize = 22, TextColor = Color.Black },
                                new Label { Text = _MainModel.selectedAppeal.Text, Margin = new Thickness(0, 5, 0, 15), Padding = 0, FontSize = 20 },
                                new Label { Text = "Загруженные изображения:", Margin = new Thickness(0, 15, 0, 5), Padding = 0, FontSize = 22, TextColor = Color.Black },
                                photoGrid
                            },
                            Spacing = 0
                        }
                    },
                    finalButton
                },
                Padding = 15
            };
        }
示例#3
0
        public PhotosPage(MainModel mainModel)
        {
            _MainModel = mainModel;

            if (_MainModel.selectedPhotos == null)
            {
                _MainModel.selectedPhotos = new ObservableCollection <Photo>()
                {
                }
            }
            ;

            InitializeComponent();

            BindingContext = this;

            if (_MainModel.selectedPhotos != null)
            {
                DeletePhoto = new DeletePhoto(_MainModel, ContinueButton);
                ContinueButton.IsEnabled = true;
            }

            takePhoto.Clicked += async(sender, args) =>
            {
                if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
                {
                    await DisplayAlert("No Camera", ":( No camera available.", "OK");

                    return;
                }

                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    Directory     = "Photos",
                    SaveToAlbum   = true,
                    PhotoSize     = PhotoSize.Full,
                    DefaultCamera = CameraDevice.Front
                });

                if (file == null)
                {
                    return;
                }

                if (_MainModel.selectedPhotos == null)
                {
                    _MainModel.selectedPhotos = new ObservableCollection <Photo>()
                    {
                    }
                }
                ;

                _MainModel.selectedPhotos.Add(new Photo
                {
                    Image = ImageSource.FromStream(() =>
                    {
                        var stream = file.GetStream();
                        return(stream);
                    }),
                    Name = file.Path.Split(new char[] { '\\', '/' }).Last()
                });
                ContinueButton.IsEnabled = true;

                DeletePhoto = new DeletePhoto(_MainModel, ContinueButton);
            };

            pickPhoto.Clicked += async(sender, args) =>
            {
                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    await DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");

                    return;
                }
                var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
                {
                    PhotoSize = PhotoSize.Full,
                });


                if (file == null)
                {
                    return;
                }

                if (_MainModel.selectedPhotos == null)
                {
                    _MainModel.selectedPhotos = new ObservableCollection <Photo>()
                    {
                    }
                }
                ;

                _MainModel.selectedPhotos.Add(new Photo
                {
                    Image = ImageSource.FromStream(() =>
                    {
                        var stream = file.GetStream();
                        return(stream);
                    }),
                    Name = file.Path.Split(new char[] { '\\', '/' }).Last()
                });
                ContinueButton.IsEnabled = true;
                DeletePhoto = new DeletePhoto(_MainModel, ContinueButton);
            };
        }

        async void OpenFullPhoto(object sender, ItemTappedEventArgs e)
        {
            Pages.FullImagePage fullImagePage = new Pages.FullImagePage((Photo)e.Item);
            await Navigation.PushAsync(fullImagePage);

            ((ListView)sender).SelectedItem = null;
        }

        async private void ContinueClicked(object sender, EventArgs e)