private void MoveAlphabetBy(int steps) { if (steps > 0) { for (var i = 0; i < steps; i++) { var firstLetterInner = InnerLetterViews.First(); var firstLetterOuter = OuterLetterViews.First(); InnerLetterViews.Remove(firstLetterInner); OuterLetterViews.Remove(firstLetterOuter); InnerLetterViews.Add(firstLetterInner); OuterLetterViews.Add(firstLetterOuter); } } else { for (var i = 0; i > steps; i--) { var lastLetterInner = InnerLetterViews.Last(); var lastLetterOuter = OuterLetterViews.Last(); InnerLetterViews.Remove(lastLetterInner); OuterLetterViews.Remove(lastLetterOuter); InnerLetterViews.Insert(0, lastLetterInner); OuterLetterViews.Insert(0, lastLetterOuter); } } }
public override void Initialize() { base.Initialize(); foreach (var letter in CommonHelper.GetShiftedAlphabet(PositionShift)) { InnerLetterViews.Add(HelpersViewModelFactory.CreateLetter(letter)); OuterLetterViews.Add(HelpersViewModelFactory.CreateLetter(letter)); } }
public override void Handle(LetterTranslation translation) { Grid.UpdateLayout(); LetterView fromView, toView; if (translation.Direction == SignalDirection.In) { fromView = InnerLetterViews.First(vm => vm.Letter == translation.Input).GetView() as LetterView; toView = OuterLetterViews.First(vm => vm.Letter == translation.Result).GetView() as LetterView; } else { fromView = OuterLetterViews.First(vm => vm.Letter == translation.Input).GetView() as LetterView; toView = InnerLetterViews.First(vm => vm.Letter == translation.Result).GetView() as LetterView; } ConnectionDrawer.Draw(fromView, toView, translation.Direction); }