コード例 #1
0
        public void Itemsプロパティを更新した場合にIndexが調整されるように()
        {
            var help = new HelpWithScroll<int>();
            Assert.AreEqual(10, help.NumberOfItemsToBeShown);

            help.Items = new int[100];
            help.ScrollDown(100);
            Assert.AreEqual(90, TestUtility.GetValue(help, "_index"));

            Assert.Throws<ArgumentNullException>(() =>
            {
                help.Items = null;
            });

            help.Items = new int[5];
            Assert.AreEqual(0, TestUtility.GetValue(help, "_index"));
        }
コード例 #2
0
        public void Test0()
        {
            var help = new HelpWithScroll<int>();

            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                help.NumberOfItemsToBeShown = 0;
            });

            Assert.AreEqual(10, help.NumberOfItemsToBeShown);
            help.NumberOfItemsToBeShown = 1;
            Assert.AreEqual(1, help.NumberOfItemsToBeShown);

            var items = new [] { 1, 2, };
            help.Items = items;

            Assert.AreEqual(0, help.NumberOfUpperItems);
            Assert.AreEqual(1, help.NumberOfLowerItems);
            CollectionAssert.AreEqual(new [] { 1, }, help.GetItemsToBeShown());

            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                help.ScrollDown(0);
            });
            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                help.ScrollUp(0);
            });

            var count = 0;
            help.UpdateScreen += (sender, e) =>
            {
                count++;
            };
            Assert.AreEqual(0, count);

            help.ScrollDown(10);
            Assert.AreEqual(1, help.NumberOfUpperItems);
            Assert.AreEqual(0, help.NumberOfLowerItems);
            CollectionAssert.AreEqual(new [] { 2, }, help.GetItemsToBeShown());
            Assert.AreEqual(1, count);
            Assert.True(help.NeedToShowButtonToScrollUp);
            Assert.False(help.NeedToShowButtonToScrollDown);

            help.ScrollDown(10);
            Assert.AreEqual(1, help.NumberOfUpperItems);
            Assert.AreEqual(0, help.NumberOfLowerItems);
            CollectionAssert.AreEqual(new [] { 2, }, help.GetItemsToBeShown());
            Assert.AreEqual(1, count);
            Assert.True(help.NeedToShowButtonToScrollUp);
            Assert.False(help.NeedToShowButtonToScrollDown);

            help.ScrollUp(10);
            Assert.AreEqual(0, help.NumberOfUpperItems);
            Assert.AreEqual(1, help.NumberOfLowerItems);
            CollectionAssert.AreEqual(new [] { 1, }, help.GetItemsToBeShown());
            Assert.AreEqual(2, count);
            Assert.False(help.NeedToShowButtonToScrollUp);
            Assert.True(help.NeedToShowButtonToScrollDown);

            help.ScrollUp(10);
            Assert.AreEqual(0, help.NumberOfUpperItems);
            Assert.AreEqual(1, help.NumberOfLowerItems);
            CollectionAssert.AreEqual(new [] { 1, }, help.GetItemsToBeShown());
            Assert.AreEqual(2, count);
            Assert.False(help.NeedToShowButtonToScrollUp);
            Assert.True(help.NeedToShowButtonToScrollDown);

            var help2 = new HelpWithScroll<int>(99);
            Assert.AreEqual(99, help2.NumberOfItemsToBeShown);
        }
コード例 #3
0
        public DaimonState(EPuzzleWindow window, Daimon daimon, int numberOfItemsToBeShown = 16)
            : base(window)
        {
            _helpWithScroll = new HelpWithScroll<Chumon>(numberOfItemsToBeShown);
            Daimon = daimon;
            DrawingObjectRoot.BackColor = EPuzzleColors.DaimonStateBackColor;

            PropertyChanged += (sender, e) =>
            {
                if ("CurrentItem" != e.PropertyName) return;
                var chumonButton = CurrentItem as ChumonButton;
                if (null != chumonButton)
                {
                    _kirokuBox.Chumon = chumonButton.Chumon;
                    _kirokuInfoBox.Chumon = chumonButton.Chumon;
                }
            };
            Action0 += (sender, e) =>
            {
                var chumonButton = CurrentItem as ChumonButton;
                if (null != chumonButton)
                {
                    Chumonを開始する(chumonButton.Chumon, this);
                    return;
                }
                var daimonButton = CurrentItem as DaimonButton;
                if (null != daimonButton)
                {
                    Window.State = FoFi(this, new DaimonState(Window, daimonButton.Daimon));
                    return;
                }
                var button = CurrentItem as EigoTestButtonItem;
                if (null != button)
                {
                    switch (button.Name)
                    {
                        case "upButton" :
                        {
                            _helpWithScroll.ScrollUp();
                            return;
                        }
                        case "downButton" :
                        {
                            _helpWithScroll.ScrollDown();
                            return;
                        }
                    }
                    var chumon = button.Tag as Chumon;
                    if (null != chumon)
                    {
                        Chumonを開始する(chumon, this);
                        return;
                    }
                }
            };
            ActionLeft += (sender, e) =>
            {
                MoveToPreviousDaimon();
            /*				if (null == Daimon.PreviousItem) return;
                Window.State = FoFi(this, new DaimonState(Window, (Daimon)Daimon.PreviousItem));
                */
            };
            ActionRight += (sender, e) =>
            {
                MoveToNextDaimon();
            /*				if (null == Daimon.NextItem) return;
                Window.State = FoFi(this, new DaimonState(Window, (Daimon)Daimon.NextItem));
                */
            };
            ActionUp += (sender, e) =>
            {
                if (null == Daimon.Parent.PreviousItem) return;
                MoveTo((MondaiDocument)Daimon.Parent.PreviousItem);
            };
            ActionDown += (sender, e) =>
            {
                if (null == Daimon.Parent.NextItem) return;
                MoveTo((MondaiDocument)Daimon.Parent.NextItem);
            };
            _helpWithScroll.UpdateScreen += (sender, e) =>
            {
                UpdateItemsToBeDrawn();
            };
            UpdateItemsToBeDrawn();
        }
コード例 #4
0
 public void スクロールすると例外が発生する不具合()
 {
     {
         var help = new HelpWithScroll<int>();
         help.Items = new int[0];
         help.NumberOfItemsToBeShown = 1;
         help.ScrollDown();
         help.ScrollUp();
     }
     {
         var help = new HelpWithScroll<int>();
         help.Items = new [] { 1, 2, 3, };
         help.NumberOfItemsToBeShown = 5;
         help.ScrollDown();
         help.ScrollUp();
     }
     {
         var help = new HelpWithScroll<int>();
         help.Items = new [] { 1, 2, 3, };
         help.NumberOfItemsToBeShown = 3;
         help.ScrollDown();
         help.ScrollUp();
     }
 }
コード例 #5
0
        public override void UpdateItemsToBeDrawn()
        {
            _tutor.もっとやる係数を適正値に修正();

            var currentItemInfo = SaveCurrentItem();

            Items.Clear();
            CurrentItem = null;

            var userInfo = Window.EPuzzleData.CurrentUserInfo;
            var chumonButtonBox = new DrawingObjectContainer()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 300, Top = 60,
            };
            Items.Add(chumonButtonBox);

            var buttonColor = Color.FromArgb(0xff, 0x00, 0x00, 0x80);
            var buttonBackColor = Color.FromArgb(0xff, 0xb0, 0xc4, 0xde);
            var chumonButtonHeight = 36;
            var chumonButtonWidth = 714;

            _helpWithScroll = GetScrollHelper(_sortType);
            _helpWithScroll.Items = GetChumons(_tutor, _sortType);
            foreach (var chumon in _helpWithScroll.GetItemsToBeShown())
            {
                var chumonButton = new ChumonButton(userInfo, chumon, true)
                {
                    Color = buttonColor,
                    BackColor = buttonBackColor,
                    Width = chumonButtonWidth,
                    Height = chumonButtonHeight,
                };

                chumonButtonBox.Items.Add(chumonButton);
            }
            if (_helpWithScroll.NeedToShowButtonToScrollUp)
            {
                var upButton = new EigoTestButtonItem()
                {
                    Position = DrawingObjectPosition.Absolute,
                    Left = DrawingObjectRoot.Width - (80 + 10),
                    Top = 15,
                    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 = DrawingObjectRoot.Width - (80 + 10),
                    Top = DrawingObjectRoot.Height - (40 + 10),
                    Width = 80,
                    Height = 40,
                    Text = "↓ " + _helpWithScroll.NumberOfLowerItems,
                    Name = "downButton",
                    IsVisible = true,
                    IsClickable = true,
                };
                Items.Add(downButton);
            //				downButton.水平方向に中央揃え();
            }

            var xxx = !chumonButtonBox.Items.Any();
            var mottoyaruButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 10,
                Top = 500,
                Width = 160,
                Height = 40,
                Text = string.Format("もっとやる ({0}回目)", もっとやる係数),
                Name = "mottoyaruButton",
                IsVisible = xxx,
                IsClickable = xxx,
            };
            Items.Add(mottoyaruButton);

            /*			var orderByGradeStringsButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 854,
                Top = 10,
                Width = 160,
                Height = 40,
                Name = "orderByGradeStringsButton",
                Text = OrderByGradeStrings ? "最新の成績順" : "復習猶予期間順",
                IsVisible = true,
                IsClickable = true,
            };
            Items.Add(orderByGradeStringsButton);*/

            var byGracePriodButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 300,
                Top = 15,
                Width = 160,
                Height = 40,
                Name = "byGracePriodButton",
                Text = "猶予順",
                IsVisible = true,
                IsClickable = TutorStateSortType.GracePriod != _sortType,
                ChangeColorWhenUnclickable = true,
            };
            Items.Add(byGracePriodButton);

            var byDateYouDidThemButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 465,
                Top = 15,
                Width = 160,
                Height = 40,
                Name = "byDateYouDidThemButton",
                Text = "試験順",
                IsVisible = true,
                IsClickable = TutorStateSortType.DateYouDidThem != _sortType,
                ChangeColorWhenUnclickable = true,
            };
            Items.Add(byDateYouDidThemButton);

            var byGradeButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 630,
                Top = 15,
                Width = 160,
                Height = 40,
                Name = "byGradeButton",
                Text = "成績順",
                IsVisible = true,
                IsClickable = TutorStateSortType.Grade != _sortType,
                ChangeColorWhenUnclickable = true,
            };
            Items.Add(byGradeButton);

            var backToStartGameStateButton = new EigoTestButtonItem()
            {
                Position = DrawingObjectPosition.Absolute,
                Left = 10,
                Top = 10,
                Width = 160,
                Height = 40,
                Name = "backToStartGameStateButton",
                Text = "タイトルに戻る",
                IsVisible = true,
                IsClickable = true,
            };
            Items.Add(backToStartGameStateButton);

            Items.Add(CreateLabelToShowNumberOfQuestionsThatHaveBeenFinished());

            Items.Add(_kirokuBox);

            RestoreCurrentItem(currentItemInfo);

            if (null == CurrentItem)
            {
                CurrentItem = GetAllItems().OfType<ChumonButton>().FirstOrDefault();
            }
        }