public override View GetSampleContent(Context context) { context1 = context; //carousel carousel = new SfCarousel(context1); List <SfCarouselItem> tempCollection = new List <SfCarouselItem>(); for (int i = 1; i <= 7; i++) { SfCarouselItem carouselItem = new SfCarouselItem(context1); carouselItem.ImageName = "images" + i; tempCollection.Add(carouselItem); } carousel.DataSource = tempCollection; carousel.SelectedIndex = 3; carousel.ScaleOffset = 0.8f; if (context1.Resources.DisplayMetrics.Density > 1.5) { carousel.ItemHeight = Convert.ToInt32(240 * context1.Resources.DisplayMetrics.Density); carousel.ItemWidth = Convert.ToInt32(170 * context1.Resources.DisplayMetrics.Density); } carousel.LayoutParameters = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent); return(carousel); }
public override Android.Views.View GetItemView(SfCarousel p0, int p1) { FrameLayout frameLayout = new FrameLayout(_context); SfCarouselItem sfCarouselItem = new SfCarouselItem(_context); ImageView imageView = new ImageView(_context); imageView.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(p0.ItemWidth, p0.ItemHeight); imageView.SetImageResource(_PicturesList[p1]); imageView.SetScaleType(ImageView.ScaleType.FitXy); frameLayout.AddView(imageView); return(frameLayout); }
private void AddCarouselItems() { AddCarouselContent(); for (int i = 0; i <= 6; i++) { var width = carousel.ItemWidth * 0.6; SfCarouselItem items = new SfCarouselItem(); UIStackView stackView = new UIStackView(); stackView.BackgroundColor = UIColor.White; stackView.Axis = UILayoutConstraintAxis.Horizontal; stackView.Frame = new CGRect(0, 0, carousel.ItemWidth, carousel.ItemHeight); stackView.Layer.CornerRadius = 10; stackView.Layer.BorderColor = UIColor.LightGray.CGColor; stackView.Layer.BorderWidth = 0.5f; UIStackView stackView1 = new UIStackView(); stackView1.Axis = UILayoutConstraintAxis.Vertical; stackView1.Frame = new CGRect(0, 0, width, carousel.ItemHeight); UILabel label1 = new UILabel(); label1.Text = headerList[i]; label1.Font = UIFont.SystemFontOfSize(14, UIFontWeight.Bold); label1.Frame = new CGRect(10, 5, width, carousel.ItemHeight * 0.25); stackView1.Add(label1); UILabel label = new UILabel(); label.Text = descriptionList[i]; label.Font = UIFont.SystemFontOfSize(10, UIFontWeight.Regular); label.Lines = 4; label.ContentMode = UIViewContentMode.TopLeft; label.LineBreakMode = UILineBreakMode.WordWrap | UILineBreakMode.TailTruncation; label.Frame = new CGRect(10, carousel.ItemHeight * 0.25, stackView1.Frame.Width - 10, carousel.ItemHeight * 0.75); stackView1.Add(label); UIImageView uiImageView = new UIImageView(); uiImageView.Image = UIImage.FromBundle(imageList[i]); uiImageView.Frame = new CGRect(width + 8, 10, carousel.ItemWidth * 0.4 - 16, carousel.ItemHeight - 20); uiImageView.Layer.CornerRadius = 7; uiImageView.Layer.BorderColor = UIColor.LightGray.CGColor; uiImageView.ClipsToBounds = true; stackView.Add(stackView1); stackView.Add(uiImageView); items.View = stackView; carouselItems.Add(items); } carousel.DataSource = carouselItems; }
public Carousel_Mobile() { viewModePicker = new UIPickerView(); PickerModel viewModel = new PickerModel(viewModeList); viewModePicker.Model = viewModel; viewModeLabel = new UILabel(); viewButton = new UIButton(); this.OptionView = new UIView(); NSMutableArray <SfCarouselItem> carouselItemCollection = new NSMutableArray <SfCarouselItem> (); carousel = new SfCarousel(); if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { carousel.Frame = new CGRect(150, 150, 300, 650); } else { carousel.Frame = new CGRect(0, 0, 300, 430); } carousel.ItemHeight = 300; carousel.ItemWidth = 150; carousel.SelectedItemOffset = 20; for (int i = 1; i <= 7; i++) { carouselItem = new SfCarouselItem(); carouselItem.ImageName = "image" + i + ".png"; carouselItemCollection.Add(carouselItem); } carousel.DataSource = carouselItemCollection; carousel.SelectedIndex = 2; this.AddSubview(carousel); offsetLabel = new UILabel(); scaleOffsetLabel = new UILabel(); rotationAngleLabel = new UILabel(); offsetLabel.Text = "OFFSET"; offsetLabel.TextColor = UIColor.Black; offsetLabel.TextAlignment = UITextAlignment.Left; offsetLabel.Font = UIFont.FromName("Helvetica", 14f); scaleOffsetLabel.Text = "SCALE OFFSET"; scaleOffsetLabel.TextColor = UIColor.Black; scaleOffsetLabel.TextAlignment = UITextAlignment.Left; scaleOffsetLabel.Font = UIFont.FromName("Helvetica", 14f); rotationAngleLabel.Text = "ROTATION ANGLE"; rotationAngleLabel.TextColor = UIColor.Black; rotationAngleLabel.TextAlignment = UITextAlignment.Left; rotationAngleLabel.Font = UIFont.FromName("Helvetica", 14f); offsetTextfield = new UITextView(); offsetTextfield.TextAlignment = UITextAlignment.Center; offsetTextfield.Layer.BorderColor = UIColor.Black.CGColor; offsetTextfield.KeyboardType = UIKeyboardType.NumberPad; offsetTextfield.BackgroundColor = UIColor.FromRGB(246, 246, 246); offsetTextfield.Text = "60"; offsetTextfield.Changed += (object sender, EventArgs e) => { if (offsetTextfield.Text.Length > 0) { carousel.Offset = nfloat.Parse(offsetTextfield.Text); } else { carousel.Offset = 60; } }; scaleOffsetTextfield = new UITextView(); scaleOffsetTextfield.TextAlignment = UITextAlignment.Center; scaleOffsetTextfield.Layer.BorderColor = UIColor.Black.CGColor; scaleOffsetTextfield.BackgroundColor = UIColor.FromRGB(246, 246, 246); scaleOffsetTextfield.KeyboardType = UIKeyboardType.NumberPad; scaleOffsetTextfield.Text = "0.8"; scaleOffsetTextfield.Changed += (object sender, EventArgs e) => { if (scaleOffsetTextfield.Text.Length > 0) { carousel.ScaleOffset = nfloat.Parse(scaleOffsetTextfield.Text); } else { carousel.ScaleOffset = (nfloat)0.8; } }; rotationAngleTextfield = new UITextView(); rotationAngleTextfield.TextAlignment = UITextAlignment.Center; rotationAngleTextfield.Layer.BorderColor = UIColor.Black.CGColor; rotationAngleTextfield.BackgroundColor = UIColor.FromRGB(246, 246, 246); rotationAngleTextfield.KeyboardType = UIKeyboardType.NumberPad; rotationAngleTextfield.Text = "45"; rotationAngleTextfield.Changed += (object sender, EventArgs e) => { if (rotationAngleTextfield.Text.Length > 0) { carousel.RotationAngle = int.Parse(rotationAngleTextfield.Text); } else { carousel.RotationAngle = 45; } }; //viewModeLabel viewModeLabel.Text = "VIEW MODE"; viewModeLabel.TextColor = UIColor.Black; viewModeLabel.TextAlignment = UITextAlignment.Left; //viewButton viewButton.SetTitle("Default", UIControlState.Normal); viewButton.SetTitleColor(UIColor.Black, UIControlState.Normal); viewButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; viewButton.Layer.CornerRadius = 8; viewButton.Layer.BorderWidth = 2; viewButton.TouchUpInside += ShowviewModePicker; viewButton.Layer.BorderColor = UIColor.FromRGB(246, 246, 246).CGColor; //viewDoneButton viewDoneButton.SetTitle("Done\t", UIControlState.Normal); viewDoneButton.SetTitleColor(UIColor.Black, UIControlState.Normal); viewDoneButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right; viewDoneButton.TouchUpInside += HidePicker; viewDoneButton.Hidden = true; viewDoneButton.BackgroundColor = UIColor.FromRGB(246, 246, 246); viewModel.PickerChanged += viewSelectedIndexChanged; viewModePicker.ShowSelectionIndicator = true; viewModePicker.Hidden = true; //viewModePicker.BackgroundColor = UIColor.Gray; }
void AddGridView() { InitializeChildGrid(); mainGrid = new FrameLayout(sampleContext); mainGrid.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); mainGrid.AddView(childGrid); maps = new SfMaps(sampleContext); maps.ZoomLevel = 4; maps.MinZoom = 4; maps.MaxZoom = 10; maps.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent); layer = new ImageryLayer(); layer.GeoCoordinates = new PointF(27.1751f, 78.0421f); PopulationMarker marker1 = new PopulationMarker(sampleContext); marker1.Latitude = 20.6843f; marker1.Longitude = -88.5678f; layer.Markers.Add(marker1); PopulationMarker marker2 = new PopulationMarker(sampleContext); marker2.Latitude = -13.1631f; marker2.Longitude = -72.5450f; layer.Markers.Add(marker2); PopulationMarker marker3 = new PopulationMarker(sampleContext); marker3.Latitude = -22.9519f; marker3.Longitude = -43.2106f; layer.Markers.Add(marker3); PopulationMarker marker4 = new PopulationMarker(sampleContext); marker4.Latitude = 41.8902; marker4.Longitude = 12.4922; layer.Markers.Add(marker4); PopulationMarker marker5 = new PopulationMarker(sampleContext); marker5.Latitude = 30.3285; marker5.Longitude = 35.4444; layer.Markers.Add(marker5); PopulationMarker marker6 = new PopulationMarker(sampleContext); marker6.Latitude = 27.1751; marker6.Longitude = 78.0421; layer.Markers.Add(marker6); PopulationMarker marker7 = new PopulationMarker(sampleContext); marker7.Latitude = 40.4319; marker7.Longitude = 116.5704; layer.Markers.Add(marker7); maps.Adapter = new MarkerAdapter(sampleContext); maps.Layers.Add(layer); mainGrid.AddView(maps); mainGrid.SetClipChildren(false); List <int> arrayList = new List <int>(); arrayList.Add(Resource.Drawable.Mexico); arrayList.Add(Resource.Drawable.Peru); arrayList.Add(Resource.Drawable.Christ); arrayList.Add(Resource.Drawable.Colosseum); arrayList.Add(Resource.Drawable.Petra); arrayList.Add(Resource.Drawable.TajMahal); arrayList.Add(Resource.Drawable.China_wall); List <string> descriptionList = new List <string>(); descriptionList.Add("Mayan ruins on Mexico's Yucatan Peninsula. It was one of the largest Maya cities, thriving from around A.D. 600 to 1200."); descriptionList.Add("An inca citadel built in the mid-1400s. It was not widely known until the early 20th century."); descriptionList.Add("An enormous statue of Jesus Christ with open arms. A symbol of Christianity across the world, the statue has also become a cultural icon of both Rio de Janeiro and Brazil."); descriptionList.Add("Built between A.D. 70 and 80. It is one of the most popular touristattractions in Europe."); descriptionList.Add("It is a historic and archaeological city in southern Jordan. Petra lies around Jabal Al-Madbah in a basin surrounded by mountains which form the eastern flank of the Arabah valley that runs from the Dead Sea to the Gulf of Aqaba."); descriptionList.Add("It is an ivory-white marble mausoleum on the southern bank of the river Yamuna in the Indian city of Agra."); descriptionList.Add("The Great Wall of China is a series of fortifications that were built across the historical northern borders of ancient Chinese states and Imperial China as protection against various nomadic groups from the Eurasian Steppe."); List <string> headerList = new List <string>(); headerList.Add("Chichen Itza, Mexico"); headerList.Add("Machu Picchu, Peru"); headerList.Add("Chirst the Redeemer, Brazil"); headerList.Add("Colosseum, Rome"); headerList.Add("Petra, Jordan"); headerList.Add("Taj Mahal, India"); headerList.Add("Great wall of China, China"); DisplayMetrics displayMetrics = sampleContext.Resources.DisplayMetrics; float screenWidth = displayMetrics.WidthPixels; float screenHeight = displayMetrics.HeightPixels; var density = displayMetrics.Density; LinearLayout layout = new LinearLayout(sampleContext); layout.Orientation = Orientation.Horizontal; layout.SetPadding(0, 0, 0, 10); layout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); layout.SetVerticalGravity(GravityFlags.Bottom); var itemWidth = screenWidth * 0.7; SfCarousel carousel = new SfCarousel(sampleContext); carousel.RotationAngle = 0; carousel.ItemWidth = (int)itemWidth; carousel.ItemHeight = (int)(110 * sampleContext.Resources.DisplayMetrics.Density); carousel.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, carousel.ItemHeight); carousel.SelectedIndex = 5; carousel.SelectedItemOffset = (int)(carousel.ItemWidth / 2) - (int)(carouselGap * density); List <SfCarouselItem> dataSource = new List <SfCarouselItem>(); for (int i = 0; i <= 6; i++) { LinearLayout linearLayout = new LinearLayout(sampleContext); linearLayout.SetBackgroundColor(Color.White); linearLayout.Orientation = Orientation.Horizontal; linearLayout.SetBackgroundResource((Resource.Drawable.carousel_corner_radius)); linearLayout.LayoutParameters = new Android.Views.ViewGroup.LayoutParams((int)itemWidth, (int)carousel.ItemHeight); var width = (int)(0.6f * itemWidth); LinearLayout layout1 = new LinearLayout(sampleContext); layout1.Orientation = Orientation.Vertical; layout1.LayoutParameters = new Android.Views.ViewGroup.LayoutParams((int)width, (int)carousel.ItemHeight); layout1.SetPadding(15, 15, 15, 15); TextView textView = new TextView(sampleContext); textView.Text = headerList[i]; textView.SetTypeface(Typeface.Default, TypefaceStyle.Bold); textView.TextAlignment = TextAlignment.TextStart; textView.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(width - 30, ViewGroup.LayoutParams.WrapContent); layout1.AddView(textView); textView = new TextView(sampleContext); textView.Text = descriptionList[i]; textView.SetMaxLines(3); textView.Ellipsize = Android.Text.TextUtils.TruncateAt.End; textView.TextAlignment = TextAlignment.TextStart; textView.SetPadding(0, 10, 0, 0); textView.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(width - 30, ViewGroup.LayoutParams.WrapContent); layout1.AddView(textView); linearLayout.AddView(layout1); SfCarouselItem sfCarouselItem = new SfCarouselItem(sampleContext); width = (int)(0.4f * itemWidth); LinearLayout layout2 = new LinearLayout(sampleContext); layout2.SetPadding(10, 15, 15, 15); layout2.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(width, carousel.ItemHeight); ImageView imageView = new ImageView(sampleContext); imageView.SetBackgroundResource((Resource.Drawable.carousel_corner_radius)); imageView.SetImageResource(arrayList[i]); imageView.SetScaleType(ImageView.ScaleType.FitXy); imageView.ClipToOutline = true; layout2.AddView(imageView); linearLayout.AddView(layout2); sfCarouselItem.ContentView = linearLayout; dataSource.Add(sfCarouselItem); } carousel.DataSource = dataSource; carousel.SelectionChanged += Carousel_SelectionChanged; layout.AddView(carousel); mainGrid.AddView(layout); LinearLayout linear = new LinearLayout(sampleContext); linear.Orientation = Orientation.Horizontal; linear.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); linear.SetHorizontalGravity(GravityFlags.End); linear.SetVerticalGravity(GravityFlags.Bottom); TextView textView1 = new TextView(sampleContext); textView1.Text = "©"; textView1.SetBackgroundColor(Color.White); textView1.SetTextColor(Color.Black); textView1.SetPadding(2, 2, 2, 2); linear.AddView(textView1); TextView textView2 = new TextView(sampleContext); textView2.Text = "OpenStreetMap contributors."; textView2.SetTextColor(Color.DeepSkyBlue); textView2.SetPadding(0, 2, 3, 2); textView2.SetBackgroundColor(Color.White); textView2.Clickable = true; textView2.Click += TextView2_Click; linear.AddView(textView2); mainGrid.AddView(linear); }