コード例 #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 override void UpdateItemsToBeDrawn()
        {
            Items.Clear();

            var rect = Window.ClientRectangle;

            var button_color = Color.FromArgb(0xff, 0x00, 0x00, 0x80);

            var helpTextBox = CreateHelpTextBox();
            helpTextBox.Left = 840;
            helpTextBox.Top = 100;
            helpTextBox.Width = 150;
            helpTextBox.Height = 400;

            //			helpTextBox.Left = 0;
            //			helpTextBox.Top = 0;
            Items.Add(helpTextBox);

            var title_label = new EigoTestLabelItem()
            {
                MarginTop = 30f,
                MarginBottom = 30f,
                Color = button_color,
                BackColor = Color.FromArgb(0xff, 0xb0, 0xc4, 0xde),
                BorderLine = true,
                Text = Daimon.Name,
                Height = 56f,
            };
            title_label.Font = EPuzzleFonts.GetFont("Arial", (int)(title_label.Height / 2f));
            title_label.MarginLeft = title_label.MarginRight = 300f;
            Items.Add(title_label);

            // 前の問題ドキュメントへ遷移するボタン
            var previousMondaiDocumentButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 800,
                Top = 10,
                Width = 40,
                Height = 40,
                Text = "↑",
                Name = "PreviousMondaiDocumentButton",
                IsVisible = Daimon.Parent.PreviousItem != null,
                IsClickable = Daimon.Parent.PreviousItem != null,
                HelpText = "前の問題ファイルに移動します。",
            };
            previousMondaiDocumentButton.Click += (sender, e) =>
            {
                if (e.Info.Button != MouseButtons.Left) return;
                OnActionUp();
            };
            Items.Add(previousMondaiDocumentButton);

            // 次の問題ドキュメントへ遷移するボタン
            var nextMondaiDocumentButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 850,
                Top = 10,
                Width = 40,
                Height = 40,
                Text = "↓",
                Name = "NextMondaiDocumentButton",
                IsVisible = Daimon.Parent.NextItem != null,
                IsClickable = Daimon.Parent.NextItem != null,
                HelpText = "次の問題ファイルに移動します。",
            };
            nextMondaiDocumentButton.Click += (sender, e) =>
            {
                if (e.Info.Button != MouseButtons.Left) return;
                OnActionDown();
            };
            Items.Add(nextMondaiDocumentButton);

            // 問題ドキュメントメニューへ遷移するボタン
            var mondaiDocumentMenuButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 900,
                Top = 10,
                Width = 40,
                Height = 40,
                Text = "=",
                Name = "MondaiMenuButton",
                HelpText = "問題ファイルの選択メニューに戻ります。",
            };
            mondaiDocumentMenuButton.Click += (sender, e) =>
            {
                MoveToMondaiDocumentMenuState();
            };
            Items.Add(mondaiDocumentMenuButton);

            // タイトルに戻るボタン
            _back_button = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 950,
                Top = 10,
                Width = 40,
                Height = 40,
                Text = "T",
                Name = "タイトル画面に戻る",
                HelpText = "タイトル画面に戻ります。",
            };
            _back_button.Font = EPuzzleFonts.GetMsGothic((int)(_back_button.Height / 2f));
            _back_button.Click += (sender, e) =>
            {
                MoveToStartGameState();
            };
            Items.Add(_back_button);

            // 成績グラフ
            _kirokuBox = new KirokuBox2()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 10,
                Top = 100,
                Width = 180,
                Height = 180,
                UserInfo = Window.EPuzzleData.CurrentUserInfo,
                Chumon = (Chumon)Daimon.Items.First(),
            };
            Items.Add(_kirokuBox);

            _kirokuInfoBox = new KirokuInfoBox()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 50,
                Top = 300,
                Width = 160,
                Height = 200,
                UserInfo = Window.EPuzzleData.CurrentUserInfo,
                Chumon = (Chumon)Daimon.Items.First(),
            };
            Items.Add(_kirokuInfoBox);

            var chumonButtonHeight = 36;
            var chumonButtonWidth = 600;
            _helpWithScroll.Items = Daimon.Items.OfType<Chumon>().ToArray();
            _chumonButtons = _helpWithScroll.GetItemsToBeShown().Select(x =>
            {
                var mondaiResult = Window.EPuzzleData.CurrentUserInfo.MondaiResults.GetBest(x.Id);
                var shoyou = null == mondaiResult ? TimeSpan.Zero : mondaiResult.所要時間;
            //				var button = new ChumonButton(new MondaiJirushi(Window.EPuzzleData.CurrentUserInfo, x), Window.EPuzzleData.CurrentUserInfo)
                var button = new ChumonButton(Window.EPuzzleData.CurrentUserInfo, x)
                {
                    Color = button_color,
                    BackColor = Color.FromArgb(0xff, 0xb0, 0xc4, 0xde),
                    Height = chumonButtonHeight,
                    Size = new SizeF(chumonButtonWidth, chumonButtonHeight),
                };
                button.MarginLeft = button.MarginRight = (DrawingObjectRoot.Width - chumonButtonWidth) / 2f;
                button.Font = EPuzzleFonts.GetFont("Arial", (int)(button.Height / 2f));
                return button;
            }).ToArray();
            foreach (var chumonButton in _chumonButtons)
            {
                Items.Add(chumonButton);
            }

            // 発音問題ボタンを追加する
            /*			if (Window.EPuzzleData.発音問題を有効にする)
            {
                var chumonCreator = new ChumonCreator(Window.EPuzzleData.PronunciationInfoContainer);
                foreach (var chumonButton in _chumonButtons)
                {
                    var proChumon = chumonCreator.GetPronunciationChumon(chumonButton.Chumon);
                    if (null == proChumon) continue;
                    var button = new EigoTestButtonItem()
                    {
                        Position = DrawingObjectPosition.Absolute,
                        Left = chumonButton.BorderRight + 10,
                        Top = chumonButton.BorderTop,
                        Width = chumonButton.Height,
                        Height = chumonButton.Height,
                        Text = "P",
                        Name = "pron-mondai",
                        Tag = proChumon,
                        BorderLine = true,
                    };
                    Items.Add(button);
                }
            }*/

            // 次のDaimonへ遷移するボタン
            var nextButtonSize = new SizeF(30, 45);
            if (null != Daimon.NextItem)
            {
                var nextDaimonButton = new NextButton()
                {
                    Position = DrawingObjectPosition.Absolute,
                    Color = button_color,
                    BackColor = Color.FromArgb(0xff, 0xb0, 0xc4, 0xde),
                    Location = new PointF(Window.ClientRectangle.Width - nextButtonSize.Width - 10, Window.ClientRectangle.Height / 2 - nextButtonSize.Height / 2),
                    Size = nextButtonSize,
                    Name = "NextDaimon",
                };
                nextDaimonButton.Click += (sender, e) =>
                {
                    if (e.Info.Button != MouseButtons.Left) return;
                    MoveToNextDaimon();
            //					OnActionRight();
                };
                Items.Add(nextDaimonButton);
            }

            // 前のDaimonへ遷移するボタン
            if (null != Daimon.PreviousItem)
            {
                var previousButton = new PreviousButton()
                {
                    Position = DrawingObjectPosition.Absolute,
                    Color = button_color,
                    BackColor = Color.FromArgb(0xff, 0xb0, 0xc4, 0xde),
                    Location = new PointF(10, Window.ClientRectangle.Height / 2 - nextButtonSize.Height / 2),
                    Size = nextButtonSize,
                    Name = "PreviousDaimon",
                };
                previousButton.Click += (sender, e) =>
                {
                    if (e.Info.Button != MouseButtons.Left) return;
                    MoveToPreviousDaimon();
            //					OnActionLeft();
                };
                Items.Add(previousButton);
            }
            if (_helpWithScroll.NeedToShowButtonToScrollUp)
            {
                var upButton = new EigoTestButtonItem()
                {
                    Position = DrawingObjectPosition.Absolute,
                    Left = 800,
                    Top = 10,
                    Width = 80,
                    Height = 40,
                    Text = "↑ " + _helpWithScroll.NumberOfUpperItems,
                    Name = "upButton",
                    IsVisible = true,
                    IsClickable = true,
                };
                Items.Add(upButton);
                upButton.水平方向に中央揃え();
            }
            if (_helpWithScroll.NeedToShowButtonToScrollDown)
            {
                var downButton = new EigoTestButtonItem()
                {
                    Position = DrawingObjectPosition.Absolute,
                    Left = 800,
                    Top = 718,
                    Width = 80,
                    Height = 40,
                    Text = "↓ " + _helpWithScroll.NumberOfLowerItems,
                    Name = "downButton",
                    IsVisible = true,
                    IsClickable = true,
                };
                Items.Add(downButton);
                downButton.水平方向に中央揃え();
            }

            {
                var label = CreateLabelToShowNumberOfQuestionsThatHaveBeenFinished();
                label.Top -= 100f;
                Items.Add(label);
            }

            var daimons = Daimon.Parent.Items.OfType<Daimon>().ToArray();
            var daimonIndex = daimons.GetIndexOf(x => object.ReferenceEquals(x, Daimon));
            var daimonButtonBox = new DaimonButtonBox(daimons, daimonIndex, Window.EPuzzleData.CurrentUserInfo)
            {
                Position = DrawingObjectPosition.Absolute,
                MarginBottom = 30f,
            };
            Items.Add(daimonButtonBox);
            daimonButtonBox.水平方向に中央揃え();
            daimonButtonBox.下揃え();
            LockButtons();
            CurrentItemにロックされていない最後の問題を設定する();
        }