• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UIImagePickerController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ViewDidLoad

		public override void ViewDidLoad ()
		{
			this.Root.Add(new Section() {

				new StyledStringElement("Load App's Sample Photo", () => {
					Decode(UIImage.FromFile("BarcodeSamples/" + this.Format.ToString().ToLower() + ".png"));
				}),
				new StyledStringElement("Choose Existing Photo", () => {
					var ipc = new UIImagePickerController();
					ipc.FinishedPickingImage += (sender, e) => {
						Decode(e.Image);

						this.InvokeOnMainThread(() => this.NavigationController.DismissViewController(true, null));
					};
					ipc.FinishedPickingMedia += (sender, e) => {
						Decode(e.EditedImage ?? e.OriginalImage);
						this.InvokeOnMainThread(() => this.NavigationController.DismissViewController(true, null));
					};
					ipc.Canceled += (sender, e) => {
						this.InvokeOnMainThread(() => this.NavigationController.DismissViewController(true, null));
					};


					this.InvokeOnMainThread(() => this.NavigationController.PresentViewController(ipc, true, null));
				}),
				new StyledStringElement("Take new Photo", () => {

				})
			});

			this.Root.Add (new Section() {
				new ImageDisplayElement(null, 160f),
				new StyledStringElement("Decoded Results will appear here")
			});
		}
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:35,代码来源:DecoderViewController.cs


示例2: FinishedPickingMedia

			public override void FinishedPickingMedia (UIImagePickerController picker, NSDictionary info)
			{
				var cb = _callback;
				_callback = null;
				picker.DismissViewController (true,null);
				cb (info);
			}
开发者ID:saedaes,项目名称:ProductFinder,代码行数:7,代码来源:Camera.cs


示例3: AddNewItem

		void AddNewItem (object sender, EventArgs args)
		{
			var picker = new UIImagePickerController ();

			this.NavigationController.PresentViewController (picker, true, new NSAction(()=>{
				Console.WriteLine("done."); 
			}));

			picker.FinishedPickingMedia += (object s, UIImagePickerMediaPickedEventArgs e) => {
				Title = NSBundle.MainBundle.LocalizedString ("Uploading photo...", "Uploading photo...");

				picker.DismissViewController (true, null);

				var randomInt = Convert.ToUInt64(new Random().NextDouble() * UInt64.MaxValue);
				var name = randomInt + ".png";

				UploadTask = new TaskFactory<CloudBlockBlob>().StartNew(()=>{
					return UploadImage(e.OriginalImage, name);
				})
				.ContinueWith((blob)=>{
					InvokeOnMainThread(()=>{
							dataSource.Objects.Insert (0, new Tuple<String, UIImage>(name, e.OriginalImage));
						Title = NSBundle.MainBundle.LocalizedString ("Photos", "Photos");
						using (var indexPath = NSIndexPath.FromRowSection (0, 0))
							TableView.InsertRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic);

					});
				});
			};

			picker.Canceled += (s, e) => {
				picker.DismissViewController (true, null);
			};
		}
开发者ID:MavenRain,项目名称:IOSAzureBlobUploader,代码行数:34,代码来源:RootViewController.cs


示例4: ViewDidLoad

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

            this.CreateAccount.TouchUpInside += (object sender, EventArgs e) => {
                //UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
                //PreferencesController welcome = (PreferencesController)board.InstantiateViewController ("preferencescontroller");
                //welcome.ImageSources = new string[] { "aaa", "a", "a", "a", "a", "a", "a", "a", "a" };

                //this.NavigationController.PushViewController(welcome, true);
                model = new RegisterModel { Email = this.Email.Text, FirstName = this.FirstName.Text, LastName = this.LastName.Text, Password = this.Password.Text };
                var request = new RestRequest();
                request.Send("http://www.sport.net/api/content/register", "POST", model);
            };

            this.ImagePicker.TouchUpInside += (s, e) => {
                // create a new picker controller
                imagePicker = new UIImagePickerController ();

                // set our source to the photo library
                imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;

                // set what media types
                imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);

                imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                imagePicker.Canceled += Handle_Canceled;

                // show the picker
                NavigationController.PresentViewController (imagePicker, true, null);

            };
        }
开发者ID:jgrozdanov,项目名称:mono-sport,代码行数:33,代码来源:SignUpController.cs


示例5: OpenCameraViewController

        public void OpenCameraViewController(object sender, EventArgs ea)
        {
            picker = new UIImagePickerController();
            picker.AllowsEditing = true;

            if(UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera))
            {
                picker.SourceType = UIImagePickerControllerSourceType.Camera;
            }
            else if(UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary))
            {
                picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            }

            picker.FinishedPickingMedia += (s, e) => {
                UIImage editedImage = e.Info[UIImagePickerController.EditedImage] as UIImage;
                imageViewPhoto.Image = editedImage;

                picker.DismissViewController (true, null);
            };

            picker.Canceled  += (s, e) => {
                picker.DismissViewController(true, null);
            };

            PresentViewController(picker, true, null);
        }
开发者ID:darochapires,项目名称:XamarinBenchmark,代码行数:27,代码来源:CameraAccessViewController.cs


示例6: FinishedPickingImage

		public override void FinishedPickingImage (UIImagePickerController picker, UIImage image, NSDictionary editingInfo)
		{	
			UIApplication.SharedApplication.SetStatusBarHidden(false, false);
			
			var imagePicker = (VCViewController)_navigationController;
			if (imagePicker.IsCameraAvailable)
				imagePicker.btnBib.Hidden = true;
						
			imagePicker.DismissModalViewControllerAnimated(true);
			
			if (imagePicker.IsCameraAvailable)
			{
				image.SaveToPhotosAlbum (delegate {
					// ignore errors
					});
			}
			
			UIViewController nextScreen = null;
			
			if (tweet != null)
			{
				nextScreen = new PhotoPostViewController(_shareNavCont, image, tweet);
			}
			else
			{
				nextScreen = new PhotoLocationViewController(_shareNavCont, image);				
			}
			
			_shareNavCont.PushViewController(nextScreen, true);
		}	
开发者ID:21Off,项目名称:21Off,代码行数:30,代码来源:pickerDelegate.cs


示例7: OnTakePhotoPressed

		void OnTakePhotoPressed (object sender, EventArgs eventArgs)
		{
			TakePhotoButton.Enabled = false;

			UIImagePickerController picker = new UIImagePickerController ();
			picker.SourceType = UIImagePickerControllerSourceType.Camera;

			picker.FinishedPickingMedia += async (o, e) => {
				// Create a moderate quality version of the image
				byte [] dataBytes;
				using (NSData data = e.OriginalImage.AsJPEG (.5f)) {
					dataBytes = new byte [data.Length];
					System.Runtime.InteropServices.Marshal.Copy (data.Bytes, dataBytes, 0, Convert.ToInt32 (data.Length));
				}

				ThePhoto.Image = e.OriginalImage;
				DetailsText.Text = "Processing...";

				((UIImagePickerController)o).DismissViewController (true, null);

				// Create a stream, send it to MCS, and get back 
				using (MemoryStream stream = new MemoryStream (dataBytes)) {
					try {
						float happyValue = await SharedProject.Core.GetAverageHappinessScore (stream);
						DetailsText.Text = SharedProject.Core.GetHappinessMessage (happyValue);
					} catch (Exception ex) {
						DetailsText.Text = ex.Message;
					}
					TakePhotoButton.Enabled = true;

				}
			};
			PresentModalViewController (picker, true);
		}
开发者ID:XpiritBV,项目名称:mini-hacks,代码行数:34,代码来源:ViewController.cs


示例8: ViewDidLoad

 public override void ViewDidLoad ()
 {
     base.ViewDidLoad ();
     
     _picker = new UIImagePickerController ();
     _pickerDel = new PickerDelegate (this);
     _picker.Delegate = _pickerDel;
     
     _actionSheet = new UIActionSheet ();
     _actionSheet.AddButton ("Library");
     _actionSheet.AddButton ("Camera");
     _actionSheet.AddButton ("Cancel");
     _actionSheet.CancelButtonIndex = 2;
     _actionSheet.Delegate = new ActionSheetDelegate (this);
     
     showPicker.TouchUpInside += delegate { _actionSheet.ShowInView (this.View); };
     
     playMovie.Hidden = true;
     
     playMovie.TouchUpInside += delegate {
         if (_mp != null) {
             View.AddSubview (_mp.View);
             _mp.SetFullscreen (true, true);
             _mp.Play ();
         }
     };
 }
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:27,代码来源:CameraDemoController.xib.cs


示例9: FinishedPickingMedia

        public override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
        {
            
            MediaFile mediaFile;
            switch ((NSString)info[UIImagePickerController.MediaType])
            {
                case MediaImplementation.TypeImage:
                    mediaFile = GetPictureMediaFile(info);
                    break;

                case MediaImplementation.TypeMovie:
                    mediaFile = GetMovieMediaFile(info);
                    break;

                default:
                    throw new NotSupportedException();
            }

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                UIApplication.SharedApplication.SetStatusBarStyle(MediaImplementation.StatusBarStyle, false);
            }

            Dismiss(picker, () => 
            {
                

                this.tcs.TrySetResult(mediaFile);
            });
        }
开发者ID:Jazzeroki,项目名称:Xamarin.Plugins,代码行数:30,代码来源:MediaPickerDelegate.cs


示例10: MvxImagePickerTask

 public MvxImagePickerTask(IMvxTouchViewPresenter presenter)
 {
     _picker = new UIImagePickerController();
     //_cameraDelegate = new CameraDelegate();
     // _picker.Delegate = _cameraDelegate;
     _presenter = presenter;
 }
开发者ID:Gert-Cominotto,项目名称:MvvmCross,代码行数:7,代码来源:MvxImagePickerTask.cs


示例11: ViewDidLoad

        public override void ViewDidLoad()
        {
            uploadImage.Enabled = false;

            imagePicker = new UIImagePickerController();
            imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);
            imagePicker.FinishedPickingMedia += finishPickImage;
            imagePicker.Canceled += cancelImagePicker;

            selectImage.TouchUpInside += (sender, e) => {
                Console.WriteLine ("Execute image picker controller");
                PresentViewController(imagePicker,true, null);
            };

            uploadImage.TouchUpInside += (sender, e) => {
                uploadResult = new CISolution.CloudinaryHelper().uploadImage(fd);

                if(uploadResult.Error == null) {
                    Console.WriteLine("Video success uploaded...");
                } else {
                    Console.WriteLine("Error : " + uploadResult.Error.Message);
                }
                uploadImage.Enabled = false;
            };
        }
开发者ID:saiber,项目名称:CloudinarySolution,代码行数:26,代码来源:UploadImageViewController.cs


示例12: PickPhotoAsync

        public async Task<IMediaFile> PickPhotoAsync()
        {
            Debug.WriteLine("PickPhotoAsync: starting");
            // setup a task to get the results back from the delegate
            var mediaInfoTask = new TaskCompletionSource<NSDictionary>();

            // setup a UI Picker to show photos
            var picker = new UIImagePickerController();
            picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            picker.MediaTypes = new string[] { UTType.Image };
            picker.AllowsEditing = false;
            picker.Delegate = new MediaDelegate { InfoTask = mediaInfoTask };
            // iPad should display the picker in a popover
            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                picker.ModalInPopover = true;
            var vc = GetViewController();
            Debug.WriteLine("PickPhotoAsync: displaying photo picker");
            vc.PresentViewController(picker, true, null);
            // wait to get the results back
            Debug.WriteLine("PickPhotoAsync: waiting for selected photo");
            var info = await mediaInfoTask.Task;
            var assetUrl = info[UIImagePickerController.ReferenceUrl] as NSUrl;
            Debug.WriteLine("PickPhotoAsync: photo selected {0}", assetUrl);
            var mediaFile = new MediaFile {Path = assetUrl.ToString()};
            Debug.WriteLine("PickPhotoAsync: returning created media file");
            return mediaFile;
        }
开发者ID:JC-Chris,项目名称:XFExtensions,代码行数:27,代码来源:MediaImplementation.cs


示例13: TakePhotoAsync

        public async Task<IMediaFile> TakePhotoAsync()
        {
            Debug.WriteLine("TakePhotoAsync: starting");
            // setup a task to get the results back from the delegate
            var mediaInfoTask = new TaskCompletionSource<NSDictionary>();

            // setup a UI Picker to display camera
            var picker = new UIImagePickerController();
            picker.SourceType = UIImagePickerControllerSourceType.Camera;
            picker.MediaTypes = new string[] { UTType.Image };
            picker.AllowsEditing = false;
            picker.Delegate = new MediaDelegate { InfoTask = mediaInfoTask };

            // display the picker
            Debug.WriteLine("TakePhotoAsync: displaying the camera");
            var vc = GetViewController();
            vc.PresentViewController(picker, true, null);

            // wait for a result
            Debug.WriteLine("TakePhotoAsync: waiting for photo from camera");
            var info = await mediaInfoTask.Task;
            var assetLocation = await SavePhotoWithLocationAsync(info);

            // create and return a media file
            Debug.WriteLine("TakePhotoAsync: picture taken & stored at {0}", assetLocation);
            var mediaFile = new MediaFile {Path = assetLocation.ToString()};
            Debug.WriteLine("TakePhotoAsync: returning created media file");
            return mediaFile;
        }
开发者ID:JC-Chris,项目名称:XFExtensions,代码行数:29,代码来源:MediaImplementation.cs


示例14: FinishedPickingMedia

        public override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
        {
            //Determine that an image was selected
            bool isImage = false;
            switch (info [UIImagePickerController.MediaType].ToString ()) {
            case "public.image":
                isImage = true;
                break;
            }

            //If it was an image, get the image
            if (isImage) {
                //Get the image - either it will be original, or edited
                var originalImage = info [UIImagePickerController.OriginalImage] as UIImage;
                var editedImage = info [UIImagePickerController.EditedImage] as UIImage;

                UIImage image = null;
                if (originalImage != null)
                    image = originalImage;
                else if (editedImage != null)
                    image = editedImage;

                picker.DismissViewController (false, () => _parentViewController.ExtractResults (image, true));
                return;
            }

            picker.DismissViewController (false,
                () => new UIAlertView ("Image not processed", "Image could not be processed", null, "OK").Show ());
        }
开发者ID:yonglehou,项目名称:Xamarin-Tesseract-OCR-iOS-1,代码行数:29,代码来源:PickerDelegate.cs


示例15: GetImagePath

        public bool GetImagePath()
        {
            string ImageRefURL = null;
            imagePicker = new UIImagePickerController ();
            imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);

            imagePicker.FinishedPickingMedia += (object sender, UIImagePickerMediaPickedEventArgs e) => {
                // determine what was selected, video or image
                bool isImage = false;
                switch (e.Info [UIImagePickerController.MediaType].ToString ()) {
                case "public.image":
                    //				Console.WriteLine("Image selected");
                    isImage = true;
                    break;
                case "public.video":
                    //				Console.WriteLine("Video selected");
                    break;
                }

                // get common info (shared between images and video)
                NSUrl referenceURL = e.Info [new NSString ("UIImagePickerControllerReferenceUrl")] as NSUrl;
                if (referenceURL != null && isImage) {
                    ImageRefURL =  referenceURL.ToString();
                }

            };

            return true;
        }
开发者ID:ctsxamarintraining,项目名称:cts440202,代码行数:30,代码来源:UploadImage_iOS.cs


示例16: ViewDidLoad

        public override void ViewDidLoad()
        {
            uploadVideo.Enabled = false;

            pickerController = new UIImagePickerController();
            pickerController.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            pickerController.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);
            pickerController.FinishedPickingMedia += finishPickImage;
            pickerController.Canceled += cancelImagePicker;

            selectVideo.TouchUpInside += (sender, e) => PresentViewController (pickerController, true, null);

            uploadVideo.TouchUpInside += (sender, e) =>  {

                uploadResult = new CISolution.CloudinaryHelper().uploadVideo(fd);

                if(uploadResult.Error == null) {
                    alertController = UIAlertController.Create("Success", uploadResult.JsonObj.ToString(), UIAlertControllerStyle.ActionSheet);
                } else {
                    alertController = UIAlertController.Create("Error", uploadResult.Error.Message, UIAlertControllerStyle.ActionSheet);
                }

                alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));
                PresentViewController(alertController,true,null);
                uploadVideo.Enabled = false;
            };
        }
开发者ID:saiber,项目名称:CloudinarySolution,代码行数:27,代码来源:UploadVideoViewController.cs


示例17: ViewDidLoad

		public override void ViewDidLoad()
		{
			base.ViewDidLoad();
			Title = "Choose Photo";
			View.BackgroundColor = UIColor.White;

			imageView = new UIImageView(new CGRect(10, 150, 300, 300));
			Add(imageView);

			choosePhotoButton = UIButton.FromType(UIButtonType.RoundedRect);
			choosePhotoButton.Frame = new CGRect(10, 80, 100, 40);
			choosePhotoButton.SetTitle("Picker", UIControlState.Normal);
			choosePhotoButton.TouchUpInside += (s, e) => {
				// create a new picker controller
				imagePicker = new UIImagePickerController();
				
				// set our source to the photo library
				imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
								
				// set what media types
				imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
				
				imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
				imagePicker.Canceled += Handle_Canceled;
				
				// show the picker
				NavigationController.PresentModalViewController(imagePicker, true);
				//UIPopoverController picc = new UIPopoverController(imagePicker);

			};
			View.Add(choosePhotoButton);
		}
开发者ID:StargrrlMoonlight,项目名称:recipes,代码行数:32,代码来源:ImageViewController.cs


示例18: ImagePickerProvider

        public ImagePickerProvider(UIViewController viewController)
        {
            _viewController = viewController;

            _imagePicker = new UIImagePickerController ();
            _imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            _imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);
        }
开发者ID:pragmaticlogic,项目名称:athena,代码行数:8,代码来源:ImagePickerProvider.cs


示例19: FinishedPickingMedia

        public override void FinishedPickingMedia(UIImagePickerController picker, MonoTouch.Foundation.NSDictionary info)
        {
            var originalImage = new NSString("UIImagePickerControllerOriginalImage");
            var image = (UIImage)info[originalImage];

            _controller.LoadImage(image);
            _controller.DismissModalViewControllerAnimated(true);
        }
开发者ID:follesoe,项目名称:FacebookBigProfile,代码行数:8,代码来源:ImagePickerDelegate.cs


示例20: Canceled

            public override void Canceled(UIImagePickerController picker)
            {
                var cb = _callback;
                _callback = null;

                picker.DismissViewController(true, (Action)null);
                cb(null);
            }
开发者ID:mehul19851,项目名称:xamarin-forms-camera,代码行数:8,代码来源:Camera.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UIImageView类代码示例发布时间:2022-05-24
下一篇:
C# UIImage类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap