示例#1
0
        void SetupGroupTab()
        {
            _btnGroupTab.AddButton(BtnWeek);
            _btnGroupTab.AddButton(BtnDay);

            _btnGroupTab.UpdateCurrentButton(BtnWeek);
            _btnGroupTab.Toggled += GroupTab_Toggled;

            _btnGroupTab.CurrentIndex = 0;
        }
        public NurseSessionStartPage()
        {
            InitializeComponent();

            UpdateParams();

            _btnGroup.AddButton(BtnLeft);
            _btnGroup.AddButton(BtnRight);

            _btnGroup.Toggled += _btnGroup_Toggled;
        }
        /// <summary>
        /// Constructor -- Initialize the model and binds buttons events and other ui actions
        /// </summary>
        public DashboardTabPage()
        {
            try {
                InitializeComponent();

                _tabViews = new List <RootViewBase>()
                {
                    PageDashboardDetail, PageHistory, PageModesDashboard, PageReminder, PageSettings
                };

                _btnGroup.Toggled += (sender, btn, index) =>
                {
                    if (btn != BtnSettings)
                    {
                        _lastSelectedButton = btn;
                    }
                    SetCurrentIndex(index);
                };

                foreach (View v in _gridTabBtns.Children)
                {
                    var btn = v as ButtonEx;
                    if (btn != null)
                    {
                        _btnGroup.AddButton(btn);
                    }
                }
            }
            catch (Exception ex) {
                throw;
            }
        }
示例#4
0
        /// <summary>
        /// Constructor -- Initialize the model and binds buttons events and other ui actions
        /// </summary>
        public CaregiverTabbedPage()
        {
            try
            {
                InitializeComponent();

                _tabViews = new List <IRootView>()
                {
                    PageCaregiverDashboard, PageInventory, PageSettings, PageFAQ
                };

                _btnGroup.Toggled += (sender, btn, index) =>
                {
                    if (btn != BtnSettings)
                    {
                        _lastSelectedButton = btn;
                    }
                    SetCurrentIndex(index);
                };

                foreach (View v in _gridTabBtns.Children)
                {
                    var btn = v as ButtonEx;
                    if (btn != null)
                    {
                        _btnGroup.AddButton(btn);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        private void ConfigureBottleAndInventory()
        {
            _btnGroupMilk.AddButton(_btnMilkFormula);
            _btnGroupMilk.AddButton(_btnBreastMilk);
            _btnGroupMilk.Toggled += (sender, item, index) =>
            {
                _gridMilkOptions.IsVisible = item == _btnBreastMilk;
                if (_gridMilkOptions.IsVisible == false)
                {
                    _btnGroupBreastMilk.UpdateCurrentButton(null);
                }
                this.InvalidateMeasure();
            };

            _btnGroupBreastMilk.AddButton(_btnMilkFridge);
            _btnGroupBreastMilk.AddButton(_btnMilkFreezer);
            _btnGroupBreastMilk.AddButton(_btnMilkOther);

            _btnGroupBreastMilk.Toggled += (sender, item, index) =>
            {
                if (!_updatingMilkStorageFromCode)
                {
                    if (item == _btnMilkFridge)
                    {
                        InventoryView.Initialize(InventoryFilter.Fridge);
                        ViewModel.ShowInventoryCommand?.Execute(true);
                        LeftPageType = null;
                    }
                    else if (item == _btnMilkFreezer)
                    {
                        InventoryView.Initialize(InventoryFilter.Freezer);
                        ViewModel.ShowInventoryCommand?.Execute(true);
                        LeftPageType = null;
                    }
                    else if (item == _btnMilkOther)
                    {
                        InventoryView.Initialize(InventoryFilter.Other);
                        ViewModel.ShowInventoryCommand?.Execute(true);
                        LeftPageType = null;
                    }
                    else
                    {
                        ViewModel.ShowInventoryCommand?.Execute(false);
                    }
                }
            };
        }
示例#6
0
        /// <summary>
        /// Constructor -- Initialize the model and binds buttons events and other ui actions
        /// </summary>
        public NurseSessionLogPage()
        {
            InitializeComponent();

            // Moved from AddSession page.
            if (null == HistorySession)
            {
                HistorySession = HistoryManager.Instance.CreateSession(SessionType.Nurse);
            }

            BtnAddNote.CornerRadius = 1;

            _btnGroup.AddButton(BtnLeft);
            _btnGroup.AddButton(BtnRight);

            _btnGroup.Toggled += (sender, item, index) =>
            {
                PullDataFromModel(item);
            };

            ViewModel = new NurseSessionLogModel(ShowNotepad)
            {
                NotReadyToSave     = true,
                ShowSavedPopupPage = false
            };

            BindingContext = ViewModel;

            _updateTime = new Action(() =>
            {
                if (HistorySession != null)
                {
                    try
                    {
                        if (NurseStartTime.Time.HasValue)
                        {
                            HistorySession.LeftBreastStartTime  = _selectedDate + _selectedStartTime;
                            HistorySession.RightBreastStartTime = _selectedDate + _selectedStartTime;

                            TotalCount();

                            ViewModel.NotReadyToSave = false;
                        }
                        else
                        {
                            TotalCount();
                        }

                        if (NurseTotalTime.Time.HasValue)
                        {
                            if (!String.IsNullOrEmpty(ParseTime(ViewModel.FirstTime)))
                            {
                                if (TimeSpan.TryParseExact(ViewModel.FirstTime, @"mm\:ss", null, out TimeSpan resultTime))
                                {
                                    HistorySession.LeftBreastEndTime = HistorySession.LeftBreastStartTime + resultTime;
                                }
                            }
                            if (!String.IsNullOrEmpty(ParseTime(ViewModel.LastTime)))
                            {
                                if (TimeSpan.TryParseExact(ViewModel.LastTime, @"mm\:ss", null, out TimeSpan resultTime))
                                {
                                    HistorySession.RightBreastEndTime = HistorySession.RightBreastStartTime + resultTime;
                                }
                            }
                        }

                        ResolveNurseStartTimeFormat();
                    }
                    catch (Exception ex)
                    {
                        Debugger.Break();
                        NurseTotalTime.Time = TimeSpan.FromMinutes(0);
                    }

                    //if (_btnGroup.CurrentButton != null)
                    //{
                    //    if (NurseStartTime.Time.HasValue)
                    //    {
                    //        HistorySession.LeftBreastStartTime = _selectedDate + _selectedStartTime;
                    //        HistorySession.RightBreastStartTime = _selectedDate + _selectedStartTime;
                    //    }

                    //    if (NurseTotalTime.Time.HasValue)
                    //    {
                    //        try
                    //        {
                    //            //string[] parts = LblDuraPicker.Text.Split(new string[] {":"},
                    //            //    StringSplitOptions.RemoveEmptyEntries);
                    //            //if (parts.Length >= 2)
                    //            //{
                    //            //    if (_btnGroup.CurrentButton == BtnLeft)
                    //            //    {
                    //            //        HistorySession.LeftBreastEndTime =
                    //            //        HistorySession.LeftBreastStartTime.AddHours(Convert.ToInt32(parts[0]));
                    //            //        HistorySession.LeftBreastEndTime = HistorySession.LeftBreastEndTime.AddMinutes(Convert.ToInt32(parts[1]));
                    //            //        model.NotReadyToSave = false;
                    //            //    }
                    //            //    else if (_btnGroup.CurrentButton == BtnRight)
                    //            //    {
                    //            //        HistorySession.RightBreastEndTime =
                    //            //        HistorySession.RightBreastStartTime.AddHours(Convert.ToInt32(parts[0]));
                    //            //        HistorySession.RightBreastEndTime = HistorySession.RightBreastEndTime.AddMinutes(Convert.ToInt32(parts[1]));
                    //            //        model.NotReadyToSave = false;
                    //            //    }
                    //            //}
                    //        }
                    //        catch
                    //        {
                    //        }
                    //    }
                    //}
                }
            });

            NurseDate.CalendarDate   = DateTime.Now;
            NurseDate.ValidationFunc = (dateToValidate) =>
            {
                if (dateToValidate > DateTime.Now.Date)
                {
                    ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime);
                    return(false);
                }

                if (dateToValidate + _selectedStartTime >= DateTime.Now)
                {
                    ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime);
                    return(false);
                }

                if (NurseTotalTime.Time.HasValue)
                {
                    try
                    {
                        var date = dateToValidate + _selectedStartTime;
                        date = date.AddHours(NurseTotalTime.Time.Value.Hours);
                        date = date.AddMinutes(NurseTotalTime.Time.Value.Minutes);
                        if (date >= DateTime.Now)
                        {
                            ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime);
                            return(false);
                        }
                    }
                    catch
                    {
                        return(false);
                    }
                }

                return(true);
            };

            NurseDate.AfterAction = () =>
            {
                _selectedDate = NurseDate.Date.Value;
                _updateTime();
            };

            NurseStartTime.ValidationFunc = timeValidate =>
            {
                if (_selectedDate + timeValidate >= DateTime.Now)
                {
                    ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime);
                    return(false);
                }

                if (NurseTotalTime.Time.HasValue)
                {
                    try
                    {
                        var date = NurseDate.Date.Value + timeValidate;
                        date = date.AddHours(NurseTotalTime.Time.Value.Hours);
                        date = date.AddMinutes(NurseTotalTime.Time.Value.Minutes);
                        if (date >= DateTime.Now)
                        {
                            ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime);
                            return(false);
                        }
                    }
                    catch
                    {
                        return(false);
                    }
                }

                return(true);
            };

            NurseStartTime.AfterAction = () =>
            {
                _selectedStartTime = NurseStartTime.Time.Value;
                _updateTime();
            };

            NurseTotalTime.ValidationFunc = timeValidate =>
            {
                if (NurseStartTime.Time.HasValue)
                {
                    var date = _selectedDate + _selectedStartTime;
                    date = date.AddHours(timeValidate.Hours);
                    date = date.AddMinutes(timeValidate.Minutes);
                    if (date >= DateTime.Now)
                    {
                        ModalAlertPage.ShowAlertWithClose(AppResource.PickingFutureTime);
                        return(false);
                    }
                }

                return(true);
            };

            NurseTotalTime.AfterAction = () =>
            {
                _updateTime();
            };

            BtnSave.Clicked += (s, e) =>
            {
                if (_historyModel != null)
                {
                    if (null != ProfileManager.Instance?.CurrentProfile?.CurrentBaby)
                    {
                        _historyModel.ChildID   = ProfileManager.Instance.CurrentProfile.CurrentBaby.Id;
                        _historyModel.ChildName = ProfileManager.Instance.CurrentProfile.CurrentBaby.Name;

                        HistoryManager.Instance.AddSession(_historyModel);
                    }
                    else
                    {
                        ModalAlertPage.ShowAlertWithClose(AppResource.NoChildError);
                    }
                }
                ViewModel.ShowSavedPopupPage = true;
                //UpdateTitlebarInfo(false, Color.FromHex("#11442B"));

                _timer.Enable = true;
                _timer.Start(() =>
                {
                    PageManager.Me.SetCurrentPage(typeof(DashboardTabPage));
                    return(false);
                });
            };

            Titlebar.IsVisible            = true;
            LeftPageType                  = typeof(DashboardTabPage);
            Titlebar.LeftButton.IsVisible = true;
            Titlebar.LeftButton.SetDynamicResource(StyleProperty, "CancelButton");

            NurseTotalTime.Time = TimeSpan.FromMinutes(0);
        }