public override void ViewDidLoad() { base.ViewDidLoad(); // Sets the preview to the image record passed in ImageView.Image = ImageRecord.FullImage; // sets up font picker and picks a random font model = new PickerViewModel(this); FontPicker.Model = model; var randomFont = (new Random()).Next() % UIFont.FamilyNames.Length; FontPicker.Select(randomFont, 0, false); // Sets up the label with random font ImageLabel.Font = UIFont.FromName(UIFont.FamilyNames [randomFont], 24); // sets delegates so enter dimsisses keyboard TagField.ShouldReturn = TextFieldShouldReturn; HiddenText.ShouldReturn = TextFieldShouldReturn; // typing into the hiddent text field automatically updates the label on the image HiddenText.EditingChanged += OnDidEditField; // start editing the text field as soon as the view is done loading HiddenText.BecomeFirstResponder(); }
public override void ViewDidLoad () { base.ViewDidLoad (); var leftBtn = new UIBarButtonItem(Utils.Translate("cancel"), UIBarButtonItemStyle.Plain, CancelClicked); NavigationItem.LeftBarButtonItem = leftBtn; var rightBtn = new UIBarButtonItem(Utils.Translate("done"), UIBarButtonItemStyle.Done, DoneClicked); NavigationItem.RightBarButtonItem = rightBtn; pickerViewModel = new PickerViewModel(this); picker.Source = pickerViewModel; if(Value.Length == 1) Value = "00" + Value; if(Value.Length == 2) Value = "0" + Value; int cols = Value.Length; foreach(var c in Value.Reverse()){ cols --; picker.Select(Int32.Parse(c.ToString()), cols, false); } NumberDidChange(); }
private void BindClassRooms(List <RoomModel> roomsList) { if (classRoomPicker == null) { modelClassRooms = new ClassRoomPickerViewModel(roomsList); classRoomPicker = new UIPickerView() { Frame = new CGRect(50, 220, View.Bounds.Width - 100, 200), ShowSelectionIndicator = true, Model = modelClassRooms, }; classRoomPicker.AccessibilityNavigationStyle = UIAccessibilityNavigationStyle.Automatic; classRoomPicker.ContentMode = UIViewContentMode.Center; var subViewTop = new UIView(new CGRect(classRoomPicker.Bounds.X - 20, classRoomPicker.Bounds.Y + 85, classRoomPicker.Bounds.Width, 1)); var subViewBottom = new UIView(new CGRect(classRoomPicker.Bounds.X - 20, classRoomPicker.Bounds.Y + 115, classRoomPicker.Bounds.Width, 1)); subViewTop.BackgroundColor = UIColor.White; subViewBottom.BackgroundColor = UIColor.White; classRoomPicker.AddSubview(subViewTop); classRoomPicker.AddSubview(subViewBottom); View.AddSubviews(classRoomPicker); classRoomPicker.Select(0, 0, true); } if (loadingOverlay != null) { loadingOverlay.Hide(); } }
/// <summary> /// Shows the action sheet picker from the view that was set as the owner. /// </summary> public void Show(UIPickerViewModel model) { // declare vars float titleBarHeight = 40; SizeF doneButtonSize = new SizeF(71, 30); SizeF actionSheetSize = new SizeF(owner.Frame.Width, Picker.Frame.Height + titleBarHeight); RectangleF actionSheetFrame = new RectangleF(0, owner.Frame.Height - actionSheetSize.Height , actionSheetSize.Width, actionSheetSize.Height); // show the action sheet and add the controls to it actionSheet.ShowInView(owner); // resize the action sheet to fit our other stuff actionSheet.Frame = actionSheetFrame; // move our picker to be at the bottom of the actionsheet (view coords are relative to the action sheet) Picker.Frame = new RectangleF (Picker.Frame.X, titleBarHeight, Picker.Frame.Width, Picker.Frame.Height); Picker.Model = model; // move our label to the top of the action sheet titleLabel.Frame = new RectangleF(10, 4, owner.Frame.Width - 100, 35); // move our button doneButton.Frame = new RectangleF(actionSheetSize.Width - doneButtonSize.Width - 10, 7, doneButtonSize.Width, doneButtonSize.Height); }
protected override ModalEditViewController CreateModalEditViewController(UIViewController parent) { var modalPicker = new ModalPickerViewController(HeaderText, parent); if (Components != null) { _pickerViewModel = new BareUISimplePickerWithMultipleComponentsViewModel(modalPicker.PickerView) { Collections = Components }; } else if (ItemToViewConverter != null || ItemsSource.OfType <UIView>().Any()) { _pickerViewModel = new BareUICustomPickerViewModel(modalPicker.PickerView) { ItemToViewConverter = ItemToViewConverter, ItemsSource = ItemsSource }; } else { _pickerViewModel = new BareUISimplePickerViewModel(modalPicker.PickerView) { ItemsSource = ItemsSource }; } modalPicker.PickerView.Model = _pickerViewModel; return(modalPicker); }
public override void ViewDidLoad() { base.ViewDidLoad(); UIPickerViewModel pickerViewModel = new UIPickerViewModel(); //SP::Assign the dictioanry keys to the picker /* * https://github.com/xamarin/ios-samples/blob/master/MonoCatalog-MonoDevelop/PickerViewController.xib.cs * https://stackoverflow.com/questions/36510230/xamarin-ios-uipickerview-tutorial */ foreach (String key in translateClass.dictionaries.Keys) { //LangPicker.Add(key); } UITapGestureRecognizer gestureRecognizer = new UITapGestureRecognizer(() => translateClass.ChangeDirection()); gestureRecognizer.NumberOfTapsRequired = 2; TextBoxOne.AddGestureRecognizer(gestureRecognizer); TextBoxTwo.AddGestureRecognizer(gestureRecognizer); TextBoxOne.Changed += (object sender, EventArgs e) => { TextBoxTwo.Text = translateClass.TranslateString(TextBoxOne.ToString(), LangPicker.ToString()); }; }
protected void SetupPicker(UITextField field, string type) { // Setup the toolbar UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit(); // Create a 'done' button for the toolbar and add it to the toolbar UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { field.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); UIPickerViewModel picker_model = new UIPickerViewModel(); if (type == "time") { picker_model = new TimePickerViewModel(field); } else if (type == "ranking") { picker_model = new RankingPickerViewModel(field); } else if (type == "hr") { picker_model = new HRPickerViewModel(field); } else if (type == "pace") { picker_model = new PacePickerViewModel(field); } else if (type == "type") { picker_model = new PTypePickerViewModel(field); } UIPickerView picker = new UIPickerView(); picker.BackgroundColor = UIColor.White; picker.Model = picker_model; picker.ShowSelectionIndicator = true; field.InputView = picker; field.InputAccessoryView = toolbar; field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString) { return(false); }); }
public override void ViewDidLoad () { base.ViewDidLoad (); // Sets the preview to the image record passed in ImageView.Image = ImageRecord.FullImage; // sets up font picker and picks a random font model = new PickerViewModel (this); FontPicker.Model = model; var randomFont = (new Random ()).Next () % UIFont.FamilyNames.Length; FontPicker.Select (randomFont, 0, false); // Sets up the label with random font ImageLabel.Font = UIFont.FromName (UIFont.FamilyNames [randomFont], 24); // sets delegates so enter dimsisses keyboard TagField.ShouldReturn = TextFieldShouldReturn; HiddenText.ShouldReturn = TextFieldShouldReturn; // typing into the hiddent text field automatically updates the label on the image HiddenText.EditingChanged += OnDidEditField; // start editing the text field as soon as the view is done loading HiddenText.BecomeFirstResponder (); }