コード例 #1
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            if (AddToMainForm != null)
            {
                // Create a TeamEventArgs to hold the information to pass to the main form
                TeamEventArgs newTeam = new TeamEventArgs();

                // fill in the newteam object with the user inputed information
                newTeam.TeamName = txt_TeamName.Text;
                newTeam.City     = txt_City.Text;
                if (rad_AFC.Checked == true)
                {
                    newTeam.Division = rad_AFC.Text;
                }
                else
                {
                    newTeam.Division = rad_NFC.Text;
                }

                // invoke the custom EventHandler and close form
                AddToMainForm(this, newTeam);
                this.Close();
            }

            // invoke the custom event handler
            AddButtonChecker?.Invoke(this, new EventArgs());
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: jwclary/Project-Portfolio3
        private void lst_NFC_DoubleClick(object sender, EventArgs e)
        {
            //Instantiated new form
            AddTeamForm newTeam = new AddTeamForm();

            // subscribe to the event handler method
            PopulateAddTeamForm      += newTeam.MainForm_PopulateAddTeamForm;
            newTeam.AddToMainForm    += AddToDivisionsLists;
            newTeam.AddButtonChecker += AddTeamForm_AddButtonChecker;

            // cast the object as a Character
            FootballTeam team = (FootballTeam)lst_NFC.SelectedItem;

            // create the CharEventArgs to be sent
            TeamEventArgs args = new TeamEventArgs();

            args.TeamName = team.TeamName;
            args.City     = team.City;
            args.Division = team.Division;

            // invoke the custom EventHandler
            PopulateAddTeamForm(this, args);

            // present the AddTeamForm
            newTeam.ShowDialog();

            lst_NFC.SelectedIndex = -1;
        }
コード例 #3
0
 //--------------------------EVENT HANDLER METHODS--------------------------
 public void MainForm_PopulateAddTeamForm(object sender, TeamEventArgs e)
 {
     // populate the user input controls from the selected ListBox object
     txt_TeamName.Text = e.TeamName;
     txt_City.Text     = e.City;
     if (e.Division == "AFC")
     {
         rad_AFC.Checked = true;
     }
     else
     {
         rad_NFC.Checked = true;
     }
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: jwclary/Project-Portfolio3
        //-------------------------EVENT HANDLER METHODS-------------------------
        // event handler method to add the object to the ListBox
        public void AddToDivisionsLists(object sender, TeamEventArgs e)
        {
            // create the Character object
            FootballTeam team = new FootballTeam();

            team.TeamName = e.TeamName;
            team.City     = e.City;
            team.Division = e.Division;

            // add that object to either ListBox
            if (team.Division == "AFC")
            {
                lst_AFC.Items.Add(team);
            }
            else
            {
                lst_NFC.Items.Add(team);
            }
        }