コード例 #1
0
        public HelpItemState(EPuzzleWindow window, HelpItemBase[] helpItems, int helpItemIndex, WindowState parentState)
            : base(window)
        {
            _helpItems = helpItems;
            _helpItemIndex = helpItemIndex;
            _parentState = parentState;

            var helpItemButtons = helpItems.Select(helpItem =>
            {
                var helpItemButton = new EigoTestButtonItem("", 20f, 18f)
                {
                    Position = DrawingObjectPosition.Absolute,
                    MarginRight = 10f,
                    MarginBottom = 10f,
                    Tag = helpItem,
                };
                return helpItemButton;
            });
            var helpItemButtonContainer = new DrawingObjectContainer()
            {
                Position = DrawingObjectPosition.Absolute,
                MarginLeft = 50f,
                Height = 40f,
            };
            helpItemButtonContainer.Items.AddRange(helpItemButtons);
            helpItemButtonContainer.Items[helpItemIndex].IsClickable = false;
            Items.Add(helpItemButtonContainer);

            for (int i = 1; i < helpItemButtonContainer.Items.Count(); i++)
            {
                var s = helpItemButtonContainer.Items[i - 1];
                var t = helpItemButtonContainer.Items[i];
                t.Left = s.Left + s.OuterWidth;
            }
            helpItemButtonContainer.下揃え();

            var modoruButton = new EigoTestButtonItem("続ける", 80f, 50f)
            {
                Position = DrawingObjectPosition.Absolute,
                Name = "tsudukeru",
                MarginRight = 50f, MarginBottom = 10f,
            };
            Items.Add(modoruButton);
            modoruButton.右揃え();
            modoruButton.下揃え();

            if (0 < helpItemIndex)
            {
                var previousButton = new PreviousButton()
                {
                    Position = DrawingObjectPosition.Absolute,
                    MarginLeft = 10f,
                    Tag = helpItemIndex - 1,
                };
                Items.Add(previousButton);
                previousButton.垂直方向に中央揃え();
            }
            if (helpItemIndex < helpItemButtonContainer.Items.Count() - 1)
            {
                var nextButton = new NextButton()
                {
                    Position = DrawingObjectPosition.Absolute,
                    MarginRight = 10f,
                    Tag = helpItemIndex + 1,
                };
                Items.Add(nextButton);
                nextButton.垂直方向に中央揃え();
                nextButton.右揃え();
            }
            if (!string.IsNullOrWhiteSpace(_helpItems[helpItemIndex].ImageFile))
            {
                var imageFile = Path.Combine(window.EPuzzleData.HelpDirectory, _helpItems[helpItemIndex].ImageFile);
                var imageItem = new ImageItem(imageFile)
                {
                    Position = DrawingObjectPosition.Absolute,
                    MarginTop = 20f,
                };
                Items.Add(imageItem);
                imageItem.水平方向に中央揃え();
            }

            Action0 += (sender, e) =>
            {
                if (CurrentItem is NextButton)
                {
                    MoveTo((int)CurrentItem.Tag);
                }
                else if (CurrentItem is PreviousButton)
                {
                    MoveTo((int)CurrentItem.Tag);
                }
                else if (CurrentItem.Tag is HelpItem)
                {
                    var index = Array.IndexOf(helpItems, CurrentItem.Tag);
                    MoveTo(index);
                }
                else if ("tsudukeru" == CurrentItem.Name)
                {
                    Window.State = parentState;
                }
            };
            Action3 += (sender, e) =>
            {
                Window.State = parentState;
            };
        }
コード例 #2
0
        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));
            };
        }