Пример #1
0
        public void ShowPicker()
        {
            InitPicker();

            picker.Select((int)ViewModel.ValidityTime.Month - 1, 0, false);
            picker.Select((int)ViewModel.ValidityTime.Year - DateTime.Today.Year, 1, false);

            popoverPicker.PresentPopoverFromRect(btnPick.Frame, vContent, WYPopoverArrowDirection.Down, true);
        }
 private void SelectPickerValue(UIPickerView customModelPickerView, TimeCountdownPicker myTimePicker)
 {
     if (myTimePicker == null)
     {
         return;
     }
     customModelPickerView.Select(new nint(myTimePicker.SelectedTime.Hours), 0, false);
     customModelPickerView.Select(new nint(myTimePicker.SelectedTime.Minutes), 2, false);
     customModelPickerView.Select(new nint(myTimePicker.SelectedTime.Seconds), 4, false);
 }
Пример #3
0
 public override void Selected(UIPickerView picker, nint row, nint component)
 {
     if(component == 0 && row > picker.SelectedRowInComponent(1))
     {
         picker.Select(row, 1, true);
     }
     if(component == 1 && row < picker.SelectedRowInComponent(0))
     {
         picker.Select(row, 0, true);
     }
 }
 public override void Selected(UIPickerView picker, nint row, nint component)
 {
     if (component == 0 && row > picker.SelectedRowInComponent(1))
     {
         picker.Select(row, 1, true);
     }
     if (component == 1 && row < picker.SelectedRowInComponent(0))
     {
         picker.Select(row, 0, true);
     }
 }
Пример #5
0
        void AddObjectToSource(int newIndex)
        {
            PropertyInfo prop = null;

            var    item = Element.ItemsSource.Cast <object>().ToList().ElementAt(newIndex);
            string text = "";

            if (!string.IsNullOrWhiteSpace(Element.DisplayTextField))
            {
                if (prop == null)
                {
                    prop = item.GetType().GetRuntimeProperty(Element.DisplayTextField);
                }

                if (prop != null && prop.GetValue(item) != null)
                {
                    text = prop.GetValue(item).ToString();
                    pickerModel.AddData(text);
                }
            }
            else
            {
                text = item + "";
                pickerModel.AddData(text);
            }

            if (!string.IsNullOrWhiteSpace(Element.Placeholder))
            {
                pickerModel.InsertData(0, Element.Placeholder);
            }

            var index = (!string.IsNullOrWhiteSpace(Element.Placeholder)) ?
                        Element.SelectedIndex + 1 : Element.SelectedIndex;

            if (newIndex == index)
            {
                //Control.Text = text;
                //                                var selectedIndex = element.SelectedIndex;
                //                                if (!string.IsNullOrEmpty(element.Placeholder))
                //                                    selectedIndex = selectedIndex < 0 ? 0 : selectedIndex + 1;
                //
                if (pickerModel.Count() > 0)
                {
                    picker.Select(index, 0, false);
                }

                Control.Text = pickerModel.GetText(index);
            }
            picker.ReloadAllComponents();
        }
Пример #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var toolBar       = new UIToolbar(new CGRect(0, 0, 320, 44));
            var doneButton    = new UIBarButtonItem(UIBarButtonSystemItem.Done);
            var flexibleSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            toolBar.SetItems(new UIBarButtonItem[] { flexibleSpace, doneButton }, true);

            var model  = new SelectionModePickerViewModel();
            var picker = new UIPickerView();

            picker.Model = model;
            picker.Select((nint)(int)Grid.SelectionMode, 0, true);
            SelectionModeField.InputView          = picker;
            SelectionModeField.InputAccessoryView = toolBar;
            SelectionModeField.Text = pickerOptionStrings[2];

            doneButton.Clicked += (s, e) =>
            {
                var selectedIndex = (int)picker.SelectedRowInComponent(0);
                var selectedMode  = (GridSelectionMode)selectedIndex;
                SelectionModeField.Text = pickerOptionStrings[selectedIndex];
                Grid.SelectionMode      = selectedMode;
                Grid.BecomeFirstResponder();
            };

            var data = Customer.GetCustomerList(100);

            Grid.ItemsSource       = data;
            Grid.AllowResizing     = GridAllowResizing.Both;
            Grid.SelectionChanged += OnSelectionChanged;
        }
        private void PopulateData()
        {
            var soundString = _defaults.StringForKey(Constants.UserDefaultsNotificationSoundsKey);

            NotificationSoundPicker.Text = soundString;
            _notificationSoundPicker.Select((int)soundString.DehumanizeTo <Constants.NotificationSounds>(), 0, false);
        }
        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();
            }
        }
Пример #9
0
        private void CreateFilterSheet(List <Category> categories)
        {
            alertController = UIAlertController.Create("Categorias", "", UIAlertControllerStyle.ActionSheet);
            alertController.View.UserInteractionEnabled = true;

            var height = NSLayoutConstraint.Create(alertController.View, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 200);

            alertController.View.AddConstraint(height);

            categoriesPicker = new UIPickerView(new CGRect(0, 20, UIScreen.MainScreen.Bounds.Width - 20, 180))
            {
                Model = new FilterCategoriesPickerModel(categories, FilterAndClose)
            };

            alertController.View.AddSubview(categoriesPicker);
            categoriesPicker.Select(_selectedCategory, 0, true);

            PresentViewController(alertController, true, () =>
            {
                UITapGestureRecognizer recognizer = new UITapGestureRecognizer((tapRecognizer) =>
                {
                    alertController.DismissViewController(true, null);
                });

                alertController.View.Superview.Subviews[0].AddGestureRecognizer(recognizer);
            });
        }
        public override void Selected(UIPickerView picker, nint row, nint component)
        {
            if (DeliveryDays.IsNullOrEmpty() || (int)row >= DeliveryDays.Count)
            {
                return;
            }

            if (component == 0)
            {
                SelectedDay = DeliveryDays[(int)row];

                picker.ReloadComponent(1);

                var sameValueRow = SelectedDay?.Times?.FindIndex(x => x.Name.Equals(SelectedTime?.Name)) ?? -1;
                var newTimeRow   = (sameValueRow > 0 ? sameValueRow : 0);

                picker.Select(newTimeRow, 1, true);
                SelectedTime = SelectedDay.Times[newTimeRow];
            }
            else
            {
                SelectedTime = SelectedDay.Times[(int)row];
            }

            SelectedItem = SelectedTime;
            if (SelectedChangedCommand != null && SelectedChangedCommand.CanExecute(SelectedItem))
            {
                SelectedChangedCommand.Execute(SelectedItem);
            }
        }
        public static void ToPickerWithValues(this UITextField textField, IList <string> values, int index, Action <int> action)
        {
            var toolBar       = new UIToolbar(new CGRect(0, 0, 320, 44));
            var doneButton    = new UIBarButtonItem(UIBarButtonSystemItem.Done);
            var flexibleSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            toolBar.SetItems(new UIBarButtonItem[] { flexibleSpace, doneButton }, true);

            var model  = new UIPickerViewStringArrayModel();
            var picker = new UIPickerView();

            picker.Model = model;
            foreach (var displayValue in values)
            {
                model.Items.Add(displayValue.ToString());
            }
            picker.Select(index, 0, true);
            textField.InputView          = picker;
            textField.InputAccessoryView = toolBar;
            textField.Text = values[index].ToString();

            doneButton.Clicked += (s, e) =>
            {
                var selectedIndex = (int)picker.SelectedRowInComponent(0);
                textField.Text = values[selectedIndex].ToString();
                textField.EndEditing(true);
                action?.Invoke(selectedIndex);
            };
        }
Пример #12
0
        /*public override UIView GetView(UIPickerView pickerView, nint row, nint component, UIView view)
         * {
         *  //if (view == null) {
         *      CGSize rowSize = pickerView.RowSizeForComponent(component);
         *      UILabel lbl = new UILabel(new CGRect(new CGPoint(0, 0), rowSize));
         *
         *      lbl.TextColor = UIColor.Black;
         *      lbl.Font = UIFont.SystemFontOfSize(m_fontSize);
         *      lbl.TextAlignment = UITextAlignment.Center;
         *      lbl.Text = m_names[(int)row];
         *      return lbl;
         *  //}
         *  //return view;
         * }*/

        public override void Selected(UIPickerView pickerView, nint row, nint component)
        {
            SelectedRow = (int)row;
            pickerView.Select(row, component, false);

            RowSelected?.Invoke((int)row);
        }
        void UpdatePickerSelectedIndex(int formsIndex)
        {
            var source = (PickerSource)_picker.Model;

            source.SelectedIndex = formsIndex;
            source.SelectedItem  = formsIndex >= 0 ? Element.Items[formsIndex] : null;
            _picker.Select(Math.Max(formsIndex, 0), 0, true);
        }
        private void ResetButton_TouchUpInside(object sender, EventArgs e)
        {
            // Remove any currently displayed result.
            _polygonsOverlay.Graphics.Remove(_resultGraphic);

            // Clear the selected spatial operation.
            _operationPicker.Select(0, 0, true);
        }
Пример #15
0
        private void SetPicker(object sender, EventArgs e)
        {
            UITextField field = (UITextField)sender;

            if (field.Text != "")
            {
                pickerView.Select(PopOverModel.Items.IndexOf(field.Text), 0, true);
            }
        }
Пример #16
0
        public void ShowPicker()
        {
            InitPicker();

            DateTime now      = DateTime.UtcNow.ToLocalTime();
            DateTime birthday = DateTime.UtcNow.ToLocalTime();

            if (ViewModel.User.DateOfBirth != null && !ViewModel.User.DateOfBirth.Equals("na"))
            {
                birthday = DateTime.Parse(ViewModel.User.DateOfBirth);
            }

            picker.Select(99 - (now.Year - birthday.Year), 0, false);
            picker.Select((int)birthday.Month - 1, 1, false);
            picker.Select((int)birthday.Day - 1, 2, false);

            popoverPicker.PresentPopoverFromRect(btnPick.Frame, this.View, WYPopoverArrowDirection.Down, true);
        }
 public override void Selected(UIPickerView pickerView, nint row, nint component)
 {
     if (component == 0)
     {
         selectedRow = pickerView.SelectedRowInComponent(component);
         pickerView.ReloadComponent(1);
         pickerView.Select(0, 1, true);
     }
 }
Пример #18
0
        public bool SelectById(UIPickerView pickerView, int id)
        {
            int index = rows.FindIndex((LanguageChoice obj) => obj.Id == id);

            pickerView.Select(index + 1, 0, true);

            // found?
            return(index != -1);
        }
Пример #19
0
        public void ShowLanguagePicker()
        {
            InitPicker();

            var list = AppConstants.Languages.ToList();

            picker.Select(list.IndexOf(ViewModel.Language), 0, true);

            popoverPicker.PresentPopoverFromRect(btnPickLanguage.Frame, vContent, WYPopoverArrowDirection.Up, true);
        }
Пример #20
0
        public void ShowRepeatPicker()
        {
            View.EndEditing(true);
            InitRepeatPicker();

            var list = new List <string>(AppConstants.Repeats);

            repeatPicker.Select(list.IndexOf(ViewModel.SelectedRepeat), 0, true);
            repeatPopoverPicker.PresentPopoverFromRect(btnRepeat.Frame, vContent, WYPopoverArrowDirection.Down, true);
        }
Пример #21
0
 /// <summary>
 /// Updates the picker.
 /// </summary>
 private void UpdatePicker()
 {
     Control.Placeholder = Element.Title;
     Control.Text        = (Element.SelectedIndex <= -1 || Element.Items == null) ? "" : Element.Items[Element.SelectedIndex];
     _picker.ReloadAllComponents();
     if (Element.SelectedIndex > -1 && Element.Items != null && Enumerable.Any <string>(Element.Items))
     {
         _picker.Select(Element.SelectedIndex, 0, true);
     }
 }
Пример #22
0
        public virtual bool SetText(string text, string alignment = null, bool tiggered = false)
        {
            m_originalText = text;

            m_alignment = string.IsNullOrEmpty(alignment) ? m_alignment : alignment;
            // Add extra space for buttons, otherwise they don't look good.
            if (m_viewX is UIButton)
            {
                if (m_alignment == "left")
                {
                    text = " " + text;
                }
                else if (m_alignment == "right")
                {
                    text = text + " ";
                }
            }
            AlignText(alignment);

            if (WidgetType == UIType.COMBOBOX && !tiggered)
            {
                SetComboboxText(text);
            }
            else if (ViewX is UIButton)
            {
                ((UIButton)ViewX).SetTitle(text, UIControlState.Normal);
            }
            else if (ViewX is UILabel)
            {
                ((UILabel)ViewX).Text = text;
            }
            else if (ViewX is UITextField)
            {
                ((UITextField)ViewX).Text = text;
            }
            else if (ViewX is UITextView)
            {
                ((UITextView)ViewX).Text = text;
            }
            else if (ViewX is UIPickerView && !tiggered)
            {
                UIPickerView        picker = ViewX as UIPickerView;
                TypePickerViewModel model  = picker.Model as TypePickerViewModel;
                int row = model.StringToRow(text);
                picker.Select((int)row, 0, true);
                model.Selected(picker, (int)row, 0);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Пример #23
0
            public bool SelectItem(UIPickerView pickerView, string item)
            {
                int index = Array.IndexOf(data, item);

                if (index > 0)
                {
                    pickerView.Select(index, 0, false);
                    return(true);
                }
                return(false);
            }
        private UIPickerView CreateHoursField()
        {
            var hoursField = new UIPickerView()
            {
                Frame = new CGRect(100, 200, View.Bounds.Width - 120, 40),
            };

            hoursField.Model = new TimesheetEntryHoursViewModel();
            hoursField.Select(32, 0, true);
            return(hoursField);
        }
Пример #25
0
 public void pickerSelectCancel(UIPickerView pickerView)
 {
     for (int i = 0; i < pickerView.NumberOfComponents; i++)
     {
         pickerView.Select(this.originalSelectedRow[i], i, false);
         if (i < pickerView.NumberOfComponents - 1)
         {
             // 觸發selected去reload component
             this.Selected(pickerView, this.originalSelectedRow[i], i);
         }
     }
 }
Пример #26
0
        private void SetupFeedView()
        {
            if (this.ViewModel.SelectedFeedVm == null)
            {
                this.NoMenu.Hidden = true;
                this.FeedName.Text = string.Empty;
                return;
            }

            this.FeedSelection.SelectedSegment = this.ViewModel.Items.IndexOf(this.ViewModel.SelectedFeedVm);

            this.FeedName.Text = this.ViewModel.SelectedFeedVm.Feed.Name;

            if (this.ViewModel.SelectedFeedVm.Items.Count > 0)
            {
                this.NoMenu.Hidden = true;

                this.Menu = this.ViewModel.SelectedFeedVm.FindItemClosestToSelectedDay();

                var index = this.ViewModel.SelectedFeedVm.Items.IndexOf(this.Menu);
                this.Backward.Enabled = index != 0;
                this.Forward.Enabled  = index != this.ViewModel.SelectedFeedVm.Items.Count - 1;

                this.DateInput.Enabled = true;
                this.DateInput.Text    = this.Menu.Title;

                var datePickerModel = new DatePickerModel(this.ViewModel.SelectedFeedVm.Items);
                datePickerModel.PickerChanged += this.Model_PickerChanged;

                var dateInputInputView = new UIPickerView
                {
                    Model = datePickerModel
                };

                dateInputInputView.Select(index, 0, false);

                this.DateInput.InputView = dateInputInputView;

                this.LoadWebView();
            }
            else
            {
                this.NoMenu.Hidden = false;

                this.DateInput.Enabled = false;
                this.DateInput.Text    = string.Empty;

                this.Backward.Enabled = false;
                this.Forward.Enabled  = false;

                this.WebView.LoadHtmlString(string.Empty, null);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var exercisePickerModel = new PickerModel(PickerListHelper.GetExerciseTypeStrings());

            _exerciseTypePicker = MirroredPicker.Create(exercisePickerModel, ExerciseType, doneAction: ShowHideCustomName);

            var repetitionsPickerModel = new PickerModel(Enumerable.Range(1, 100).Select(n => n.ToString()).ToList());

            _repetitionTypePicker = MirroredPicker.Create(repetitionsPickerModel, NumberOfRepetitions, doneAction: ShowHideCustomName);

            if (SelectedExerciseId.HasValue)
            {
                _selectedExercise = Data.GetExerciseById(SelectedExerciseId.Value);

                ExerciseType.Text = _selectedExercise.Type.Humanize();
                _exerciseTypePicker.Select((int)_selectedExercise.Type, 0, false);
                NumberOfRepetitions.Text = _selectedExercise.Quantity.ToString();
                _repetitionTypePicker.Select(_selectedExercise.Quantity - 1, 0, false);
                CustomExerciseName.Text = _selectedExercise.CombinedName;
            }
            else
            {
                ExerciseType.Text = PickerListHelper.GetExerciseTypeStrings()[0];
                _exerciseTypePicker.Select(0, 0, false);
                NumberOfRepetitions.Text = "10";
                _repetitionTypePicker.Select(9, 0, false);
                CustomExerciseName.Text = string.Empty;
            }

            ShowHideCustomName();
            AddButtons();

            var pickerTextFields = View.Subviews.OfType <PickerUITextField>().ToArray();

            Colors.SetTextPrimaryColor(pickerTextFields);
            CustomExerciseName.BackgroundColor = Colors.MainBackgroundColor;
            CustomExerciseName.TextColor       = Colors.PrimaryColor;
        }
Пример #28
0
            public void Attach(UIPickerView pickerView, UITableView tableView, NSIndexPath indexPath)
            {
                pickerView.Model = this;
                pickerView.ShowSelectionIndicator = false;

                this.tableView = tableView;
                this.indexPath = indexPath;

                if (selectedIndex > 0)
                {
                    pickerView.Select(selectedIndex, 0, true);
                }
            }
Пример #29
0
        void BuildUI()
        {
            headingLabel.Frame         = new CoreGraphics.CGRect(0, 20, View.Bounds.Width, 38);
            headingLabel.Text          = "Mars Habitat Price Predictor";
            headingLabel.TextAlignment = UITextAlignment.Center;
            headingLabel.Font          = UIFont.BoldSystemFontOfSize(20);
            this.View.Add(headingLabel);
            var topMargin = 60;

            solarPanelLabel.Frame         = new CoreGraphics.CGRect(0, topMargin, View.Bounds.Width / 3, 38);
            solarPanelLabel.Text          = "Solar Panels";
            solarPanelLabel.TextAlignment = UITextAlignment.Center;
            this.View.Add(solarPanelLabel);
            greenhousesLabel.Frame         = new CoreGraphics.CGRect(View.Bounds.Width / 2 - View.Bounds.Width / 6, topMargin, View.Bounds.Width / 3, 38);
            greenhousesLabel.Text          = "Greenhouses";
            greenhousesLabel.TextAlignment = UITextAlignment.Center;
            this.View.Add(greenhousesLabel);
            sizeLabel.Frame         = new CoreGraphics.CGRect(View.Bounds.Width / 3 * 2, topMargin, View.Bounds.Width / 3, 38);
            sizeLabel.Text          = "Acres";
            sizeLabel.TextAlignment = UITextAlignment.Center;
            this.View.Add(sizeLabel);

            pickerView.ShowSelectionIndicator = true;
            pickerView.Frame       = new CoreGraphics.CGRect(0, topMargin, View.Bounds.Width, 250);
            datasource.OnSelected += updatePredictedPrice;
            pickerView.Delegate    = datasource;
            pickerView.DataSource  = datasource;
            pickerView.Select(2, Feature.SolarPanels, false); // default select the second item in each list
            pickerView.Select(2, Feature.Greenhouses, false);
            pickerView.Select(2, Feature.Size, false);
            this.View.Add(pickerView);

            priceLabel.Frame         = new CoreGraphics.CGRect(0, 300, View.Bounds.Width, 38);
            priceLabel.Text          = "$$$$$";
            priceLabel.TextAlignment = UITextAlignment.Center;
            priceLabel.Font          = UIFont.BoldSystemFontOfSize(20);
            this.View.Add(priceLabel);
        }
Пример #30
0
        private void PopulateData()
        {
            ReminderPeriod.Text = _schedule.PeriodDisplayString;
            _schedulePicker.Select((int)_schedule.Period, 0, false);

            var startHour     = GetCivilianHour(_schedule.StartTime.Hour);
            var startMinute   = _schedule.StartTime.Minute.ToString("D2");
            var startMeridian = GetMeridian(_schedule.StartTime.Hour);

            StartTime.Text = $"{startHour}:{startMinute} {startMeridian}";
            _startTimePicker.Select(startHour - 1, 0, false);
            _startTimePicker.Select(int.Parse(startMinute) / 15, 1, false);
            _startTimePicker.Select(_schedule.StartTime.Hour < 12 ? 0 : 1, 2, false);

            var endHour     = GetCivilianHour(_schedule.EndTime.Hour);
            var endMinute   = _schedule.EndTime.Minute.ToString("D2");
            var endMeridian = GetMeridian(_schedule.EndTime.Hour);

            EndTime.Text = $"{endHour}:{endMinute} {endMeridian}";
            _endTimePicker.Select(endHour - 1, 0, false);
            _endTimePicker.Select(int.Parse(endMinute) / 15, 1, false);
            _endTimePicker.Select(_schedule.EndTime.Hour < 12 ? 0 : 1, 2, false);
        }
        void Select(int number)
        {
            var idx = _model.Items.IndexOf(number);

            if (idx == -1)
            {
                number = _model.Items[0];
                idx    = 0;
            }
            _picker.Select(idx, 0, false);
            _model.SelectedItem    = number;
            _model.SelectedIndex   = idx;
            _model.PreSelectedItem = number;
        }
 public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
 {
     model = new CounterPickerDataModel(model.Counter);
     var vc = new MyViewController (this) {
         Autorotate = dvc.Autorotate
     };
     counterPicker = CreatePicker ();
     counterPicker.Frame = PickerFrameWithSize (counterPicker.SizeThatFits (SizeF.Empty));
     counterPicker.Model = model;
     for (int d = 0; d < model.Items.Count; d++) {
         counterPicker.Select(model.SelectedIndex[d], d, true);
     }
     vc.View.BackgroundColor = UIColor.Black;
     vc.View.AddSubview (counterPicker);
     dvc.ActivateController (vc);
 }
Пример #33
0
        public PickerAlert(string[] values, int currentSelected, Action<int> selected)
            : base(new RectangleF(0, 0, 320f, 480f))
        {
            AutosizesSubviews = true;
            this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            _values = values;
            _currentSelected = currentSelected;
            _selected = selected;

            _pickerView = new UIPickerView();
            _pickerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            _pickerView.ShowSelectionIndicator = true;
            _pickerView.Model = new PickerModel(values);
            _pickerView.BackgroundColor = UIColor.FromRGB(244, 244, 244);
            _pickerView.Select(currentSelected, 0, false);

            _toolbar = new UIToolbar();
            _toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;

            _toolbar.Items = new UIBarButtonItem[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
                    _selected(_pickerView.SelectedRowInComponent(0));
                    Dismiss();
                })
            };

            _innerView = new UIView(new RectangleF(0, Frame.Height, Frame.Width, 44f + _pickerView.Frame.Height));
            _innerView.AutosizesSubviews = true;
            _innerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;

            _toolbar.Frame = new RectangleF(0, 0, Frame.Width, 44f);
            _innerView.Add(_toolbar);

            _pickerView.Frame = new RectangleF(0, 44f, Frame.Width, _pickerView.Frame.Height);
            _innerView.Add(_pickerView);

            Add(_innerView);
        }
		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);
			} ;

		}
Пример #35
0
            /// <summary>
            /// Updates the selected items.
            /// </summary>
            /// <param name="picker">Picker.</param>
            /// <param name="value">Value.</param>
            public void UpdateSelectedItems(UIPickerView picker,object value)
            {
                if (value == null)
                    SelectedItems = null;

                if (value is object[])
                {
                    var vals = (object[])value;

                    var aMsg = String.Empty;

                    for (int index = 0; index < vals.Length; index++)
                    {
                        var theVal = vals[index];

                        if (mDataDict.Count == 0)
                            return;

                        var aList = mDataDict[index];

                        if (theVal is int)
                        {
                            //index of the selected item
                            var iVal = (int)theVal;

                            if (iVal < aList.Items.Count
                                && iVal >= 0)
                            {
                                var aItem = aList.Items[iVal];

                                aMsg += aItem.DisplayValue + mTableViewCell.SeperatorCharacter;
                            }

                            picker.Select(iVal,index,true);
                        }
                        else if (theVal is string)
                        {
                            //selected value of the selected item
                            var sVal = (string)theVal;

                            foreach (var aItem in aList.Items)
                            {
                                if (aItem.SelectedValue != null
                                    && aItem.SelectedValue is String)
                                {
                                    if (((string)aItem.SelectedValue).ToLower().Equals(sVal.ToLower()))
                                    {
                                        picker.Select(aList.Items.IndexOf(aItem),index,true);

                                        aMsg += aItem.DisplayValue + mTableViewCell.SeperatorCharacter;
                                    }
                                }
                                else if (aItem.SelectedValue != null)
                                {
                                    if (aItem.SelectedValue == theVal)
                                    {
                                        picker.Select(aList.Items.IndexOf(aItem),index,true);

                                        aMsg += aItem.DisplayValue + mTableViewCell.SeperatorCharacter;
                                    }
                                }

                            }

                        }
                    }

                    if (aMsg.EndsWith(mTableViewCell.SeperatorCharacter))
                        aMsg = aMsg.Substring(0,aMsg.LastIndexOf(mTableViewCell.SeperatorCharacter));

                    mTableViewCell.RightLabel.Text = aMsg;

                    SelectedItems = vals;
                }
            }
Пример #36
0
        partial void actionChangeKey(NSObject sender)
        {
            _actionSheet = new UIActionSheet("Title", null, string.Empty, string.Empty, null);

            var pickerView = new UIPickerView(new RectangleF(0, 44, 320, 300));
            pickerView.ShowSelectionIndicator = true;
            pickerView.WeakDelegate = this;

            var toolbar = new UIToolbar(new RectangleF(0, 0, 320, 44));
            toolbar.BarStyle = UIBarStyle.Black;

            UIBarButtonItem flexSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            var button = new UIButton(UIButtonType.Custom);
            button.SetTitle("Done", UIControlState.Normal);
            button.Layer.CornerRadius = 8;
            button.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
            button.Font = UIFont.FromName("HelveticaNeue-Bold", 12.0f);
            button.Frame = new RectangleF(0, 20, 60, 30);
            button.TouchUpInside += (sender2, e) => {
                int key = _keys[pickerView.SelectedRowInComponent(0)].Item1;
                OnChangeKey(key);
                _actionSheet.DismissWithClickedButtonIndex(0, true);
            };
            var btnDone = new UIBarButtonItem(button);
            toolbar.SetItems(new UIBarButtonItem[2] { flexSpace, btnDone }, true);

            _actionSheet.AddSubview(toolbar);
            _actionSheet.AddSubview(pickerView);
            _actionSheet.ShowInView(UIApplication.SharedApplication.KeyWindow);
            _actionSheet.Bounds = new RectangleF(0, 0, 320, 344);

            int index = _keys.IndexOf(_currentKey);
            pickerView.Select(index, 0, false);
        }
 private UIPickerView CreateHoursField()
 {
     var hoursField = new UIPickerView()
     {
         Frame = new CGRect(100, 200, View.Bounds.Width - 120, 40),
     };
     hoursField.Model = new TimesheetEntryHoursViewModel();
     hoursField.Select(32, 0, true);
     return hoursField;
 }
		public void UpdateSelection(UIPickerView uipv)
		{
			if(selectedInches > 0)
			{
				for(int i = 0; i < Inches.Length; i++)
				{
					if(Inches[i] == selectedInches.ToString())
					{
						uipv.Select(i, 0, true);
						break;
					}
				}
			}
			
			if(selectedFraction != null)
			{
				for(int i = 0; i < Fractions.Length; i++)
				{
					if(Fractions[i] == selectedFraction.ToString())
					{
						uipv.Select(i, 1, true);
						break;
					}
				}
			}
			
		}
        public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            model = new TimePickerDataModel(model.Time);
            var vc = new MyViewController (this) {
                Autorotate = dvc.Autorotate
            };
            counterPicker = CreatePicker ();
            counterPicker.Frame = PickerFrameWithSize (counterPicker.SizeThatFits (SizeF.Empty));
            counterPicker.Model = model;
            for (int d = 0; d < model.Times.Count; d++) {
                counterPicker.Select(model.SelectedIndex[d], d, true);
            }

            // pass value changed
            model.ValueChanged += delegate {
                if (this.ValueChanged != null) {
                    Value = model.FormatValue ();

                    this.ValueChanged (this, new EventArgs ());
                }
            };

            vc.View.BackgroundColor = backgroundColor;
            vc.View.AddSubview (counterPicker);
            dvc.ActivateController (vc);
        }