Пример #1
0
        private void BindSleepDetailData()
        {
            txtCurrentDate.Text = _currentViewDate.ToString("yyyy/MM");
            var sleepData = _sleepService.GetSleepDataByDate(_currentViewDate)
                            .OrderByDescending(d => d.SleepTime);

            listBoxDetail.ItemsSource = sleepData.ToList();
        }
Пример #2
0
        private void BindInitialValue()
        {
            if (this.NavigationContext.QueryString.ContainsKey("id"))
            {
                _guId = this.NavigationContext.QueryString["id"];
            }

            if (this.NavigationContext.QueryString.ContainsKey("date"))
            {
                _currentViewDate = Convert.ToDateTime(this.NavigationContext.QueryString["date"]);
            }

            var data = _sleepService.GetSleepDataByDate(_currentViewDate).FirstOrDefault(d => d.Id == new Guid(_guId));

            if (data != null)
            {
                datePickerSleep.Value = data.SleepTime;
                timePickerSleep.Value = data.SleepTime;
                datePickerWake.Value  = data.WakeTime;
                timePickerWake.Value  = data.WakeTime;
            }
        }
Пример #3
0
        public void CreateChart(bool isRenderAll)
        {
            Chart chart = new Chart();

            chart.AxesX.Add(new Axis {
                Title = "睡眠量"
            });
            chart.AxesY.Add(new Axis {
                Title = "Day"
            });

            DataSeries dataSeries = new DataSeries();

            dataSeries.RenderAs = RenderAs.Bar;

            IList <SleepModel> data = new List <SleepModel>();

            Title title = new Title();

            if (isRenderAll)
            {
                title.Text = "睡眠量統計 - All";
                data       = _sleepService.GetSleepDataAll();
            }
            else
            {
                title.Text = "睡眠量統計 - " + _currentViewDate.ToString("yyyy/MM");
                data       = _sleepService.GetSleepDataByDate(_currentViewDate);
            }
            chart.Titles.Add(title);

            var dataGroup = data.GroupBy(d => d.SleepQuantify)
                            .OrderBy(g => (SleepQuantify)g.Key);

            foreach (var group in dataGroup)
            {
                DataPoint dataPoint = new DataPoint();
                dataPoint.YValue      = group.Count();
                dataPoint.ToolTipText = group.Count().ToString();
                dataPoint.AxisXLabel  = CommonService.GetEnumDescription(group.Key);

                dataPoint.Color = GetColor(group.Key);

                dataSeries.DataPoints.Add(dataPoint);
            }

            chart.Series.Add(dataSeries);
            ContentPanel.Children.Add(chart);
        }