当前位置: 首页>>代码示例>>C#>>正文


C# UIImagePickerController.TakePicture方法代码示例

本文整理汇总了C#中UIImagePickerController.TakePicture方法的典型用法代码示例。如果您正苦于以下问题:C# UIImagePickerController.TakePicture方法的具体用法?C# UIImagePickerController.TakePicture怎么用?C# UIImagePickerController.TakePicture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIImagePickerController的用法示例。


在下文中一共展示了UIImagePickerController.TakePicture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CameraOptions

		public CameraOptions overlaySettings = new CameraOptions(); // default values

		public CameraOverlayView (UIImagePickerController controller, CameraOptions _settings, CGRect frame) : base (frame)
		{
			log ("Intializing Camera Overlay from frame...");
			if(_settings != null)
				overlaySettings = _settings;

			// Clear the background of the overlay:
			this.Opaque = false;  
			this.BackgroundColor = UIColor.Clear;  // transparent

			UIImage overlayGraphic;
			string OverlayImage = _settings.Overlay;

			log ("Overlay Image: "+OverlayImage);
			if (OverlayImage != null && File.Exists("./"+OverlayImage+".png")){
					log ("Overlay Image: "+OverlayImage + " found!");
					overlayGraphic = UIImage.FromBundle (OverlayImage+".png");

			} else {
				log ("Overlay Image not found");
				// Load the image to show in the overlay:
				overlayGraphic = UIImage.FromBundle (@"overlaygraphic.png");
			}
			overlayGraphic = overlayGraphic.ImageWithRenderingMode (UIImageRenderingMode.AlwaysTemplate);  // convert image to template

			UIImageView overlayGraphicView = new UIImageView (overlayGraphic);
			overlayGraphicView.Frame = new CGRect(
				overlaySettings.GuidelinesMargins, 
				overlaySettings.GuidelinesMargins, 
				frame.Width - overlaySettings.GuidelinesMargins * 2 , 
				frame.Height - overlaySettings.GuidelinesMargins * 2);

			log ("guidelines tint color: " + overlaySettings.GuidelinesColorHexadecimal);
			UIColor color = GetUIColorfromHex (overlaySettings.GuidelinesColorHexadecimal);
			if (color != null)
				overlayGraphicView.TintColor = color;

			this.AddSubview (overlayGraphicView);

			ScanButton scanButton = new ScanButton (
				new CGRect ((frame.Width / 2) - (overlaySettings.ScanButtonWidth /2), frame.Height - overlaySettings.ScanButtonHeight - overlaySettings.ScanButtonMarginBottom , 
					overlaySettings.ScanButtonWidth, overlaySettings.ScanButtonHeight), overlaySettings);
			scanButton.TouchUpInside += delegate(object sender, EventArgs e) {

				log("Scan Button TouchUpInside... " );

				controller.TakePicture();
			};

			this.AddSubview (scanButton);

			if (overlaySettings.DescriptionLabelText != null) {
				UILabel label = new UILabel (new CGRect (overlaySettings.DescriptionLabelMarginLeftRight, 
									frame.Height - overlaySettings.DescriptionLabelHeight - overlaySettings.DescriptionLabelMarginBottom, 
					frame.Width - overlaySettings.DescriptionLabelMarginLeftRight * 2, overlaySettings.DescriptionLabelHeight));  // applying "DescriptionLabelMarginLeftRight" margins to width and x position
				label.Text = overlaySettings.DescriptionLabelText;

				color = GetUIColorfromHex (overlaySettings.DescriptionLabelColorHexadecimal);
				if(color != null)
					label.TextColor = color; 
				label.BaselineAdjustment = UIBaselineAdjustment.AlignCenters;
				label.TextAlignment = UITextAlignment.Center; // centered aligned
				label.LineBreakMode = UILineBreakMode.WordWrap; // wrap text by words
				label.Lines = 2;

				if (overlaySettings.DescriptionLabelFontFamilyName != null) {
					UIFont labelFont = UIFont.FromName (overlaySettings.DescriptionLabelFontFamilyName, overlaySettings.DescriptionLabelFontSize);
					if (labelFont != null) {
						label.Font = labelFont;
					} else {
						log ("Font family [" + overlaySettings.DescriptionLabelFontFamilyName + "] for 'DescriptionLabelFontFamilyName' not found");
					}
				}

				this.AddSubview (label);
			}

			UILabel cancelLabel = new UILabel (new CGRect ((frame.Width / 4) - (overlaySettings.CancelButtonWidth /2), 
				frame.Height - overlaySettings.CancelButtonHeight - overlaySettings.ScanButtonMarginBottom, 
				overlaySettings.CancelButtonWidth, overlaySettings.CancelButtonHeight));
			cancelLabel.Text = overlaySettings.CancelButtonText;
			color = GetUIColorfromHex (overlaySettings.CancelButtonColorHexadecimal);
			if(color != null)
				cancelLabel.TextColor = color;
			cancelLabel.BaselineAdjustment = UIBaselineAdjustment.AlignCenters;
			cancelLabel.TextAlignment = UITextAlignment.Center; // centered aligned

			// list of available ios fonts: https://developer.xamarin.com/recipes/ios/standard_controls/fonts/enumerate_fonts/
			if (overlaySettings.CancelButtonFontFamilyName != null) {
				UIFont cancelLabelFont = UIFont.FromName (overlaySettings.CancelButtonFontFamilyName, overlaySettings.CancelButtonFontSize);
				if (cancelLabelFont != null) {
					cancelLabel.Font = cancelLabelFont;
				} else {
					log ("Font family [" + overlaySettings.CancelButtonFontFamilyName + "] for 'CancelButtonFontFamilyName' not found");
				}
			}

			UITapGestureRecognizer cancelLabelTap = new UITapGestureRecognizer(() => {
//.........这里部分代码省略.........
开发者ID:Appverse,项目名称:appverse-mobile,代码行数:101,代码来源:CameraOverlayView.cs


注:本文中的UIImagePickerController.TakePicture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。