public void Load(FoodMarker marker)
        {
            nfloat imageHeight = 130;
            var    imageMeta   = marker.FoodMarkerPhotos.Where(p => p.ImageRank == 1).First();

            if (marker.FoodMarkerPhotos.Where(p => p.ImageRank == 2).Any())
            {
                imageMeta = marker.FoodMarkerPhotos.Where(p => p.ImageRank == 2).First();
            }

            UIImage uiImage;

            using (var url = new NSUrl(imageMeta.ImageUrl))
            {
                using (var data = NSData.FromUrl(url))
                {
                    uiImage = UIImage.LoadFromData(data);
                }
            }
            _image.Image = uiImage;

            _image.Frame = new CGRect(
                0,
                5f,
                ControlProps.Width,
                imageHeight
                );
            _image.ContentMode        = UIViewContentMode.ScaleAspectFill;
            _image.Center             = new CGPoint(ContainingView.Center.X, _image.Center.Y);
            _image.ClipsToBounds      = true;
            _image.Layer.CornerRadius = 15f;


            Configuration.TintColor = UIColor.Yellow;
            var gallery = new AlbumViewController()
            {
                LazyDataSource = (view, size, mediaTypes) =>
                                 new LocalFilesDataSource(view, size, mediaTypes)
                {
                    ImagesPath = (new FoodMarkerImageDirectory()).GetDir()
                },
                LazyDelegate = (view, source) => new LocalFilesDelegate(view, (LocalFilesDataSource)source)
            };

            var gestureRec = new UITapGestureRecognizer(() =>
            {
                _controller.PresentViewController(gallery, true, null);
            });

            gestureRec.CancelsTouchesInView = false;
            _image.AddGestureRecognizer(gestureRec);
            _image.UserInteractionEnabled = true;

            View.Frame = new CGRect(
                0,
                _parentContainer.View.Frame.GetMaxY(),
                ContainingView.Frame.Width,
                imageHeight + 10f
                );
        }
        public async Task <bool> SaveFoodMarker(FoodMarker foodMarker,
                                                double lat,
                                                double lng)
        {
            var addressRet = await _extRestService.GetRestaurantAddressGeocode(lat, lng);

            if (!addressRet.IsSuccess)
            {
                return(false);
            }
            string address = addressRet.Obj;

            foodMarker.RestaurantAddress  = address;
            foodMarker.RestaurantPosition = $"POINT({lng} {lat})";

            var _validator = new FoodMarkerValidator(foodMarker);

            if (!_validator.Validate())
            {
                return(false);
            }

            var ret = await _restService.PostFoodMarker(foodMarker);

            if (!ret.IsSuccess)
            {
                _tokenPersistance.RemoveToken(WebApiCred.KeyChainTokenKey);
                OnFail(ret, new EventArgs());
                return(false);
            }
            foodMarker.FoodMarkerId = ret.Obj.Id;

            return(true);
        }
        public void Load(FoodMarker marker)
        {
            _categoryName.Text          = marker.CategoryName;
            _categoryName.TextColor     = ControlProps.UIColors.Gray;
            _categoryName.Font          = UIFont.FromName("Helvetica", 14f);
            _categoryName.TextAlignment = UITextAlignment.Center;
            _categoryName.LineBreakMode = UILineBreakMode.WordWrap;
            _categoryName.Lines         = 0;
            _categoryName.Frame         = new CGRect(0, 5f, ControlProps.Width, 0);
            LabelSizeCalculator.SetCenterAndHeightBasedOnText(ContainingView, _categoryName);

            _restaurantAddress.Text          = marker.RestaurantAddress;
            _restaurantAddress.TextColor     = ControlProps.UIColors.Gray;
            _restaurantAddress.Font          = UIFont.FromName("Helvetica", 14f);
            _restaurantAddress.TextAlignment = UITextAlignment.Center;
            _restaurantAddress.LineBreakMode = UILineBreakMode.WordWrap;
            _restaurantAddress.Lines         = 0;
            _restaurantAddress.Frame         = new CGRect(0, _categoryName.Frame.GetMaxY() + 10f, ControlProps.Width, 0);
            LabelSizeCalculator.SetCenterAndHeightBasedOnText(ContainingView, _restaurantAddress);

            View.BackgroundColor = ControlProps.UIColors.Brown;
            View.Frame           = new CGRect(
                0,
                _parentContainer.View.Frame.GetMaxY(),
                ContainingView.Frame.Width,
                _categoryName.Frame.Height + _restaurantAddress.Frame.Height + 20f
                );
        }
        public void Load(FoodMarker marker)
        {
            _image.Image = UIImage.FromBundle("TrashButton");
            var gestureRec = new UITapGestureRecognizer(async() =>
            {
                if (OnDelete != null)
                {
                    await OnDelete(marker.FoodMarkerId);
                }
            });

            gestureRec.CancelsTouchesInView = false;
            _image.AddGestureRecognizer(gestureRec);
            _image.UserInteractionEnabled = true;

            _image.Frame = new CGRect(
                0,
                15f,
                40f,
                40f
                );

            _image.Center = new CGPoint(ContainingView.Center.X, _image.Center.Y);

            View.Frame = new CGRect(
                0,
                _parentContainer.View.Frame.GetMaxY(),
                ContainingView.Frame.Width,
                60f
                );
        }
示例#5
0
        public FoodMarkerPhotosFileSystemService(FoodMarker marker)
        {
            IDirectory directory = new FoodMarkerImageDirectory();

            _marker          = marker;
            _directoryAccess = new DirectoryAccess(directory);
            _path            = directory.GetDir();
        }
示例#6
0
        private void NewFoodMarkerOnLoad(object sender, EventArgs e)
        {
            FoodMarker           newMarker         = (FoodMarker)sender;
            AnnotationService    annotationService = new AnnotationService();
            FoodMarkerAnnotation annotation        = annotationService.LoadAnnotations(newMarker);

            _foodMarkerAnnotationDict.Add(newMarker.FoodMarkerId, annotation);
            MapView.AddAnnotation(annotation);
        }
示例#7
0
 public IEnumerable<FoodMarker> GetFoodMarkers()
 {
     List<FoodMarker> retLst = new List<FoodMarker>();
     IEnumerable<FoodMarkerDTO> foodMarkersDto = _repo.GetFoodMarkers();
     foreach (FoodMarkerDTO foodMarkerDto in foodMarkersDto)
     {
         FoodMarker foodMarker = _mapper.Map<FoodMarker>(foodMarkerDto);
         retLst.Add(foodMarker);
     }
     return retLst;
 }
示例#8
0
        public int Post([FromBody] FoodMarkerClient reqObj)
        {
            if (reqObj == null)
            {
                BadRequest();
            }

            FoodMarker foodMarker = _mapper.Map <FoodMarker>(reqObj);

            return(_service.PostFoodMarker(foodMarker));
        }
        public void PopulateBottomSheetWithFoodMarkerData(FoodMarker foodMarker)
        {
            if (m_FoodMarkerItem.HasValue)
            {
                if (m_FoodMarkerItem == foodMarker.FoodMarkerId)
                {
                    return;
                }
            }

            _foodMarker = foodMarker;

            SetUI();
            ShowBottomSheetFromBelow();
        }
        public FoodMarkerAnnotation LoadAnnotations(FoodMarker marker)
        {
            FoodMarkerAnnotation annotation = new FoodMarkerAnnotation(marker);

            annotation.imgFileName = marker.FoodMarkerId.ToString();

            UIImage uiImage;

            if (marker.FoodMarkerPhotos != null &&
                marker.FoodMarkerPhotos.Where(p => p.ImageRank == 1).Any())
            {
                var iconImage = marker.FoodMarkerPhotos.Where(p => p.ImageRank == 1).First();

                using (var url = new NSUrl(iconImage.ImageUrl))
                {
                    using (var data = NSData.FromUrl(url))
                    {
                        if (data != null)
                        {
                            uiImage = UIImage.LoadFromData(data);
                        }
                        else
                        {
                            uiImage = UIImage.FromBundle("DataBox");
                        }
                    }
                }
            }
            else
            {
                uiImage = UIImage.FromBundle("DataBox");
            }

            uiImage = uiImage.Scale(new CGSize(MapSettings.AnnotationSize.Width,
                                               MapSettings.AnnotationSize.Height));

            using (NSData data = uiImage.AsPNG())
            {
                byte[] buffer = new byte[data.Length];
                System.Runtime.InteropServices.Marshal.Copy(data.Bytes, buffer, 0, Convert.ToInt32(data.Length));
                _directoryAccess.UploadFile(buffer, annotation.imgFileName);
            }

            return(annotation);
        }
        public void Load(FoodMarker marker)
        {
            _comment.Text          = marker.Comment;
            _comment.TextColor     = ControlProps.UIColors.Black;
            _comment.Font          = UIFont.PreferredBody;
            _comment.TextAlignment = UITextAlignment.Center;
            _comment.LineBreakMode = UILineBreakMode.WordWrap;
            _comment.Lines         = 0;
            _comment.Frame         = new CGRect(0, 5f, ControlProps.Width, 0);
            LabelSizeCalculator.SetCenterAndHeightBasedOnText(ContainingView, _comment);

            View.BackgroundColor = ControlProps.UIColors.Yellow;
            View.Frame           = new CGRect(
                0,
                _parentContainer.View.Frame.GetMaxY(),
                ContainingView.Frame.Width,
                _comment.Frame.Height + 10f
                );
        }
        public void Load(FoodMarker marker)
        {
            _rating.ItemCount                    = 5;
            _rating.Precision                    = SFRatingPrecision.Standard;
            _rating.TooltipPlacement             = SFRatingTooltipPlacement.None;
            _rating.RatingSettings.UnRatedStroke = ControlProps.UIColors.White;
            _rating.Readonly = true;
            _rating.Frame    = new CGRect(0, 5f, 92, 20);
            _rating.Center   = new CGPoint(ContainingView.Center.X, _rating.Center.Y);
            _rating.ItemSize = 15;
            _rating.Value    = (nfloat)marker.Rating;

            View.BackgroundColor = ControlProps.UIColors.Pink;
            View.Frame           = new CGRect(
                0,
                _parentContainer.View.Frame.GetMaxY(),
                ContainingView.Frame.Width,
                25
                );
        }
示例#13
0
        public async Task <IActionResult> CreateFoodMarker(FoodMarkerClient reqObj)
        {
            if (reqObj == null)
            {
                BadRequest();
            }

            JSONRetObj <int?> retObj = new JSONRetObj <int?>();

            try
            {
                retObj.IsSuccess = true;
                FoodMarker    foodMarker    = Mapper.Map <FoodMarker>(reqObj);
                FoodMarkerDTO foodMarkerDto = Mapper.Map <FoodMarkerDTO>(foodMarker);
                int           foodMarkerId  = _repoFoodMarker.Post(foodMarkerDto);

                foreach (var file in Request.Form.Files)
                {
                    FoodMarkerImageData postImageMeta = new FoodMarkerImageData(foodMarkerId, file.FileName);

                    var postImageMetaDto = Mapper.Map <FoodMarkerImageDataDTO>(postImageMeta);

                    postImageMeta.Id = postImageMetaDto.Id = _repoImageMeta.Post(postImageMetaDto);

                    Stream stream = file.OpenReadStream();
                    await _repoImageFile.PostFile(postImageMetaDto, file.ContentType, stream);
                }

                retObj.ResponseObj = foodMarkerId;
            }
            catch (Exception ex)
            {
                retObj.IsSuccess = false;
                retObj.Message   = ex.Message;
            }

            ViewData["RetObj"] = retObj;

            return(View("_Success"));
        }
        public void Load(FoodMarker marker)
        {
            _restaurantName.Text          = marker.RestaurantName;
            _restaurantName.TextColor     = ControlProps.UIColors.Black;
            _restaurantName.Font          = UIFont.FromName("Menlo-BoldItalic", 16f);
            _restaurantName.TextAlignment = UITextAlignment.Center;
            _restaurantName.LineBreakMode = UILineBreakMode.WordWrap;
            _restaurantName.Lines         = 0;
            _restaurantName.Frame         = new CGRect(
                0,
                0,
                ControlProps.Width,
                0
                );
            LabelSizeCalculator.SetCenterAndHeightBasedOnText(ContainingView, _restaurantName);

            View.Frame = new CGRect(
                0,
                _parentContainer.View.Frame.GetMaxY(),
                ContainingView.Frame.Width,
                _restaurantName.Frame.Height + 10f
                );
        }
        public void Load(FoodMarker marker)
        {
            _fromText.Text          = "from";
            _fromText.TextColor     = ControlProps.UIColors.Black;
            _fromText.Font          = UIFont.FromName("Helvetica-BoldOblique", 12f);
            _fromText.TextAlignment = UITextAlignment.Center;
            _fromText.LineBreakMode = UILineBreakMode.WordWrap;
            _fromText.Lines         = 0;
            _fromText.Frame         = new CGRect(
                0,
                0,
                ControlProps.Width,
                0
                );
            LabelSizeCalculator.SetCenterAndHeightBasedOnText(ContainingView, _fromText);

            View.Frame = new CGRect(
                0,
                _parentContainer.View.Frame.GetMaxY(),
                ContainingView.Frame.Width,
                _fromText.Frame.Height + 10f
                );
        }
示例#16
0
        public FoodMarkerClient Get(int id)
        {
            FoodMarker foodMarker = _service.GetFoodMarker(id);

            return(_mapper.Map <FoodMarkerClient>(foodMarker));
        }
示例#17
0
        private async void OkButtonPressed()
        {
            PostFoodMarkerOkButton.Hidden = true;
            PostFoodMarkerOkButton.Image  = UIImage.FromBundle("CheckButtonPressed");
            _activityIndicatorView.StartAnimating();
            try
            {
                var images = _mediaPickerService.GetMediaFromPending();
                if (images == null || images.Count == 0)
                {
                    NotCorrect();
                    return;
                }
                var foodMarker = new FoodMarker()
                {
                    FoodName       = PostFoodMarkerName.Text,
                    CategoryName   = PostFoodMarkerCategory.Text,
                    Comment        = PostFoodMarkerComment.Text,
                    RestaurantName = PostFoodMarkerRestaurant.Text
                };

                string rating = PostFoodMarkerRating.Text;
                foodMarker.Rating = (String.IsNullOrWhiteSpace(rating)? -1 : Convert.ToInt32(rating));


                double            lat     = _locationManager.Location.Coordinate.Latitude;
                double            lng     = _locationManager.Location.Coordinate.Longitude;
                FoodMarkerService service = new FoodMarkerService();

                bool isSaved = await service.SaveFoodMarker(foodMarker, lat, lng);

                if (!isSaved)
                {
                    NotCorrect();
                    return;
                }

                if (images != null && images.Count != 0)
                {
                    var imageMetas = await service.SavePhotos(foodMarker.FoodMarkerId, _mediaPickerService.GetMediaFromPending());

                    foodMarker.FoodMarkerPhotos = imageMetas;
                    _mediaPickerService.ClearPending();
                }

                if (OnSaveSuccess != null)
                {
                    OnSaveSuccess((object)foodMarker, new EventArgs());
                }
                CloseButtonPressed();
            }
            catch
            {
                _activityIndicatorView.StopAnimating();
                UIImageView errorView = new UIImageView();
                errorView.Image = UIImage.FromBundle("ErrorScreen");
                double side = (View.Frame.Width * 2.0 / 3.0);
                errorView.Frame  = new CoreGraphics.CGRect(0, 0, side, side);
                errorView.Center = View.Center;
                View.AddSubview(errorView);
                View.BringSubviewToFront(errorView);
                NSTimer.CreateScheduledTimer(3.0, delegate
                {
                    errorView.RemoveFromSuperview();
                });
                PostFoodMarkerOkButton.Hidden = false;
            }
        }
示例#18
0
 public int PostFoodMarker(FoodMarker foodMarker)
 {
     FoodMarkerDTO foodMarkerDTO = _mapper.Map<FoodMarkerDTO>(foodMarker);
     int id = _repo.Post(foodMarkerDTO);
     return id;
 }
示例#19
0
 public FoodMarker GetFoodMarker(int id)
 {
     FoodMarkerDTO foodMarkerDto = _repo.GetFoodMarker(id);
     FoodMarker foodMarker = _mapper.Map<FoodMarker>(foodMarkerDto);
     return foodMarker;
 }
 public void Load(FoodMarker marker)
 {
     View.Frame = new CGRect(0, 0, ContainingView.Frame.Width, 0);
 }