static void RunLab1()
        {
            int rangeFrom = 0, rangeTo = 0;

            while (rangeFrom >= rangeTo)
            {
                rangeFrom = CPrompt.GetInt(Task1Name, "Введите начало диапазона:");
                rangeTo   = CPrompt.GetInt(Task1Name, "Введите конец диапазона:");

                if (rangeFrom >= rangeTo)
                {
                    CAlert.Show($"Неверный диапазон. Начальное значение { rangeFrom } больше или равно конечному { rangeTo }");
                }
            }

            var randomGen = new RandomGenerator(rangeFrom, rangeTo);

            CPrinter.PrintHeader(Task1Name);
            CPrinter.PrintEmptyLine();

            ConsoleKeyInfo keyInfo;

            do
            {
                CPrinter.PrintText($"Случайное значение: { randomGen.GetNext() }");
                CPrinter.PrintEmptyLine();
                CPrinter.PrintFooter("Для выхода нажмите X или Escape. Для генерации следующего значения - любую другую клавишу.");
                keyInfo            = Console.ReadKey(true);
                Console.CursorTop -= 4;
            }while (keyInfo.Key != ConsoleKey.Escape && keyInfo.Key != ConsoleKey.X);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public Boolean IsDefaultAlert(CAlert alert)
 {
     foreach (CAlert c in _defaultAlerts)
     {
         if (c.Type == alert.Type && c.Info.ToLower() == alert.Info.ToLower())
             return true;
     }
     return false;
 }
Пример #4
0
        partial void CmdChangePos_TouchUpInside(UIButton sender)
        {
            // ---------------------------------------------------------

            if (g.UsingDh && gameState == EGameState.PreGame)
            {
                // Allow to choose dh...
                CAlert.ShowActionSheet(
                    "Change Position",
                    "Choose a new position for the selected player:",
                    new string[] { "c", "1b", "2b", "3b", "ss", "lf", "cf", "rf", "dh", "Cancel" },
                    new Action <UIAlertAction>[] {
                    //alert => PostPosChangeMsg(1),
                    alert => PostPosChangeMsg(2),
                    alert => PostPosChangeMsg(3),
                    alert => PostPosChangeMsg(4),
                    alert => PostPosChangeMsg(5),
                    alert => PostPosChangeMsg(6),
                    alert => PostPosChangeMsg(7),
                    alert => PostPosChangeMsg(8),
                    alert => PostPosChangeMsg(9),
                    alert => PostPosChangeMsg(10),
                    alert => PostPosChangeMsg(-1)
                },
                    this
                    );
            }
            else
            {
                // Cannot choose dh...
                CAlert.ShowActionSheet(
                    "Change Position",
                    "Choose a new position for the selected player:",
                    new string[] { "c", "1b", "2b", "3b", "ss", "lf", "cf", "rf", "Cancel" },
                    new Action <UIAlertAction>[] {
                    //alert => PostPosChangeMsg(1),
                    alert => PostPosChangeMsg(2),
                    alert => PostPosChangeMsg(3),
                    alert => PostPosChangeMsg(4),
                    alert => PostPosChangeMsg(5),
                    alert => PostPosChangeMsg(6),
                    alert => PostPosChangeMsg(7),
                    alert => PostPosChangeMsg(8),
                    alert => PostPosChangeMsg(9),
                    alert => PostPosChangeMsg(-1)
                },
                    this
                    );
            }
        }
Пример #5
0
        partial void CmdTestIt_TouchUpInside(UIButton sender)
        {
            // --------------------------------------------------------
            cmdDoIt.Hidden = false;

            //ShowYesNoAlert(
            //   "OK / Cancel Alert",
            //   "This is a sample alert with an OK / Cancel Button",
            //   "Okay", "Cancel",
            //   alert => cmdDoIt.SetTitle ("Okay", UIControlState.Normal),
            //   alert => cmdDoIt.SetTitle ("Cancel", UIControlState.Normal),
            //   this
            //);


            //// This demonstrates that even though the lambdas are sent & executed in a foriegn class,
            //// they see the local environment, namely the local vars sOkay and sCanc.
            //   string sOkay = "Okay!";
            //   string sCanc = "Cancel!";
            //   CAlert.ShowYesNoAlert (
            //      "OK / Cancel Alert",
            //      "This is a sample alert with an OK / Cancel Button",
            //      "Okay", "Cancel",
            //      alert => cmdDoIt.SetTitle (sOkay, UIControlState.Normal),
            //      alert => cmdDoIt.SetTitle (sCanc, UIControlState.Normal),
            //      this
            //   );


            CAlert.ShowActionSheet(
                "Action Sheet sample",
                "This is a sample action sheet with 3 actions",
                new string [] { "Yes", "No", "Maybe" },
                new Action <UIAlertAction> [] {
                alert => cmdDoIt.SetTitle("Yes", UIControlState.Normal),
                alert => cmdDoIt.SetTitle("No", UIControlState.Normal),
                alert => cmdDoIt.SetTitle("Maybe", UIControlState.Normal)
            },
                this
                );
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
        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;
//         }
        }
Пример #8
0
        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);
                }
            };
        }