Пример #1
0
 public static void Init(UIKit.UIApplication app, Foundation.NSDictionary launchOptions)
 {
     FacebookApi.IsUsingNative = true;
     fb.CoreKit.ApplicationDelegate.SharedInstance.FinishedLaunching(app, launchOptions);
     FacebookApi.ShowFacebookAuthenticator = (a) => invoker.BeginInvokeOnMainThread(() => Login(a));
     Native.RegisterCallBack("facebook", Callback);
 }
        public void FinishedPickingMedia(UIImagePickerController picker, Foundation.NSDictionary info)
        {
            var image = info [UIImagePickerController.OriginalImage] as UIImage;

            imgProfile.Image = image;
            imgCover.Image   = image;
            picker.DismissViewController(true, null);
        }
Пример #3
0
        private void Initialize(IAccessToken token, string path, Foundation.NSDictionary parameters, string httpMethod = default(string), string version = default(string))
        {
            _token     = (token as iOSAccessToken).ToNative();
            Path       = path;
            HttpMethod = httpMethod;
            Version    = version;

            _request = new GraphRequest(Path, parameters == null ? null : parameters, _token.TokenString, HttpMethod, Version);
        }
        public override void ObserveValue(Foundation.NSString keyPath,
                                          Foundation.NSObject ofObject,
                                          Foundation.NSDictionary change,
                                          IntPtr context)
        {
            var top = (Bounds.Size.Height - ContentSize.Height * ZoomScale) / 2.0;

            top = top < 0.0 ? 0.0 : top;
            this.SetContentOffset(CGPoint.Empty, false);
        }
Пример #5
0
        public void FinishedPickingMedia(UIImagePickerController picker, Foundation.NSDictionary info)
        {
            UIImage imagen = new UIImage();
            var     image  = info[UIImagePickerController.OriginalImage] as UIImage;
            //Le damos una nuevo tamanio a la imagen
            var images = ResizeUIImage(image, 128, 128);

            imgProfile.ContentMode = UIViewContentMode.ScaleAspectFit;

            imgProfile.Image = images;
            var imagec2 = ResizeUIImage(image, 359, 259);

            imgCover.Image = imagec2;
            picker.DismissViewController(true, null);
        }
Пример #6
0
        public void FinishedPickingMedia(UIImagePickerController picker, Foundation.NSDictionary info)
        {
            var image = info[UIImagePickerController.OriginalImage] as UIImage;


            imgAdjuntoM.Image = image;

            //Encoding
            string encodedString = imgAdjuntoM.Image.AsJPEG(0.23f).GetBase64EncodedString(NSDataBase64EncodingOptions.None);

            foto = encodedString;

            //Descoding
            //byte[] encodedDataAsBytes = System.Convert.FromBase64String (foto);
            //NSData ImageData = NSData.FromArray(encodedDataAsBytes);
            //var img = UIImage.LoadFromData(ImageData);
            //imgAdjunto.Image = img;
            picker.DismissViewController(true, null);
        }
Пример #7
0
 public static NSAttributedString CreateWithRTFD(NSData rtfdData, out NSDictionary resultDocumentAttributes)
 {
     return(new NSAttributedString(rtfdData, NSAttributedStringDataType.RTFD, out resultDocumentAttributes));
 }
Пример #8
0
        public async void FinishedPickingImage(UIKit.UIImagePickerController picker, UIKit.UIImage image, Foundation.NSDictionary editingInfo)
        {
            if (this.TouchedBack)
            {
                BTProgressHUD.Show("Guardando Imagen");
                await Task.Run(() =>
                {
                    image = ImageHelper.ReescalProfileBackImage(image);
                    Miembro.Usuario_Fotografia_FondoPerfil = image?.AsPNG().ToArray();
                    if (this.GuardarInfo())
                    {
                        BTProgressHUD.Dismiss();
                        BTProgressHUD.Show("Información guardada con éxito");
                        //this.PublicarPost(Miembro.Usuario_Nombre + " " + Miembro.Usuario_Apellidos + " actualizó su foto de fondo", Miembro.Usuario_Fotografia_FondoPerfil, 2);
                    }
                });

                BTProgressHUD.Dismiss();
                this.btnImageBackGround.SetBackgroundImage(image, UIControlState.Normal);
            }
            else if (this.TouchedProfile)
            {
                BTProgressHUD.Show("Guardando Imagen");
                await Task.Run(() =>
                {
                    image = ImageHelper.ReescalProfileImage(image);
                    Miembro.Usuario_Fotografia_Perfil = image?.AsPNG().ToArray();
                    if (this.GuardarInfo())
                    {
                        //this.PublicarPost(Miembro.Usuario_Nombre + " " + Miembro.Usuario_Apellidos + " actualizó su foto de perfil", Miembro.Usuario_Fotografia_Perfil, 1);
                    }
                });

                BTProgressHUD.Dismiss();
                this.btnProfileImage.SetBackgroundImage(image, UIControlState.Normal);
            }
            this.TouchedBack    = false;
            this.TouchedProfile = false;
            picker.DismissViewController(true, null);
        }
Пример #9
0
        public void FinishedPickingImage(UIImagePickerController picker, UIImage image, Foundation.NSDictionary editingInfo)
        {
            picker.DismissViewController(true, null);

            imgPhoto.Image       = image;
            txtResult.Text       = "Recognizing...";
            btnRecognize.Enabled = false;

            RecognizeImage(image);
        }
        /// <inheritdoc/>
        public override bool FinishedLaunching(UIApplication application, Foundation.NSDictionary launchOptions)
        {
            ComposeDelegate();

            return(true);
        }
		public bool RecordAudio()
		{
			try {
				var audioSession = AVFoundation.AVAudioSession.SharedInstance ();
				var err = audioSession.SetCategory (AVFoundation.AVAudioSessionCategory.PlayAndRecord);
				if (err != null) {
					return false;
				}
				err = audioSession.SetActive (true);
				if (err != null) {
					return false;
				}
				string directoryname = string.Empty;

				try {
					var documents =
						Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
					directoryname = System.IO.Path.Combine (documents, "PurposeColor/Audio");
					System.IO.Directory.CreateDirectory(directoryname);
				} catch (Exception ex) {
					var test = ex.Message;
				}

			    fileName = string.Format ("Audio{0}.wav", DateTime.Now.ToString ("yyyyMMddHHmmss"));
			    audioFilePath = System.IO.Path.Combine (directoryname, fileName);

				url = Foundation.NSUrl.FromFilename (audioFilePath);

				//set up the NSObject Array of values that will be combined with the keys to make the NSDictionary
				Foundation.NSObject[] values = new NSObject[] {
					NSNumber.FromFloat (44100.0f), //Sample Rate
					NSNumber.FromInt32 ((int)AudioToolbox.AudioFormatType.LinearPCM), //AVFormat
					NSNumber.FromInt32 (1), //Channels
					NSNumber.FromInt32 (16) //PCMBitDepth
				};
				
				//Set up the NSObject Array of keys that will be combined with the values to make the NSDictionary
				NSObject[] keys = new NSObject[] {
					AVAudioSettings.AVSampleRateKey,
					AVAudioSettings.AVFormatIDKey,
					AVAudioSettings.AVNumberOfChannelsKey,
					AVAudioSettings.AVLinearPCMBitDepthKey
				};
				//Set Settings with the Values and Keys to create the NSDictionary
				settings = NSDictionary.FromObjectsAndKeys (values, keys);
				var error  = new NSError();
				//Set recorder parameters
				recorder = AVAudioRecorder.Create (url, new AudioSettings (settings), out error);
				//Set Recorder to Prepare To Record
				recorder.PrepareToRecord ();
				recorder.Record ();

				return true;
			}
			catch (Exception ex) 
			{
				var tt = ex.Message;
				return false;
			}

		}
Пример #12
0
 public void FinishedPickingImage(UIKit.UIImagePickerController picker, UIKit.UIImage image, Foundation.NSDictionary editingInfo)
 {
     ImagenPublicacion = ImageHelper.ReescalImage(image);
     this.btnImageComment.SetImage(image, UIControlState.Normal);
     this.btnDeleteImge.Hidden        = false;
     this.btnPublicar.Enabled         = true;
     this.btnImageComment.ContentMode = UIViewContentMode.ScaleAspectFit;
     this.btnImageComment.Enabled     = true;
     picker.DismissViewController(true, null);
 }
Пример #13
0
 public void FinishedPickingImage(UIKit.UIImagePickerController picker, UIKit.UIImage image, Foundation.NSDictionary editingInfo)
 {
     if (this.TouchedBack)
     {
         image = ImageHelper.ReescalProfileBackImage(image);
         this.btnFondoImagen.SetBackgroundImage(image, UIControlState.Normal);
         NewInfoPerfil.Usuario_Fotografia_FondoPerfil = image?.AsPNG().ToArray();
     }
     else if (this.TouchedProfile)
     {
         image = ImageHelper.ReescalProfileImage(image);
         this.btnImagen.SetBackgroundImage(image, UIControlState.Normal);
         NewInfoPerfil.Usuario_Fotografia_Perfil = image?.AsPNG().ToArray();
     }
     this.TouchedBack    = false;
     this.TouchedProfile = false;
     picker.DismissViewController(true, null);
 }
Пример #14
0
 public static void Integrate(string appKey, Foundation.NSDictionary localyticsOptions)
 {
     Localytics.IntegratePrivate(appKey, localyticsOptions);
     NSObject notificationObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidBecomeActiveNotification, (obj) => { });
 }
Пример #15
0
        public void FinishedPickingImage(UIKit.UIImagePickerController picker, UIKit.UIImage image, Foundation.NSDictionary editingInfo)
        {
            this.ImagenEmpresa.Image = image;
            NSData imageData = image.AsPNG();

            InfoPerifl.Empresa_Actual.Empresa_Logotipo_Perfil = new Byte[imageData.Length];
            EventosVistaTrabajoDelegate.InfoEmpresa(InfoPerifl);
            picker.DismissViewController(true, null);
        }
Пример #16
0
 public NSObservedChange(NSDictionary source)
 {
     dict = source;
 }
		public async  Task<bool> DownloadFiles ( List<string> downloadUrlList, CancellationToken cancelToken  )
		{

			try 
			{
				int requiredHeight = (int)(App.screenHeight * 0.5 * App.screenDensity);
				int requiredWidth = (int)(App.screenWidth * App.screenDensity);
				int imageHeight = 0;
				int imagewidth = 0;

				foreach (var item in downloadUrlList)
				{
					if( cancelToken != null )
						cancelToken.ThrowIfCancellationRequested();

					string fileName = Path.GetFileName(item);

					Uri uri = new Uri( App.DownloadsPath + fileName);

					if( !File.Exists( App.DownloadsPath + fileName ))
					{
						WebClient webClient = new WebClient();
						await webClient.DownloadFileTaskAsync ( item,  App.DownloadsPath + fileName );
						webClient.Dispose();

						#region Resize and compression

						try {
							ImageIO.CGImageSource myImageSource = null;
							myImageSource = ImageIO.CGImageSource.FromUrl(uri,null);
							var ns = new Foundation.NSDictionary();
							var imageProperties = myImageSource.CopyProperties(ns, 0);
							myImageSource.Dispose();
							myImageSource = null;

							var iwid = imageProperties[CGImageProperties.PixelWidth];
							var ihei = imageProperties[CGImageProperties.PixelHeight];
							ns.Dispose();
							ns = null;

							bool doResize = false;

							imagewidth = Convert.ToInt32(Convert.ToString(iwid));
							imageHeight = Convert.ToInt32(Convert.ToString(ihei));
							if (imagewidth < 5000 && imageHeight < 5000) {
								if(imageHeight > imagewidth)
								{
									if(imageHeight > requiredHeight || imagewidth > requiredWidth)
									{
										doResize = true;
									}
								}
								else
								{
									if(imageHeight > requiredWidth || imagewidth > requiredHeight)
									{
										doResize = true;
									}
								}

							}

							if(doResize)
							{
								UIImage image = null;

								Byte[] myByteArray = null;
								IResize resize = Xamarin.Forms.DependencyService.Get<IResize>();
								Byte[] myByteA = null;

								image = UIImage.FromFile(App.DownloadsPath +fileName);

								if(image == null)
								{
									continue;
								}

								try {
									NSData imageData = image.AsPNG();
									myByteArray = new Byte[imageData.Length];
									System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, myByteArray, 0, Convert.ToInt32(imageData.Length));
									myByteA = new Byte[imageData.Length];
									myByteA = resize.Resize(myByteArray, requiredWidth, requiredHeight, App.DownloadsPath + fileName);

									try {
										int compress_ratio = 99;
										if(myByteA.Length < 100000) {
											compress_ratio = 99;
										}
										else if(myByteA.Length < 400000) {
											compress_ratio = 98;
										}else if(myByteA.Length < 600000) {
											compress_ratio = 97;
										}
										else if(myByteA.Length < 800000) {
											compress_ratio = 96;
										}else{
											compress_ratio = 90;
										}
										MemoryStream compressedImage = resize.CompessImage(compress_ratio, new MemoryStream(myByteA));
										myByteA = new Byte[compressedImage.ToArray().Length];
										myByteA = compressedImage.ToArray();
									} catch (System.Exception ex) {
										var test = ex.Message;
									}

									imageData.Dispose();
									myByteArray = null;
									imageData.Dispose();
									imageData = null;

								} catch (Exception ex) 
								{
									var test = ex.Message;

									myByteA = null;
									continue;
								}

								if(myByteA != null && myByteA.Length > 0)
								{
									FileStream fstream = new FileStream(App.DownloadsPath + fileName, FileMode.Create, FileAccess.ReadWrite);
									fstream.Write(myByteA, 0, myByteA.Length);
									fstream.Close();
									fstream.Dispose();
									fstream = null;
								}

								myByteA = null;
								image.Dispose();
								image  = null;
							}
						} catch (Exception ex) {
							var test = ex.Message;

							FileStream fstream = new FileStream(App.DownloadsPath + fileName, FileMode.Create);
							fstream.Close();
							fstream.Dispose();
							fstream = null;
						}
						#endregion
					}
				}
				return true;
			} 
			catch (Exception ex) 
			{
				Debug.WriteLine ( ex.Message );
				return false;
			}

		}
Пример #18
0
 public void FinishedPickingImage(UIKit.UIImagePickerController picker, UIKit.UIImage image, Foundation.NSDictionary editingInfo)
 {
     ImagenPublicacion     = image;
     btnRemoveImage.Hidden = false;
     btnComentar.Enabled   = true;
     this.btnImagen.SetImage(image, UIControlState.Normal);
     this.btnImagen.ContentMode = UIViewContentMode.ScaleAspectFit;
     this.btnImagen.Enabled     = true;
     picker.DismissViewController(true, null);
 }
Пример #19
0
 public static NSAttributedString CreateWithHTML(NSData htmlData, out NSDictionary resultDocumentAttributes)
 {
     return(new NSAttributedString(htmlData, NSAttributedStringDataType.HTML, out resultDocumentAttributes));
 }
Пример #20
0
 public static StatusCode TryCopyCurrentNetworkInfo(string interfaceName, out Foundation.NSDictionary currentNetworkInfo) => throw new NotSupportedException();
Пример #21
0
 public static NSAttributedString CreateWithDocFormat(NSData wordDocFormat, out NSDictionary docAttributes)
 {
     return(new NSAttributedString(wordDocFormat, NSAttributedStringDataType.DocFormat, out docAttributes));
 }
Пример #22
0
 public NSAttributedStringDocumentAttributes(NSDictionary dictionary) : base(dictionary)
 {
 }
Пример #23
0
            public override async void FinishedPickingMedia(UIImagePickerController picker, Foundation.NSDictionary info)
            {
                await picker.PresentingViewController.DismissViewControllerAsync(true);

                var mediaType = (NSString)info[UIImagePickerController.MediaType];

                if (mediaType == UTType.Image)
                {
                    var image = (UIImage)info[UIImagePickerController.OriginalImage];
                    image.SaveToPhotosAlbum((img, error) => {
                        if (error != null)
                        {
                            var alert = UIAlertController.Create("Image Not Saved",
                                                                 "Sorry, unable to save the new image!",
                                                                 UIAlertControllerStyle.Alert);

                            alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                            _parent.PresentViewController(alert, true, null);
                        }

                        // Note: The image view will auto refresh as the photo's are being observed in the other VCs
                    });
                }
            }