public MatchesHard(Random task, Random word, Repo repo) : this() { string current; int tagInd, wordInd; for (var i = 0; i < ContentLeft.Length; i++) { Again: tagInd = task.Next(repo.topics.Count); wordInd = word.Next(repo.topics[tagInd].words.Count); current = repo.topics[tagInd].words[wordInd].word; if (ContentLeft.Contains(current)) { goto Again; } CorrectPair[i] = new KeyValuePair <int, int>(tagInd, wordInd); var AnagramWord = new char?[current.Length]; var forbiddenLiter = new List <int>(); int iter = 0; Random rand = new Random((int)DateTime.Now.Ticks); while (!AnagramWord.All(x => x.HasValue)) { int _index = rand.Next(current.Length); if (!forbiddenLiter.Contains(_index)) { AnagramWord[iter] = current[_index]; iter++; forbiddenLiter.Add(_index); } } ContentLeft[i] = (new string(AnagramWord.Select(x => x.Value).ToArray())).Replace('\"', '\''); } //права частина var forbiddenIndexes = new List <int>(); var randInd = new Random(Environment.TickCount); int index = 0; int I; while (((string[])ContentRight).Any(x => x == null)) { I = randInd.Next(5); if (!forbiddenIndexes.Contains(I)) { forbiddenIndexes.Add(I); ((string[])ContentRight)[index] = repo.topics[CorrectPair[I].Key].words[CorrectPair[I].Value].translates[0].translate; PairRight[index] = CorrectPair[I]; index++; } } }
public MatchesImage(Random task, Random word, Repo repo) : this() { string current; int tagInd, wordInd; for (var i = 0; i < ContentLeft.Length; i++) { Again: tagInd = task.Next(repo.topics.Count); wordInd = word.Next(repo.topics[tagInd].words.Count); current = repo.topics[tagInd].words[wordInd].word; if (ContentLeft.Contains(current)) { goto Again; } CorrectPair[i] = new KeyValuePair <int, int>(tagInd, wordInd); ContentLeft[i] = current.Replace('\"', '\''); } //права частина var forbiddenIndexes = new List <int>(); var randInd = new Random(Environment.TickCount); int index = 0; int I; while (((Image[])ContentRight).Any(x => x == null)) { I = randInd.Next(5); if (!forbiddenIndexes.Contains(I)) { forbiddenIndexes.Add(I); ((Image[])ContentRight)[index] = repo.topics[CorrectPair[I].Key].words[CorrectPair[I].Value].translates[0].image; ((Image[])ContentRight)[index].Width = 64; ((Image[])ContentRight)[index].Height = 64; PairRight[index] = CorrectPair[I]; index++; } } }