Пример #1
0
        public Spellbook(string directory, int firstLevel, int lastLevel, string spellcaster)
        {
            this.spellcaster = spellcaster;

            InitializeComponent();
            lvlLabels = new TextBlock[10];
            lvlLabels[0] = textBlock1;
            lvlLabels[1] = textBlock2;
            lvlLabels[2] = textBlock3;
            lvlLabels[3] = textBlock4;
            lvlLabels[4] = textBlock5;
            lvlLabels[5] = textBlock6;
            lvlLabels[6] = textBlock7;
            lvlLabels[7] = textBlock8;
            lvlLabels[8] = textBlock9;
            lvlLabels[9] = textBlock10;

            spellbookLevels = new SpellbookLevel[10];
            for (int i = firstLevel; i <= lastLevel; i++)
            {
                System.IO.StreamReader SR;
                try
                {
                    SR = System.IO.File.OpenText(directory + "\\spells\\" + spellcaster + "\\" + i.ToString() + ".txt");
                    spellbookLevels[i] = new SpellbookLevel(SR.ReadToEnd());
                }
                catch
                {
                    spellbookLevels[i] = new SpellbookLevel("");
                }

                    lvlLabels[i].DataContext = spellbookLevels[i];

            }
            spellbookLevels[firstLevel].Selected = true;
            selectedLevel = spellbookLevels[firstLevel];
            allSpells.DataContext = selectedLevel;
            preparedSpells.DataContext = selectedLevel;
        }
Пример #2
0
        private void textBlock10_GotFocus(object sender, MouseButtonEventArgs e)
        {
            TextBlock senderBlock = (TextBlock)sender;
            if (selectedLevel != null)
                selectedLevel.Selected = false;

            selectedLevel = spellbookLevels[(int)App.getFloatFromString(senderBlock.Text)];
            selectedLevel.Selected = true;
            allSpells.DataContext = selectedLevel;
            preparedSpells.DataContext = selectedLevel;
        }