Beispiel #1
0
        public MonthPage(JournalMonth month)
        {
            _month = month;

            Title = month.Date.ToString("MMMM - yyyy");
            SfChart chart = CreateChart(month);

            ListView list = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                RowHeight = 40
            };

            list.ItemsSource  = month.Records;
            list.ItemTemplate = new DataTemplate(typeof(DreamRecordCell));
            list.ItemTapped  += ItemTapped;

            StackLayout layout = new StackLayout()
            {
                Children =
                {
                    chart,
                    list
                }
            };

            Content = layout;
        }
Beispiel #2
0
        public JournalPage()
        {
            Title = "Dream Journal";
            NavigationPage.SetBackButtonTitle(this, "Journal");

            DateTime now   = DateTime.UtcNow;
            DateTime start = DreamsAPI.InstallDate;

            _months = new ObservableCollection <JournalMonth>();

            IEnumerable <DreamRecord> records = DreamsAPI.GetRecords();

            //Console.WriteLine(start);
            while (start <= now)
            {
                Console.WriteLine($"{start}");
                JournalMonth jMonth = new JournalMonth()
                {
                    Date = start
                };
                jMonth.Records = new ObservableCollection <DreamRecord>(from rec in records
                                                                        where rec.DateRecorded.Month == start.Month && rec.DateRecorded.Year == start.Year
                                                                        select rec);
                jMonth.RecordCount = jMonth.Records.Count;
                _months.Add(jMonth);

                start = start.AddMonths(1);
            }

            ListView list = new ListView()
            {
                SeparatorVisibility = SeparatorVisibility.None
            };

            list.ItemsSource  = _months;
            list.ItemTemplate = new DataTemplate(typeof(JournalMonthCell));
            list.ItemTapped  += MonthTapped;

            StackLayout layout = new StackLayout()
            {
                Children =
                {
                    list
                }
            };

            Content = layout;
        }
Beispiel #3
0
        SfChart CreateChart(JournalMonth month)
        {
            _points = new ObservableCollection <ChartDataPoint>();

            SfChart chart = new SfChart()
            {
                HeightRequest = 250
            };

            chart.Title.Text = "Monthly Emotion Overview";

            PieSeries series = new PieSeries()
            {
                XBindingPath = "Emotion",
                YBindingPath = "Value"
            };

            series.ColorModel.Palette      = ChartColorPalette.Custom;
            series.DataMarker              = new ChartDataMarker();
            series.DataMarkerPosition      = CircularSeriesDataMarkerPosition.OutsideExtended;
            series.DataMarker.LabelContent = LabelContent.Percentage;

            series.ColorModel.CustomBrushes.Clear();
            chart.Legend = new ChartLegend();

            Emotion        emotion  = Emotion.None;
            List <Emotion> emotions = DreamsAPI.GetEmotions();

            for (int index = 0; index < emotions.Count; index++)
            {
                emotion = emotions[index];
                List <DreamRecord> records = new List <DreamRecord>(from rec in month.Records
                                                                    where rec.Emotion == emotion
                                                                    select rec);
                _points.Add(new ChartDataPoint(emotion.ToString(), records.Count));
                series.ColorModel.CustomBrushes.Add(DreamsAPI.GetEmotionColor(emotion));
            }

            series.ItemsSource = _points;

            chart.Series.Add(series);

            return(chart);
        }
Beispiel #4
0
        void RecordUpdated(DreamRecord previous, DreamRecord record)
        {
            if (record.DateRecorded.Month != previous.DateRecorded.Month)
            {
                JournalMonth month = null;
                for (int index = 0; index < _months.Count; index++)
                {
                    month = _months[index];

                    if (month.Date.Month == previous.DateRecorded.Month)
                    {
                        month.Records.Remove(record);
                        month.RecordCount--;
                    }
                    else if (month.Date.Month == record.DateRecorded.Month)
                    {
                        month.Records.Add(record);
                        month.RecordCount++;
                    }
                }
            }
        }