public MemorizeStageWindow(MemorizeStage stage)
        {
            InitializeComponent();

            this.stage = stage;
            if (this.stage != null)
            {
                if (this.stage is MemorizeStableStage)
                {
                    this.stableRadioButton.IsChecked = true;
                }
                else if (this.stage is MemorizeRandomItemStage)
                {
                    this.randomRadioButton.IsChecked = true;
                    this.itemCountTextBox.Text       = ((MemorizeRandomItemStage)this.stage).ItemCount.ToString();
                }
                else if (this.stage is MemorizeMathStage)
                {
                    this.mathStageRadioButton.IsChecked = true;
                    MemorizeMathStage mathStage = this.stage as MemorizeMathStage;
                    this.addCheckBox.IsChecked      = mathStage.Plus;
                    this.minusCheckBox.IsChecked    = mathStage.Minus;
                    this.multiplyCheckBox.IsChecked = mathStage.Multiplication;
                    this.divisionCheckBox.IsChecked = mathStage.Division;
                    this.minValueTextBox.Text       = mathStage.MinValue.ToString();
                    this.maxValueTextBox.Text       = mathStage.MaxValue.ToString();
                    this.mathCountTextBox.Text      = mathStage.ItemCount.ToString();
                }
            }
        }
Exemplo n.º 2
0
        private void prepareMemorizeItemList()
        {
            if (this.ActiveStage is MemorizeStableStage)
            {
                foreach (string id in ((MemorizeStableStage)this.ActiveStage).MemorizeItemIds)
                {
                    var queryItem = from item in this.memorizeEntry.Items
                                    where item.Id == id
                                    select item;
                    this.memorizeItemList.Add(queryItem.First().ObjectA);
                    this.memorizeItemList.Add(queryItem.First().ObjectB);
                }
            }
            else if (this.ActiveStage is MemorizeRandomItemStage)
            {
                List <int> tempIndexList   = new List <int>();
                List <int> pickedIndexList = new List <int>();
                for (int i = 0; i < this.memorizeEntry.Items.Count; i++)
                {
                    tempIndexList.Add(i);
                }

                Random rand = new Random(Environment.TickCount);
                for (int i = 0; i < ((MemorizeRandomItemStage)this.ActiveStage).ItemCount; i++)
                {
                    if (tempIndexList.Count == 0)
                    {
                        break;
                    }

                    int randIndex = rand.Next(tempIndexList.Count);
                    pickedIndexList.Add(tempIndexList[randIndex]);
                    tempIndexList.RemoveAt(randIndex);
                }

                foreach (int index in pickedIndexList)
                {
                    this.memorizeItemList.Add(this.memorizeEntry.Items[index].ObjectA);
                    this.memorizeItemList.Add(this.memorizeEntry.Items[index].ObjectB);
                }
            }
            else if (this.ActiveStage is MemorizeMathStage)
            {
                MemorizeMathStage mathStage = this.ActiveStage as MemorizeMathStage;
                mathStage.GenerateItems();
                foreach (MemorizeItem item in mathStage.Items)
                {
                    this.memorizeItemList.Add(item.ObjectA);
                    this.memorizeItemList.Add(item.ObjectB);
                }
            }

            this.shuffleItems();
        }
Exemplo n.º 3
0
        private void prepareStages()
        {
            if (this.Entry.Stages.Count == 0 &&
                this.Entry.Items.Count >= 3)
            {
                int count = this.Entry.Items.Count;
                if (count > 20)
                {
                    count = 20;
                }
                for (int i = 3; i <= count; i++)
                {
                    if (this.exclusiveStageList.Contains(i))
                    {
                        continue;
                    }

                    this.Entry.Stages.Add(this.generateStage(i));
                }
            }
            else
            {
                List <MemorizeStage> tempList = new List <MemorizeStage>();
                foreach (var stage in this.Entry.Stages)
                {
                    if (stage is MemorizeRandomItemStage)
                    {
                        MemorizeRandomItemStage randStage = stage as MemorizeRandomItemStage;
                        if (this.exclusiveStageList.Contains(randStage.ItemCount))
                        {
                            tempList.Add(stage);
                        }
                    }
                    else if (stage is MemorizeMathStage)
                    {
                        MemorizeMathStage mathStage = stage as MemorizeMathStage;
                        if (this.exclusiveStageList.Contains(mathStage.ItemCount))
                        {
                            tempList.Add(stage);
                        }
                    }
                }

                foreach (var stage in tempList)
                {
                    this.Entry.Stages.Remove(stage);
                }
            }
        }