void CreateNewPickerDialog() { CustomPicker view = _element; _dialog = new PicturePickerDialog(Context, (o, e) => { //Clear focus when it is destroyed Control.ClearFocus(); //Set to null after clearing focus _dialog = null; }); _dialog.SetListViewItems((name) => { view.SelectedItem = name; _dialog.Dismiss(); }); _dialog.SetCancelButton("Cancel", (s, o) => { _dialog.Dismiss(); }); _dialog.SetPickerTitle(view.Title); }
/// <summary> /// Người dùng chọn option mong muốn tìm kiếm, khi khởi tạo thì chọn mặc định là tìm quanh tôi /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Picker_SelectedIndexChanged(object sender, EventArgs e) { picker = sender as CustomPicker; if (picker.SelectedIndex == 0) { if (firstApper == false) { model.clubSearch.isFreshing = false; model.clubSearch.ListClub.Clear(); model?.LoadObject(1, 25000); Device.StartTimer(TimeSpan.FromMilliseconds(300), () => { Task.Run(() => { model.clubSearch.isFreshing = false; }); return(false); }); } MySearch.Placeholder = "Đang tìm kiếm quanh 50km"; MySearch.PlaceholderColor = Color.Gray; MySearch.Text = ""; MySearch.IsEnabled = false; nearSearch.IsVisible = true; lvAutoComplete.IsVisible = false; } else { nearSearch.IsVisible = false; lvAutoComplete.IsVisible = true; MySearch.Placeholder = "Điền Xã/Phường, Quận/Huyện, Tỉnh/Thành Phố"; MySearch.PlaceholderColor = Color.Gray; MySearch.IsEnabled = true; } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); element = (CustomPicker)this.Element; if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Icon)) { Control.Background = AddPickerStyles(element.Icon); //Control.SetHintTextColor(Android.Graphics.Color.#533f95); } try { if (!string.IsNullOrEmpty(e.NewElement?.FontFamily)) { if (e.NewElement?.FontFamily == "Raleway-ExtraBold") { var font = Typeface.CreateFromAsset(Android.App.Application.Context.ApplicationContext.Assets, e.NewElement.FontFamily + ".ttf"); Control.Typeface = font; } else { var font = Typeface.CreateFromAsset(Android.App.Application.Context.ApplicationContext.Assets, e.NewElement.FontFamily + ".otf"); Control.Typeface = font; } } } catch (System.Exception) { } }
private void SetTextAlignment(CustomPicker picker) { if (picker == null) { return; } if (picker.TextAlignment == PickerTextAlignment.Left) { Control.TextAlignment = UITextAlignment.Left; } if (picker.TextAlignment == PickerTextAlignment.Center) { Control.TextAlignment = UITextAlignment.Center; } if (picker.TextAlignment == PickerTextAlignment.Right) { Control.TextAlignment = UITextAlignment.Right; } if (picker.TextAlignment == PickerTextAlignment.Justified) { Control.TextAlignment = UITextAlignment.Justified; } if (picker.TextAlignment == PickerTextAlignment.Natural) { Control.TextAlignment = UITextAlignment.Natural; } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); element = (CustomPicker)this.Element; /*if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image)) * Control.Background = AddPickerStyles(element.Image);*/ // creating gradient drawable for the curved background var _gradientBackground = new GradientDrawable(); _gradientBackground.SetShape(ShapeType.Rectangle); _gradientBackground.SetColor(Android.Graphics.Color.Transparent.ToArgb()); // Thickness of the stroke line _gradientBackground.SetStroke(2, Android.Graphics.Color.Green); // Radius for the curves /* _gradientBackground.SetCornerRadius( * DpToPixels(this.Context, Convert.ToSingle(0)));*/ // set the background of the Control.SetBackground(_gradientBackground); }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); element = (CustomPicker)this.Element; if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image)) { Control.Background = AddPickerStyles(element.Image); } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); try { CustomPicker element = Element as CustomPicker; if (e.NewElement != null) { element = Element as CustomPicker; } else { element = e.OldElement as CustomPicker; } if (Control != null) { //var element = Element as CustomPicker; var textGiven = element.EnterText; Control.BorderStyle = UITextBorderStyle.Line; Control.Layer.CornerRadius = 0; Control.ExclusiveTouch = true; //Control.AttributedPlaceholder = new NSAttributedString(element.Title, null, UIColor.Black); if (!string.IsNullOrWhiteSpace(textGiven)) { Control.Text = textGiven; } Control.TextColor = UIColor.Black; Control.AdjustsFontSizeToFitWidth = true; Control.TintColor = UIColor.Black; Control.AttributedPlaceholder = new Foundation.NSAttributedString(Control.AttributedPlaceholder.Value, foregroundColor: UIColor.Black); if (element.CustomFontFamily == "Avenir65") { Control.Font = UIFont.FromName("AvenirLTStd-Medium.ttf", 18f); } else if (element.CustomFontFamily == "Avenir45") { Control.Font = UIFont.FromName("AvenirLTStd-Book.ttf", 18f); } else { } if (element.CustomFontSize != 0) { UIFont font = Control.Font.WithSize(element.CustomFontSize); Control.Font = font; } else { } } } catch (Exception ex) { var msg = ex.Message; } }
private void languagePicker_SelectedIndexChanged(object sender, System.EventArgs e) { try{ CustomPicker picker = sender as CustomPicker; var selectedItem = picker.SelectedItem; } catch (Exception ex) { } }
public View UpdateAttributesUI(ComosWebSDK.UI.UIOptions ui) { StackLayout stack = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, }; if (!ui.ReadOnly) { editablevalues.Add(ui); } AbsoluteLayout.SetLayoutBounds(stack, new Rectangle( ui.x, ui.y, ui.width, ui.height)); stack.Children.Add(new Label() { Text = ui.Text, WidthRequest = App.WidthPixels / 3, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Start, }); CustomPicker p = new CustomPicker() { HorizontalOptions = LayoutOptions.FillAndExpand, IsEnabled = !ui.ReadOnly, }; foreach (var c in ui.Options.Keys) { p.Items.Add(c); } p.BindingContext = ui; if (ui.CachedValue != "" && ui.CachedValue != ui.Value) { p.SelectedItem = ui.CachedValue; p.TextColor = (Color)App.Current.Resources["spec-only-cache"]; CheckValue(ui.NestedName, ui.CachedValue, ui.Value); } else { p.SelectedItem = ui.Value; } p.SelectedIndexChanged += PickerSelectionChanged; stack.Children.Add(p); return(stack); }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); try { CustomPicker element = Element as CustomPicker; if (e.NewElement != null) { element = Element as CustomPicker; } else { element = e.OldElement as CustomPicker; } if (Control != null) { GradientDrawable gd = new GradientDrawable(); //gd.SetCornerRadius(45); // increase or decrease to changes the corner look gd.SetColor(global::Android.Graphics.Color.Transparent); //gd.SetStroke(2, global::Android.Graphics.Color.Gray); this.Control.SetBackgroundDrawable(gd); this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions); //Control.Text = element.EnterText; Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black)); //for placeholder //this.Control.InputType = InputTypes.TextVariationPassword; if (element.CustomFontSize != 0.0) { Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize); //Control.SetTextSize(Android.Util.ComplexUnitType.Dip, element.CustomFontSize); } if (element.CustomFontFamily == "MontserratBold") { Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Bold.ttf"); Control.Typeface = font; } else if (element.CustomFontFamily == "MontserratLight") { Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Light.ttf"); Control.Typeface = font; } else { Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Regular.ttf"); Control.Typeface = font; } } } catch (Exception ex) { var msg = ex.Message; } }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); try { CustomPicker element = Element as CustomPicker; if (Control != null) { //var element = Element as CustomPicker; var textGiven = element.EnterText; Control.BorderStyle = UITextBorderStyle.None; Control.Layer.CornerRadius = 10; Control.ExclusiveTouch = true; //Control.AttributedPlaceholder = new NSAttributedString(element.Title, null, UIColor.Black); if (!string.IsNullOrWhiteSpace(textGiven)) { //Control.Text = textGiven; } Control.TextColor = UIColor.Black; Control.AdjustsFontSizeToFitWidth = true; Control.TintColor = UIColor.Black; Control.AttributedPlaceholder = new Foundation.NSAttributedString(Control.AttributedPlaceholder.Value, foregroundColor: UIColor.Black); var fSize = (element.CustomFontSize == 0) ? 20.0f : ((nfloat)(element.CustomFontSize)); if (element.CustomFontFamily == "MontserratBold") { Control.Font = UIFont.FromName("Montserrat-Bold", fSize); } else if (element.CustomFontFamily == "MontserratLight") { Control.Font = UIFont.FromName("Montserrat-Light", fSize); } else { Control.Font = UIFont.FromName("Montserrat-Regular", fSize); } /* * if (element.CustomFontSize != 0) * { * UIFont font = Control.Font.WithSize(element.CustomFontSize); * Control.Font = font; * } * else * { * } */ } } catch (Exception ex) { var msg = ex.Message; } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); element = (CustomPicker)this.Element; if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Icon)) { Control.Background = AddPickerStyles(element.Icon); Control.SetHintTextColor(Android.Graphics.Color.Gray); } }
void UpdatePickerPlaceholder() { if (picker == null) { picker = Element as CustomPicker; } if (picker.Placeholder != null) { Control.Hint = picker.Placeholder; } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); element = (CustomPicker)this.Element; if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image)) { Control.Background = AddPickerStyles(element.Image); } Control.Background = new ColorDrawable(Android.Graphics.Color.Transparent); }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (Control != null) { picker = (CustomPicker)e.NewElement; //Indexes of priority items starts at 0. Values of priority items starts at 1. //SetSelection get value of item but sets index of item. Control.SelectedIndex = Int32.Parse(picker.PickerValue) - 1; } }
// Setta il FONT_SIZE private void SetFont(CustomPicker picker) { UIFont uiFont; if (picker.Font != Font.Default && (uiFont = picker.Font.ToUIFont()) != null) { Control.Font = uiFont; } else if (picker.Font == Font.Default) { Control.Font = UIFont.SystemFontOfSize(17f); } }
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (e.NewElement != null) { picker = Element as CustomPicker; UpdatePickerPlaceholder(); if (picker.SelectedIndex <= -1) { UpdatePickerPlaceholder(); } } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (e.OldElement == null) { if (e.NewElement != null) { element = (CustomPicker)Element; if (!string.IsNullOrEmpty(element.Image)) { switch (element.ImageAlignment) { case ImageAlignmentEnum.Left: Control.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.Image), null, null, null); break; case ImageAlignmentEnum.Right: Control.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null); break; } } //Control.CompoundDrawablePadding = 25; //Control.Background.SetColorFilter(element.LineColor.ToAndroid(), PorterDuff.Mode.SrcAtop); if (element.IsCurvedCornersEnabled) { // creating gradient drawable for the curved background var _gradientBackground = new GradientDrawable(); _gradientBackground.SetShape(ShapeType.Rectangle); _gradientBackground.SetColor(element.BackgroundColor.ToAndroid()); // Thickness of the stroke line _gradientBackground.SetStroke(element.BorderWidth, element.BorderColor.ToAndroid()); // Radius for the curves _gradientBackground.SetCornerRadius( DpToPixels(this.Context, Convert.ToSingle(element.CornerRadius))); // set the background of the Control.SetBackground(_gradientBackground); } // Set padding for the internal text from border Control.SetPadding( (int)DpToPixels(this.Context, Convert.ToSingle(12)), Control.PaddingTop, (int)DpToPixels(this.Context, Convert.ToSingle(12)), Control.PaddingBottom); } } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); try { element = Element as CustomPicker; System.Diagnostics.Debug.WriteLine("Current Page is " + this.GetType().ToString() + " : " + e.PropertyName); UpdateElementWithChanges(); } catch (Exception ex) { var msg = ex.Message; } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (Element != null && Control != null) { Control.SetBackgroundResource(Shared.Core.Resource.Drawable.border); CustomPicker picker = (CustomPicker)Element; Control.SetTextColor(picker.TextColor.ToAndroid()); } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (Control != null) { Control.BackgroundColor = UIKit.UIColor.Clear; } if (Element != null) { _customPicker = (CustomPicker)Element; _customPicker.IsValidChanged += OnIsValidChanged; } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); element = (CustomPicker)this.Element; if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image)) { Control.Background = AddPickerStyles(element.Image); } Control.Background = Android.App.Application.Context.GetDrawable(Resource.Drawable.rounded_corners); Control.Gravity = GravityFlags.CenterVertical; Control.SetPadding(10, 0, 0, 0); Control.TextSize = 18; }
public override void Draw(Canvas canvas) { CustomPicker customEntry = (CustomPicker)this.Element; // Create path to clip var path = new Path(); path.AddRoundRect(0, 0, Width, Height, DpToPixels(this.Context, Convert.ToSingle(customEntry.CornerRadius)), DpToPixels(this.Context, Convert.ToSingle(customEntry.CornerRadius)), Path.Direction.Ccw); canvas.Save(); canvas.ClipPath(path); base.Draw(canvas); }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (Control == null) { return; } CustomPicker picker = (CustomPicker)Element; if (e.PropertyName == CustomPicker.TextColorProperty.PropertyName) { SetTextColor(picker); } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (this.Control == null || e.NewElement == null) { return; } if (e.OldElement == null && e.NewElement == null) { return; } _element = e.NewElement as CustomPicker; this.Control.Click += OnPickerClick; }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); CustomPicker picker = (CustomPicker)Element; if (picker != null) { //TOGLIE IL BORDO Control.BorderStyle = UITextBorderStyle.None; Control.Font = UIFont.FromName("Avenir", 14f); SetPlaceholder(picker); //SetFont(datePicker); SetTextColor(picker); } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (e.OldElement != null || e.NewElement != null) { CustomPicker customPicker = e.NewElement as CustomPicker; Control.SetHintTextColor(Android.Graphics.Color.ParseColor(customPicker.TextColor)); Control.SetTextColor(Android.Graphics.Color.ParseColor(customPicker.TextColor)); GradientDrawable gd = new GradientDrawable(); gd.SetColor(global::Android.Graphics.Color.Transparent); this.Control.SetBackgroundDrawable(gd); this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions); Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.White)); } }
private void SetIcon(CustomPicker view) { if (!string.IsNullOrEmpty(view.Icon)) { //Control.LeftViewMode = UITextFieldViewMode.Always; //Control.LeftViewRect(new CGRect(5, 5, 5, 5)); //Control.LeftView = new UIImageView(UIImage.FromBundle(view.Icon)); Control.RightViewMode = UITextFieldViewMode.Always; Control.RightViewRect(new CGRect(5, 5, 5, 5)); Control.RightView = new UIImageView(UIImage.FromBundle(view.Icon)); } else { Control.LeftViewMode = UITextFieldViewMode.Never; Control.LeftView = null; } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); element = (CustomPicker)this.Element; if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image)) { Control.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null); } if (e.NewElement == null || e.OldElement != null) { return; } Control.Click += Control_Click; }
protected async override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); element = (CustomPicker)this.Element; if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image)) { var userId = CRM.Common.Helpers.Settings.CRM_UserRole; //await SecureStorage.GetAsync(AppConstant.UserRole); //if (userId == "2") // element.Image = "ic_dropdown_green"; //else element.Image = "ic_dropdown"; //element.TitleColor = Xamarin.Forms.Color.FromHex(App.nav_bar_color); //element.TextColor = Xamarin.Forms.Color.FromHex(App.nav_bar_color); Control.Background = AddPickerStyles(element.Image); } }
public ExercisePage(SimpleExercise exercise, bool isExerciseEdit = false, int exid = 1) { this.exercise = exercise; this.isExerciseEdit = isExerciseEdit; Title = isExerciseEdit ? "Edit Exercise Prescription Details" : "Add Exercise Prescription Details"; Label exerciseNameLabel = new Label { Text = exercise.Exercise.ExerciseName, FontSize = 45 }; Label exerciseCategoryLabel = new Label { Text = exercise.Exercise.Bodypart, FontSize = 40 }; StackLayout exerciseStack = new StackLayout { Orientation = StackOrientation.Vertical, Children = { exerciseNameLabel, exerciseCategoryLabel } }; Image exerciseImage = new Image { HorizontalOptions = LayoutOptions.StartAndExpand, WidthRequest = 180, HeightRequest = 180, }; var exerciseFrame = new Frame { Content = exerciseImage, OutlineColor = Color.Silver, Padding = new Thickness(20), HorizontalOptions = LayoutOptions.EndAndExpand, }; try { if (exercise.Exercise.ImageFile.Trim() != "") { String imageBasePath = "http://www.mymobilefit.com/StrengthImages/"; String finalImagePath = imageBasePath + exercise.Exercise.ImageFile.Trim(); exerciseImage.Source = new UriImageSource { Uri = new Uri(finalImagePath), CachingEnabled = true, CacheValidity = new TimeSpan(5, 0, 0, 0) }; } } catch (Exception e2) { String exceptionMessage = e2.Message; } StackLayout exercisePrescriptionHeaderStackLayout = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { exerciseStack, exerciseFrame } }; CustomPicker setPicker = new CustomPicker { Title = "Sets" }; foreach(int sets in SimpleExercise.SetOptions) { setPicker.Items.Add(sets.ToString()); }; CustomPicker repPicker = new CustomPicker { Title = "Reps" }; foreach (int reps in SimpleExercise.RepOptions) { repPicker.Items.Add(reps.ToString()); }; CustomPicker weightPicker = new CustomPicker { Title = "Weight" }; foreach(int weight in SimpleExercise.WeightOptions) { weightPicker.Items.Add(weight.ToString()); } CustomPicker seatPositionLabelPicker1 = new CustomPicker { Title = "Label", WidthRequest = 200 }; CustomPicker seatPositionLabelPicker2 = new CustomPicker { Title = "Label", WidthRequest = 200 }; CustomPicker seatPositionLabelPicker3 = new CustomPicker { Title = "Label", WidthRequest = 200 }; CustomPicker seatPositionLabelPicker4 = new CustomPicker { Title = "Label", WidthRequest = 200 }; foreach(string seatPosLabel in SimpleExercise.SeatPositionLabelOptions) { seatPositionLabelPicker1.Items.Add(seatPosLabel); seatPositionLabelPicker2.Items.Add(seatPosLabel); seatPositionLabelPicker3.Items.Add(seatPosLabel); seatPositionLabelPicker4.Items.Add(seatPosLabel); } CustomPicker seatPositionValuePicker1 = new CustomPicker { Title = "Value", WidthRequest = 90 }; CustomPicker seatPositionValuePicker2 = new CustomPicker { Title = "Value", WidthRequest = 90 }; CustomPicker seatPositionValuePicker3 = new CustomPicker { Title = "Value", WidthRequest = 90 }; CustomPicker seatPositionValuePicker4 = new CustomPicker { Title = "Value", WidthRequest = 90 }; foreach(string seatPosValue in SimpleExercise.SeatPositionValueOptions) { seatPositionValuePicker1.Items.Add(seatPosValue); seatPositionValuePicker2.Items.Add(seatPosValue); seatPositionValuePicker3.Items.Add(seatPosValue); seatPositionValuePicker4.Items.Add(seatPosValue); } //Set selected index bindings this.BindingContext = exercise; setPicker.SetBinding(Picker.SelectedIndexProperty, "Sets"); repPicker.SetBinding(Picker.SelectedIndexProperty, "Reps"); weightPicker.SetBinding(Picker.SelectedIndexProperty, "Weight"); seatPositionLabelPicker1.SetBinding(Picker.SelectedIndexProperty, "SeatPosition1Label"); seatPositionLabelPicker2.SetBinding(Picker.SelectedIndexProperty, "SeatPosition2Label"); seatPositionLabelPicker3.SetBinding(Picker.SelectedIndexProperty, "SeatPosition3Label"); seatPositionLabelPicker4.SetBinding(Picker.SelectedIndexProperty, "SeatPosition4Label"); seatPositionValuePicker1.SetBinding(Picker.SelectedIndexProperty, "SeatPosition1Value"); seatPositionValuePicker2.SetBinding(Picker.SelectedIndexProperty, "SeatPosition2Value"); seatPositionValuePicker3.SetBinding(Picker.SelectedIndexProperty, "SeatPosition3Value"); seatPositionValuePicker4.SetBinding(Picker.SelectedIndexProperty, "SeatPosition4Value"); StackLayout labelsStackLayout = new StackLayout { Padding = new Thickness(20), Children = { exercisePrescriptionHeaderStackLayout, new StackLayout { Children = { new Label { Text = "Target Sets: " }, setPicker }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(10), Spacing = 40 }, new StackLayout { Children = { new Label { Text = "Target Reps: " }, repPicker }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(10), Spacing = 40 }, new StackLayout { Children = { new Label { Text = "Target Weight (lbs): " }, weightPicker }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(10), Spacing = 40 }, new StackLayout { Children = { new Label { Text = "Seat Pos 1: " }, seatPositionLabelPicker1, seatPositionValuePicker1 //seatPosition1Entry }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(10), Spacing = 35 }, new StackLayout { Children = { new Label { Text = "Seat Pos 2: " }, seatPositionLabelPicker2, seatPositionValuePicker2 }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(10), Spacing = 35 } , new StackLayout { Children = { new Label { Text = "Seat Pos 3: " }, seatPositionLabelPicker3, seatPositionValuePicker3 }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(10), Spacing = 35 } , new StackLayout { Children = { new Label { Text = "Seat Pos 4: " }, seatPositionLabelPicker4, seatPositionValuePicker4 }, Orientation = StackOrientation.Horizontal, Padding = new Thickness(10), Spacing = 35 } }, Spacing = 20 }; if(isExerciseEdit) { ToolbarItem cancelItem = new ToolbarItem { Text = "Cancel", Icon = Device.OnPlatform("cancel.png", "ic_action_cancel", "Images/cancel.png"), Order = ToolbarItemOrder.Primary }; cancelItem.Clicked += async (sender, args) => { bool confirm = await this.DisplayAlert("Edit Exercise", "Cancel exercise edit?", "Yes", "No"); if (confirm) { await this.Navigation.PopAsync(); } }; this.ToolbarItems.Add(cancelItem); ToolbarItem deleteItem = new ToolbarItem { Text = "Delete", Icon = Device.OnPlatform("discard.png", "ic_action_discard.png", "Images/delete.png"), Order = ToolbarItemOrder.Primary }; deleteItem.Clicked += async (sender, args) => { bool confirm = await this.DisplayAlert("Delete Exercise", "Delete this exercise?", "Yes", "No"); if (confirm) { exercise.Delete(); App.WorkoutCreatorContext.Exercises.Remove(exercise); await this.Navigation.PopAsync(); } }; this.ToolbarItems.Add(deleteItem); } this.BackgroundColor = Color.FromRgb(0, 191, 255); this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 0); this.Content = labelsStackLayout; }
public UserRegistrationView () { BindingContext = new UserViewModel(this.Navigation); indicator = new ActivityIndicator { Color = Colors.DarkGray.ToFormsColor(), HorizontalOptions=LayoutOptions.Center, VerticalOptions=LayoutOptions.Center, }; //indicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsLoading"); //indicator.SetBinding (ActivityIndicator.IsVisibleProperty, "IsLoading"); stack_CoverPage = new StackLayout { WidthRequest=Width, HeightRequest = Width/4, //BackgroundColor=Color.Red, BackgroundColor=Colors.DarkGray.ToFormsColor(), }; img_User = new CircleImage { WidthRequest = Width/4, HeightRequest = Width/4, HorizontalOptions = LayoutOptions.Center, //BackgroundColor=Color.Yellow, TranslationY=-((Width/4)/2+10), Aspect=Aspect.Fill, Source="CircleImage.png", }; img_User.SetBinding(CircleImage.SourceProperty, "ImageSource", BindingMode.Default); ViewModel.ProfilePicture = img_User; btn_camera = new Image { Source="camera.png", WidthRequest=Width/8, HeightRequest=Height/8, HorizontalOptions=LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, BackgroundColor=Xamarin.Forms.Color.Red, }; var Cameratap = new TapGestureRecognizer(OnCameraTapped); btn_camera.IsEnabled = true; btn_camera.GestureRecognizers.Clear(); btn_camera.GestureRecognizers.Add(Cameratap); btn_gallery = new Image { Source="gallery.png", WidthRequest=Width/8, HeightRequest=Height/8, HorizontalOptions=LayoutOptions.End, VerticalOptions = LayoutOptions.Center, BackgroundColor=Xamarin.Forms.Color.Green, }; var Gallerytap = new TapGestureRecognizer(OnGalleryTapped); btn_gallery.IsEnabled = true; btn_gallery.GestureRecognizers.Clear(); btn_gallery.GestureRecognizers.Add(Gallerytap); stack_pop = new StackLayout { HeightRequest = Width / 2, WidthRequest = Width / 2, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = Xamarin.Forms.Color.White, TranslationY=Width / 2, Opacity = 1, Children = { new StackLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Orientation = StackOrientation.Horizontal, TranslationY=Width/6, Children= { btn_camera, btn_gallery } } } }; stack_popup = new StackLayout { WidthRequest = Width, HeightRequest = Height, BackgroundColor=Xamarin.Forms.Color.Transparent, Children= { stack_pop } }; image_bg = new Image { WidthRequest = Width, HeightRequest = Height, HorizontalOptions=LayoutOptions.FillAndExpand, VerticalOptions=LayoutOptions.FillAndExpand, Source="bg.png", IsVisible=false }; var PopUpGestureRecognizer = new TapGestureRecognizer { //ViewModel.SelectPictureCommand.Execute(null); Command = new Command (() => { //ViewModel.SelectPictureCommand.Execute(null); var eAndN = new Tuple<Easing, string>[] { new Tuple<Easing, string> (Easing.Linear, "Linear") }; double w = Width; double h = Height; var newPos = new Rectangle(0, h, w, h); var eAndName = eAndN[iClicks]; var easing = eAndName.Item1; stack_popup.LayoutTo(newPos, 80, easing); iClicks %= eAndN.Length; image_bg.IsVisible=false; }), NumberOfTapsRequired = 1 }; stack_popup.GestureRecognizers.Add(PopUpGestureRecognizer); var ProfilePictureGestureRecognizer = new TapGestureRecognizer { //ViewModel.SelectPictureCommand.Execute(null); Command = new Command (() => { var eAndN = new Tuple<Easing, string>[] { new Tuple<Easing, string> (Easing.Linear, "Linear") }; double w = Width; double h = Height; var newPos = new Rectangle(0, 0, w, h); var eAndName = eAndN[iClicks]; var easing = eAndName.Item1; stack_popup.LayoutTo(newPos, 80, easing); iClicks %= eAndN.Length; image_bg.IsVisible=true; }), NumberOfTapsRequired = 1 }; img_User.GestureRecognizers.Add(ProfilePictureGestureRecognizer); txt_Name = new EditText { WidthRequest = Width, HorizontalOptions = LayoutOptions.Center, Placeholder="FullName", TextColor=Colors.DarkGray.ToFormsColor(), BackgroundColor=Xamarin.Forms.Color.Transparent, HeightRequest=Width/10, }; txt_Name.SetBinding(Entry.TextProperty, "UserRegInfo.name"); txt_Email = new EditText { WidthRequest = Width, HorizontalOptions = LayoutOptions.Center, Keyboard=Keyboard.Email, Placeholder="Email", TextColor=Colors.DarkGray.ToFormsColor(), BackgroundColor=Xamarin.Forms.Color.Transparent, HeightRequest=Width/10 }; txt_Email.SetBinding(Entry.TextProperty, "UserRegInfo.email"); txt_Password = new EditText { WidthRequest = Width, HorizontalOptions = LayoutOptions.Center, IsPassword=true, Placeholder="Password", TextColor=Colors.DarkGray.ToFormsColor(), BackgroundColor=Xamarin.Forms.Color.Transparent, HeightRequest=Width/10 }; txt_Password.SetBinding(Entry.TextProperty, "UserRegInfo.password"); picker_Country = new CustomPicker { WidthRequest = Width, HorizontalOptions = LayoutOptions.Center, Title="Location", HeightRequest=Width/10, BackgroundColor=Xamarin.Forms.Color.Transparent, }; picker_Country.SelectedIndexChanged+=((sender, e) => { ViewModel.SelectedIndex=picker_Country.SelectedIndex; }); btn_Submit= new Button { WidthRequest = Width/2, HorizontalOptions = LayoutOptions.Center, HeightRequest=Width/8, Text="Submit", FontSize=17, TextColor=Xamarin.Forms.Color.White, BackgroundColor=Colors.DarkGray.ToFormsColor(), //CommandParameter = 1, Command= ViewModel.RegisterUser, }; stack_TopView = new StackLayout { HorizontalOptions = LayoutOptions.Fill, HeightRequest=Width/3, Padding= new Thickness(0,0,0,Height/45), //BackgroundColor=Color.Blue, Children= { stack_CoverPage,img_User } }; lbl_Expert = new Label { Text="Experts", FontSize=18, TextColor=Colors.DarkGray.ToFormsColor(), FontAttributes=FontAttributes.Bold }; stack_MiddleView = new StackLayout { HorizontalOptions = LayoutOptions.Center, VerticalOptions=LayoutOptions.StartAndExpand, Padding= new Thickness(Width/8,Height/40,Width/8,0), //BackgroundColor=Color.Pink, Spacing=Height/45, Children= { txt_Name,txt_Email,txt_Password,picker_Country,lbl_Expert } }; img_iOS = new Image { WidthRequest=Width/7, HeightRequest=Width/7, HorizontalOptions=LayoutOptions.Start, Source="iOS.png", BackgroundColor=Colors.DarkGray.ToFormsColor(), IsEnabled=false }; var iOStap = new TapGestureRecognizer(OniOSTapped); iOStap.NumberOfTapsRequired = 1; img_iOS.IsEnabled = true; img_iOS.GestureRecognizers.Clear(); img_iOS.GestureRecognizers.Add(iOStap); img_Certified = new Image { WidthRequest=Width/7, HeightRequest=Width/7, HorizontalOptions=LayoutOptions.Center, Source="Certified.png", BackgroundColor=Colors.DarkGray.ToFormsColor(), IsEnabled=false }; var Certifiedtap = new TapGestureRecognizer(OnCertifiedTapped); img_Certified.IsEnabled = true; img_Certified.GestureRecognizers.Clear(); img_Certified.GestureRecognizers.Add(Certifiedtap); img_Android = new Image { WidthRequest=Width/7, HeightRequest=Width/7, HorizontalOptions=LayoutOptions.End, Source="Android.png", BackgroundColor=Colors.DarkGray.ToFormsColor(), IsEnabled=false }; var Androidtap = new TapGestureRecognizer(OnAndroidTapped); Androidtap.NumberOfTapsRequired = 1; img_Android.IsEnabled = true; img_Android.GestureRecognizers.Clear(); img_Android.GestureRecognizers.Add(Androidtap); img_Forms = new Image { WidthRequest=Width/7, HeightRequest=Width/7, HorizontalOptions=LayoutOptions.Start, Source="Forms.png", BackgroundColor=Colors.DarkGray.ToFormsColor(), IsEnabled=false }; var Formstap = new TapGestureRecognizer(OnFormsTapped); img_Forms.IsEnabled = true; img_Forms.GestureRecognizers.Clear(); img_Forms.GestureRecognizers.Add(Formstap); img_Insights = new Image { WidthRequest=Width/7, HeightRequest=Width/7, HorizontalOptions=LayoutOptions.Center, Source="Insight.png", BackgroundColor=Colors.DarkGray.ToFormsColor(), IsEnabled=false }; var Insightstap = new TapGestureRecognizer(OnInsightTapped); img_Insights.IsEnabled = true; img_Insights.GestureRecognizers.Clear(); img_Insights.GestureRecognizers.Add(Insightstap); img_Testcloud = new Image { WidthRequest=Width/7, HeightRequest=Width/7, HorizontalOptions=LayoutOptions.End, Source="TestCloud.png", BackgroundColor=Colors.DarkGray.ToFormsColor(), IsEnabled=false }; var Testcloudtap = new TapGestureRecognizer(OnTestCloudTapped); img_Testcloud.IsEnabled = true; img_Testcloud.GestureRecognizers.Clear(); img_Testcloud.GestureRecognizers.Add(Testcloudtap); stack_FirstExpert = new StackLayout { HorizontalOptions=LayoutOptions.Center, VerticalOptions=LayoutOptions.StartAndExpand, Orientation=StackOrientation.Horizontal, //BackgroundColor=Color.Yellow, Spacing=Height/40, Children= { img_iOS,img_Certified,img_Android } }; stack_SecondExpert = new StackLayout { HorizontalOptions=LayoutOptions.Center, VerticalOptions=LayoutOptions.StartAndExpand, Orientation=StackOrientation.Horizontal, //BackgroundColor=Color.Red, Spacing=Height/40, Children= { img_Forms,img_Insights,img_Testcloud } }; StackLayout stack_MainLayout = new StackLayout { HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions=LayoutOptions.Fill, //BackgroundColor=Color.Aqua, Spacing=Width/25, Children= { stack_MiddleView,stack_FirstExpert,stack_SecondExpert,btn_Submit } }; scroll_Main = new ScrollView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions=LayoutOptions.Start, }; scroll_Main.Content=stack_MainLayout; mainLayout = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions=LayoutOptions.End, BackgroundColor=Xamarin.Forms.Color.White, WidthRequest=Width, HeightRequest=Height, Children = { stack_TopView,scroll_Main } }; rltv_main = new RelativeLayout { WidthRequest = Width, HeightRequest = Height }; rltv_main.Children.Add(mainLayout, Constraint.Constant(0), Constraint.Constant(0),Constraint.Constant(Width),Constraint.Constant(Height)); rltv_main.Children.Add(image_bg, Constraint.Constant(0), Constraint.Constant(0),Constraint.Constant(Width),Constraint.Constant(Height)); rltv_main.Children.Add(stack_popup, Constraint.Constant(0), Constraint.Constant(Height),Constraint.Constant(Width),Constraint.Constant(Height)); this.Content = rltv_main; }