public ChumonResultState(EPuzzleWindow window, EigoTestMondai mondai, ChumonResult chumonResult, MondaiResult mondaiResult) : base(window) { _mondai = mondai; _chumonResult = chumonResult; DrawingObjectRoot.BackColor = EPuzzleColors.Color109; // var imageFile = ResultImageManager.Instance.GetFile(_mondai.Parent.GetGradeString(mondaiResult.所要時間)); // var imageFile = ResultImageManager.Instance.GetImage(_mondai.Parent.GetGradeString(mondaiResult.所要時間)); var image = window.EPuzzleData.CurrentUserInfo.ResultImageManager.GetImage(_mondai.Parent.GetGradeString(mondaiResult.所要時間, window.EPuzzleData.CurrentUserInfo)); if (null != image) { // var imageItem = new ImageItem(imageFile, true); var imageItem = new ImageItem(image.Shrink((int)DrawingObjectRoot.Width, (int)DrawingObjectRoot.Height)); imageItem.Left = 0f; imageItem.Top = 0f; imageItem.Position = DrawingObjectPosition.Absolute; Items.Add(imageItem); #if DEBUG { // 使用したファイルの記録 var imagePath = (string)image.Tag; Clipboard.SetText(imagePath); var path = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "usedImages.txt"); File.AppendAllText(path, imagePath + Environment.NewLine); } #endif // DEBUG // ResultImageManager.Instance.UpdateAccessTime(fileName); // ResultImageManager.Instance.SaveFileIfItPassed(TimeSpan.FromMinutes(10d)); } var w1 = 180f; var h1 = EPuzzleFonts.ChumonResultState_Default.Height; var backColor = EPuzzleColors.Color107; var kirokuBox = new KirokuBox2() { BorderLine = false, Position = DrawingObjectPosition.Absolute, Width = 200, UserInfo = Window.EPuzzleData.CurrentUserInfo, Chumon = (Chumon)_mondai.Parent, Color = EPuzzleColors.ChumonResultState_KirokuBox2_Color, BackColor = EPuzzleColors.ChumonResultState_KirokuBox2_BackColor, BackColorA = EPuzzleColors.ChumonResultState_KirokuBox2_BackColorA, BackColorB = EPuzzleColors.ChumonResultState_KirokuBox2_BackColorB, LineColor = EPuzzleColors.ChumonResultState_KirokuBox2_LineColor, NodeColor = EPuzzleColors.ChumonResultState_KirokuBox2_NodeColor, }; Items.Add(kirokuBox); var box = new DrawingObjectContainer() { Position = DrawingObjectPosition.Absolute, Color = EPuzzleColors.Color108, BackColor = backColor, Width = w1, PaddingLeft = 10f, PaddingRight = 10f, PaddingTop = 10f, PaddingBottom = 10f, BorderLine = false, }; Items.Add(box); { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = mondai.Parent.LongName, Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); } { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = string.Format("グレード: {0}({1:0.00})", mondai.Parent.GetGradeString(mondaiResult.所要時間, window.EPuzzleData.CurrentUserInfo), mondai.Parent.GetGrade(mondaiResult.所要時間, window.EPuzzleData.CurrentUserInfo)), Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); } { var duration = mondai.Parent.復習までの猶予期間を取得(window.EPuzzleData.CurrentUserInfo); if (null != duration) { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = string.Format("復習猶予期間: {0:0.0}日", ((TimeSpan)duration).TotalDays), Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); } } { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = string.Format("基準時間: {0}", EigoTestMondai.符号無時間文字列(_mondai.Parent.GetTimeLimit(window.EPuzzleData.CurrentUserInfo))), Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); } { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = string.Format("所要時間: {0}", EigoTestMondai.符号無時間文字列(mondaiResult.所要時間)), Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); } { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = string.Format("基準との差: {0}", EigoTestMondai.符号付時間文字列(mondaiResult.所要時間 - _mondai.Parent.GetTimeLimit(window.EPuzzleData.CurrentUserInfo))), Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); } /* { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = string.Format("Perfect: {0}", string.Join("", chumonResult.ShomonResults.Select(x => x.IsPerfect ? "■" : "□").ToArray())), Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); }*/ { var height = 25f; var stars = chumonResult.ShomonResults.Select(x => { var star = new Pentagram(2) { Color = EPuzzleColors.PerfectStarOnChumonResultState, Width = height, Height = height, Tag = x.IsPerfect, PaddingLeft = 3f, PaddingBottom = 3f, }; return star; }).ToArray(); /* for (int i = 0; i < stars.Length; i++) { stars[i].Left = stars[0].OuterWidth * i; stars[i].Top = DrawingObjectRoot.Height - stars[0].OuterHeight; } */ for (int i = 0; i < stars.Length; i++) { stars[i].Left = stars[0].OuterWidth * i; stars[i].Top = 0f; } if (stars.Any()) { var starbox = new DrawingObjectContainer() { Position = DrawingObjectPosition.Absolute, Left = 0f, Top = DrawingObjectRoot.Height - stars.First().OuterHeight, Width = stars.Last().OuterRight - stars.First().OuterLeft, Height = stars.First().OuterHeight, // BackColor = EPuzzleColors.Color107, }; starbox.Items.AddRange(stars); Items.Add(starbox); } // Items.AddRange(stars); } /* { var bestMondaiResult = window.EPuzzleData.CurrentUserInfo.MondaiResults.GetBest(mondai.Parent.Id); if (null != bestMondaiResult) { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = string.Format("最速記録: {0}", EigoTestMondai.符号無時間文字列(bestMondaiResult.所要時間)), Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); } } { var bestMondaiResult = window.EPuzzleData.CurrentUserInfo.MondaiResults.GetBest(mondai.Parent.Id); if (null != bestMondaiResult) { var item = new EigoTestLabelItem() { Color = EPuzzleColors.Color108, Text = string.Format("最速との差: {0}", EigoTestMondai.符号付時間文字列(mondaiResult.所要時間 - bestMondaiResult.所要時間)), Font = EPuzzleFonts.ChumonResultState_Default, Width = w1, Height = h1, StringFormat = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, }, }; box.Items.Add(item); } }*/ /* var retryButton = new EigoTestButtonItem() { Position = DrawingObjectPosition.Absolute, Color = EPuzzleColors.Color108, Text = "再挑戦", Name = "retryButton", Font = EPuzzleFonts.ChumonResultState_Default, Width = 80, Height = h1, }; Items.Add(retryButton);*/ /* // 右がbox box.Left = DrawingObjectRoot.Width - ( box.OuterWidth + kirokuBox.OuterWidth ); box.Top = DrawingObjectRoot.Height - box.OuterHeight; kirokuBox.Height = box.OuterHeight; kirokuBox.Left = DrawingObjectRoot.Width - kirokuBox.OuterWidth; kirokuBox.Top = box.Top; */ box.Left = DrawingObjectRoot.Width - box.OuterWidth; box.Top = DrawingObjectRoot.Height - box.OuterHeight; kirokuBox.Height = box.OuterHeight; kirokuBox.Left = box.OuterLeft - kirokuBox.OuterWidth; kirokuBox.Top = box.Top; Action0 += (sender, e) => { MouseUpInternal(new MouseEventInfo(new PointF(0f, 0f), MouseButtons.Left)); }; }
public void SetValues(TimeSpan seigenJikan, MondaiResult[] mondaiResults) { _seigenJikan = seigenJikan; _mondaiResults = mondaiResults; _points = null; }
// Static members public static string GetString(MondaiResult mondaiResult, Chumon chumon, EPuzzleUserInfo userInfo) { var text = string.Format ( @"({0}日前) {1} {2:00}:{3:00} ({4})", (int)Math.Round((EPuzzleTime.Now - mondaiResult.EndTime).TotalDays), mondaiResult.EndTime.ToString("yyyy/MM/dd(ddd) HH:mm"), (int)mondaiResult.所要時間.TotalMinutes, (int)mondaiResult.所要時間.Seconds, chumon.GetGradeString(mondaiResult.所要時間, userInfo) ); return text; }
public double GetGrade(MondaiResult mondaiResult, EPuzzleUserInfo userInfo) { if (null == mondaiResult) throw new ArgumentNullException(); if (Id != mondaiResult.MondaiId) throw new ArgumentException("Ids are not equal."); return GetGrade(mondaiResult.所要時間, GetTimeLimit(userInfo)); }
public void SaveMondaiResult(MondaiResult mondaiResult) { CurrentUserInfo.MondaiResults.Add(mondaiResult); Save(); }
// GetPoint()は強制的に期間を限定するが、GetPoints2()は最古の結果からの全期間 public static IEnumerable<PointF> GetPoints2(Chumon chumon, double minGrade, double maxGrade, RectangleF rectangle, MondaiResult[] mondaiResults, EPuzzleUserInfo userInfo) { if (!mondaiResults.Any()) return Enumerable.Empty<PointF>(); var items = mondaiResults.OrderByDescending(x => x.StartTime).ToArray(); var t0 = items.Last().StartTime; var duration = EPuzzleTime.Now - t0; var points = items.Select(mondaiResult => { var grade = chumon.GetGrade(mondaiResult, userInfo); if (grade < minGrade) { grade = minGrade; } else if (grade > maxGrade) { grade = maxGrade; } grade -= minGrade; grade /= maxGrade - minGrade; var t = (mondaiResult.StartTime - t0).Ticks / (double)duration.Ticks; return new PointF((float)(t * rectangle.Width + rectangle.Left), (float)(grade * rectangle.Height + rectangle.Top)); }); return points; }