Exemplo n.º 1
0
        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 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;
	    }
Exemplo n.º 3
0
 public PickerModel(CommitmentStatus[] values)
 {
     _values = values;
 }