Пример #1
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     this.OkayBtn.Clicked += (sender, e) => {
         DismissViewController(true, null);
         // get & parse params
         this.YourWeightTF.ResignFirstResponder();
         string your_w   = this.YourWeightTF.Text;
         string desire_w = this.DesireWeightTF.Text;
         m_my_weight = System.Convert.ToInt32(your_w, 10);
         int goal_diff = m_my_weight - System.Convert.ToInt32(desire_w, 10);
         int a_days    = System.Convert.ToInt32(this.AtackTF.Text, 10);
         // clear prev schedule
         ScheduleManager.DeleteAllScheduleRecords();
         // calculate and save schedule(attack& cruise for now)
         List <ScheduleRecord> recs_list = ScheduleMaker.makeAttackCruise(goal_diff, a_days, DateTime.Now.Date);
         foreach (var sch in recs_list)
         {
             sch.m_weight = m_my_weight;
             ScheduleManager.SaveScheduleRecord(sch);
         }
         PrefsRecord pref = PrefsManager.GetPrefsRecordValue("isDietStarted");
         pref.PrefValue = "1";                // diet have started
         PrefsManager.UpdatePrefsRecord(pref);
     };
 }
Пример #2
0
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // Copy the database across (if it doesn't exist)
            var appdir   = NSBundle.MainBundle.ResourcePath;
            var seedFile = Path.Combine(appdir, "Base/DukappDB.db3");

            if (!File.Exists(DukappCore.DAL.DukappRepository.DatabaseFilePath))
            {
                File.Copy(seedFile, DukappCore.DAL.DukappRepository.DatabaseFilePath);
            }
            // create a new window instance based on the screen size
            DukappCore.DAL.DukappRepository.Open();
            RectangleF mrect = UIScreen.MainScreen.Bounds;

            window   = new UIWindow(mrect);
            home_scr = new HomeVC();
            RectangleF rct = home_scr.View.Bounds;
            var        rootNavigationController = new UINavigationController();

            rootNavigationController.NavigationBarHidden    = true;
            rootNavigationController.NavigationBar.BarStyle = UIBarStyle.Black;
            rootNavigationController.PushViewController(home_scr, true);
            window.RootViewController = rootNavigationController;

            app.SetStatusBarStyle(UIStatusBarStyle.LightContent, true);
            // window.RootViewController = home_scr;
            // make the window visible
            window.MakeKeyAndVisible();
            PrefsRecord rec = PrefsManager.GetPrefsRecordValue("isDietStarted");

            if (rec.PrefValue == "0")
            {
                welcome_scr = new WelcomeVC(home_scr);
                //rootNavigationController.PushViewController(welcome_scr, true);
                home_scr.PresentViewController(welcome_scr, true, null);
            }
            return(true);
        }
Пример #3
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);
            };
        }