コード例 #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;
            };
        }