Exemple #1
0
 public ScoreCard(byte numofrds, string fighter1, string fighter2)
 {
     this.ScoreID = ScoreCard.GetNextScoreCardID(this);
     // Create array and initialize each element, since Array of Custom Classes default to "null".
     this.Rounds     = Enumerable.Range(0, numofrds).Select(i => new Round()).ToArray();
     this.Fighter1   = new Fighter(fighter1);
     this.Fighter2   = new Fighter(fighter2);
     this.Date       = DateTime.Now;
     this.ScoreTitle = $"{Fighter1.Name} vs {Fighter2.Name}";
 }
Exemple #2
0
 public void DePopulateUI()
 {
     DePopulateRDTable();
     this.main_Card = new CombatSportsScore.ScoreCard();
     this.labelScoreCardID.LabelProp = "ID: x";
     this.lblFighter1Name.LabelProp  = this.main_Card.Fighter1.Name;
     this.lblFighter2Name.LabelProp  = this.main_Card.Fighter2.Name;
     this.labelDate.LabelProp        = "MM-DD-YYYY";
     this.entryScoreCardName.Text    = this.main_Card.ScoreTitle;
     this.GtkScrolledWindow.Hide();
     this.frameTotalScore.Hide();
     this.textviewFightComment.Buffer.Clear();
     this.textviewFightComment.Hide();
     this.statusbarFooter.Hide();
     this.SaveScoreCardAction.Sensitive = false;
 }
Exemple #3
0
    private void LoadCard(string savepath)
    {
        string dataobj;

        // Read in saved ScoreCard dataobj
        using (StreamReader inputFile = new StreamReader(savepath))
        {
            dataobj = inputFile.ReadToEnd();
            /**** TODO Test for magic header or raise Exception and exit out      ******/
        }

        // Check if the a main ScoreCard has been created for the program, if not, make one.
        if (this.main_Card == null)
        {
            this.main_Card = new CombatSportsScore.ScoreCard();
        }

        this.main_Card = JsonConvert.DeserializeObject <CombatSportsScore.ScoreCard>(dataobj);
        PopulateRDTable((byte)this.main_Card.Rounds.Length, true);
        PopulateUI();
    }
Exemple #4
0
 protected static int GetNextScoreCardID(ScoreCard instance) => ++ ScoreCard.currentScoreID;
Exemple #5
0
    protected void OnNewScoreCardActionActivated(object sender, EventArgs e)
    {
        Dialog popupNumRounds = new Gtk.Dialog("New ScoreCard", this, DialogFlags.Modal, Stock.Ok, 200, Stock.Cancel, 400);

        Label enterRounds = new Label("Number of Rounds");

        popupNumRounds.VBox.Add(enterRounds);

        int[] list = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
        #pragma warning disable CS0612 // Type or member is obsolete
        Combo comboNumRounds = new Combo();
        #pragma warning restore CS0612 // Type or member is obsolete
        comboNumRounds.PopdownStrings = Array.ConvertAll(list, ele => ele.ToString());
        comboNumRounds.DisableActivate();
        comboNumRounds.SetValueInList(true, false);

        popupNumRounds.VBox.Add(comboNumRounds);
        popupNumRounds.ShowAll();

        int response_value = popupNumRounds.Run();

        if (response_value == 200)
        {
            {
                Dialog popupFighters = new Gtk.Dialog("Enter Fighters", this, DialogFlags.Modal, Stock.Ok, 200, Stock.Cancel, 400);
                popupFighters.BorderWidth     = 4;
                popupFighters.DefaultResponse = (Gtk.ResponseType) 200;


                HBox hbox = new HBox(false, 8);
                hbox.BorderWidth = 8;
                popupFighters.VBox.PackStart(hbox, false, false, 0);

                Image stock = new Image(Stock.DialogQuestion, IconSize.Dialog);
                hbox.PackStart(stock, false, false, 0);

                Table table = new Table(2, 2, false);
                table.RowSpacing    = 4;
                table.ColumnSpacing = 4;
                hbox.PackStart(table, true, true, 0);

                Label label = new Label("Fighter 1");
                table.Attach(label, 0, 1, 0, 1);
                Entry entryFighter1 = new Entry();
                table.Attach(entryFighter1, 1, 2, 0, 1);

                label = new Label("Fighter 2");
                table.Attach(label, 0, 1, 1, 2);
                Entry entryFighter2 = new Entry();
                table.Attach(entryFighter2, 1, 2, 1, 2);
                entryFighter2.ActivatesDefault = true;

                entryFighter1.MaxLength = 40;
                entryFighter2.MaxLength = 40;

                hbox.ShowAll();

                int response_value2 = popupFighters.Run();
                if (response_value2 == 200)
                {
                    DePopulateUI();
                    DePopulateRDTable();

                    this.main_Card = new CombatSportsScore.ScoreCard(Convert.ToByte(comboNumRounds.Entry.Text), entryFighter1.Text.Trim(), entryFighter2.Text.Trim());
                    PopulateRDTable(Convert.ToByte(comboNumRounds.Entry.Text));
                    PopulateUI();
                    PopulateTotals();
                }

                popupFighters.Destroy();
            }
        }

        popupNumRounds.Destroy();
    }