private void init() { Dictionary <string, string> months = new Dictionary <string, string>(); months.Add("January", "01"); months.Add("February", "02"); months.Add("March", "03"); months.Add("April", "04"); months.Add("May", "05"); months.Add("June", "06"); months.Add("July", "07"); months.Add("August", "08"); months.Add("September", "09"); months.Add("October", "10"); months.Add("November", "11"); months.Add("December", "12"); OppNameTB.Text = myGame.GetName(); // reformat date string date = myGame.GetDate(); //parse year string year = date.Substring(date.IndexOf("-") + 5, 4); YearTB.Text = year; // parse day string day = string.Empty; foreach (char c in date.Substring(date.IndexOf("-") + 1, 3)) { if (char.IsDigit(c)) { day += c; } } if (day.Length < 2) { day = "0" + day; } DayCB.Text = day; // parse month string month = months[date.Substring(0, date.IndexOf("-"))]; MonthCB.Text = month; // set game type GameTypeCB.Text = myGame.GetGameType().ToString(); // reformat and set game location string loc = myGame.GetLoc().Substring(1, 1); MessageBox.Show(loc); GameLocCB.Text = loc; }
/// <summary> /// set all label data context /// </summary> private void Set_Labels() { // give value to all properties in model object MyModelObject ControlDC = new MyModelObject() { GameName = myGame.GetName(), GameType = myGame.GetGameType(), GameLoc = myGame.GetLoc(), GameDate = myGame.GetDate(), HomeGoals = myGame.GetHomeGoals().ToString(), OppGoals = myGame.GetOppGoals().ToString() }; // set all data context bindings for labels in team main window NameLBL.DataContext = ControlDC; TypeLBL.DataContext = ControlDC; LocLBL.DataContext = ControlDC; DateLBL.DataContext = ControlDC; HomeGoalsLBL.DataContext = ControlDC; OppGoalsLBL.DataContext = ControlDC; }