/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { var rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); CrossMedia.SetFlags("UwpUseNewMediaImplementation"); rootFrame.NavigationFailed += OnNavigationFailed; FFImageLoading.Forms.Platform.CachedImageRenderer.Init(); Xamarin.Forms.Forms.Init(e); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); }
// on select of Gallery private async Task galleryFunc() { #if __IOS__ var picker = new MediaPicker(); try { if (!picker.PhotosSupported) { UserDialogs.Instance.HideLoading(); UserDialogs.Instance.Alert("Photo Gallery is unavailable"); } else { var result = await picker.PickPhotoAsync(); if (result == null) { return; } else { var memoryStream = new MemoryStream(); UserDialogs.Instance.ShowLoading("Uploading Image...", MaskType.Black); result.GetStream().CopyTo(memoryStream); imageByteArray_BlaffrViewModel = memoryStream.ToArray(); } Device.BeginInvokeOnMainThread(() => { ProfilePic = ImageSource.FromStream(() => result.GetStream()); }); UIKit.UIImage image = new UIKit.UIImage(result.Path); UIKit.UIImage highres = image; Foundation.NSData d = highres.AsJPEG(0.7f); Byte[] myByteArray = new Byte[d.Length]; System.Runtime.InteropServices.Marshal.Copy(d.Bytes, myByteArray, 0, Convert.ToInt32(d.Length)); imageByteArray_BlaffrViewModel = myByteArray; var p = ImageSource.FromStream(() => result.GetStream()); await this.OnPhotoReceived(result.Path, ""); } } catch (Exception ex) { string x = ex.Message; } #endif #if __ANDROID__ var picker = new CrossMedia(); try { //if (!picker.IsLocalVoiceInteractionSupported) //{ // UserDialogs.Instance.HideLoading(); // UserDialogs.Instance.Alert("Photo Gallery is unavailable"); //} //else //{ // var result = await picker(); // if (result == null) // return; // else // { // var memoryStream = new MemoryStream(); // UserDialogs.Instance.ShowLoading("Uploading Image...", MaskType.Black); // result.GetStream().CopyTo(memoryStream); // imageByteArray_ViewModel = memoryStream.ToArray(); // } // Device.BeginInvokeOnMainThread(() => // { // imageSource = ImageSource.FromStream(() => result.GetStream()); // }); // //UIKit.UIImage image = new UIKit.UIImage(result.Path); // //var highres = image; // //var d = highres.AsJPEG(0.7f); // //Byte[] myByteArray = new Byte[d.Length]; // //System.Runtime.InteropServices.Marshal.Copy(d.Bytes, myByteArray, 0, Convert.ToInt32(d.Length)); // //imageByteArray_ViewModel = myByteArray; // //var p = ImageSource.FromStream(() => result.GetStream()); // await this.OnPhotoReceived(result.Path, ""); //} } catch (Exception ex) { string x = ex.Message; } #endif }