private void SetPickerToView() { _picker_model = new CountryCodePickerView(); _picker = new UIPickerView(); _picker.Model = _picker_model; _picker.ShowSelectionIndicator = true; _picker.BackgroundColor = UIColor.White; var toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); var doneButton = new UIBarButtonItem(Application.LocalizedString("Validate"), UIBarButtonItemStyle.Done, (s, e) => { CountryCodeTextField.Text = _picker_model.ValuesPicker[(int)_picker.SelectedRowInComponent(0)].Item1.ToString(); CountryCodeLabel.Text = _picker_model.ValuesPicker[(int)_picker.SelectedRowInComponent(0)].Item2.ToString(); CountryCodeTextField.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); CountryCodeTextField.TouchDown += SetPicker; CountryCodeTextField.InputView = _picker; CountryCodeTextField.InputAccessoryView = toolbar; }
public void SetUpEndDatePicker() { UIDatePicker datePicker = new UIDatePicker(); datePicker.Mode = UIDatePickerMode.Date; UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { if (endDate > startDate) { var selectedDate = NSDateToDateTime(datePicker.Date); DatePickerEnd.Text = selectedDate.ToString("dd MMMMM yyyy dddd"); DatePickerEnd.ResignFirstResponder(); endDate = selectedDate; } else { UIAlertController alertController = UIAlertController.Create("Error", "The end date must be after the start date", UIAlertControllerStyle.Alert); PresentViewController(alertController, true, null); } }); toolbar.SetItems(new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), doneButton }, true); this.DatePickerEnd.InputView = datePicker; this.DatePickerEnd.InputAccessoryView = toolbar; }
protected override void AssingViews() { BackButton.TouchUpInside += (o, e) => presenter.BackClicked(); ModifyButton.TouchUpInside += (o, e) => presenter.SaveClicked(PhoneTextField.Text); PhoneTextField.ShouldReturn += (textview) => { PhoneTextField.ResignFirstResponder(); return(true); }; var doneToolbar = new UIToolbar(new CGRect(0, 0, 300, 40)); doneToolbar.BarStyle = UIBarStyle.Default; var flexSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null, null); var done = new UIBarButtonItem(AppDelegate.LanguageBundle.GetLocalizedString("msg_ok"), UIBarButtonItemStyle.Done, this, null); done.Clicked += (o, e) => { PhoneTextField.ResignFirstResponder(); }; var items = new UIBarButtonItem[2]; items[0] = flexSpace; items[1] = done; doneToolbar.Items = items; doneToolbar.SizeToFit(); PhoneTextField.InputAccessoryView = doneToolbar; styleView(); applyTraslations(); }
public UIMonthTextField(IntPtr handle) : base(handle) { monthPicker = new MonthPickerView(); // Setup the toolbar UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit(); // Create a 'done' button for the toolbar UIBarButtonItem unitDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { this.Text = monthPicker.SelectedDate.ToString(this.format); this._currentDate = monthPicker.SelectedDate; this.ResignFirstResponder(); }); // Create flexible space UIBarButtonItem unitFlex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); // Add button and unitFlexible space to the toolbar toolbar.SetItems(new UIBarButtonItem[]{unitFlex, unitDoneButton}, true); // Tell the textbox to use the picker for input this.InputView = monthPicker; // Display the toolbar over the pickers this.InputAccessoryView = toolbar; }
public override void ViewDidLoad () { base.ViewDidLoad (); string selectedColor = ""; PickerModel model = new PickerModel(); model.ValueChanged += (sender, e) => { selectedColor = model.SelectedItem; }; UIPickerView picker = new UIPickerView(); picker.ShowSelectionIndicator = false; picker.BackgroundColor = UIColor.White; picker.Model = model; this.color.Text = model.SelectedItem; UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { this.color.Text = selectedColor; this.color.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true); this.color.InputView = picker; this.color.InputAccessoryView = toolbar; }
public UICurrencyTextField(IntPtr handle) : base(handle) { unitPicker = new CurrencyPickerView(); // Setup the unitToolbar UIToolbar unitToolbar = new UIToolbar(); unitToolbar.BarStyle = UIBarStyle.Black; unitToolbar.Translucent = true; unitToolbar.SizeToFit(); // Create a 'done' button for the unitToolbar UIBarButtonItem unitDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { base.Text = unitPicker.SelectedValue; this.selectedIndex = unitPicker.SelectedKey; this.ResignFirstResponder(); }); // Create flexible space UIBarButtonItem unitFlex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); // Add button and unitFlexible space to the unitToolbar unitToolbar.SetItems(new UIBarButtonItem[]{unitFlex, unitDoneButton}, true); // Tell the textbox to use the picker for input this.InputView = unitPicker; // Display the toolbar over the pickers this.InputAccessoryView = unitToolbar; }
public override void ViewDidLoad() { base.ViewDidLoad(); UIDatePicker datePicker = new UIDatePicker(); datePicker.Mode = UIDatePickerMode.Date; datePicker.BackgroundColor = UIColor.White; datePicker.MinimumDate = DateTime.Today.AddDays(-7); datePicker.MaximumDate = DateTime.Today.AddDays(7); UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { DateTime dateTime = DateTime.SpecifyKind(datePicker.Date, DateTimeKind.Unspecified); this.textField.Text = dateTime.ToString("MM-dd-yyyy"); this.textField.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); this.textField.InputAccessoryView = toolbar; textField.InputView = datePicker; }
// Constructor that takes a picker for defining new statistics. public ChooseStatisticOverlay(CGRect frame, nfloat transparency, UIColor color, UIPickerView statPicker) : base(frame) { // Store the statistics picker. var statisticPicker = statPicker; // Create a semi-transparent overlay with the specified background color. BackgroundColor = color; Alpha = transparency; // Set the total height and width of the control set. nfloat totalHeight = 400; nfloat totalWidth = 320; // Find the bottom x and y of the view. nfloat centerX = Frame.Width / 2; nfloat centerY = Frame.Bottom - 40; // Find the start x and y for the control layout (aligned to the bottom of the view). nfloat controlX = centerX - totalWidth / 2; nfloat controlY = centerY - totalHeight; // Toolbar with "Add" and "Done" buttons. UIToolbar toolbar = new UIToolbar { BarStyle = UIBarStyle.Black, Translucent = false }; toolbar.SizeToFit(); // Add Button (add the new stat and don't dismiss the UI). UIBarButtonItem addButton = new UIBarButtonItem("Add", UIBarButtonItemStyle.Done, (s, e) => { // Get the selected StatisticDefinition. StatDefinitionModel statPickerModel = statisticPicker.Model as StatDefinitionModel; StatisticDefinition newStatDefinition = statPickerModel.SelectedStatDefinition; if (newStatDefinition != null) { // Fire the OnMapInfoEntered event and provide the statistic definition. OnStatisticDefined?.Invoke(this, newStatDefinition); } }); // Done Button (dismiss the UI, don't use the selected statistic). UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Plain, (s, e) => { OnCanceled.Invoke(this, null); }); // Add the buttons to the toolbar. toolbar.SetItems(new[] { addButton, doneButton }, true); // Define the location of the statistic picker. controlY = controlY + 200; statisticPicker.Frame = new CGRect(controlX, controlY, totalWidth, 200); // Set the location for the toolbar. controlY = controlY + 220; toolbar.Frame = new CGRect(controlX, controlY, totalWidth, 30); // Add the controls. AddSubviews(toolbar, statisticPicker); }
private void SetupPicker() { ProductsModelPickerView model = new ProductsModelPickerView(this.products); model.PickerChanged += (sender, e) => { this.selectedProduct = e.SelectedValue; }; UIPickerView picker = new UIPickerView(); picker.ShowSelectionIndicator = true; picker.Model = model; UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { this.tfProduto.Text = selectedProduct; this.tfProduto.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); this.tfProduto.InputView = picker; this.tfProduto.InputAccessoryView = toolbar; }
public override void ViewDidLoad () { base.ViewDidLoad (); UIDatePicker datePicker = new UIDatePicker (); datePicker.Mode = UIDatePickerMode.Date; datePicker.BackgroundColor = UIColor.White; datePicker.MinimumDate = DateTime.Today.AddDays(-7); datePicker.MaximumDate = DateTime.Today.AddDays(7); UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { DateTime dateTime = DateTime.SpecifyKind(datePicker.Date, DateTimeKind.Unspecified); this.textField.Text = dateTime.ToString("MM-dd-yyyy"); this.textField.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true); this.textField.InputAccessoryView = toolbar; textField.InputView = datePicker; }
public static void UiSetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType keyboardType) { var toolbar = new UIToolbar { BarStyle = UIBarStyle.Black, Translucent = true, }; txt.KeyboardType = keyboardType; toolbar.SizeToFit(); var text = new UITextView(new CGRect(0, 0, 200, 32)) { ContentInset = UIEdgeInsets.Zero, KeyboardType = keyboardType, Text = txt.Text, UserInteractionEnabled = true }; text.Layer.CornerRadius = 4f; text.BecomeFirstResponder(); var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { text.ResignFirstResponder(); txt.ResignFirstResponder(); }); toolbar.UserInteractionEnabled = true; toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); txt.InputAccessoryView = toolbar; }
public UIToolbar GetToolbar(UIView views) { if (TextField == null) { throw new Exception("You must initialize TextField in the contructor."); } if (views == null) { throw new Exception("The parameter view can not be null."); } Toolbar = new UIToolbar(); Toolbar.BarStyle = UIBarStyle.Default; Toolbar.Translucent = true; Toolbar.SizeToFit(); var doneButton = new UIBarButtonItem(Application.LocalizedString("Validate"), UIBarButtonItemStyle.Done, (s, e) => { foreach (var view in views.Subviews) { if (view.IsFirstResponder) { TextField.Text = PickerViewModel.ValuesPicker[(int)SelectedRowInComponent(0)].ToString(); TextField.ResignFirstResponder(); } } }); Toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); return(Toolbar); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.White; Title = "Done Button Example"; var lbl = new UILabel(new CGRect(5, 30, 200, 20)); lbl.Text = "Enter some numbers"; lbl.Font = UIFont.SystemFontOfSize(12f); View.AddSubview(lbl); _txtNumbers = new UITextField(new CGRect(5, 50, 200, 20)); _txtNumbers.KeyboardType = UIKeyboardType.NumberPad; _txtNumbers.BorderStyle = UITextBorderStyle.RoundedRect; // Add Done button UIToolbar keyboardToolbar = new UIToolbar(); keyboardToolbar.SizeToFit(); UIBarButtonItem flexBarButton = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null, null); UIBarButtonItem doneBarButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, this, new ObjCRuntime.Selector("endEditing:")); keyboardToolbar.Items = new UIBarButtonItem[] { flexBarButton, doneBarButton }; _txtNumbers.InputAccessoryView = keyboardToolbar; View.AddSubview(_txtNumbers); }
public override void ViewDidLoad() { saveButton.TouchUpInside += SaveExpense; // Use a picker view to select our category choices. categoryPicker = new UIPickerView(); categoryPicker.Model = pickerData = new TextFieldPickerData(categoryText, new[] { "Lodging", "Meal", "Transportation", "Other" }); categoryText.InputView = categoryPicker; // Use a Toolbar to add a "Done" button to dismiss the picker. pickerToolbar = new UIToolbar { BarTintColor = UIColor.White, Translucent = false, }; doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => categoryText.ResignFirstResponder()); var flexibleSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null); pickerToolbar.Items = new [] { flexibleSpace, doneButton }; pickerToolbar.SizeToFit(); categoryText.InputAccessoryView = pickerToolbar; // Update the UI with the selected expense. OnUpdateDetails(); }
public void SetUpFirstDatePicker() { UIDatePicker datePicker = new UIDatePicker(); datePicker.Mode = UIDatePickerMode.Date; UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { var selectedDate = NSDateToDateTime(datePicker.Date); DatePickerStart.Text = selectedDate.ToString("dd MMMMM yyyy dddd"); monthView.ChangeDate(selectedDate); DatePickerStart.ResignFirstResponder(); startDate = selectedDate; }); toolbar.SetItems(new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), doneButton }, true); this.DatePickerStart.InputView = datePicker; this.DatePickerStart.InputAccessoryView = toolbar; }
private void OpenDatePicker() { UIView dateView = new UIView(); dateView.BackgroundColor = UIColor.White; UIToolbar pickerToolbar = new UIToolbar(new CGRect(0, 0, View.Bounds.Width, 44)); pickerToolbar.BarStyle = UIBarStyle.Default; pickerToolbar.Translucent = true; pickerToolbar.SizeToFit(); UIDatePicker datePicker = new UIDatePicker(); datePicker.Frame = new CGRect(0, 44, datePicker.Bounds.Width, datePicker.Bounds.Height); datePicker.Mode = UIDatePickerMode.DateAndTime; datePicker.Date = DateUtil.DateTimeToNSDate(Date); datePicker.BackgroundColor = UIColor.White; pickerToolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("OK", UIBarButtonItemStyle.Done, (sender, eventArgs) => { Date = DateUtil.NSDateToDateTime(datePicker.Date); dateView.RemoveFromSuperview(); DateButton.SetTitle(Date.ToShortDateString() + " " + Date.ToShortTimeString(), UIControlState.Normal); }) }; dateView.Frame = new CGRect(0, View.Frame.Height - pickerToolbar.Bounds.Height - datePicker.Bounds.Height, View.Frame.Width, pickerToolbar.Bounds.Height + datePicker.Bounds.Height); dateView.AddSubview(pickerToolbar); dateView.AddSubview(datePicker); Add(dateView); }
public override void ViewDidLoad () { base.ViewDidLoad (); this.NavigationItem.HidesBackButton = true; if(isFrom == "") setAccountResponse (Constant.selectedAffialte ); Appdata.setButtonBorder (btnSave); btnSave.BackgroundColor = Appdata.buttonBackgroundColor; if (UserInterfaceIsPhone) SetLayoytIPhone (); else SetLayoytIPad (); UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; 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) => { Console.WriteLine ("Calling Done!"); }); toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true); }
public static UIPickerView Create(PickerModel model, UITextField fieldToMirror, Func <IList <string>, string> transformFunction = null, Action doneAction = null, Action changeAction = null) { var pickerView = new UIPickerView { Model = model }; var toolbar = new UIToolbar { BarStyle = UIBarStyle.Default, BarTintColor = Colors.PrimaryColor, Translucent = true }; toolbar.SizeToFit(); model.PickerChanged += (sender, e) => { var fieldVal = transformFunction == null ? e.SelectedValues[0].ToString() : transformFunction(e.SelectedValues.Select(o => o.ToString()).ToList()); fieldToMirror.Text = fieldVal; changeAction?.Invoke(); }; var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { fieldToMirror.ResignFirstResponder(); doneAction?.Invoke(); }); doneButton.SetTitleTextAttributes(new UITextAttributes { TextColor = UIColor.White }, UIControlState.Normal); toolbar.SetItems(new[] { doneButton }, true); fieldToMirror.InputView = pickerView; fieldToMirror.InputAccessoryView = toolbar; return(pickerView); }
protected void SetupReadyPickup(UITextField field, List <KeyValuePair <object, string> > list, Action <string> callback) { // Setup the picker and model MapPickerModel model = new MapPickerModel(list); model.PickerChanged += (sender, e) => { Facade.Instance.CurrentRide.ReadyReservationId = e.SelectedKey.ToString(); field.Text = e.SelectedValue; field.SendActionForControlEvents(UIControlEvent.ValueChanged); }; UIPickerView picker = new UIPickerView(); picker.ShowSelectionIndicator = true; picker.Model = model; picker.BackgroundColor = new UIColor((nfloat)(19.0 / 255.0), (nfloat)(36.0 / 255.0), (nfloat)(65.0 / 255.0), (nfloat)1.0); picker.TintColor = UIColor.White; // 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) => { if (String.IsNullOrEmpty(Facade.Instance.CurrentRide.CreditCardId) && list.Count > 0) { Facade.Instance.CurrentRide.ReadyReservationId = list [0].Key.ToString(); field.Text = list [0].Value.ToString(); field.SendActionForControlEvents(UIControlEvent.ValueChanged); AppSettings.SelectedCard = list [0].Key.ToString(); } field.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); UIView topView = new UIView(toolbar.Frame); UIButton btnDone = new UIButton(new CGRect(0, 0, toolbar.Frame.Width, toolbar.Frame.Height)); btnDone.SetTitle("SELECT RIDE READY FOR PICKUP", UIControlState.Normal); btnDone.BackgroundColor = new UIColor((nfloat)(21.0 / 255.0), (nfloat)(100.0 / 255.0), (nfloat)(179.0 / 255.0), (nfloat)1.0); btnDone.TouchUpInside += (object sender, EventArgs e) => { var reservationID = Facade.Instance.CurrentRide.ReadyReservationId; callback(reservationID); field.ResignFirstResponder(); }; topView.AddSubview(btnDone); field.InputView = picker; field.InputAccessoryView = topView; field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString) { return(false); }); }
public static MvxPickerViewModel CreatePicker(this UITextField textField) { var picker = new UIPickerView(); var pickerViewModel = new MvxPickerViewModel(picker); picker.Model = pickerViewModel; picker.ShowSelectionIndicator = true; var toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit(); var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { //This dismisses the picker view and returns control to the main screen. textField.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); //This associates the picker view with the textview textField.InputView = picker; //This will insert the toolbar into the pickerview. This will allow the user to dismiss the //view once a choice has been made. textField.InputAccessoryView = toolbar; return(pickerViewModel); }
private void CreateDatePicker() { UIDatePicker datePicker = new UIDatePicker(); datePicker.Mode = UIDatePickerMode.Date; datePicker.BackgroundColor = UIColor.White; //datePicker.MinimumDate = (NSDate)DateTime.Today.AddDays(-7); datePicker.MaximumDate = (NSDate)DateTime.Today; UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { DateTime dateTime = DateTime.SpecifyKind((DateTime)datePicker.Date, DateTimeKind.Unspecified); this.UITextFieldDOB.Text = dateTime.ToString("MM-dd-yyyy"); this.UITextFieldDOB.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); UITextFieldDOB.InputAccessoryView = toolbar; UITextFieldDOB.InputView = datePicker; }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. #region ComboBox UIPickerView pickerView = new UIPickerView(); pickerModel = new PickerModel(lbldato, emocion); pickerView.Model = pickerModel; // Instanciar un toolbar UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; //Crear un label var labelTitulo = new UILabel(new CGRect(x: 0, y: 50, width: 150, height: 20)) { BackgroundColor = UIColor.Clear, TextColor = UIColor.Gray.ColorWithAlpha(0.5f), TextAlignment = UITextAlignment.Left, Text = txtDato.Placeholder }; labelTitulo.SizeToFit(); // Crear los UIBarButtonItem de nuestra toolbar var tituloCajaTexto = new UIBarButtonItem(labelTitulo); var cancelarBoton = new UIBarButtonItem("Cancelar", UIBarButtonItemStyle.Done, (s, e) => { this.txtDato.ResignFirstResponder(); }); var espacioEntreBoton = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null, null); var listoButton = new UIBarButtonItem("Listo", UIBarButtonItemStyle.Done, (s, e) => { this.txtDato.Text = emocion[pickerView.SelectedRowInComponent(0)]; this.txtDato.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { cancelarBoton, espacioEntreBoton, tituloCajaTexto, espacioEntreBoton, listoButton }, true); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; pickerView.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.SizeToFit(); // Tell the textbox to use the picker for input this.txtDato.InputView = pickerView; // Display the toolbar over the pickers this.txtDato.InputAccessoryView = toolbar; #endregion rootNode = Database.DefaultInstance.GetRootReference(); btnGuardarDia.TouchUpInside += BtnGuardarDia_TouchUpInside; btnImage.TouchUpInside += BtnImage_TouchUpInside; }
private void SetupToolbar() { toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit(); txtTitle.InputAccessoryView = toolbar; }
protected void SetupCreditCards(UITextField field, UIImageView image, List <KeyValuePair <object, string> > list, List <KeyValuePair <object, object> > list1) { // Setup the picker and model MyPickerModel model = new MyPickerModel(list); model.PickerChanged += (sender, e) => { Facade.Instance.CurrentRide.CreditCardId = e.SelectedKey.ToString(); field.Text = e.SelectedValue; field.SendActionForControlEvents(UIControlEvent.ValueChanged); for (int i = 0; i < list1.Count; i++) { if (list1[i].Key.ToString() == e.SelectedKey.ToString()) { image.Image = (UIImage)list1[i].Value; } } AppSettings.SelectedCard = e.SelectedKey.ToString(); }; UIPickerView picker = new UIPickerView(); picker.ShowSelectionIndicator = true; picker.Model = model; picker.BackgroundColor = new UIColor((nfloat)(19.0 / 255.0), (nfloat)(36.0 / 255.0), (nfloat)(65.0 / 255.0), (nfloat)1.0); // 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) => { if (String.IsNullOrEmpty(Facade.Instance.CurrentRide.CreditCardId) && list.Count > 0) { Facade.Instance.CurrentRide.CreditCardId = list [0].Key.ToString(); field.Text = list [0].Value.ToString(); field.SendActionForControlEvents(UIControlEvent.ValueChanged); AppSettings.SelectedCard = list [0].Key.ToString(); } field.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); field.InputView = picker; field.InputAccessoryView = toolbar; field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString) { return(false); }); }
public override void ViewWillAppear(bool animated) { this.ConfigureBackButton(BackLink, OutputPane); if (NavigationItem != null) { NavigationItem.Title = title ?? string.Empty; } if (NavigationController != null && NavigationController.NavigationBar != null) { if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { NavigationController.NavigationBar.BarTintColor = headerColor; NavigationController.NavigationBar.TintColor = titleColor; } else { NavigationController.NavigationBar.TintColor = headerColor ?? UIColor.Black; } NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes() { ForegroundColor = titleColor }; } if (toolbar != null) { toolbar.SizeToFit(); toolbar.Frame = new CGRect(0, View.Bounds.Height - toolbar.Frame.Height, View.Bounds.Width, toolbar.Frame.Height); } CGRect frame = View.Bounds; // create the signature capture view drawingImageView.Frame = frame; drawingImageView.Layer.MasksToBounds = true; // this seems to cause image corruption if (drawingImageView.Image != null) { nfloat widthScaleFactor = drawingImageView.Frame.Width / drawingImageView.Image.Size.Width; nfloat heightScaleFactor = drawingImageView.Frame.Height / drawingImageView.Image.Size.Height; nfloat scaleFactor = Math.Min((float)widthScaleFactor, (float)heightScaleFactor); nfloat width = drawingImageView.Image.Size.Width * scaleFactor; nfloat height = drawingImageView.Image.Size.Height * scaleFactor; nfloat x = (frame.Width - width) / 2; nfloat y = (frame.Height - height) / 2; frame = new CGRect(x, y, drawingImageView.Image.Size.Width * scaleFactor, drawingImageView.Image.Size.Height * scaleFactor); } drawingCanvas.Frame = frame; }
public static UIToolbar MakeToolbar() { var toolbar = new UIToolbar() { TranslatesAutoresizingMaskIntoConstraints = false }; toolbar.SizeToFit(); return(toolbar); }
UIView CreateAccessoryView() { var tools = new UIToolbar(); tools.BarStyle = UIBarStyle.Default; tools.Items = CreateButtons().ToArray(); tools.SizeToFit(); return(tools); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. UIDatePicker pickerView = new UIDatePicker(); pickerView.Mode = UIDatePickerMode.DateAndTime; // Instanciar un toolbar UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; //Crear un label var labelTitulo = new UILabel(new CGRect(x: 0, y: 50, width: 150, height: 20)) { BackgroundColor = UIColor.Clear, TextColor = UIColor.Gray.ColorWithAlpha(0.5f), TextAlignment = UITextAlignment.Left, Text = txtFecha.Placeholder }; labelTitulo.SizeToFit(); // Crear los UIBarButtonItem de nuestra toolbar var tituloCajaTexto = new UIBarButtonItem(labelTitulo); var cancelarBoton = new UIBarButtonItem("Cancelar", UIBarButtonItemStyle.Done, (s, e) => { this.txtFecha.ResignFirstResponder(); }); var espacioEntreBoton = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null, null); var listoButton = new UIBarButtonItem("Listo", UIBarButtonItemStyle.Done, (s, e) => { NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "yyyy-MM-dd"; this.txtFecha.Text = dateFormat.ToString(pickerView.Date); this.txtFecha.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { cancelarBoton, espacioEntreBoton, tituloCajaTexto, espacioEntreBoton, listoButton }, true); toolbar.TranslatesAutoresizingMaskIntoConstraints = false; pickerView.TranslatesAutoresizingMaskIntoConstraints = false; toolbar.SizeToFit(); // Tell the textbox to use the picker for input txtFecha.InputView = pickerView; // Display the toolbar over the pickers this.txtFecha.InputAccessoryView = toolbar; }
public override void ViewDidLoad() { base.ViewDidLoad(); MesajTextView.Changed += MesajTextView_Changed; List <ContactDTO> KonuList = new List <ContactDTO> { new ContactDTO { topic = "Teknik Sorun" }, new ContactDTO { topic = "Şikayet" }, new ContactDTO { topic = "Öneri" }, new ContactDTO { topic = "Diğer" } }; for (int i = 0; i < KonuList.Count; i++) { KonuName.Add(KonuList[i].topic); } SetupPicker(textField, KonuName); GonderButton.TouchUpInside += GonderButton_TouchUpInside; #region DONE BUtton UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); var gradientLayer = new CAGradientLayer(); gradientLayer.Colors = new[] { UIColor.FromRGB(15, 0, 241).CGColor, UIColor.FromRGB(2, 0, 100).CGColor }; gradientLayer.Locations = new NSNumber[] { 0, 1 }; gradientLayer.StartPoint = new CoreGraphics.CGPoint(0, 1); gradientLayer.EndPoint = new CoreGraphics.CGPoint(1, 0); gradientLayer.Frame = toolbar.Bounds; toolbar.Layer.MasksToBounds = true; toolbar.Layer.InsertSublayer(gradientLayer, 0); UIBarButtonItem doneButton = new UIBarButtonItem("Tamam", UIBarButtonItemStyle.Done, (s, e) => { MesajTextView.ResignFirstResponder(); }); doneButton.TintColor = UIColor.White; toolbar.SetItems(new[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), doneButton }, true); MesajTextView.InputAccessoryView = toolbar; #endregion }
public UIView GetView(IDictionary <string, object> inputCustomProperties, MyFormHandler myFormHandler) { this.PickerView = new UIPickerView(); this.Items = inputCustomProperties.GetCustomProperty <IList <DropdownItem> >("items"); this.Items.Insert(0, new DropdownItem { Label = "", Value = "" }); PickerModel model = new PickerModel(this.Items.Select(a => a.Label).ToArray()); model.PickerChanged += (sender, e) => { var selected = this.Items.SingleOrDefault(a => a.Label.Equals(e.SelectedValue)); var value = new DropdownValue <string>(selected?.Value); this.SelectedValue = value; }; this.PickerView.ShowSelectionIndicator = true; this.PickerView.Model = model; // Setup the toolbar UIToolbar toolbar = new UIToolbar { BarStyle = UIBarStyle.Black, Translucent = true }; toolbar.SizeToFit(); this.TextField = new UITextField(); this.TextField.Layer.CornerRadius = 8; this.TextField.Layer.BorderColor = UIColor.LightGray.CGColor; this.TextField.Layer.BorderWidth = 1; UIView paddingView = new UIView(new CGRect(0, 0, 10, 20)); this.TextField.LeftView = paddingView; this.TextField.LeftViewMode = UITextFieldViewMode.Always; // Create a 'done' button for the toolbar and add it to the toolbar UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { this.TextField.Text = this.SelectedValue.Value; this.TextField.ResignFirstResponder(); }); toolbar.SetItems(new [] { doneButton }, true); // Tell the textbox to use the picker for input this.TextField.InputView = this.PickerView; // Display the toolbar over the pickers this.TextField.InputAccessoryView = toolbar; return(this.TextField); }
protected void SetDatePicker(UITextField field, UIDatePickerMode mode = UIDatePickerMode.Time, String format = "{0: d MMMM yyyy}", bool futureDatesOnly = true, DateTime?minimumDateTime = null, bool changeOnEdit = false) { UIDatePicker picker = new UIDatePicker(); picker.Mode = UIDatePickerMode.Date; picker.MaximumDate = ToNSDate(DateTime.Now.AddYears(1)); if (minimumDateTime != null) { NSDate nsMinDateTime = ToNSDate((DateTime)minimumDateTime); picker.MinimumDate = nsMinDateTime; } if (futureDatesOnly) { NSDate nsMinDateTime = ToNSDate(DateTime.Now); //picker.SetDate picker.MinimumDate = nsMinDateTime; } picker.ValueChanged += (object s, EventArgs e) => { if (futureDatesOnly) { NSDate nsMinDateTime = ToNSDate(DateTime.Now); picker.MinimumDate = nsMinDateTime; } if (changeOnEdit) { updateSetupDateTimePicker(field, picker.Date, format, s, e); } }; // 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) => { updateSetupDateTimePicker(field, picker.Date, format, s, e, true); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); field.InputView = picker; field.InputAccessoryView = toolbar; field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString) { return(false); }); }
protected void SetupInputAccessoryToolbar(UIColor tintColor) { var allFields = View.AllSubviews(new Type[] { typeof(UITextField), typeof(UITextView) }); for (var i = 0; i < allFields.Count; i++) { var toolbar = new UIToolbar(); toolbar.TintColor = tintColor; toolbar.Translucent = true; toolbar.SizeToFit(); var doneButton = new UIBarButtonItem("Готово", UIBarButtonItemStyle.Done, null); toolbar.SetItems(new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), doneButton }, false); var textField = allFields[i] as UITextField; if (textField != null) { if (textField.InputAccessoryView == null) { doneButton.Clicked += (s, e) => textField.ResignFirstResponder(); textField.InputAccessoryView = toolbar; } textField.ShouldReturn = (tF) => { if (i + 1 >= allFields.Count) { textField.ResignFirstResponder(); } else { var field = allFields[i + 1] as UITextField; if (field != null && field.Enabled) { field.BecomeFirstResponder(); } var view = allFields[i + 1] as UITextView; if (view != null && view.Editable) { view.BecomeFirstResponder(); } } return(false); }; } var textView = allFields[i] as UITextView; if (textView != null && textView.InputAccessoryView == null) { doneButton.Clicked += (s, e) => textView.ResignFirstResponder(); textView.InputAccessoryView = toolbar; } } }
public void SetInputAccessoryView() { if (string.IsNullOrEmpty(blankPicker.DoneButtonText) && string.IsNullOrEmpty(blankPicker.CancelButtonText)) { Control.InputAccessoryView = null; return; } var toolbar = new UIToolbar { BarStyle = UIBarStyle.Default, Translucent = true }; toolbar.SizeToFit(); var items = new List <UIBarButtonItem>(); if (!string.IsNullOrEmpty(blankPicker.CancelButtonText)) { var cancelButton = new UIBarButtonItem(blankPicker.CancelButtonText, UIBarButtonItemStyle.Done, (s, ev) => { Control.ResignFirstResponder(); }); cancelButton.Clicked += (sender, e) => { blankPicker.SendCancelClicked(); }; items.Add(cancelButton); } var flexible = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); items.Add(flexible); if (!string.IsNullOrEmpty(blankPicker.DoneButtonText)) { var doneButton = new UIBarButtonItem(blankPicker.DoneButtonText, UIBarButtonItemStyle.Done, (sd, ev) => { var s = (PickerSource)_picker.Model; if (s.SelectedIndex == -1 && blankPicker.Items != null && blankPicker.Items.Count > 0) { UpdatePickerSelectedIndex(0); } UpdatePickerFromModel(s); if (ElementController != null) { ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false); } Control.ResignFirstResponder(); }); doneButton.Clicked += (sender, e) => { blankPicker.SendDoneClicked(); }; items.Add(doneButton); } toolbar.SetItems(items.ToArray(), true); Control.InputAccessoryView = toolbar; Control.InputAccessoryView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight; }
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); }); }
private void GenerateToolBar() { _toolbar = new UIToolbar(); _toolbar.SizeToFit(); _toolbar.Frame = new CGRect(0, View.Frame.Height - NavigationController.NavigationBar.Frame.Height, View.Frame.Width, Constants.GalleryToolbarHeight); _toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth; _toolbar.Hidden = true; View.AddSubview(_toolbar); CreateToolbarItems(); }
public override UITableViewCell GetCell (UITableView tv) { Value = FormatDate (DateValue); EntryElementCell cell = (EntryElementCell)tv.DequeueReusableCell("DateTimeElement"); if (cell == null){ cell = new EntryElementCell("DateTimeElement"); } cell.Update(this, tv); var picker = CreatePicker(); picker.ValueChanged += (sender, e) => { this.DateValue = picker.Date; cell.DetailTextLabel.Text = FormatDate(picker.Date); this.Value = FormatDate(picker.Date); cell.SetNeedsLayout(); }; cell.TextField.EditingDidBegin += (sender, e) => { this.DateValue = picker.Date; cell.DetailTextLabel.Text = FormatDate(picker.Date); this.Value = FormatDate(picker.Date); cell.SetNeedsLayout(); }; cell.TextField.InputView = picker; cell.TextField.Alpha = 0; cell.TextLabel.TextColor = Appearance.LabelTextColor; cell.TextLabel.HighlightedTextColor = Appearance.LabelHighlightedTextColor; cell.TextLabel.Font = Appearance.LabelFont; cell.DetailTextLabel.Text = FormatDate(this.DateValue); cell.DetailTextLabel.TextColor = Appearance.DetailLabelTextColor; cell.DetailTextLabel.Font = Appearance.DetailLabelFont; cell.DetailTextLabel.HighlightedTextColor = Appearance.DetailLabelHighlightedTextColor; cell.BackgroundColor = Appearance.BackgroundColorEditable; var toolbar = new UIToolbar(); toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (e, a)=>{ cell.TextField.ResignFirstResponder(); }) }; toolbar.SizeToFit(); cell.TextField.InputAccessoryView = toolbar; return cell; }
public static void SetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType keyboardType, string closeButtonText = "Done") { UIToolbar toolbar = new UIToolbar (); txt.KeyboardType = keyboardType; toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit (); UIBarButtonItem doneButton = new UIBarButtonItem (closeButtonText, UIBarButtonItemStyle.Done, (s, e) => { txt.ResignFirstResponder (); }); toolbar.SetItems (new UIBarButtonItem[]{doneButton}, true); txt.InputAccessoryView = toolbar; }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); var rawStatuses = Enum.GetValues(typeof(CommitmentStatus)); var statuses = new CommitmentStatus[rawStatuses.Length]; var i = 0; foreach (CommitmentStatus status in rawStatuses) { statuses[i] = status; i++; } _pickerModel = new PickerModel(statuses); _statusSelectedEventHandler = (sender, args) => { _selectedStatus = args.SelectedValue; }; _pickerModel.PickerChanged += _statusSelectedEventHandler; _statusPicker = new UIPickerView { ShowSelectionIndicator = true, Model = _pickerModel }; // Setup the toolbar var toolbar = new UIToolbar { BarStyle = UIBarStyle.Black, Translucent = true }; toolbar.SizeToFit(); _barButtonClickEventHandler = (s, e) => { DisasterStatusText.Text = Enum.GetName(typeof(CommitmentStatus), _selectedStatus); DisasterStatusText.ResignFirstResponder(); }; // Create a 'done' button for the toolbar and add it to the toolbar _doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, _barButtonClickEventHandler); toolbar.SetItems(new[] { _doneButton }, true); // Tell the textbox to use the picker for input DisasterStatusText.InputView = _statusPicker; // Display the toolbar over the pickers DisasterStatusText.InputAccessoryView = toolbar; }
public void pickerViewModel(UITextField textFieldItem, List<string> segmentosStrings, UIButton button) { PickerModel picker_model_Segmentos = new PickerModel (segmentosStrings); UIPickerView picker_Segmentos = new UIPickerView (); picker_Segmentos.Model = picker_model_Segmentos; picker_Segmentos.ShowSelectionIndicator = true; UIToolbar toolbar = new UIToolbar (); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit (); var tapRecognizer = new UITapGestureRecognizer (); tapRecognizer.AddTarget(() => { Console.WriteLine("CLICK"); }); tapRecognizer.NumberOfTapsRequired = 2; tapRecognizer.NumberOfTouchesRequired = 1; picker_Segmentos.AddGestureRecognizer(tapRecognizer); UIBarButtonItem doneButton = new UIBarButtonItem ("Done", UIBarButtonItemStyle.Bordered,(s, e) => { // Console.WriteLine((int)picker_Segmentos.SelectedRowInComponent); Console.WriteLine(picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString ()); textFieldItem.Text = picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString (); if(button.Tag == 2 || button.Tag == 3){ Console.WriteLine("longCode ButtonClicked"); } textFieldItem.ResignFirstResponder (); }); UIBarButtonItem cancelButton = new UIBarButtonItem ("cancel", UIBarButtonItemStyle.Bordered, (s, e) => { textFieldItem.ResignFirstResponder (); }); toolbar.SetItems (new UIBarButtonItem[]{ doneButton, cancelButton }, true); toolbar.TintColor = UIColor.White; textFieldItem.InputView = picker_Segmentos; this.View.BackgroundColor = UIColor.Clear; textFieldItem.InputAccessoryView = toolbar; textFieldItem.AddGestureRecognizer (tapRecognizer); }
public override void ViewDidLoad () { base.ViewDidLoad (); Title = "Toolbar"; View.BackgroundColor = UIColor.GroupTableViewBackgroundColor; toolbar = new UIToolbar() { BarStyle = UIBarStyle.Default }; toolbar.SizeToFit (); float toolbarHeight = toolbar.Frame.Height; var mainViewBounds = View.Bounds; toolbar.Frame = new RectangleF (mainViewBounds.X, (float)(mainViewBounds.Y + mainViewBounds.Height - toolbarHeight * 2 + 2), mainViewBounds.Width, toolbarHeight); View.AddSubview (toolbar); currentSystemItem = UIBarButtonSystemItem.Done; CreateToolbarItems (); systemButtonPicker.Model = new ItemPickerModel (this); }
/// <summary> /// /// </summary> public ActionSheetPicker(UIView owner) { // save our uiview owner this._owner = owner; // configure the title label titleLabel.BackgroundColor = UIColor.Clear; titleLabel.TextColor = UIColor.LightTextColor; titleLabel.Font = UIFont.BoldSystemFontOfSize (18); // create + configure the action sheet _actionSheet = new UIActionSheet () { Style = UIActionSheetStyle.BlackTranslucent }; _actionSheet.Clicked += (s, e) => { Console.WriteLine ("Clicked on item {0}", e.ButtonIndex); }; // add our controls to the action sheet _actionSheet.AddSubview (picker); _actionSheet.AddSubview (titleLabel); //actionSheet.AddSubview (doneButton); // Add the toolbar _toolbar = new UIToolbar(new RectangleF(0, 0, _actionSheet.Frame.Width, 10)); _toolbar.BarStyle = UIBarStyle.Black; _toolbar.Translucent = true; // Add the done button _doneButton = new UIBarButtonItem("Aceptar",UIBarButtonItemStyle.Done, null); _doneButton.Clicked += (object sender, EventArgs e) => { _actionSheet.DismissWithClickedButtonIndex (0, true); }; _toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null, null), _doneButton }; _toolbar.SizeToFit(); _actionSheet.Add (_toolbar); }
public UIDateTextField(IntPtr handle) : base(handle) { datePicker = new UIDatePicker(); dateFormatter = new NSDateFormatter(); dateFormatter.DateStyle = NSDateFormatterStyle.Long; // Set up the date picker datePicker.Mode = UIDatePickerMode.Date; datePicker.MinimumDate = DateTime.Today.AddMonths (-2); datePicker.MaximumDate = DateTime.Today; datePicker.ValueChanged += (s, e) => { this.Text = dateFormatter.ToString((s as UIDatePicker).Date); this._currentDate = DateTime.SpecifyKind((s as UIDatePicker).Date, DateTimeKind.Unspecified); }; // Setup the dateToolbar UIToolbar dateToolbar = new UIToolbar(); dateToolbar.BarStyle = UIBarStyle.Black; dateToolbar.Translucent = true; dateToolbar.SizeToFit(); // Create a 'done' button for the dateToolbar UIBarButtonItem dateDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { this.ResignFirstResponder(); }); // Create flexible space UIBarButtonItem dateFlex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); // Add button and dateFlexible space to the dateToolbar dateToolbar.SetItems(new UIBarButtonItem[]{dateFlex, dateDoneButton}, true); this.InputView = datePicker; this.InputAccessoryView = dateToolbar; }
public ActionSheetDatePickerCustom (UIView owner) { picker = new UIDatePicker (CGRect.Empty); // save our uiview owner this._owner = owner; // create + configure the action sheet _actionSheet = new UIActionSheet () { Style = UIActionSheetStyle.BlackTranslucent }; _actionSheet.Clicked += (s, e) => { Console.WriteLine ("Clicked on item {0}", e.ButtonIndex); }; // configure the title label titleLabel = new UILabel (new CGRect (0, 0, _actionSheet.Frame.Width, 10)); titleLabel.BackgroundColor = UIColor.Clear; titleLabel.TextColor = UIColor.Black; titleLabel.Font = UIFont.BoldSystemFontOfSize (18); // Add the toolbar _toolbar = new UIToolbar (new CGRect (0, 0, _actionSheet.Frame.Width, 10)); _toolbar.BarStyle = UIBarStyle.Default; _toolbar.Translucent = true; // Add the done button _doneButton = new UIBarButtonItem ("Gereed", UIBarButtonItemStyle.Done, null); _toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null, null), _doneButton }; _toolbar.SizeToFit (); _actionSheet.AddSubview (picker); _actionSheet.Add (_toolbar); _actionSheet.AddSubview (titleLabel); }
public void SetupToolbarOnKeyboard(UITextView txt) { UIToolbar toolbar = new UIToolbar (); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit (); UIBarButtonItem doneButton = new UIBarButtonItem ("Close", UIBarButtonItemStyle.Done, (s, e) => { txt.ResignFirstResponder (); }); doneButton.TintColor = UIColor.Gray; UIBarButtonItem goButton = new UIBarButtonItem ("Run", UIBarButtonItemStyle.Done, (s, e) => { txt.ResignFirstResponder (); OnRun (); }); toolbar.SetItems (new UIBarButtonItem[]{doneButton, goButton}, true); txt.InputAccessoryView = toolbar; }
public override void ViewDidLoad () { base.ViewDidLoad (); SizeF containerSize = View.Bounds.Size; mainMapView = new MKMapView () { UserInteractionEnabled = true, Delegate = new MapDelegate (), ScrollEnabled = true, }; var toolbar = new UIToolbar () { AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth, }; toolbar.SizeToFit (); SizeF toolbarSize = toolbar.Bounds.Size; toolbar.Frame = new RectangleF (0, containerSize.Height - toolbarSize.Height, containerSize.Width, toolbarSize.Height); mainMapView.Frame = new RectangleF (0, 0, containerSize.Width, containerSize.Height - toolbarSize.Height); var resetButton = new UIBarButtonItem ("Reset", UIBarButtonItemStyle.Bordered, removePins); var flexibleSpace = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null, null); var share = new UIBarButtonItem ("Log", UIBarButtonItemStyle.Bordered, tappedShare); View.AddSubview (mainMapView); View.AddSubview (toolbar); toolbar.SetItems (new UIBarButtonItem [] { resetButton, flexibleSpace, share }, true); setUpGesture (); itemsArray = new List<MyAnnotation> (); }
public DatePickerView() { Frame=new RectangleF (0f, 0f, 100f*Device.screenWidthP,260f); toolbar = new UIToolbar(RectangleF.Empty); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.UserInteractionEnabled = true; toolbar.SizeToFit(); cancelBtn = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, delegate { if(cancelBtnClick!=null) { cancelBtnClick(this,EventArgs.Empty); } }); flexibleSpaceBtn = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null); doneBtn = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate { if(doneBtnClick!=null) { doneBtnClick(this,EventArgs.Empty); } }); itemsBtn = new UIBarButtonItem[] { cancelBtn, flexibleSpaceBtn, doneBtn }; toolbar.SetItems(itemsBtn, true); Add (toolbar); datePicker = new UIDatePicker(new RectangleF(0f,44f,100f*Device.screenWidthP,216f)); datePicker.Mode = UIDatePickerMode.Date; datePicker.MaximumDate = NSDate.Now; datePicker.TimeZone = NSTimeZone.LocalTimeZone; datePicker.UserInteractionEnabled = true; datePicker.BackgroundColor = UIColor.White; Add (datePicker); }
void AddToolbarItems( ) { mToolbar = new UIToolbar ( ) { BarStyle = UIBarStyle.Default }; mToolbar.SizeToFit ( ); // Here's how you find these if you need them //float toolbarHeight = mToolbar.Frame.Height; //float navBarHeight = NavigationController.NavigationBar.Frame.Height; var forward = new UIBarButtonItem ( "Forward", UIBarButtonItemStyle.Bordered, ForwardClicked ); var animate = new UIBarButtonItem ( "Animate", UIBarButtonItemStyle.Bordered, AnimateClicked ); mToolbar.Items = new [] { forward, animate }; NavigationController.SetToolbarHidden ( false, true ); SetToolbarItems ( mToolbar.Items, true ); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.White; var scrollView = new UIScrollView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height)) { ScrollEnabled = true, ContentSize = new CGSize(View.Bounds.Size.Width, View.Bounds.Size.Height), AutoresizingMask = UIViewAutoresizing.FlexibleDimensions }; View.AddSubview(scrollView); using (var set = new BindingSet<LocalizableViewModel>()) { UIFont font = UIFont.SystemFontOfSize(10); var label = new UILabel(new CGRect(20, 0, View.Frame.Width - 40, 25)) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth, TextColor = UIColor.Green, Font = font }; set.Bind(label).To(() => vm => BindingSyntaxEx.Resource(LocalizationManager.ResourceName, () => LocalizableResources.AddText)); scrollView.AddSubview(label); label = new UILabel(new CGRect(20, 25, View.Frame.Width - 40, 25)) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth, TextColor = UIColor.Green, Font = font }; set.Bind(label).To(() => vm => BindingSyntaxEx.Resource(LocalizationManager.ResourceName, () => LocalizableResources.EditText)); scrollView.AddSubview(label); label = new UILabel(new CGRect(20, 50, View.Frame.Width - 40, 25)) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth, TextColor = UIColor.Green, Font = font }; set.Bind(label).To(() => vm => BindingSyntaxEx.Resource(LocalizationManager.ResourceName, () => LocalizableResources.DeleteText)); scrollView.AddSubview(label); var textField = new UITextField(new CGRect(20, 75, View.Frame.Width - 40, 30)) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth, BorderStyle = UITextBorderStyle.RoundedRect, ShouldChangeCharacters = (field, range, replacementString) => false }; set.Bind(textField).To(() => model => model.SelectedCulture); scrollView.AddSubview(textField); var pickerView = new UIPickerView { ShowSelectionIndicator = true }; set.Bind(pickerView, AttachedMemberConstants.ItemsSource) .To(() => model => model.Cultures); set.Bind(pickerView, AttachedMemberConstants.SelectedItem) .To(() => model => model.SelectedCulture) .TwoWay(); var toolbar = new UIToolbar { BarStyle = UIBarStyle.Black, Translucent = true }; toolbar.SizeToFit(); var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => textField.ResignFirstResponder()); toolbar.SetItems(new[] { doneButton }, true); textField.SetInputViewEx(pickerView); textField.InputAccessoryView = toolbar; } }
public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath) { TableItem item = tableItems[indexPath.Section].Items[indexPath.Row]; UIToolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { this.owner.View.EndEditing(true); }); toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); switch (item.CellType) { default: return new UITableViewCell(); case "SearchTermsCell": var searchTermsCell = (SearchTermsCell)tableView.DequeueReusableCell(SearchTermsCell.Key); if (searchTermsCell == null) searchTermsCell = new SearchTermsCell(); searchTermsCell.TermsField.Placeholder = "Search: " + this.owner.Category.Value; searchTermsCell.AccessibilityIdentifier = "SearchTermsField"; searchTermsCell.TermsField.EditingChanged += delegate { AddSearchItem("query", searchTermsCell.TermsField.Text); }; searchTermsCell.TermsField.TouchUpInside += delegate { this.owner.FieldSelected = searchTermsCell.TermsField.InputView; }; return searchTermsCell; case "PriceInputCell": var priceInputCell = (PriceCell)tableView.DequeueReusableCell(PriceCell.Key); if (priceInputCell == null) priceInputCell = new PriceCell(); priceInputCell.HeaderLabel.AttributedText = new NSAttributedString(item.Heading, Constants.LabelAttributes); priceInputCell.NumChanged += (object sender, EventArgs e) => { AddSearchItem("min_price", priceInputCell.MinPriceField.Text); AddSearchItem("max_price", priceInputCell.MaxPriceField.Text); }; priceInputCell.MaxPriceField.EditingDidBegin += (object sender, EventArgs e) => { this.owner.FieldSelected = priceInputCell.MaxPriceField.InputView; }; priceInputCell.MinPriceField.EditingDidBegin += (object sender, EventArgs e) => { this.owner.FieldSelected = priceInputCell.MinPriceField.InputView; }; return priceInputCell; case "MinMaxCell": var minMaxCell = (GenericPriceCell)tableView.DequeueReusableCell(GenericPriceCell.Key); if (minMaxCell == null) minMaxCell = new GenericPriceCell(); minMaxCell.HeaderLabel.AttributedText = new NSAttributedString(item.Heading, Constants.LabelAttributes); minMaxCell.NumChanged += delegate { switch (item.Heading) { case "Sq Feet": AddSearchItem("minSqft", minMaxCell.MinField.Text); AddSearchItem("maxSqft", minMaxCell.MaxField.Text); break; case "Year": AddSearchItem("min_auto_year", minMaxCell.MinField.Text); AddSearchItem("max_auto_year", minMaxCell.MaxField.Text); break; case "Odometer": AddSearchItem("min_auto_miles", minMaxCell.MinField.Text); AddSearchItem("max_auto_miles", minMaxCell.MaxField.Text); break; default: break; } }; minMaxCell.MaxField.EditingDidBegin += (object sender, EventArgs e) => { this.owner.FieldSelected = minMaxCell.MaxField.InputView; }; minMaxCell.MinField.EditingDidBegin += (object sender, EventArgs e) => { this.owner.FieldSelected = minMaxCell.MinField.InputView; }; return minMaxCell; case "MakeModelCell": var makeModelCell = (TitledSearchCell)tableView.DequeueReusableCell(TitledSearchCell.Key); if (makeModelCell == null) makeModelCell = new TitledSearchCell(); makeModelCell.Title.AttributedText = new NSAttributedString(item.Heading, Constants.LabelAttributes); makeModelCell.TermsField.Placeholder = item.SubHeading; makeModelCell.TermsField.EditingChanged += delegate { AddSearchItem("auto_make_model", makeModelCell.TermsField.Text); }; makeModelCell.TermsField.EditingDidBegin += delegate { this.owner.FieldSelected = makeModelCell.TermsField.InputView; }; return makeModelCell; case "PickerSelectorCell": var pickerSelectorCell = (PickerSelectorCell)tableView.DequeueReusableCell(PickerSelectorCell.Key); if (pickerSelectorCell == null) pickerSelectorCell = PickerSelectorCell.Create(); pickerSelectorCell.Title.AttributedText = new NSAttributedString(item.Heading, Constants.LabelAttributes); picker_model = new SearchPickerModel(item.PickerOptions, false); picker = new UIPickerView(); picker.Model = picker_model; picker.ShowSelectionIndicator = true; if (item.Heading == "Sub Category") { var firstItem = item.PickerOptions[0].PickerWheelOptions[0]; this.owner.SubCategory = firstItem; pickerSelectorCell.Display.AttributedText = new NSAttributedString((string)firstItem.Key, Constants.LabelAttributes); } picker_model.PickerChanged += (object sender, PickerChangedEventArgs e) => { string resultKey = e.SelectedKey.ToString(); string resultValue = null; if (e.SelectedValue != null) resultValue = e.SelectedValue.ToString(); Console.WriteLine(resultKey + " From " + e.FromComponent); pickerSelectorCell.Display.AttributedText = new NSAttributedString(resultKey, Constants.LabelAttributes); if (item.Heading == "Min Bedrooms") AddSearchItem("bedrooms", resultValue); else if (item.Heading == "Min Bathrooms") AddSearchItem("bathrooms", resultValue); else if (item.Heading == "Posted Date") this.owner.WeeksOld = (int?)Convert.ToInt16(resultValue); else if (item.Heading == "Max Listings") this.owner.MaxListings = Convert.ToInt16(resultValue); else if (item.Heading == "Sub Category") this.owner.SubCategory = new KeyValuePair<object, object>(resultKey, resultValue); }; pickerSelectorCell.InputTextField.InputView = picker; pickerSelectorCell.InputTextField.InputAccessoryView = toolbar; pickerSelectorCell.InputTextField.EditingDidBegin += (object sender, EventArgs e) => { this.owner.KeyboardBounds = picker.Bounds; this.owner.FieldSelected = pickerSelectorCell; pickerSelectorCell.Accessory = UITableViewCellAccessory.Checkmark; }; pickerSelectorCell.InputTextField.EditingDidEnd += delegate { pickerSelectorCell.Accessory = UITableViewCellAccessory.None; }; return pickerSelectorCell; case "ComboTableCell": var tableSelectorCell = (PickerSelectorCell)tableView.DequeueReusableCell(PickerSelectorCell.Key); if (tableSelectorCell == null) tableSelectorCell = PickerSelectorCell.Create(); tableSelectorCell.Title.AttributedText = new NSAttributedString(item.Heading, Constants.LabelAttributes); ComboPickerTableSource comboSource = new ComboPickerTableSource(item.PickerOptions); UITableView comboPicker = new UITableView(); comboPicker.Source = comboSource; comboPicker.Bounds = new CoreGraphics.CGRect(0, 0, this.owner.View.Bounds.Width, 0.4f * this.owner.View.Bounds.Height); comboSource.ValueChanged += (object sender, PickerChangedEventArgs e) => { string resultKey = e.SelectedKey.ToString(); string resultValue = null; if (e.SelectedValue != null) resultValue = e.SelectedValue.ToString(); if (this.owner.Conditions.ContainsKey(resultKey)) { this.owner.Conditions.Remove(resultKey); Console.WriteLine("Removed Key: " + resultKey + ", Value: " + resultValue); } else { this.owner.Conditions.Add(resultKey, new KeyValuePair<object, object>(item.SubHeading, resultValue)); Console.WriteLine("Added Key: " + resultKey + ", Value: " + resultValue); } var keys = (from kvp in this.owner.Conditions where (string)kvp.Value.Key == item.SubHeading select (string)kvp.Key).ToList(); var text = keys.Count > 0 ? String.Join(", ", keys.ToArray()) : "Any"; tableSelectorCell.Display.AttributedText = new NSAttributedString(text, Constants.LabelAttributes); }; tableSelectorCell.InputTextField.InputView = comboPicker; tableSelectorCell.InputTextField.InputAccessoryView = toolbar; tableSelectorCell.InputTextField.EditingDidBegin += (object sender, EventArgs e) => { this.owner.KeyboardBounds = comboPicker.Bounds; this.owner.FieldSelected = tableSelectorCell; tableSelectorCell.Accessory = UITableViewCellAccessory.Checkmark; }; tableSelectorCell.InputTextField.EditingDidEnd += delegate { tableSelectorCell.Accessory = UITableViewCellAccessory.None; }; return tableSelectorCell; } }
public KeyboardInputView (RectangleF frame) : base(frame) { _toolbar = new UIToolbar (frame); var toolbarItems = new UIBarButtonItem[] { new UIBarButtonItem (UIBarButtonSystemItem.Cancel, CancelButton_Tapped), new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null), new UIBarButtonItem (UIBarButtonSystemItem.Done, DoneButton_Tapped) }; _toolbar.SetItems (toolbarItems, false); _toolbar.SizeToFit (); _title = new UILabel (RectangleF.Empty); _title.Font = UIFont.SystemFontOfSize (UIFont.LabelFontSize * 1.2f); _title.BackgroundColor = UIColor.Clear; _title.LineBreakMode = UILineBreakMode.TailTruncation; _title.Lines = 2; _description = new UILabel (RectangleF.Empty); _description.Font = UIFont.SystemFontOfSize (UIFont.LabelFontSize); _description.TextColor = UIColor.DarkTextColor.ColorWithAlpha (0.95f); _description.BackgroundColor = UIColor.Clear; _title.LineBreakMode = UILineBreakMode.TailTruncation; _description.Lines = 2; _textFieldContainer = new UIScrollView(new RectangleF(0, 0, 100, 100)); _textField = new UITextField (_textFieldContainer.Bounds); _textField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _textField.BorderStyle = UITextBorderStyle.RoundedRect; _textField.Delegate = new TextFieldDelegate (this); _textFieldContainer.Add (_textField); Add (_toolbar); Add (_title); Add (_description); Add (_textFieldContainer); AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; AutosizesSubviews = false; Opaque = true; BackgroundColor = UIColor.FromRGB (0xC5, 0xCC, 0xD4); SetNeedsLayout (); }
public override UITableViewCell GetCell (Cell item, UITableViewCell reusableCell, UITableView tv) { var cell = base.GetCell (item, reusableCell, tv); var datepickerCell = (DatePickerEntryCell)item; UITextField textField = null; if (cell != null) textField = (UITextField)cell.ContentView .Subviews [0]; // Default datepicker display attributes var mode = UIDatePickerMode.Date; var displayFormat = "d"; var date = NSDate.Now; var isLocalTime = false; // Update datepicker based on Cell's properties if (datepickerCell != null) { // Kind must be Universal or Local to cast to // NSDate if (datepickerCell.Date.Kind == DateTimeKind.Unspecified) { var local = new DateTime (datepickerCell.Date.Ticks, DateTimeKind.Local); date = (NSDate)local; } else date = (NSDate)datepickerCell.Date; isLocalTime = datepickerCell.Date.Kind == DateTimeKind.Local || datepickerCell.Date.Kind == DateTimeKind.Unspecified; } // Create iOS datepicker var datepicker = new UIDatePicker { Mode = mode, BackgroundColor = UIColor.White, Date = date, TimeZone = isLocalTime ? NSTimeZone.LocalTimeZone : new NSTimeZone("UTC") }; // Create a toolbar with a done button that will // close the datepicker and set the selected value var done = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { var pickedDate = (DateTime)datepicker.Date; if (isLocalTime) pickedDate = pickedDate.ToLocalTime(); // Update the Date property on the Cell if (datepickerCell != null) datepickerCell.Date = pickedDate; // Update the value of the UITextField within the // Cell if (textField != null) { textField.Text = pickedDate.ToString(displayFormat); textField.ResignFirstResponder(); } }); var toolbar = new UIToolbar { BarStyle = UIBarStyle.Default, Translucent = false }; toolbar.SizeToFit (); toolbar.SetItems (new[] { done }, true); // Set the input view, toolbar and initial value for // the Cell's UITextField if (textField != null) { textField.InputView = datepicker; textField.InputAccessoryView = toolbar; if (datepickerCell != null) textField.Text = datepickerCell.Date.ToString (displayFormat); } return cell; }
public override UITableViewCell GetCell (UITableView tv) { _tableView = tv; var cell = tv.DequeueReusableCell (cellkey); if (cell == null) { cell = new UITableViewCell (UITableViewCellStyle.Default, cellkey); cell.SelectionStyle = UITableViewCellSelectionStyle.None; } else { //RemoveTag (cell, 1); } cell.BackgroundColor = Appearance.BackgroundColorEditable; if (entry == null) { SizeF size = ComputeEntryPosition (tv, cell); float width = cell.ContentView.Bounds.Width; entry = CreateTextField (new RectangleF ( 0, 0, width, size.Height + (height))); entry.Font = Appearance.LabelFont; var toolbar = new UIToolbar(); toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (e, a)=>{ entry.ResignFirstResponder(); }) }; toolbar.SizeToFit(); entry.InputAccessoryView = toolbar; entry.Font = inputFont; entry.Changed += delegate { FetchValue (); }; entry.Ended += delegate { FetchValue (); if (OnValueChanged!=null) OnValueChanged(this); }; // entry.ShouldReturn += delegate { // // if (ShouldReturn != null) // return ShouldReturn (); // // RootElement root = GetImmediateRootElement (); // EntryElement focus = null; // // if (root == null) // return true; // // foreach (var s in root.Sections) { // foreach (var e in s.Elements) { // if (e == this) { // focus = this; // } else if (focus != null && e is EntryElement) { // focus = e as EntryElement; // break; // } // } // // if (focus != null && focus != this) // break; // } // // if (focus != this) // focus.BecomeFirstResponder (true); // else // focus.ResignFirstResponder (true); // // return true; // }; entry.Started += delegate { entry.ReturnKeyType = UIReturnKeyType.Default; }; } if (becomeResponder) { entry.BecomeFirstResponder (); becomeResponder = false; } entry.KeyboardType = KeyboardType; entry.PlaceholderText = PlaceholderText; entry.AutocapitalizationType = AutocapitalizationType; entry.AutocorrectionType = AutocorrectionType; cell.TextLabel.Text = Caption; cell.ContentView.AddSubview (entry); return cell; }
public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. this.NavigationController.NavigationBarHidden = true; //UIPickerView-------------------------------------------------------------- //model for data loading PickerModel model = new PickerModel(this.View); //picker UIPickerView picker = new UIPickerView(); picker.Frame = new RectangleF(0,164,768,216); picker.ShowSelectionIndicator = true; picker.Model = model; //-------------------------------------------------------------------------- //Setup the toolbar UIToolbar toolbar = new UIToolbar(); toolbar.Frame = new RectangleF(0,380,768,44); 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) => { //do something after the values is selected // this.txtCurrentAltitude.ResignFirstResponder(); picker.RemoveFromSuperview(); toolbar.RemoveFromSuperview(); } ); UIBarButtonItem loadButton = new UIBarButtonItem ("Load",UIBarButtonItemStyle.Bordered, (s,e) => { //do something after the values is selected } ); toolbar.SetItems(new UIBarButtonItem[]{doneButton,loadButton},true); btnLoadPicker.TouchUpInside += (object sender, EventArgs e) => { this.View.AddSubview(picker); this.View.AddSubview(toolbar); }; //UIPickerView-------------------------------------------------------------- //DialogView---------------------------------------------------------------- FPLView.BackgroundColor = new UIColor(0.89f,0.78f,0.56f,1.00f); ListBoxDialog lbd = new ListBoxDialog(); MTDView.AddSubview(lbd.View); btnFPLLoad.BackgroundColor = new UIColor(0.78f,0.65f,0.39f,1.00f); //COLOR ON PRESS // btnFPLLoad.TintColor = new UIColor(0.78f,0.65f,0.39f,1.00f); btnFPLCancel.BackgroundColor = new UIColor(0.78f,0.65f,0.39f,1.00f); btnFPLCancel.TouchUpInside += (object sender, EventArgs e) => { FPLView.RemoveFromSuperview(); }; btnDialog.TouchUpInside += (object sender, EventArgs e) => { this.View.AddSubview(FPLView); }; }
private void SetupPicker() { // Setup the picker and model PickerModel model = new PickerModel(this.colors); model.PickerChanged += (sender, e) => { this.selectedColor = e.SelectedValue; }; UIPickerView picker = new UIPickerView(); picker.ShowSelectionIndicator = true; picker.Model = model; // 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) => { this.ColorTextField.Text = selectedColor; this.ColorTextField.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true); // Tell the textbox to use the picker for input this.ColorTextField.InputView = picker; // Display the toolbar over the pickers this.ColorTextField.InputAccessoryView = toolbar; }
private void CreatePicker_PrivacyLevels() { // Create Picker var picker = new UIPickerView (); picker.Model = new PrivacyLevelViewModel(prayerService.PrivacyLevels); picker.ShowSelectionIndicator = true; // Create Toolbar for Picker UIToolbar toolbar = new UIToolbar (); toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit (); // Event Handler for Done Button on Drop Down UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,(s,e) => { foreach (UIView view in this.View.Subviews) { if (view.IsFirstResponder) { UITextField textview = (UITextField)view; var pickerItem = picker.Model as PrivacyLevelViewModel; textview.Text = pickerItem.SelectedItem.Level; textview.ResignFirstResponder (); } } } ); toolbar.SetItems (new UIBarButtonItem[]{doneButton},true); // Set Textbox to use Picker txtPrivacy.InputView = picker; txtPrivacy.InputAccessoryView = toolbar; // Select Item currently in Textbox txtPrivacy.TouchDown += (sender, e) => { UITextField field = (UITextField)sender; var index = 0; if (field.Text != ""){ index = prayerService.PrivacyLevels.FindIndex (a => a.Level == field.Text); } picker.Select (index, 0, true); } ; }
public override void ViewDidLoad() { base.ViewDidLoad (); RegisterForKeyboardNotifications(); this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("backgrounds/Pattern_Cloth")); this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Save, SaveButtonHandler), true); myScrollView = new UIScrollView(new RectangleF(0,0,this.View.Bounds.Width,this.View.Bounds.Height)); myScrollView.ContentSize = new SizeF(this.View.Bounds.Width,this.View.Bounds.Height+25); myScrollView.ContentInset = new UIEdgeInsets(0,0,25,0); myScrollView.UserInteractionEnabled = true; myScrollView.ScrollsToTop = true; myScrollView.AlwaysBounceVertical = true; myScrollView.Bounces = true; this.View.AddSubview(myScrollView); myLabel = new UILabel(new RectangleF(10,10,myScrollView.Bounds.Width-20,31)); myLabel.Text = "Scout Info"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.BoldSystemFontOfSize(18); myScrollView.AddSubview(myLabel); myLabel = new UILabel(new RectangleF(10,51,100,31)); myLabel.Text = "First Name"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myScrollView.AddSubview(myLabel); txtFirstName = new UITextField(new RectangleF(112,51,190,31)); txtFirstName.Font = UIFont.SystemFontOfSize(18); txtFirstName.BackgroundColor = UIColor.White; txtFirstName.BorderStyle = UITextBorderStyle.RoundedRect; txtFirstName.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtFirstName.ClearButtonMode = UITextFieldViewMode.WhileEditing; myScrollView.AddSubview(txtFirstName); myLabel = new UILabel(new RectangleF(10,87,100,31)); myLabel.Text = "Last Name"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myScrollView.AddSubview(myLabel); txtLastName = new UITextField(new RectangleF(112,87,190,31)); txtLastName.Font = UIFont.SystemFontOfSize(18); txtLastName.BackgroundColor = UIColor.White; txtLastName.BorderStyle = UITextBorderStyle.RoundedRect; txtLastName.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtLastName.ClearButtonMode = UITextFieldViewMode.WhileEditing; myScrollView.AddSubview(txtLastName); myLabel = new UILabel(new RectangleF(10,123,100,31)); myLabel.Text = "Nickname"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myScrollView.AddSubview(myLabel); txtNickName = new UITextField(new RectangleF(112,123,190,31)); txtNickName.Font = UIFont.SystemFontOfSize(18); txtNickName.BackgroundColor = UIColor.White; txtNickName.BorderStyle = UITextBorderStyle.RoundedRect; txtNickName.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtNickName.ClearButtonMode = UITextFieldViewMode.WhileEditing; myScrollView.AddSubview(txtNickName); myLabel = new UILabel(new RectangleF(10,159,100,31)); myLabel.Text = "Den"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myScrollView.AddSubview(myLabel); myActionSheet = new UIActionSheet(); myActionSheet.Style = UIActionSheetStyle.BlackTranslucent; toolbarDen = new UIToolbar(RectangleF.Empty); toolbarDen.BarStyle = UIBarStyle.Black; toolbarDen.Translucent = true; toolbarDen.UserInteractionEnabled = true; toolbarDen.SizeToFit(); UIBarButtonItem btnCancel = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, PickerButtonCancelHandler); UIBarButtonItem btnFlexibleSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null); UIBarButtonItem btnDone = new UIBarButtonItem(UIBarButtonSystemItem.Done, PickerButtonDoneHandler); UIBarButtonItem[] items = new UIBarButtonItem[] { btnCancel, btnFlexibleSpace, btnDone }; toolbarDen.SetItems(items, true); myActionSheet.AddSubview(toolbarDen); pickerDen = new UIPickerView(RectangleF.Empty); myDenPicker = new DenPicker(); myDenPicker.Items.Add(""); myDenPicker.Items.Add("Tiger"); myDenPicker.Items.Add("Wolf"); myDenPicker.Items.Add("Bear"); myDenPicker.Items.Add("Weblo"); pickerDen.Source = myDenPicker; pickerDen.UserInteractionEnabled = true; pickerDen.ShowSelectionIndicator = true; myActionSheet.AddSubview(pickerDen); txtDen = new UITextField(new RectangleF(112,159,190,31)); txtDen.Font = UIFont.SystemFontOfSize(18); txtDen.BackgroundColor = UIColor.White; txtDen.BorderStyle = UITextBorderStyle.RoundedRect; txtDen.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtDen.ClearButtonMode = UITextFieldViewMode.WhileEditing; txtDen.EditingDidBegin += delegate { //prevent keyboard from popping up txtDen.ResignFirstResponder(); txtDen.InputView = pickerDen; actionSheetSize = new SizeF (this.View.Frame.Width,364); // RectangleF actionSheetFrame = new RectangleF (0, this.View.Bounds.Height - actionSheetSize.Height, // actionSheetSize.Width, actionSheetSize.Height); myActionSheet.ShowInView(this.View); myActionSheet.Frame = new RectangleF (0, UIScreen.MainScreen.Bounds.Height - 320, actionSheetSize.Width, 320); pickerDen.Frame = new RectangleF(0, 44, myActionSheet.Frame.Width, 216); }; myScrollView.AddSubview(txtDen); myLabel = new UILabel(new RectangleF(10,195,100,31)); myLabel.Text = "Mom's Name"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myLabel.AdjustsFontSizeToFitWidth = true; myScrollView.AddSubview(myLabel); txtMomName = new UITextField(new RectangleF(112,195,190,31)); txtMomName.Font = UIFont.SystemFontOfSize(18); txtMomName.BackgroundColor = UIColor.White; txtMomName.BorderStyle = UITextBorderStyle.RoundedRect; txtMomName.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtMomName.ClearButtonMode = UITextFieldViewMode.WhileEditing; myScrollView.AddSubview(txtMomName); myLabel = new UILabel(new RectangleF(10,231,100,31)); myLabel.Text = "Dad's Name"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myLabel.AdjustsFontSizeToFitWidth = true; myScrollView.AddSubview(myLabel); txtDadName = new UITextField(new RectangleF(112,231,190,31)); txtDadName.Font = UIFont.SystemFontOfSize(18); txtDadName.BackgroundColor = UIColor.White; txtDadName.BorderStyle = UITextBorderStyle.RoundedRect; txtDadName.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtDadName.ClearButtonMode = UITextFieldViewMode.WhileEditing; myScrollView.AddSubview(txtDadName); myLabel = new UILabel(new RectangleF(10,267,100,31)); myLabel.Text = "Email"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myScrollView.AddSubview(myLabel); txtEmail = new UITextField(new RectangleF(112,267,190,31)); txtEmail.Font = UIFont.SystemFontOfSize(18); txtEmail.BackgroundColor = UIColor.White; txtEmail.BorderStyle = UITextBorderStyle.RoundedRect; txtEmail.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtEmail.ClearButtonMode = UITextFieldViewMode.WhileEditing; txtEmail.KeyboardType = UIKeyboardType.EmailAddress; myScrollView.AddSubview(txtEmail); myLabel = new UILabel(new RectangleF(10,303,100,31)); myLabel.Text = "Home Phone"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myLabel.AdjustsFontSizeToFitWidth = true; myScrollView.AddSubview(myLabel); txtHomePhone = new UITextField(new RectangleF(112,303,190,31)); txtHomePhone.Font = UIFont.SystemFontOfSize(18); txtHomePhone.BackgroundColor = UIColor.White; txtHomePhone.BorderStyle = UITextBorderStyle.RoundedRect; txtHomePhone.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtHomePhone.ClearButtonMode = UITextFieldViewMode.WhileEditing; myScrollView.AddSubview(txtHomePhone); myLabel = new UILabel(new RectangleF(10,339,100,31)); myLabel.Text = "Mobile Phone"; myLabel.BackgroundColor = UIColor.Clear; myLabel.Font = UIFont.SystemFontOfSize(18); myLabel.AdjustsFontSizeToFitWidth = true; myScrollView.AddSubview(myLabel); txtMobilePhone = new UITextField(new RectangleF(112,339,190,31)); txtMobilePhone.Font = UIFont.SystemFontOfSize(18); txtMobilePhone.BackgroundColor = UIColor.White; txtMobilePhone.BorderStyle = UITextBorderStyle.RoundedRect; txtMobilePhone.VerticalAlignment = UIControlContentVerticalAlignment.Center; txtMobilePhone.ClearButtonMode = UITextFieldViewMode.WhileEditing; myScrollView.AddSubview(txtMobilePhone); if (ScoutAction == "EditScout") { FetchScoutForEditing(ScoutID); } }
public KeyboardInputView (RectangleF frame) : base(frame) { _toolbar = new UIToolbar (frame); var toolbarItems = new UIBarButtonItem[] { new UIBarButtonItem (UIBarButtonSystemItem.Cancel, CancelButton_Tapped), new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null), new UIBarButtonItem (UIBarButtonSystemItem.Done, DoneButton_Tapped) }; _toolbar.SetItems (toolbarItems, false); _toolbar.SizeToFit (); _textFieldContainer = new UIScrollView(new RectangleF(0, 0, 100, 100)); _textField = new UITextField (_textFieldContainer.Bounds); _textField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _textField.BorderStyle = UITextBorderStyle.RoundedRect; _textField.Delegate = new TextFieldDelegate (this); // Change this to be capitalization of all characters. Does not really seem to work _textField.AutocapitalizationType = UITextAutocapitalizationType.AllCharacters; _textFieldContainer.Add (_textField); Add (_toolbar); Add (_textFieldContainer); AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; AutosizesSubviews = false; Opaque = true; BackgroundColor = UIColor.FromRGB (0xC5, 0xCC, 0xD4); SetNeedsLayout (); }
/// <Docs> /// Bounds for the entry to create /// </Docs> /// <returns> /// /// </returns> /// <summary> /// Creates the text field. /// </summary> /// <param name='frame'> /// Frame. /// </param> protected override UITextField CreateTextField(RectangleF frame) { UITextField uITextField = base.CreateTextField(frame); string closeButtonText = "Done"; UIToolbar toolbar = new UIToolbar (); uITextField.KeyboardType = this.KeyboardType; toolbar.BarStyle = UIBarStyle.Black; toolbar.Translucent = true; toolbar.SizeToFit (); UIBarButtonItem nextButton = new UIBarButtonItem ("Next", UIBarButtonItemStyle.Bordered, (s, e) => { nextelement.BecomeFirstResponder(true); }); if(nextelement == null) nextButton.Enabled = false; UIBarButtonItem prevButton = new UIBarButtonItem ("Prev", UIBarButtonItemStyle.Bordered, (s, e) => { prevelement.BecomeFirstResponder(true); }); if(prevelement == null) prevButton.Enabled = false; UIBarButtonItem doneButton = new UIBarButtonItem (closeButtonText, UIBarButtonItemStyle.Done, (s, e) => { uITextField.ResignFirstResponder (); }); toolbar.SetItems (new UIBarButtonItem[]{prevButton, nextButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), doneButton}, true); uITextField.InputAccessoryView = toolbar; return uITextField; }
private void SetupPicker() { // Setup the picker and model PickerModel model = new PickerModel(this.colors); model.PickerChanged += (sender, e) => { this.selectedColor = e.SelectedValue; }; UIPickerView picker = new UIPickerView(); picker.ShowSelectionIndicator = true; picker.Model = model; http://www.windowsphone.com/tr-tr/store/app/anl%C4%B1k-hava-durumu/b26e9109-01c5-4e2d-9914-7ee19d2a0aa0?signin=truehttp://www.windowsphone.com/tr-tr/store/app/anl%C4%B1k-hava-durumu/b26e9109-01c5-4e2d-9914-7ee19d2a0aa0?signin=true // 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("Tamam", UIBarButtonItemStyle.Done, (s, e) => { this.modulSec.Text = selectedColor; this.modulSec.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true); // Tell the textbox to use the picker for input this.modulSec.InputView = picker; // Display the toolbar over the pickers this.modulSec.InputAccessoryView = toolbar; }