Exemplo n.º 1
0
        //public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        //{
        //	base.PrepareForSegue(segue, sender);

        //	// set the View Controller that’s powering the screen we’re
        //	// transitioning to

        //	var callHistoryContoller = segue.DestinationViewController as CallHistoryController;

        //	//set the Table View Controller’s list of phone numbers to the
        //	// list of dialed phone numbers

        //	if (callHistoryContoller != null)
        //	{
        //		callHistoryContoller.PhoneNumbers = PhoneNumbers;
        //	}
        //}



        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            TranslateButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // Convert the phone number with text to a number
                // using PhoneTranslator.cs
                translatedNumber = PhoneTranslator.ToNumber(
                    PhoneNumberText.Text);

                // Dismiss the keyboard if text field was tapped
                PhoneNumberText.ResignFirstResponder();

                if (translatedNumber == "")
                {
                    CallButton.SetTitle("Call ", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.SetTitle("Call " + translatedNumber,
                                        UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };


            CallButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                //Store the phone number that we're dialing in PhoneNumbers
                PhoneNumbers.Add(translatedNumber);



                // Use URL handler with tel: prefix to invoke Apple's Phone app...
                var url = new NSUrl("tel:" + translatedNumber);

                // ...otherwise show an alert dialog
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                    var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
            };

            CallHistoryButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // Launches a new instance of CallHistoryController
                CallHistoryController callHistory = this.Storyboard.InstantiateViewController("CallHistoryController") as CallHistoryController;
                if (callHistory != null)
                {
                    callHistory.PhoneNumbers = PhoneNumbers;
                    this.NavigationController.PushViewController(callHistory, true);
                }
            };
        }
Exemplo n.º 2
0
        public void ShowCallHistory(IMainView view)
        {
            CallHistoryController callHistoryView = UIViewControllerHelper.StoryboardInstance <CallHistoryController>();

            if (callHistoryView != null)
            {
                callHistoryView.PhoneNumbers = phoneNumber;
                view.PushViewController(callHistoryView);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.

            // On "Translate" button-up, convert the phone number with text to a number
            TranslateButton.TouchUpInside += (object sender, EventArgs e) => {
                // *** SHARED CODE from PhoneTranslator.cs ***
                translatedNumber = Core.PhonewordTranslator.ToNumber(PhoneNumberText.Text);

                PhoneNumberText.ResignFirstResponder();

                if (translatedNumber == "")
                {
                    CallButton.SetTitle("Call ", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.SetTitle("Call " + translatedNumber, UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };

            // On "Call" button-up, try to dial a phone number
            CallButton.TouchUpInside += (object sender, EventArgs e) => {
                //TODO: Step 2b: uncomment to store the phone number that we're dialing in PhoneNumbers
                PhoneNumbers.Add(translatedNumber);

                var url = new NSUrl("tel:" + translatedNumber);

                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                    var av = new UIAlertView("Not supported",
                                             "Scheme 'tel:' is not supported on this device",
                                             null,
                                             "OK",
                                             null);
                    av.Show();
                }
            };

            //TODO: Step 2d: uncomment to wire up the CallHistoryButton

            // Launches a new instance of CallHistoryController
            CallHistoryButton.TouchUpInside += (object sender, EventArgs e) => {
                CallHistoryController callHistory = this.Storyboard.InstantiateViewController("CallHistoryController") as CallHistoryController;
                if (callHistory != null)
                {
                    callHistory.PhoneNumbers = PhoneNumbers;
                }
                this.NavigationController.PushViewController(callHistory, true);
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.


            TranslateButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                translatedNumber = PhoneTranslator.ToNumber(PhoneNumberText.Text);
                PhoneNumberText.ResignFirstResponder();

                if (translatedNumber == "")
                {
                    CallButton.SetTitle("Call ", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.SetTitle("Call " + translatedNumber, UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };

            CallButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                if (translatedNumber.Length > 0)
                {
                    PhoneNumbers.Add(translatedNumber);
                }

                var url = new NSUrl("tel:" + translatedNumber);
                //...otherwise show an alert dialog.
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                    var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
            };

            CallHistoryButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                CallHistoryController callHistoryCtrl = this.Storyboard.InstantiateViewController("CallHistoryController") as CallHistoryController;
                if (callHistoryCtrl != null)
                {
                    callHistoryCtrl.PhoneNumbers = PhoneNumbers;
                    this.NavigationController.PushViewController(callHistoryCtrl, true);
                }
            };
        }
Exemplo n.º 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            View.BackgroundColor = UIColor.White;

            // Create the UI to display.
            var enterPasswordLabel = new UILabel(new RectangleF(20, 80, 280, 21));

            enterPasswordLabel.Text = "Enter a Phoneword:";
            View.Add(enterPasswordLabel);

            var phoneNumberText = new UITextField(new RectangleF(20, 119, 280, 30));

            phoneNumberText.BorderStyle = UITextBorderStyle.RoundedRect;
            phoneNumberText.Text        = "1-855-XAMARIN";
            View.Add(phoneNumberText);

            var translateButton = UIButton.FromType(UIButtonType.RoundedRect);

            translateButton.Frame = new RectangleF(20, 192, 280, 30);
            translateButton.SetTitle("Translate", UIControlState.Normal);
            View.Add(translateButton);

            var callButton = UIButton.FromType(UIButtonType.RoundedRect);

            callButton.Frame = new RectangleF(20, 269, 280, 30);
            callButton.SetTitle("Call", UIControlState.Normal);
            callButton.Enabled = false;
            View.Add(callButton);

            //TODO: Step 1: uncomment to add new Call History button to the UI.

            var callHistoryButton = UIButton.FromType(UIButtonType.RoundedRect);

            callHistoryButton.Frame = new RectangleF(20, 346, 280, 30);
            callHistoryButton.SetTitle("Call History", UIControlState.Normal);
            View.Add(callHistoryButton);

            // On "Translate" button-up, convert the phone number with text to a number
            translateButton.TouchUpInside += (object sender, EventArgs e) => {
                // *** SHARED CODE from PhoneTranslator.cs ***
                translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);

                phoneNumberText.ResignFirstResponder();

                if (translatedNumber == "")
                {
                    callButton.SetTitle("Call ", UIControlState.Normal);
                    callButton.Enabled = false;
                }
                else
                {
                    callButton.SetTitle("Call " + translatedNumber, UIControlState.Normal);
                    callButton.Enabled = true;
                }
            };

            // On "Call" button-up, try to dial a phone number
            callButton.TouchUpInside += (object sender, EventArgs e) => {
                //TODO: Step 2b: uncomment to store the phone number that we're dialing in PhoneNumbers
                PhoneNumbers.Add(translatedNumber);

                var url = new NSUrl("tel:" + translatedNumber);

                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                    var av = new UIAlertView("Not supported",
                                             "Scheme 'tel:' is not supported on this device",
                                             null,
                                             "OK",
                                             null);
                    av.Show();
                }
            };

            //TODO: Step 2d: uncomment to wire up the CallHistoryButton

            // Launches a new instance of CallHistoryController
            callHistoryButton.TouchUpInside += (object sender, EventArgs e) => {
                CallHistoryController callHistory = new CallHistoryController();
                callHistory.PhoneNumbers = PhoneNumbers;

                this.NavigationController.PushViewController(callHistory, true);
            };
        }
 public CallHistoryDataSource(CallHistoryController controller)
 {
     this.controller = controller;
 }
			public CallHistoryDataSource (CallHistoryController controller)
			{
				this.controller = controller;
			}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// Perform any additional setup after loading the view, typically from a nib.
			View.BackgroundColor = UIColor.White;

			// Create the UI to display.
			var enterPasswordLabel = new UILabel(new RectangleF(20, 80, 280, 21));
			enterPasswordLabel.Text = "Enter a Phoneword:";
			View.Add (enterPasswordLabel);

			var phoneNumberText = new UITextField(new RectangleF(20, 119, 280, 30));
			phoneNumberText.BorderStyle = UITextBorderStyle.RoundedRect;
			phoneNumberText.Text = "1-855-XAMARIN";
			View.Add (phoneNumberText);

			var translateButton = UIButton.FromType (UIButtonType.RoundedRect);
			translateButton.Frame = new RectangleF(20, 192, 280, 30);
			translateButton.SetTitle ("Translate", UIControlState.Normal);
			View.Add (translateButton);

			var callButton = UIButton.FromType (UIButtonType.RoundedRect);
			callButton.Frame = new RectangleF(20, 269, 280, 30);
			callButton.SetTitle ("Call", UIControlState.Normal);
			callButton.Enabled = false;
			View.Add (callButton);

			//TODO: Step 1: uncomment to add new Call History button to the UI.

			var callHistoryButton = UIButton.FromType (UIButtonType.RoundedRect);
			callHistoryButton.Frame = new RectangleF(20, 346, 280, 30);
			callHistoryButton.SetTitle ("Call History", UIControlState.Normal);
			View.Add (callHistoryButton);

			// On "Translate" button-up, convert the phone number with text to a number
			translateButton.TouchUpInside += (object sender, EventArgs e) => {

				// *** SHARED CODE from PhoneTranslator.cs ***
				translatedNumber = Core.PhonewordTranslator.ToNumber (phoneNumberText.Text);

				phoneNumberText.ResignFirstResponder ();

				if (translatedNumber == "") {
					callButton.SetTitle ("Call ", UIControlState.Normal);
					callButton.Enabled = false;
				} else {
					callButton.SetTitle ("Call " + translatedNumber, UIControlState.Normal);
					callButton.Enabled = true;
				}
			};

			// On "Call" button-up, try to dial a phone number
			callButton.TouchUpInside += (object sender, EventArgs e) => {

				//TODO: Step 2b: uncomment to store the phone number that we're dialing in PhoneNumbers
				PhoneNumbers.Add (translatedNumber);

				var url = new NSUrl ("tel:" + translatedNumber);

				if (!UIApplication.SharedApplication.OpenUrl (url)) {
					var av = new UIAlertView ("Not supported",
						         "Scheme 'tel:' is not supported on this device",
						         null,
						         "OK",
						         null);
					av.Show ();
				}
			};	
					
			//TODO: Step 2d: uncomment to wire up the CallHistoryButton

			// Launches a new instance of CallHistoryController
			callHistoryButton.TouchUpInside += (object sender, EventArgs e) => {
				CallHistoryController callHistory = new CallHistoryController();
				callHistory.PhoneNumbers = PhoneNumbers;

				this.NavigationController.PushViewController (callHistory, true);
			};
		}
Exemplo n.º 9
0
        // PrepareForSegue is only used when a Segue is created in the storyboard
        // our final implementation handles this transition in code when
        // CallHistoryButton is pressed

//		public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender)
//		{
//			base.PrepareForSegue (segue, sender);
//
//			// set the View Controller that’s powering the screen we’re
//			// transitioning to
//
//			var callHistoryContoller = segue.DestinationViewController as CallHistoryController;
//
//			//set the Table View Controller’s list of phone numbers to the
//			// list of dialed phone numbers
//
//			if (callHistoryContoller != null) {
//				callHistoryContoller.PhoneNumbers = PhoneNumbers;
//			}
//		}

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.

            // Start with the CallButton Disabled
            CallButton.Enabled = false;

            // Code for when TranslateButton is pressed
            TranslateButton.TouchUpInside += (object sender, EventArgs e) => {
                // Convert the phone number with text to a number
                // using PhoneTranslator.cs
                translatedNumber = Core.PhonewordTranslator.ToNumber(
                    PhoneNumberText.Text);

                // Dismiss the keyboard if text field was tapped
                PhoneNumberText.ResignFirstResponder();


                if (translatedNumber == "")
                {
                    // If the Translate Button was pressed with no input entered, set the Call Button
                    // to its original state
                    CallButton.SetTitle("Call", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    // If the Translate Button was pressed with an input, add the translated number
                    // to the Call Button title and enable the Button to be pressed.
                    CallButton.SetTitle("Call " + translatedNumber, UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };

            // Code for when CallHistoryButton is pressed
            CallHistoryButton.TouchUpInside += (object sender, EventArgs e) => {
                // Launches a new instance of CallHistoryController
                CallHistoryController callHistory = this.Storyboard.InstantiateViewController("CallHistoryController") as CallHistoryController;
                if (callHistory != null)
                {
                    // Set the PhoneNumbers List in the CallHistoryController to the PhoneNumbersList in this View Controller
                    callHistory.PhoneNumbers = PhoneNumbers;
                    // Push the callHistoryController onto the NavigationController's stack
                    this.NavigationController.PushViewController(callHistory, true);
                }
            };

            // Code for when CallButton is pressed
            CallButton.TouchUpInside += (object sender, EventArgs e) => {
                //store the phone number that we're dialing in PhoneNumbers
                // only if a number has been entered
                if (translatedNumber != "")
                {
                    PhoneNumbers.Add(translatedNumber);
                }

                //build the new url
                var url = new NSUrl("tel:" + translatedNumber);

                // Use URL handler with tel: prefix to invoke Apple's Phone app,
                // otherwise show an alert dialog

                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                    var av = new UIAlertView("Not supported",
                                             "Scheme 'tel:' is not supported on this device",
                                             null,
                                             "OK",
                                             null);
                    av.Show();
                }
            };
        }