public DatePickeriOSCell(NSString cellId, DatePickerCell nativeCell) : base(UITableViewCellStyle.Default, cellId) { NativeCell = nativeCell; SelectionStyle = UITableViewCellSelectionStyle.Gray; _datePickerView = new UIDatePicker(); _datePickerView.Date = nativeCell.Date.ToNSDate(); _datePickerView.ValueChanged += (sender, e) => { NativeCell.Date = _datePickerView.Date.ToDateTime(); }; ContentView.Add(_datePickerView); }
protected void BuildTable() { string[] MedicalLevels = new string[] { "None", "Nonemergency", "EMR", "BLS", "ALS" }; Dictionary <DutyStatus, string> Statuses = new Dictionary <DutyStatus, string>(); Statuses.Add(DutyStatus.OFF_DUTY, "Off Duty"); Statuses.Add(DutyStatus.ON_DUTY, "On Duty"); Statuses.Add(DutyStatus.OOS, "Out of Service"); List <string> StatusValues = new List <string>(Statuses.Values); PickerViewCell StatusCell = VehicleDetailPickerCell.Create(StatusValues); StatusCell.TextLabel.Text = "Status"; StatusCell.RightLabelTextAlignment = UITextAlignment.Right; StatusCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; StatusCell.SelectedObject = new object[] { StatusValues.IndexOf(Statuses[CurrentApparatus.Status.DutyStatus]) }; StatusCell.OnItemChanged += (object sender, PickerCellArgs e) => { Parent.UpdateStatus((string)e.Items[0]); }; PickerViewCell PersonnelCell = VehicleDetailPickerCell.Create(CurrentApparatus.Seats); PersonnelCell.TextLabel.Text = "Personnel Count"; PersonnelCell.RightLabelTextAlignment = UITextAlignment.Right; PersonnelCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; PersonnelCell.SelectedObject = new object[] { CurrentApparatus.Status.PersonnelCount }; PersonnelCell.OnItemChanged += (object sender, PickerCellArgs e) => { Parent.UpdatePersonnel(Convert.ToInt32(e.Items[0])); }; PickerViewCell MedicalLevelCell = VehicleDetailPickerCell.Create(new List <string>(MedicalLevels)); MedicalLevelCell.TextLabel.Text = "Medical Level"; MedicalLevelCell.RightLabelTextAlignment = UITextAlignment.Right; MedicalLevelCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; MedicalLevelCell.SelectedObject = new object[] { System.Array.IndexOf(MedicalLevels, CurrentApparatus.Status.MedicalLevel) }; MedicalLevelCell.OnItemChanged += (object sender, PickerCellArgs e) => { Parent.UpdateMedicalLevel((string)e.Items[0]); }; DateTime defaultOnDutyTime; if (CurrentApparatus.Status.DutyStatus == DutyStatus.ON_DUTY) { defaultOnDutyTime = CurrentApparatus.Status.OnDutyTime; } else { defaultOnDutyTime = DateTime.Now; } DatePickerCell OnDutyTimeCell = new DatePickerCell(UIDatePickerMode.DateAndTime, defaultOnDutyTime); OnDutyTimeCell.TextLabel.Text = "On Duty Time"; OnDutyTimeCell.RightLabelTextAlignment = UITextAlignment.Right; OnDutyTimeCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; OnDutyTimeCell.OnItemChanged += (object sender, PickerCellArgs e) => { Parent.UpdateOnDutyTime((DateTime)e.Items[0]); }; DateTime defaultOffDutyTime; if (CurrentApparatus.Status.DutyStatus == DutyStatus.ON_DUTY) { defaultOffDutyTime = CurrentApparatus.Status.OffDutyTime; } else { defaultOffDutyTime = DateTime.Now.AddHours(8); } DatePickerCell OffDutyTimeCell = new DatePickerCell(UIDatePickerMode.DateAndTime, defaultOffDutyTime); OffDutyTimeCell.TextLabel.Text = "Off Duty Time"; OffDutyTimeCell.RightLabelTextAlignment = UITextAlignment.Right; OffDutyTimeCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; OffDutyTimeCell.OnItemChanged += (object sender, PickerCellArgs e) => { Parent.UpdateOffDutyTime((DateTime)e.Items[0]); }; Parent.UpdatePost("Test Post, Please Ignore"); DetailItems.Add(StatusCell); DetailItems.Add(PersonnelCell); DetailItems.Add(MedicalLevelCell); DetailItems.Add(OnDutyTimeCell); DetailItems.Add(OffDutyTimeCell); }
public DateTableViewSource() { mCells = new List <BasePickerCell>(); var aCell = new DatePickerCell(UIDatePickerMode.Date, DateTime.Now) { Key = "1234", }; aCell.TextLabel.Text = "Date"; aCell.RightLabelTextAlignment = UITextAlignment.Right; aCell.OnItemChanged += (object sender, PickerCellArgs e) => { var result = e.Items; }; mCells.Add(aCell); var someDict = new Dictionary <int, PickerViewCellComponent>(); someDict[0] = new PickerViewCellComponent() { Width = 160, Items = new List <PickerViewCellItem>() { new PickerViewCellItem() { SelectedValue = 1, DisplayValue = "Bob", }, new PickerViewCellItem() { SelectedValue = 2, DisplayValue = "John", }, } }; someDict[1] = new PickerViewCellComponent() { Width = 160, Items = new List <PickerViewCellItem>() { new PickerViewCellItem() { SelectedValue = 1, DisplayValue = "Dylan", }, new PickerViewCellItem() { SelectedValue = 2, DisplayValue = "Lennon", }, } }; // You can also use a string list for a single component // var aList = new List<String> (){ "Ringo", "John", "Paul", "George" }; // var pickerCell = new PickerViewCell(aList); var pickerCell = new PickerViewCell(someDict); pickerCell.TextLabel.Text = "Artist"; pickerCell.RightLabelTextAlignment = UITextAlignment.Right; pickerCell.SelectedObject = new object[] { 1, 1 }; pickerCell.OnItemChanged += (object sender, PickerCellArgs e) => { var result = e.Items; }; mCells.Add(pickerCell); }