Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        chordDict = new ChordSpeller();
        //chordDict.AddMajorChords();
        // Need to implement GetEnumerator to use foreach loop
        // Didn't get this error when chordDict.AddMajorChords() called within foreach loop header
        foreach (KeyValuePair <string, string> kv in chordDict.AddMajorChords())
        {
            // set TextMode proprety of TextBox to "MultiLine" to get scroll bar
            txtMajor.Text += kv.Key + " is spelled " + kv.Value + "\n";
        }

        foreach (KeyValuePair <string, string> kv in chordDict.AddMinorChords())
        {
            // TODO: this adds the minor chords to the major chords
            txtMinor.Text += kv.Key + " is spelled " + kv.Value + "\n";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // This version stores the entire ChordSpeller object in Session
        if (Session[SPELLER] == null)
        {
            // The first time the page loads, instantiate a new speller
            speller = new ChordSpeller();
            ApplySettings();            // load all chord types by default
            Session[SPELLER] = speller; // store the speller in Session
            Session[CLICKS]  = 0;
        }
        else
        {
            // Otherwise, get the current speller out of Session
            speller = (ChordSpeller)Session[SPELLER];
            lblChordToSpell.Text = speller.ChordName;    // this label must persist through each postback
            lblUserSpelling.Text = speller.UserSpelling; // persisting here so that when you click Check Answer it still displays
            lblUser.Text         = speller.UserName;
        }

        DisplayStats();
    }