private void OnCreateNewLeague(object sender, EventArgs e)
 {
     using (SaveFileDialog dlg = new SaveFileDialog())
     {
         dlg.AddExtension    = true;
         dlg.CheckFileExists = false;
         dlg.CheckPathExists = true;
         dlg.CreatePrompt    = false;
         dlg.DefaultExt      = "json";
         dlg.OverwritePrompt = true;
         dlg.Title           = "Select New League Filename";
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             PromptFromList prompt = new PromptFromList("Select Fantasy League", Enum.GetNames(typeof(Leagues)));
             if (prompt.ShowDialog() == DialogResult.OK)
             {
                 Leagues fantasyLeague;
                 if (Enum.TryParse(prompt.SelectedItem, out fantasyLeague))
                 {
                     League league = League.Create(fantasyLeague);
                     league.Save(dlg.FileName);
                     this.LoadPlayers(dlg.FileName);
                 }
             }
         }
     }
 }
        private void OnLaunchSnakeCenter(object sender, EventArgs e)
        {
            PromptFromList prompt = new PromptFromList("Select Your Team", this.league.Teams.Select(t => t.Name));

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                new SnakeCenter(this.league, this.fileName, prompt.SelectedItem).Show();
            }
        }
        private void OnLaunchAnalysisCenter(object sender, EventArgs e)
        {
            PromptFromList prompt = new PromptFromList("Select Team", this.league.Teams.Select(t => t.Name));

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                new AnalysisCenter(this.league.Clone(), this.league.Teams.First(t => t.Name == prompt.SelectedItem)).Show();
            }
        }
        private void OnGetTopFreeAgentSwaps(object sender, EventArgs e)
        {
            PromptFromList prompt = new PromptFromList("Select Team", this.league.Teams.Select(t => t.Name));

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                string html = FantasyAlgorithms.RosterAnalysis.GetTopNFreeAgentPickups(this.league.Clone(), LeagueConstants.For(this.league.FantasyLeague).ScoringStatExtractors, prompt.SelectedItem);
                this.wbOut.DocumentText = html;
            }
        }
Example #5
0
        private void OnPlayerSelected(object sender, System.EventArgs e)
        {
            PromptFromList prompt = new PromptFromList(string.Format("Which team drafted {0}?", this.lvTarget.SelectedItems[0].Text), this.teamsForAssignment);

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                IPlayer clonedPlayer = this.lvTarget.SelectedItems[0].Tag as IPlayer;
                if (clonedPlayer != null)
                {
                    IPlayer player = this.league.AllPlayers.FirstOrDefault(p => p.ESPNId == clonedPlayer.ESPNId);
                    if (player != null)
                    {
                        player.FantasyTeam = prompt.SelectedItem;
                        this.league.Save(this.fileName);
                        this.UpdatePlayerList();
                    }
                }
            }
        }