protected override void InitIteration()
        {
            base.InitIteration();

            var currentIteration = GetCurrentIteration <LetterDropIteration>();

            // Randomize font case
            var random   = new Random();
            var fontCase = (Case)(random.Next(2) + 1);

            // Generate Options
            currentIteration.Options = GenerateOptions(currentIteration, 10, fontCase);

            // Generate Task letters
            currentIteration.TaskItems = new List <TaskItem>();
            foreach (var letter in currentIteration.LettersToLearn)
            {
                var taskLetter = new TaskLetter(letter.ToCase(fontCase));
                var taskItem   = new TaskItem(taskLetter, null, true);
                currentIteration.TaskItems.Add(taskItem);
            }

            currentIteration.TaskItems.Shuffle();
            flLetters.RemoveAllViews();

            // Add options to view
            var letterAdapter = new LetterAdapter(Activity.BaseContext, 0, currentIteration.Options);

            for (var i = 0; i < currentIteration.Options.Count; i++)
            {
                // Add letter to view
                var view   = letterAdapter.GetView(i, null, null);
                var letter = currentIteration.Options.ElementAt(i).Letter;

                // Add drag
                view.Touch += (sender, e) => {
                    var data = ClipData.NewPlainText("letter", letter);
                    (sender as View).StartDrag(data, new View.DragShadowBuilder(sender as View), null, 0);
                };

                flLetters.AddView(view);
            }

            // Add task letters to view
            useAlternateView       = currentIteration.TaskItems.Count > 5;
            llTaskItems.Visibility = (useAlternateView) ? ViewStates.Gone : ViewStates.Visible;
            flTaskItems.Visibility = (useAlternateView) ? ViewStates.Visible : ViewStates.Gone;
            BuildTaskLetters(currentIteration.TaskItems);
        }
Beispiel #2
0
        void BuildOptions(List <LetterBase> options)
        {
            flLetters.RemoveAllViews();
            var adapter = new LetterAdapter(Activity.BaseContext, 0, options);

            for (int i = 0; i < options.Count; i++)
            {
                // Add letter to view
                var view   = adapter.GetView(i, null, null);
                var letter = options.ElementAt(i).Letter;

                view.Touch += (sender, e) => {
                    var data = ClipData.NewPlainText("letter", letter);
                    (sender as View).StartDrag(data, new View.DragShadowBuilder(sender as View), null, 0);
                };

                flLetters.AddView(view);
            }
        }
Beispiel #3
0
        protected override void InitIteration()
        {
            base.InitIteration();

            var currentIteration = GetCurrentIteration <FindMissingLetterIteration>();

            // Set random font case for whole iteration
            fontCase = Case.Lower;
            if (currentIteration.RandomizeCase)
            {
                var random = new Random();
                fontCase = (Case)(random.Next(2) + 1);
            }

            // Create task letters
            ResetCorrectTaskLetter(currentIteration.TaskItems);
            BuildTaskLetters(currentIteration.TaskItems, fontCase);

            // Generate options
            currentIteration.Options = GenerateOptions(currentIteration, 10, fontCase);

            flLetters.RemoveAllViews();
            var letterAdapter = new LetterAdapter(Activity.BaseContext, 0, currentIteration.Options.Cast <LetterBase>().ToList());

            for (var i = 0; i < currentIteration.Options.Count; i++)
            {
                // Add letter to view
                var view   = letterAdapter.GetView(i, null, null);
                var letter = currentIteration.Options.ElementAt(i).Letter;

                // Add drag
                view.Touch += (sender, e) => {
                    var data = ClipData.NewPlainText("letter", letter);
                    (sender as View).StartDrag(data, new View.DragShadowBuilder(sender as View), null, 0);
                };

                flLetters.AddView(view);
            }
        }