public AnkimonState(EPuzzleWindow window, Ankimon ankimon) : base(window) { Ankimon = ankimon; _shomonStateHelper = new ShomonStateHelper(this); _ankimonBox = new AnkimonBox() { MarginLeft = 100f, MarginTop = 100f, MarginRight = 100f, }; Items.Add(_ankimonBox); foreach (var container in ankimon.AnkimonItems.Select(ankimonItem => { var ankimonRowContainer = new AnkimonRowContainer() { MarginLeft = 10f, MarginTop = 0f, AnkimonItem = ankimonItem, }; ankimonRowContainer.Label.Text = ankimonItem.Name; var collection = ankimonRowContainer.WordCardContainer.Items; foreach (var word in ankimonItem.MondaiWords) { collection.Add(new WordCard(word)); } ((DrawingObjectContainer.DrawingObjectCollection)collection).CollectionChanged += Handler0; return ankimonRowContainer; })) { _ankimonBox.Items.Add(container); } int i = 0; do { Shuffle(); if (i++ > 100) { throw new ApplicationException("指定された回数を超えても問題がシャッフルできません: " + Ankimon.Id); } } while (正解判定()); Action0 += (sender, e) => { _subState.Action0((WindowState)sender); }; Action1 += (sender, e) => { _subState.Action1((WindowState)sender); }; Action3 += (sender, e) => { Window.State = new PauseState(Window, this); }; CurrentItem = GetAllItems().First(x => x is WordCard); }
public ShomonStateBase(EPuzzleWindow window, Shomon shomon) : base(window) { if (null == shomon) throw new ArgumentNullException(); Shomon = shomon; _shomonStateHelper = new ShomonStateHelper(this); NeedToPlaySounds += (sender, e) => { /* foreach (var sound in e.Sounds) { Window.EPuzzleData.CurrentUserInfo.SoundPlayer.Play(sound.FileName); } */ Window.EPuzzleData.CurrentUserInfo.SoundPlayer.Play(e.Sounds.Select(x => x.FileName), true); }; Action0 += (sender, e) => { if (null == CurrentItem) return; switch (CurrentItem.Name) { case "info" : { _shomonStateHelper.ShowInformation(); break; } case "back" : { BackToChumonMenu(); break; } case "hajimekara" : { WindowState.Chumonを開始する((Chumon)Shomon.Parent, Window.WindowStateWhichHasStartedChumon); break; } case "pause" : { Pause(); break; } case "showCorrectAnswer" : { _userHasSeenCorrectAnswer = true; var text = string.Join(Environment.NewLine, shomon.CorrectAnswers.Select(x => string.Format(@"{0}", x.Text)).ToArray()); Window.State = new InformationState(Window, this, text); break; } case "playSound" : { PlaySounds(); break; } } }; Action3 += (sender, e) => { Pause(); }; Action4 += (sender, e) => { PlaySounds(); }; }