Esempio n. 1
0
        /// <summary>
        ///     //// 读取     Console.WriteLine(testText);
        //// 设置
        ///vWindowType.InvokeMember("testText",         BindingFlags.SetProperty, null, vWindow, new object[] { "Zswang 路过" });
        //// 执行方法
        ///vWindowType.InvokeMember("ShowMessage",         BindingFlags.InvokeMethod, null, vWindow, new object[] { 12345 });
        /// </summary>
        void voteThread()
        {
            voteTimer.Start(3600000.0);
            while (voteMainLive)
            {
                try
                {
                    //try agentip until ok
                    switch (voteState)
                    {
                    case 20:
                        postSearch();
                        voteState = -1;
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    //voteState = 2;
                }
                Thread.Sleep(1000);
            }
        }
Esempio n. 2
0
        private void BtnSave_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(EntryName.Text))
            {
                return;
            }

            Titlebar.IsVisible = false;
            RootLayout.Style   = (Style)Application.Current.Resources["AbsoluteLayout_FullScreen"];

            ViewModel.ShowMainPage       = false;
            ViewModel.ShowSavedPopupPage = true;

            if (ExperienceManager.Instance.EditingExperience != null)
            {
                ExperienceManager.Instance.EditingExperience.Name = EntryName.Text.Trim();
                if (EntryDesc.Text != null)
                {
                    ExperienceManager.Instance.EditingExperience.Description = EntryDesc.Text.Trim();
                }
                ExperienceManager.Instance.Save(ExperienceManager.Instance.EditingExperience);
            }

            _timer.Enable = true;
            _timer.Start(() =>
            {
                FinishSession();
                return(false);
            });
        }
        /// <summary>
        /// Shows the saved popup
        /// </summary>
        private void ShowSavedPopup()
        {
            if (!BtnCalibPt1.IsInteractable && !BtnCalibPt2.IsInteractable)
            {
                _model.ShowSavedPopup = true;
                UpdateTitlebarInfo(false, Color.FromHex("#11442B"));

                _timer.Enable = true;
                _timer.Start(() =>
                {
                    PageManager.Me.SetCurrentPage(typeof(PumpDetailPage));
                    return(false);
                });
            }
        }
        /// <summary>
        /// Gets called when this page is about to show and performs the initialization
        /// </summary>
        public override void AboutToShow()
        {
            listView.SelectedItem = null;
            LblTitle.Text         = PumpManager.Instance.NewPumps.Count == 0 ? "NO PUMPS DETECTED" : (PumpManager.Instance.NewPumps.Count == 1 ? "PUMP DETECTED" : "PUMPS DETECTED");
            LblInfo.Text          = PumpManager.Instance.NewPumps.Count == 0 ? "Move within range of a pump to activate it."
                : "You are in range of more than one pump. Which one would you like to activate?";

            //Titlebar.TitleBackColor = Color.FromHex("#083954");
            base.AboutToShow();

            if (PumpManager.Instance.NewPumps.Count == 0)
            {
                _timer.Enable = true;
                _timer.Start(() =>
                {
                    PageManager.Me.SetCurrentPage(typeof(MyPumpsPage));
                    return(false);
                });
            }
        }
Esempio n. 5
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);
        }