Example #1
0
		private void DoAction(Action action, MonoTouch.Foundation.NSUrlRequest request){
			switch (action) {
				case Action.Tel:
					var phoneCaller = new PhoneCaller ();
					phoneCaller.Call (request.Url.ResourceSpecifier);
					break ;
				case Action.Email:
					if (MFMailComposeViewController.CanSendMail) {
						var mail = new MFMailComposeViewController ();
						mail.SetToRecipients (new string[] { request.Url.ResourceSpecifier});
						mail.SetSubject ("");
						mail.SetMessageBody ("", false);
						mail.Finished += HandleMailFinished;
						this.PresentViewController (mail, true, null);
					} 
					break;
				case Action.Http:
					if (UIApplication.SharedApplication.CanOpenUrl(request.Url)) {
						UIApplication.SharedApplication.OpenUrl (request.Url);
					}
					break;
			}
		}
Example #2
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			
			UIButton btnIpConnect = UIButton.FromType (UIButtonType.InfoLight);
			btnIpConnect.Title (UIControlState.Normal);
			btnIpConnect.TouchDown += OnIpConnect;
			this.NavigationItem.RightBarButtonItem = new UIBarButtonItem (btnIpConnect);
			
			
			//this.View.BringSubviewToFront (this.scrollContainer);
			
			scrollContainer.ContentSize = new SizeF (this.View.Bounds.Size.Width, this.View.Bounds.Size.Height - 44);
			
			_locationManager = new CLLocationManager ();
			_locationManager.DesiredAccuracy = CLLocation.AccuracyBest;


			// deprecated in ios 6.0
			_locationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
				_userCoords = e.NewLocation.Coordinate;
				// get the distance from here to Löwenbräukeller
				var distance = e.NewLocation.DistanceFrom (new CLLocation (LATITUDE_LBK, LONGITUDE_LBK));
				string distanceText = Locale.Format("Bis zum Ziel ca: {0}", Util.DistanceToString (distance));
				txtDistance.Text = distanceText;
				if (CLLocationManager.LocationServicesEnabled) {
					_locationManager.StopUpdatingLocation ();
				}
			};

			// for ios 6.0
			_locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {

				CLLocation recentLocation = e.Locations[e.Locations.Length - 1];
				_userCoords = recentLocation.Coordinate;
				// get the distance from here to Löwenbräukeller
				var distance = recentLocation.DistanceFrom (new CLLocation (LATITUDE_LBK, LONGITUDE_LBK));
				string distanceText = Locale.Format("Bis zum Ziel ca: {0}", Util.DistanceToString (distance));
				txtDistance.Text = distanceText;
				if (CLLocationManager.LocationServicesEnabled) {
					_locationManager.StopUpdatingLocation ();
				}
			};
			
			txtPlan.TextColor = UIColor.White;
			txtPlan.BackgroundColor = UIColor.Clear;
			
			scrollContainer.SetLabelsTextColor (UIColor.White);
			scrollContainer.SetLabelsBGColor (UIColor.Clear);
			
			txtAddress.Text = "Löwenbräukeller Gastronomie GmbH\n" +
							"Nymphenburgerstrasse 2\n" + 
							"80335 München";
			txtPhone.Text = "Tel.: +49 (0)89 - 547 2669-0";
			txtFax.Text = "Fax: +49 (0)89 - 547 2669-25";
			txtMail.Text = EMAIL;
		
			
			btnPhone.SetImage (UIImage.FromBundle ("image/buttons/phone.png"), UIControlState.Normal);
			btnPhone.TouchUpInside += delegate {
				var phoneCaller = new PhoneCaller ();
				phoneCaller.Call (PHONE_NUMBER);
			};
			
			btnMail.SetImage (UIImage.FromBundle ("image/buttons/mail.png"), UIControlState.Normal);
			/*
			btnMail.TouchDown += delegate {
				var alert = new UIAlertView (EMAIL, "", null, Locale.GetText ("Cancel"), Locale.GetText ("Mailen"));
				alert.Clicked += (sender, e) => {
					if (e.ButtonIndex == 1) {
						Util.OpenUrl ("mailto:" + EMAIL);
					}
				};
				alert.Show ();
			};
			*/
			btnMail.TouchUpInside += (o, e) =>
			{
				if (MFMailComposeViewController.CanSendMail) {
					var mail = new MFMailComposeViewController ();
					mail.SetToRecipients (new string[] { EMAIL});
					mail.SetSubject ("Löwenbräu");
					mail.SetMessageBody ("", false);
					mail.Finished += HandleMailFinished;
					this.PresentViewController (mail, true, null);
				} 
			};
			
			btnMap.SetImage (UIImage.FromBundle ("image/buttons/map.png"), UIControlState.Normal);
			btnMap.TouchUpInside += delegate {
				this.NavigationController.PushViewController (new LbkMapViewController (_lbkCoords, _userCoords), true);
			};
			
			/*
			lblImpressum = new UILabel (){
				TextColor = UIColor.White,
				Text ="Impressum",
				Font = UIFont.BoldSystemFontOfSize (17f),
				BackgroundColor = UIColor.Clear,
			//AutoresizingMask = UIViewAutoresizing.FlexibleMargins | UIViewAutoresizing.FlexibleDimensions,
			};
			*/
			txtPlan.RemoveFromSuperview ();
			
			string html = string.Empty;
			try {
				using (TextReader textReader = new StreamReader("Data/kontakt.html")) {
					html = textReader.ReadToEnd ();
				}
			} catch {
			}
			
			wvImpressum = new UIWebView (){
				BackgroundColor = UIColor.Clear,
				Opaque = false,
				DataDetectorTypes = UIDataDetectorType.None,
				UserInteractionEnabled = false,
				AutoresizingMask =  UIViewAutoresizing.FlexibleDimensions,
			};
			float y = btnMail.Frame.Y + btnMail.Frame.Height + 10;
			wvImpressum.Frame = new RectangleF (10, y, this.View.Bounds.Width - 20, 580);
			wvImpressum.LoadHtmlString (html, null);
				
			//SetRest ();
			//this.scrollContainer.Add (lblImpressum);
			this.scrollContainer.Add (wvImpressum);
			scrollContainer.ContentSize = new SizeF (this.View.Bounds.Size.Width, y + wvImpressum.Frame.Height);
		}