protected void BuildPromptMarkers() { foreach (var e in this.promptMarkers) { e.RemoveFromSuperview(); } this.promptMarkers = new List <PromptMarkerView> (); var prompts = Activity.List("ActivityType=@ActivityType and TimeStamp >= @ReportStart and TimeStamp <= @ReportEnd", new{ ActivityType = ActivityType.MoodPrompt, ReportStart = this.MoodReport.StartsOn, ReportEnd = this.MoodReport.EndsOn }).ToList(); foreach (var p in prompts) { var promptView = BuildPromptLabel(p); if (this.CurrentZoomLevel.ShrinkLabels) { promptView.Shrink(); } this.promptMarkers.Add(promptView); promptView.Center = new PointF(ChartHelper.ToXPos(this.ReportStartLocal, this.ReportEndLocal, p.TimeStampLocal, this.CurrentZoomLevel.RenderLevel.DayImageWidth, ReportManager.DayStartTime, ReportManager.DayEndTime, this.CurrentZoomLevel.RenderLevel.DayMarkerWidth), 50f); this.globalMoodMap.Add(promptView); } }
private PointF DataPointToPoint(RectangleF frame, DataPoint dp) { //var x = (decimal)dp.TimeStamp.Subtract (this.StartDate).TotalMilliseconds / (decimal)this.EndDate.Subtract (this.StartDate).TotalMilliseconds * (decimal)frame.Width; var x = ChartHelper.ToXPos(this.StartDate, this.EndDate, dp.TimeStamp, frame.Width); var y = (decimal)dp.CumulativePercentage / 100M * (decimal)frame.Height; return(new PointF((float)x, (float)y)); }
protected void LoadImages() { if (this.globalMoodMap != null) { this.globalMoodMap.RemoveFromSuperview(); this.globalMoodMap = null; } globalMoodMap = new GlobalMoodMapContainerView(this.OriginalFrame); globalMoodMap.BackgroundColor = UIColor.Black; var images = ReportManager.GetReportImages(this.MoodReport, this.CurrentRenderLevel); var xPos = 0f; foreach (var img in images) { xPos += this.CurrentZoomLevel.RenderLevel.DayMarkerWidth; var imageFrame = new RectangleF(xPos, 0f, this.CurrentRenderLevel.DayImageWidth, this.CurrentRenderLevel.DayImageHeight); UIImageView imgView = new UIImageView(imageFrame); imgView.Image = img; imgView.BackgroundColor = UIColor.LightGray; this.globalMoodMap.Add(imgView); xPos += imageFrame.Width; } this.globalMoodMap.Frame = new RectangleF(this.globalMoodMap.Frame.Location, new SizeF(xPos, this.globalMoodMap.Frame.Height)); this.ContentSize = globalMoodMap.Frame.Size; this.Add(this.globalMoodMap); //add mask for future data if (this.futureMaskView != null) { this.futureMaskView.RemoveFromSuperview(); this.futureMaskView = null; } var eventNow = DateTime.UtcNow.ToLocalTime(ApplicationState.Current.EventTimeOffset); if (eventNow < this.MoodReport.EndsOnLocal) { var nowX = ChartHelper.ToXPos(this.MoodReport.StartsOnLocal, this.MoodReport.EndsOnLocal, eventNow, this.CurrentRenderLevel.DayImageWidth, ReportManager.DayStartTime, ReportManager.DayEndTime, this.CurrentRenderLevel.DayMarkerWidth); this.futureMaskView = new UIView(new RectangleF(nowX, 0, this.globalMoodMap.Bounds.Width - nowX, this.globalMoodMap.Bounds.Height)); this.futureMaskView.BackgroundColor = new UIColor(0, 0, 0, 0.5f); this.globalMoodMap.Add(this.futureMaskView); } }
public void Refresh(MoodReport report, ZoomLevel zoomLevel) { Console.WriteLine("Refresh data - {0}", zoomLevel.Name); this.MoodReport = report; this.ReportStartLocal = ReportManager.GetReportStartLocal(report); this.ReportEndLocal = ReportManager.GetReportEndLocal(report); this.DefaultZoomLevel = zoomLevel; this.SetZoomLevel(zoomLevel); this.LoadImages(); if (this.eventMarkersVisible) { BuildEventMarkers(); } else { this.ClearEventMarkers(); } if (this.promptMarkersVisible) { BuildPromptMarkers(); } else { this.ClearPromptMarkers(); } var eventNow = DateTime.UtcNow.ToLocalTime(ApplicationState.Current.EventTimeOffset); var offset = eventNow < this.ReportEndLocal ? ChartHelper.ToXPos(this.ReportStartLocal, this.ReportEndLocal, eventNow, this.CurrentRenderLevel.DayImageWidth, ReportManager.DayStartTime, ReportManager.DayEndTime, this.CurrentRenderLevel.DayMarkerWidth) - this.Bounds.Size.Width / 2 :this.ContentSize.Width - this.Bounds.Size.Width; if (offset > 0) { this.SetContentOffset(new PointF(offset, 0), true); } ZoomToDefault(); }
public void Refresh(MoodReport report, RenderLevel renderLevel) { var viewStartTime = ChartHelper.ToCurrentTime(report.StartsOn, report.EndsOn, this.globalMap.ContentOffset.X * 1 / this.globalMap.ZoomScale, renderLevel, true).Value; var viewEndTime = ChartHelper.ToCurrentTime(report.StartsOn, report.EndsOn, (this.globalMap.ContentOffset.X + this.Frame.Width) * 1 / this.globalMap.ZoomScale, renderLevel, true).Value; var labelTime = viewStartTime; var labelIndex = 0; var labelPos = 0f; while (labelTime < viewEndTime) { var pxTilEndOfDay = (float)(ReportManager.DayEndTime.Subtract(labelTime.TimeOfDay).TotalHours / ReportManager.DayEndTime.Subtract(ReportManager.DayStartTime).TotalHours) * renderLevel.DayImageWidth * this.globalMap.ZoomScale; if (pxTilEndOfDay >= labelW) { UILabel label; if (this.dayLabels.Count() > labelIndex) { label = this.dayLabels [labelIndex]; } else { label = new UILabel(new RectangleF(0, 0, labelW, labelH)); label.BackgroundColor = UIColor.Clear; label.TextColor = UIColor.White; label.Font = font; this.Add(label); this.dayLabels.Add(label); } label.Text = labelTime.ToString("ddd dd MMM"); label.Frame = new RectangleF(new PointF(labelPos, label.Frame.Y), label.Frame.Size); labelIndex++; } labelTime = labelTime.Date.AddDays(1); labelPos = (ChartHelper.ToXPos(report.StartsOn, report.EndsOn, labelTime, renderLevel.DayImageWidth, ReportManager.DayStartTime, ReportManager.DayEndTime, renderLevel.DayMarkerWidth) * this.globalMap.ZoomScale) - this.globalMap.ContentOffset.X; } while (labelIndex < this.dayLabels.Count()) { var i = this.dayLabels.Count() - 1; this.dayLabels[i].RemoveFromSuperview(); this.dayLabels.RemoveAt(i); } }
protected UIView BuildAxisLabel(DateTime timeStampLocal) { var x = ChartHelper.ToXPos(this.ReportStartLocal, this.ReportEndLocal, timeStampLocal, this.CurrentZoomLevel.RenderLevel.DayImageWidth, ReportManager.DayStartTime, ReportManager.DayEndTime, this.CurrentZoomLevel.RenderLevel.DayMarkerWidth); var titleH = 20f; var titleTopMargin = 5f; var labelW = 50f; var labelH = this.tickHeight + titleH + titleTopMargin; x = x - (labelW / 2); var y = this.globalMoodMap.Frame.Y; if (this.axisDropLine == null) { this.axisDropLine = DrawAxisDropLine(); } UIView axisLabel = new UIView(new RectangleF(x, y, labelW, this.globalMoodMap.Frame.Height)); UIImageView dropLine = new UIImageView(this.axisDropLine); dropLine.Center = new PointF(labelW / 2, dropLine.Center.Y); axisLabel.Add(dropLine); UILabel title = new UILabel(new RectangleF(0, this.globalMoodMap.Frame.Height + tickHeight + titleTopMargin, labelW, titleH)); title.Font = UIFont.FromName("HelveticaNeue-CondensedBold", 22.0f); title.TextColor = UIColor.White; title.Text = timeStampLocal.ToString("H:mm"); title.BackgroundColor = UIColor.Clear; title.TextAlignment = UITextAlignment.Center; axisLabel.Add(title); return(axisLabel); }