protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing) {
         if (model != null) {
             model.Dispose();
             model = null;
         }
         if (counterPicker != null) {
             counterPicker.Dispose();
             counterPicker = null;
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PennyFarElements.TimeWithSecondsPickerElement"/> class.
 /// </summary>
 /// <param name='caption'>
 /// Caption.
 /// </param>
 /// <param name='time'>
 /// Time.
 /// </param>
 public TimeWithSecondsPickerElement(string caption, TimeSpan time)
     : base(caption)
 {
     model = new TimePickerDataModel(time);
     backgroundColor = UIColor.Black;
 }
        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);
        }