Beispiel #1
0
        public override bool OnContextItemSelected(IMenuItem item)
        {
            var menuItemIndex = item.ItemId;

            if (menuItemIndex == 0) //Edytuj
            {
                _editDialog = new WinSelectDialog(this, "Edytuj zdjęcie", _activeCar.WIN, _selectetImage.Note);
                _editDialog.SetButtonTitle("Edytuj");
                _editDialog.Build(_carRepository.GetAllCar().Select(x => x.WIN).ToArray(), OnEdit);
                _editDialog.Show();
            }

            else if (menuItemIndex == 1) // usun
            {
                var directoryName = Path.GetDirectoryName(_selectetImage.PhotoName);
                File.Delete(_selectetImage.PhotoName);

                var deleteCar = _carRepository.DeleteImageFromCar(_selectetImage);
                if (deleteCar && directoryName != null)
                {
                    Directory.Delete(directoryName);
                }

                Toast.MakeText(this, "Usunięto", ToastLength.Short).Show();
                CreateViewForSingleCar(_activeCar.WIN);
            }
            else if (menuItemIndex == 2)//wyslij
            {
            }
            return(true);
        }
Beispiel #2
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            if (id == Resource.Id.nav_camera)
            {
                AddFromCamera();
            }
            else if (id == Resource.Id.nav_gallery)
            {
                _searchDialog = new WinSelectDialog(this, "Szukaj");
                _searchDialog.SetButtonTitle("Szukaj");
                _searchDialog.Build(_carRepository.GetAllCar().Select(x => x.WIN).ToArray(), SearchAction, false);
                _searchDialog.Show();
            }
            else if (id == Resource.Id.nav_slideshow)
            {
            }
            else if (id == Resource.Id.nav_manage)
            {
            }
            else if (id == Resource.Id.nav_share)
            {
            }
            else if (id == Resource.Id.nav_send)
            {
            }

            DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            drawer.CloseDrawer(GravityCompat.Start);
            return(true);
        }
        private async Task AddFormGalery()
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsPickPhotoSupported)
            {
                Toast.MakeText(this, "Brak uprawnień", ToastLength.Short).Show();
                return;
            }
            var file = await CrossMedia.Current.PickPhotoAsync();

            _file = new Java.IO.File(file.Path);
            _addFromGaleryDialog = new WinSelectDialog(this, "Dodaj z galeri", _activeCar?.WIN);
            _addFromGaleryDialog.SetButtonTitle("Dodaj");
            _addFromGaleryDialog.Build(_carRepository.GetAllCar().Select(x => x.WIN).ToArray(), AddFromGaleryOkAction);
            _addFromGaleryDialog.Show();
        }