void ReleaseDesignerOutlets()
        {
            if (addButton != null)
            {
                addButton.Dispose();
                addButton = null;
            }

            if (CancelButton != null)
            {
                CancelButton.Dispose();
                CancelButton = null;
            }

            if (DateButton != null)
            {
                DateButton.Dispose();
                DateButton = null;
            }

            if (WeightField != null)
            {
                WeightField.Dispose();
                WeightField = null;
            }
        }
        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();

            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";
            Button.TouchUpInside          += delegate
            {
                var title = string.Format("{0} clicks!", count++);
                Button.SetTitle(title, UIControlState.Normal);
            };

            // Perform any additional setup after loading the view, typically from a nib.
            DateButton.AccessibilityIdentifier = "dateButton";
            DateButton.TouchUpInside          += delegate
            {
                var langsMain   = NSBundle.MainBundle.PreferredLocalizations;
                var langsLocale = NSLocale.PreferredLanguages;
                var langMain    = langsMain[0];
                var langLocale  = langsLocale[0];
                var dt          = DateTime.Now;
                Thread.CurrentThread.CurrentCulture = new CultureInfo(langLocale);
                var title = dt.ToString("d");
                DateButton.SetTitle(title, UIControlState.Normal);
            };
        }
示例#4
0
        public static void AddTodayButton(UltraCalendarCombo calendar)
        {
            DateButton db = new DateButton();

            db.Action  = DateButtonAction.SelectDay;
            db.Caption = "今天";
            db.Type    = DateButtonType.Today;
            calendar.DateButtons.Add(db);
        }
示例#5
0
 public void Prompt(DateButton dateButton)
 {
     foreach (Button b in GetComponentsInChildren <Button>())
     {
         b.interactable = false;
     }
     PromptWindow.SetActive(true);
     PromptWindow.GetComponentInChildren <Text>().text = dateButton.Commute.ToString();
     editDate = dateButton;
 }
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     addButton.TouchUpInside += delegate
     {
         if (Weight == null)
         {
             WeightData data = new WeightData();
             String     v    = WeightField.Text;
             try
             {
                 data.Value = Double.Parse(v);
                 data.Unit  = "kg";
                 data.Date  = Date;
                 OnAddWeight?.Invoke(this, new WeightEventArgs(data));
                 DismissViewController(false, null);
             }
             catch
             {
             }
         }
         else
         {
             OnDeleteWeight?.Invoke(this, new WeightEventArgs(Weight));
             DismissViewController(false, null);
         }
     };
     CancelButton.TouchUpInside += delegate
     {
         DismissViewController(false, null);
     };
     DateButton.TouchUpInside += (sender, e) =>
     {
         WeightField.ResignFirstResponder();
         OpenDatePicker();
     };
     if (Weight != null)
     {
         Date             = Weight.Date;
         WeightField.Text = Weight.Value.ToString("F");
         addButton.SetTitle("Borrar", UIControlState.Normal);
     }
     else
     {
         Date = DateTime.Now;
     }
     DateButton.SetTitle(Date.ToShortDateString() + " " + Date.ToShortTimeString(), UIControlState.Normal);
 }
示例#7
0
 /// <summary>
 /// Stores drag data
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="data"></param>
 /// <param name="adorner"></param>
 internal DragData(DateButton parent, object data, DragAdorner adorner)
 {
     Parent  = parent;
     Data    = data;
     Adorner = adorner;
 }