private string GetPosChangeMsg(int pos, int bix) { // ----------------------------------------------- //CBatter bat = g.t[(int)abMng].bat[lineupCard.CurrentLineup[this.SelectedRow].bx]; CBatter bat = g.t[(int)abMng].bat[bix]; string msg; //var alert = new CAlert(); if (gameState != EGameState.PreGame && bat.where == 10) { CAlert.ShowOkAlert("", "Can't move DH to the field", "OK", this); msg = ""; } else if (bat.where == pos) { CAlert.ShowOkAlert("", "Fielder is already at position", "OK", this); msg = ""; } else { msg = "Move " + bat.bname + " to " + CGame.PosName[pos]; } return(msg); }
public async override void Selected(UIPickerView picker, nint row, nint component) { // --------------------------------------------------------------------------- try { ctlr.StartActivity(); switch (component) { case 0: if (row == 0) { teamList.Clear(); } else { string yr = yearList[(int)row - 1]; //teamList = GFileAccess.GetTeamsInLeague(s, out usingDh); teamList = await DataAccess.GetTeamListForYearFromCache(int.Parse(yr)); } picker.Select(row: 0, component: 1, false); // Reset team to row 0 picker.ReloadComponent(1); break; case 1: if (row == 0) { PickerChanged(new CTeamRecord(), false); } else { PickerChanged(teamList[(int)row - 1], true); } break; } ctlr.StopActivity(); } catch (Exception ex) { ctlr.StopActivity(); CAlert.ShowOkAlert("Error selecting year", ex.Message, "OK", ctlr); } }
public override void ViewDidLoad() { // ---------------------------------- base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. cmdDoIt.TouchUpInside += delegate(object sender, EventArgs e) { // ------------------------------------------------- try { switch (operation.type) { case 'h': lineupCard.ReplacePlayer(operation.x, operation.y); lineupCard.SetLineupCard(); dgvLineupCard.ReloadData(); dgvLineupCard.Source = new CLineupCardSource((int)abMng, this); CAlert.ShowOkAlert("Lineup change", "Change made!", "OK", this); break; case 'r': lineupCard.ReplacePlayer(operation.x, operation.y); lineupCard.SetLineupCard(); dgvLineupCard.ReloadData(); dgvLineupCard.Source = new CLineupCardSource((int)abMng, this); CAlert.ShowOkAlert("Lineup change", "Change made!", "OK", this); break; case 's': // Some validation... CBatter bx = g.t[(int)abMng].bat[operation.x]; CBatter by = g.t[(int)abMng].bat[operation.y]; if (gameState != EGameState.PreGame && bx.where == 10) { CAlert.ShowOkAlert("Lineup change", "Replacing DH is not supported. (You can pinch hit.)", "Got it", this); } //else if (bx.where == 1 && by.px == 0) { // CAlert.ShowOkAlert("Lineup change", "Replacing pitcher with position player is not supported.", "Got it", this); //} else { lineupCard.ReplacePlayer(operation.x, operation.y); // If new player is a p-type, he goes in as p. Else as old player's pos.... [subst.1] lineupCard.AssignPos(operation.y, by.px == 1 ? 1 : operation.p); lineupCard.SetLineupCard(); dgvLineupCard.ReloadData(); dgvLineupCard.Source = new CLineupCardSource((int)abMng, this); CAlert.ShowOkAlert("Lineup change", "Change made!", "OK", this); } break; case 'p': // Some validation... if (gameState != EGameState.PreGame && g.t[(int)abMng].bat[operation.x].where == 10) { CAlert.ShowOkAlert("Lineup change", "Moving DH to the field is not supported.", "Got it", this); } else if (g.t[(int)abMng].bat[operation.x].where == 1) { CAlert.ShowOkAlert("Lineup change", "Playing a pitcher at a position is not supported.", "Got it", this); } else { lineupCard.AssignPos(operation.x, operation.p); lineupCard.SetLineupCard(); dgvLineupCard.ReloadData(); dgvLineupCard.Source = new CLineupCardSource((int)abMng, this); CAlert.ShowOkAlert("Lineup change", "Change made!", "OK", this); } break; } } catch (Exception ex) { // AssignPos will throw exception if it detects you are putting a // non-pitcher in as pitcher. (Based on his .px property being 0.) // I guess restricting the available list to pitchers would be // cleaner... future change. // So do nothing here. CAlert.ShowOkAlert("Lineup change", ex.Message, "Got it", this); } lblAction.Text = ""; EnableControl(cmdDoIt, false); }; // Read text from disk regarding instructions plus expanation // of fielding ratings. // ------------------------------------------------------------------- using (StreamReader f = GFileAccess.GetOtherFileReader("Strings/Instructions1.txt")) { lblInstructions.Text = f.ReadToEnd(); } using (StreamReader f = GFileAccess.GetOtherFileReader("Strings/Fielding1.txt")) { lblInstructions.Text += "\r\n" + f.ReadToEnd(); } SetupCard(); string msg = g.t[(int)abMng].nick; switch (gameState) { case EGameState.Offense: msg += " At Bat"; break; case EGameState.Defense: msg += " In Field"; break; case EGameState.PreGame: msg += " Pre-game"; break; } lblGameState.Text = msg; // cmdSac.Image = CSApp.Properties.Resources.GreyLight; // cmdSteal.Image = CSApp.Properties.Resources.GreyLight; // cmdIP.Image = CSApp.Properties.Resources.GreyLight; // // switch (g.specialPlay) { // case SPECIAL_PLAY.Bunt: // cmdSac.Image = CSApp.Properties.Resources.CyanLight; // break; // case SPECIAL_PLAY.Steal: // cmdSteal.Image = CSApp.Properties.Resources.CyanLight; // break; // case SPECIAL_PLAY.IP: // cmdIP.Image = CSApp.Properties.Resources.CyanLight; // break; // } }
public override void ViewDidLoad() { // ---------------------------------- base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. SetSwitches(RunMode); SetSpeech(SpeechOn); cmdClose.TouchUpInside += delegate(object sender, EventArgs e) { // ------------------------------------------------------------- }; // In the following ValueChanged handlers for the option switches, // if the switch setting is 'Off', we can assume that the othe // switches are also off, and so the resultant RunMode s/b 'Normal'... optAuto.ValueChanged += delegate(object sender, EventArgs e) { // ------------------------------------------------------------- //SetSwitches(); if (optAuto.On) { RunMode = CGame.RunMode.Auto; optFast.On = optFastEog.On = false; } else { RunMode = CGame.RunMode.Normal; } }; optFast.ValueChanged += delegate(object sender, EventArgs e) { // ------------------------------------------------------------- if (optFast.On) { RunMode = CGame.RunMode.Fast; optAuto.On = optFastEog.On = false; } else { RunMode = CGame.RunMode.Normal; } }; optFastEog.ValueChanged += delegate(object sender, EventArgs e) { // ------------------------------------------------------------- if (optFastEog.On) { RunMode = CGame.RunMode.FastEog; optAuto.On = optFast.On = false; } else { RunMode = CGame.RunMode.Normal; } }; optSpeech.ValueChanged += delegate(object sender, EventArgs e) { // ------------------------------------------------------------- SpeechOn = optSpeech.On; }; optFastEOP.ValueChanged += delegate(object sender, EventArgs e) { // ------------------------------------------------------------------ if (optFastEOP.On) { this.RunMode = CGame.RunMode.FastEOP; SpeechOn = optSpeech.On = false; } else { this.RunMode = CGame.RunMode.Normal; } }; cmdSaveBoxScore.TouchUpInside += delegate(object sender, EventArgs e) { // -------------------------------------------------- try { //var ok = new CAlert(); CAlert.ShowOkAlert("Options", "Not implimented in this version", "OK", this); // string fName = // GFileAccess.ResultsFolder + @"\" + // DateTime.Now.ToString("yyyy-MM-dd HH-mm") + " " // + mGame.city[0] + " at " + mGame.city[1] + ".txt"; // // // mGame.PrintBox(fName); // // MessageBox.Show( // "The box score was written to the following file:\r\n" + // fName + "\r\n\r\n" + // //"You can view it by opening the file in NotePad or\n\r" + // //"a word processing program such as Microsoft Word."); // "It will now be opened in Windows Notepad..."); // // // Open the box score txt file in Notepad... // this.Hide(); // System.Diagnostics.Process proc = new System.Diagnostics.Process(); // proc.EnableRaisingEvents = false; // proc.StartInfo.FileName = "Notepad.exe"; // proc.StartInfo.Arguments = fName; // proc.Start(); } catch (Exception ex) { // MessageBox.Show( // "There was an error trying to save the box score.\r\n\r\n" + // "The error was:\r\n" + // ex.Message); } }; }