Beispiel #1
0
 public override void ViewDidDisappear(bool animated)
 {
     base.ViewDidDisappear(animated);
     if (m_parent_vc != null)
     {
         if (prefs_scr == null)
         {
             prefs_scr = new PrefsVC();
         }
         //this.NavigationController.PushViewController (prefs_scr, true);
         m_parent_vc.PresentViewController(prefs_scr, true, null);
     }
 }
Beispiel #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("Images/png/[email protected]"));
            this.TitleImage.Image     = UIImage.FromFile("images/png/divisions/[email protected]");
            this.HomeBtn.SetBackgroundImage(UIImage.FromFile("images/png/[email protected]"), UIControlState.Normal);
            // get if notifs enabled
            PrefsRecord rec = PrefsManager.GetPrefsRecordValue("NotifDate");

            if (rec.PrefValue != "0" &&
                UIApplication.SharedApplication.ScheduledLocalNotifications.GetLength(0) > 0)
            {
                m_notifTime           = UIApplication.SharedApplication.ScheduledLocalNotifications[0].FireDate;
                this.EnableDiarySw.On = true;
                EnableDiaryControls(true);
            }
            else
            {
                m_notifTime = NSDate.Now;
                EnableDiaryControls(false);
            }
            this.TimePicker.Date = m_notifTime;
            this.HoursTb.Text    = NSDateToDateTime(m_notifTime).ToString("HH:mm");

            this.OnResetHistory.TouchUpInside += async(sender, e) => {
                int button = await ShowAlert("Сброс истории", "Вы уверены?", "Да", "Нет");

                if (button == 0)
                {
                    PrefsRecord pref = PrefsManager.GetPrefsRecordValue("isDietStarted");
                    pref.PrefValue = "0";
                    PrefsManager.UpdatePrefsRecord(pref);
                    PrefsManager.ClearHistory();
                    if (prefs_scr == null)
                    {
                        prefs_scr = new PrefsVC();
                    }
                    PresentViewController(prefs_scr, true, null);
                }
            };

            this.HomeBtn.TouchUpInside += (sender, e) =>
            {
                this.NavigationController.PopToRootViewController(true);
            };

            this.HoursTb.Started += (sender, e) =>
            {
                this.HoursTb.EndEditing(true);
            };

            this.HoursTb.TouchDown += (sender, e) =>
            {
                this.TimePicker.Hidden = false;
                this.SetTimeBtn.Hidden = false;
                //this.HoursTb.UserInteractionEnabled = false;
            };

            this.EnableDiarySw.TouchUpInside += (sender, e) =>
            {
                EnableDiaryControls(this.EnableDiarySw.On);
                EnableDiaryNotification(this.EnableDiarySw.On);
                PrefsRecord pref = PrefsManager.GetPrefsRecordValue("NotifDate");
                pref.PrefValue = this.EnableDiarySw.On == true ? "1":"0";
                PrefsManager.UpdatePrefsRecord(pref);
                this.TimePicker.Hidden = true;
                this.SetTimeBtn.Hidden = true;
            };

            this.SetTimeBtn.TouchUpInside += (sender, e) =>
            {
                m_notifTime = this.TimePicker.Date;
                DateTime date = NSDateToDateTime(m_notifTime);
                this.HoursTb.Text      = date.ToString("HH:mm");
                this.SetTimeBtn.Hidden = true;
                EnableDiaryNotification(true);
                this.TimePicker.Hidden = true;
                this.HoursTb.EndEditing(true);
            };
        }