Ejemplo n.º 1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            _baby = await BabyManager.Load();

            if (string.IsNullOrEmpty(_baby.Name))
            {
                this.pageTitle.Text = "请输入宝宝信息";
                return;
            }
            else
            {
                ConstellationType type = GetConstellationType(_baby.Birthday);
                string constellation = GetConstellationName(type);
                string title = string.Format("{0}的星座是{1}",_baby.NickName, constellation);
                this.pageTitle.Text = title;
                //BitmapImage image = new BitmapImage(new Uri(@"ms-appx:/Assets/Constellation/巨蟹座.jpg"));
                string imagePath = string.Format(@"ms-appx:/Assets/Constellation/{0}.jpg", constellation);
                BitmapImage image = new BitmapImage(new Uri(imagePath));
                this.image.Source = image;

                string jsonPath = constellation + ".json";
                ConstellationInfo info = await FileHelper.LoadData<ConstellationInfo>(jsonPath, "Assets\\Constellation", true);
                this.description.Text = info.Description;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            _baby = await BabyManager.Load();
            _weights = await WeightManager.Load();

            if (string.IsNullOrEmpty(_baby.Name))
            {
                this.pageTitle.Text = "请输入宝宝信息";
                return;
            }
            else
            {
                string title = string.Format("{0}的体重是:", _baby.NickName);
                this.pageTitle.Text = title;
            }

            if (0 == _weights.Count)
            {
                _weights = MockWeights();
            }

            if (_weights.Count > 0)
            {
                listWeight.ItemsSource = _weights;
                UpdateCharts();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            _baby = await BabyManager.Load();

            if (!string.IsNullOrWhiteSpace(_baby.Name))
            {
                tbName.Text = _baby.Name;
                tbNickname.Text = _baby.NickName;
                tbBirthday.Text = _baby.Birthday.ToString();
            }
            else
                tbName.Text = "千万别忘记宝宝名字哟";
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            _baby = await BabyManager.Load();

            if (string.IsNullOrEmpty(_baby.Name))
            {
                this.pageTitle.Text = "请输入宝宝信息";
                return;
            }
            else
            {
                string zodiac = getShengXiao(_baby.Birthday);
                string title = string.Format("{0}的生肖是{1}", _baby.NickName, zodiac);
                this.pageTitle.Text = title;
            }
        }
Ejemplo n.º 5
0
        // TODO implement the singletion
        //public static BabyInfo BabyInstance()
        //{
        //    //if (null == _baby)
        //    //{
        //    //    _baby = new BabyInfo();
        //    //}
        //    return _baby;
        //}

        public static async Task <BabyInfo> Load()
        {
            var storageFolder = KnownFolders.DocumentsLibrary;

            try
            {
                _baby = await FileHelper.LoadData <BabyInfo>(BABYINFO_PATH);
            }
            catch (FileNotFoundException)
            {
                //return null;
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
            return(_baby);
        }
Ejemplo n.º 6
0
        // TODO implement the singletion
        //public static BabyInfo BabyInstance()
        //{
        //    //if (null == _baby)
        //    //{
        //    //    _baby = new BabyInfo();
        //    //}
        //    return _baby;
        //}

        public static async Task<BabyInfo> Load()
        {
            var storageFolder = KnownFolders.DocumentsLibrary;

            try
            {
                _baby = await FileHelper.LoadData<BabyInfo>(BABYINFO_PATH);
            }
            catch (FileNotFoundException)
            {
                //return null;
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
            return _baby;
        }
Ejemplo n.º 7
0
        private async void Init()
        {
            //DateTime birth = MockBirth();
            //await BabyManager.Load();
            //_baby = BabyManager.BabyInstance();
            _baby = await BabyManager.Load();

            if (string.IsNullOrEmpty(_baby.Name))
            {
                this.pageName.Text = "请输入宝宝信息";
                return;
            }

            string title = string.Format("{0}诞生了:",_baby.NickName);
            this.pageName.Text = title;
            DateTime birth = _baby.Birthday;
    
            TimeSpan span = DateTime.Now - birth;

            int days = span.Days;
            string daysToShow = string.Format("总共{0}天", days);
            this.tbDays.Text = daysToShow;

            int hours = days * 24 + span.Hours;
            string hoursToShow = string.Format("总共{0}小时", hours);
            this.tbHours.Text = hoursToShow;

            int minutes = hours * 60 + span.Hours;
            //double totalMinutes = span.TotalMinutes;
            string minutesToShow = string.Format("总共{0}分钟", minutes);
            this.tbMinutes.Text = minutesToShow;

            ShowSeconds(span);

            _timer = new DispatcherTimer();
            _timer.Tick += timer_Tick;
            _timer.Interval = new TimeSpan(0, 0, 3);

            if(!_timer.IsEnabled)
                _timer.Start();
        }