コード例 #1
0
        /// <summary>
        /// Submits the button.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void SubmitButton(NSObject sender)
        {
            try
            {
                // Get and set variables from form
                var busDirectionValue = BusDirectionComboBox.StringValue;
                var busStopValue      = BusStopNameTextBox.StringValue;
                var busRouteValue     = BusRouteTextBox.StringValue;

                // Run business logic
                var nextBus         = new NextBusOperation();
                var timeInMinutes   = nextBus.GetTimeInMinutesForNextBus(busRouteValue, busStopValue, busDirectionValue);
                var stringToDisplay = timeInMinutes.ToString() + " minutes";

                // Output
                Console.WriteLine(stringToDisplay);
                OutputTimeLabel.StringValue = stringToDisplay;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                OutputTimeLabel.StringValue = "Error";

                var alert = new NSAlert
                {
                    MessageText     = "Error",
                    InformativeText = ex.Message
                };

                alert.RunModal();
            }
        }
コード例 #2
0
        partial void RunTestButton(NSObject sender)
        {
            try
            {
                var nextBus       = new NextBusOperation();
                var timeInMinutes = nextBus.GetTimeInMinutesForNextBus("METRO Blue Line", "Target Field Station Platform 1", "south");

                // Output
                var stringToDisplay = "Test succeeds with output: " + timeInMinutes;

                Console.WriteLine(stringToDisplay);
                OutputText.StringValue = stringToDisplay;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                OutputText.StringValue = "Error";

                var alert = new NSAlert
                {
                    MessageText     = "Error",
                    InformativeText = "Test failed. " + ex.Message
                };

                alert.RunModal();
            }
        }
コード例 #3
0
        partial void RunTest2Button(NSObject sender)
        {
            try
            {
                var nextBus       = new NextBusOperation();
                var timeInMinutes = nextBus.GetTimeInMinutesForNextBus("Express - Target - Hwy 252 and 73rd Av P&R - Mpls", "Target North Campus Building F", "south");

                // Output
                var stringToDisplay = "Test succeeds with output: " + timeInMinutes;

                Console.WriteLine(stringToDisplay);
                Output2Text.StringValue = stringToDisplay;
            }
            catch (ApplicationException ex)
            {
                if (ex.Message.Contains("There are no scheduled stops here"))
                {
                    var stringToDisplay = "Test succeeds: no scheduled stops";

                    Console.WriteLine(stringToDisplay);
                    Output2Text.StringValue = stringToDisplay;
                }
                else
                {
                    Console.WriteLine(ex.Message);
                    Output2Text.StringValue = "Error";

                    var alert = new NSAlert
                    {
                        MessageText     = "Error",
                        InformativeText = "Test failed. " + ex.Message
                    };

                    alert.RunModal();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Output2Text.StringValue = "Error";

                var alert = new NSAlert
                {
                    MessageText     = "Error",
                    InformativeText = "Test failed. " + ex.Message
                };

                alert.RunModal();
            }
        }