public CoworkingDetailPage() { InitializeComponent(); localStorage = new LocalStorage(); //TODO: Refactor var cw = GlobalObjectsHelper.SelectedCoworking; var opt = GlobalObjectsHelper.CwSearchOptions; if (opt.BeginDate != null && opt.EndDate != null && opt.BeginWork != null && opt.BeginWork != null) { var freeSeats = new CoworkingsHelper().GetAvailableSeats(cw.Id, СorrectDate(opt.BeginDate.Value, opt.BeginWork.Value), СorrectDate(opt.EndDate.Value, opt.EndWork.Value)); var seatsCount = 0; if (freeSeats.Status == System.Net.HttpStatusCode.OK) { seatsCount = freeSeats.SeatsNum.Value; } GlobalObjectsHelper.SelectedCoworking.UpdateSeatsAvailable(seatsCount); } int count = cw.WorkingDays.Count; Hours1.ItemsSource = cw.WorkingDays.GetRange(0, Math.Min(WDAYS_COUNT, count)); if (cw.WorkingDays.Count > WDAYS_COUNT) { Hours2.ItemsSource = cw.WorkingDays.GetRange(WDAYS_COUNT, count - WDAYS_COUNT); } foreach (var amenty in cw.Amenties) { var imgSource = IconGetter.GetAmentyIcon(amenty.RawName); if (imgSource != null) { var stack = new StackLayout(); var label = new Label { Text = amenty.Name, TextColor = Color.Black }; var img = new AmentyImage { Source = ImageSource.FromFile(imgSource), WidthRequest = 50, HeightRequest = 50, Value = amenty.Description }; img.Clicked += OnAmenty; stack.Children.Add(img); stack.Children.Add(label); Amenties.Children.Add(stack); } } Task.Run(() => { LoadImages(cw); }); BindingContext = cw; }
public Android.Views.View GetInfoWindow(Marker marker) { int cnt = 0; var pin = GetMapPin(marker); if (pin == null) { return(null); } foreach (var amenty in pin.Amenties) { var imgSource = IconGetter.GetAmentyIcon(amenty); if (imgSource != null) { cnt++; } } var inflater = Android.App.Application.Context.GetSystemService(Context.LayoutInflaterService) as Android.Views.LayoutInflater; var view = inflater.Inflate(Resource.Layout.CoworkingWindowInfo, null); if (cnt != 0) { view = inflater.Inflate(Resource.Layout.CoworkingWindowInfoAmenty, null); } var infoTitle = view.FindViewById <TextView>(Resource.Id.InfoWindowTitle); var image = view.FindViewById <ImageView>(Resource.Id.CoworkingImage); var workTime = view.FindViewById <TextView>(Resource.Id.WorkTime); var distance = view.FindViewById <TextView>(Resource.Id.Distance); if (cnt != 0) { var amenties = view.FindViewById <LinearLayout>(Resource.Id.Linear); foreach (var amenty in pin.Amenties) { var imgSource = IconGetter.GetAmentyIcon(amenty); if (imgSource != null) { ImageView imageView = new ImageView(Context); imageView.SetPadding(0, 0, 0, 0); imageView.SetAdjustViewBounds(true); int id = (int)typeof(Resource.Drawable).GetField(imgSource.Replace(".png", "")).GetValue(null); imageView.SetImageBitmap(BitmapFactory.DecodeResource(Resources, id)); amenties.AddView(imageView); } } } if (pin.Cover != null) { var compressed = ImageResizer.ResizeImage(pin.Cover, 300, 170); var decodedString = Base64.Decode(compressed.Base64, Base64.Default); Bitmap decodedByte = BitmapFactory.DecodeByteArray(decodedString, 0, decodedString.Length); image.SetImageBitmap(decodedByte); } else { var bmp = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Noimage); image.SetImageBitmap(bmp); } workTime.Text = pin.Time; distance.Text = pin.Distance; infoTitle.Text = marker.Title; return(view); }