Ejemplo n.º 1
0
        /// <summary>
        /// Open the form on my vertical monitor so I don't have to move it because I'm lazy
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ESform_Load(object sender, EventArgs e)
        {
            if (Screen.AllScreens.Length >= 1)
            {
                // Get the data of the second monitor
                var monitor = Screen.AllScreens[2].WorkingArea;
                // Change the wingow to the second monitor
                Location = monitor.Location;
            }

            NHLTeam nhlteam = (Methods.SelectCurrent() != null) ? JsonConvert.DeserializeObject <NHLTeam>(Methods.SelectCurrent()) : new NHLTeam();

            TeamNametb.Text = nhlteam.Name;
            string selYr = "2020-2021";

            Dictionary <string, NHLTeam> org = JsonConvert.DeserializeObject <Dictionary <string, NHLTeam> >(Methods.GiveHistory <string>());

            // Iterate over each key to populate the year listbox and team dictionary
            foreach (var item in org)
            {
                // Check if year is not already in the year listbox before adding
                if (TeamYearlb.FindString(item.Key) == ListBox.NoMatches)
                {
                    TeamYearlb.Items.Add(item.Key);
                }

                // Check if year is not already in the dictionary before adding the team
                if (!Methods.SetCurrent(item.Key))
                {
                    Methods.Add(item.Key, JsonConvert.SerializeObject(item.Value));
                }
            }

            // Load in the team for the selected year
            Methods.SetCurrent(selYr);
            nhlteam = (Methods.SelectCurrent() != null) ? JsonConvert.DeserializeObject <NHLTeam>(Methods.SelectCurrent()) : new NHLTeam();

            TeamNametb.Text = nhlteam.Name;

            NHLrb.Checked = true;
            AHLrb.Checked = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load user lines from Roster folder in root project folder
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoadLinesbtn_Click(object sender, EventArgs e)
        {
            string nhlTeamName = TeamNametb.Text;
            string filePath    = "";

            //string fileContent = File.ReadAllText(Path.Combine("..\\..\\Rosters\\", (nhlTeamName + ".txt")));               // Setup path of the file

            string fileContent = filePath == "" ? File.ReadAllText(Path.Combine("..\\..\\Rosters\\", (nhlTeamName + ".txt"))) : File.ReadAllText(filePath);

            Dictionary <string, NHLTeam> org = JsonConvert.DeserializeObject <Dictionary <string, NHLTeam> >(fileContent);      // Read the file and place data in dictionary

            // Find the team of the selected year
            string selYr = TeamYearlb.SelectedItem == null ? "2020-2021" : TeamYearlb.SelectedItem.ToString();


            // Iterate over each key to populate the year listbox and team dictionary
            foreach (var item in org)
            {
                // Check if year is not already in the year listbox before adding
                if (TeamYearlb.FindString(item.Key) == ListBox.NoMatches)
                {
                    TeamYearlb.Items.Add(item.Key);
                }

                // Check if year is not already in the dictionary before adding the team
                if (!Methods.SetCurrent(item.Key))
                {
                    Methods.Add(item.Key, JsonConvert.SerializeObject(item.Value));
                }
            }

            // Load in the team for the selected year
            Methods.SetCurrent(selYr);
            NHLTeam team = JsonConvert.DeserializeObject <NHLTeam>(Methods.SelectCurrent());

            TeamNametb.Text = team.Name;

            NHLrb.Checked = team.League ? true : false;
            AHLrb.Checked = team.League ? false : true;

            Recordtb.Text  = team.Record;
            Playofftb.Text = team.Playoff;

            // Load Goalies
            G1tb.Text    = team.goalies.Starter.Name.ToString();
            G1OVRtb.Text = team.goalies.Starter.Overall.ToString();
            G2tb.Text    = team.goalies.Backup.Name.ToString();
            G2OVRtb.Text = team.goalies.Backup.Overall.ToString();

            // Go through each line
            foreach (EvenStrengthLines line in team.ESL)
            {
                int unit = line.Line;
                switch (unit)
                {
                case 1:                                                         // First Line / First Pair
                    LW1tb.Text    = line.LeftWing.Name.ToString();
                    LW1OVRtb.Text = line.LeftWing.Overall.ToString();
                    C1tb.Text     = line.Center.Name.ToString();
                    C1OVRtb.Text  = line.Center.Overall.ToString();
                    RW1tb.Text    = line.RightWing.Name.ToString();
                    RW1OVRtb.Text = line.RightWing.Overall.ToString();
                    LD1tb.Text    = line.LeftDefence.Name.ToString();
                    LD1OVRtb.Text = line.LeftDefence.Overall.ToString();
                    RD1tb.Text    = line.RightDefence.Name.ToString();
                    RD1OVRtb.Text = line.RightDefence.Overall.ToString();
                    break;

                case 2:                                                         // Second Line / Second Pair
                    LW2tb.Text    = line.LeftWing.Name.ToString();
                    LW2OVRtb.Text = line.LeftWing.Overall.ToString();
                    C2tb.Text     = line.Center.Name.ToString();
                    C2OVRtb.Text  = line.Center.Overall.ToString();
                    RW2tb.Text    = line.RightWing.Name.ToString();
                    RW2OVRtb.Text = line.RightWing.Overall.ToString();
                    LD2tb.Text    = line.LeftDefence.Name.ToString();
                    LD2OVRtb.Text = line.LeftDefence.Overall.ToString();
                    RD2tb.Text    = line.RightDefence.Name.ToString();
                    RD2OVRtb.Text = line.RightDefence.Overall.ToString();
                    break;

                case 3:                                                         // Third Line / Third Pair
                    LW3tb.Text    = line.LeftWing.Name.ToString();
                    LW3OVRtb.Text = line.LeftWing.Overall.ToString();
                    C3tb.Text     = line.Center.Name.ToString();
                    C3OVRtb.Text  = line.Center.Overall.ToString();
                    RW3tb.Text    = line.RightWing.Name.ToString();
                    RW3OVRtb.Text = line.RightWing.Overall.ToString();
                    LD3tb.Text    = line.LeftDefence.Name.ToString();
                    LD3OVRtb.Text = line.LeftDefence.Overall.ToString();
                    RD3tb.Text    = line.RightDefence.Name.ToString();
                    RD3OVRtb.Text = line.RightDefence.Overall.ToString();
                    break;

                case 4:                                                         // Fourth Line
                    LW4tb.Text    = line.LeftWing.Name.ToString();
                    LW4OVRtb.Text = line.LeftWing.Overall.ToString();
                    C4tb.Text     = line.Center.Name.ToString();
                    C4OVRtb.Text  = line.Center.Overall.ToString();
                    RW4tb.Text    = line.RightWing.Name.ToString();
                    RW4OVRtb.Text = line.RightWing.Overall.ToString();
                    break;

                case 5:                                                         // Scratched
                    LW5tb.Text    = line.LeftWing.Name.ToString();
                    LW5OVRtb.Text = line.LeftWing.Overall.ToString();
                    C5tb.Text     = line.Center.Name.ToString();
                    C5OVRtb.Text  = line.Center.Overall.ToString();
                    RW5tb.Text    = line.RightWing.Name.ToString();
                    RW5OVRtb.Text = line.RightWing.Overall.ToString();
                    LD4tb.Text    = line.LeftDefence.Name.ToString();
                    LD4OVRtb.Text = line.LeftDefence.Overall.ToString();
                    RD4tb.Text    = line.RightDefence.Name.ToString();
                    RD4OVRtb.Text = line.RightDefence.Overall.ToString();
                    break;
                }
            }
        }