void AdMessages1_TouchUpInside(object sender, EventArgs e)
        {
            var ad = DataObject.Ads[0];
            var brokerPhoneNumber = ad.BrokerCellPhone;
            var smsTo             = NSUrl.FromString("sms:" + brokerPhoneNumber);

            if (UIApplication.SharedApplication.CanOpenUrl(smsTo))
            {
                //UIApplication.SharedApplication.OpenUrl(smsTo);

                //Clay Martin 1/1/18: Change app name to BuyPlane
                string textMessageBody = "Inquiry about " + ad.Name + " from GlobalAir.com BuyPlane Magazine";

                Action successCallBack = async() =>
                {
                    //Send Inquiry
                    var response = await AdInquiryResponse.AdInquiry(int.Parse(ad.ID), string.Empty, string.Empty, brokerPhoneNumber, string.Empty
                                                                     , ad.BrokerId, AdInquirySource.Text, textMessageBody);

                    if (response.Status != "Success")
                    {
                        HelperMethods.SendBasicAlert("Oops", "There was a problem sending your email to the aircraft broker. Please try again");
                    }
                };

                //try to send text message in the ap
                HelperMethods.ShowAndSendSMS(this, new string[] { brokerPhoneNumber }, textMessageBody, successCallBack);
            }
            else
            {
                var av = new UIAlertView("Not supported",
                                         "Text messaging is not supported on this device",
                                         null,
                                         "OK",
                                         null);
                av.Show();
            }
        }
Exemple #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            BtnVideoLocal.TouchUpInside += delegate
            {
                AVPlayer      Reproductor;
                AVPlayerLayer CapadeReproductor;
                AVAsset       Recurso;
                AVPlayerItem  RecursoReproducir;

                Recurso                 = AVAsset.FromUrl(NSUrl.FromFilename("VID-20180501-WA0001.mp4"));
                RecursoReproducir       = new AVPlayerItem(Recurso);
                Reproductor             = new AVPlayer(RecursoReproducir);
                CapadeReproductor       = AVPlayerLayer.FromPlayer(Reproductor);
                CapadeReproductor.Frame = new CGRect(50, 100, 300, 300);
                View.Layer.AddSublayer(CapadeReproductor);
                Reproductor.Play();
            };

            BtnVideoInternet.TouchUpInside += delegate
            {
                AVPlayer      Reproductor;
                AVPlayerLayer CapadeReproductor;
                AVAsset       Recurso;
                AVPlayerItem  RecursoReproducir;

                Recurso                 = AVAsset.FromUrl(NSUrl.FromString("https://www.youtube.com/watch?v=DEz-imekZDw"));
                RecursoReproducir       = new AVPlayerItem(Recurso);
                Reproductor             = new AVPlayer(RecursoReproducir);
                CapadeReproductor       = AVPlayerLayer.FromPlayer(Reproductor);
                CapadeReproductor.Frame = new CGRect(50, 340, 300, 300);
                View.Layer.AddSublayer(CapadeReproductor);
                Reproductor.Play();
            };

            // Perform any additional setup after loading the view, typically from a nib.
        }
Exemple #3
0
        /// <summary>
        /// Process any drag operations initialized by the user to this <see cref="AppKit.TextKit.Formatter.SourceTextView"/>.
        /// If one or more files have dragged in, the contents of those files will be copied into the document at the
        /// current cursor location.
        /// </summary>
        /// <returns><c>true</c>, if drag operation was performed, <c>false</c> otherwise.</returns>
        /// <param name="sender">The caller that initiated the drag operation.</param>
        /// <remarks>
        /// See Apple's drag and drop docs for more details (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html)
        /// </remarks>
        public override bool PerformDragOperation(NSDraggingInfo sender)
        {
            // Attempt to read filenames from pasteboard
            var plist = (NSArray)sender.DraggingPasteboard.GetPropertyListForType(NSPasteboard.NSFilenamesType);

            // Was a list of files returned from Finder?
            if (plist != null)
            {
                // Yes, process list
                for (nuint n = 0; n < plist.Count; ++n)
                {
                    // Get the current file
                    var path     = plist.GetItem <NSString> (n);
                    var url      = NSUrl.FromString(path);
                    var contents = File.ReadAllText(path);

                    // Insert contents at cursor
                    NSRange range = SelectedRange;
                    TextStorage.BeginEditing();
                    Replace(range, contents);
                    TextStorage.EndEditing();

                    // Expand range to fully encompass new content and
                    // reformat
                    range = new NSRange(range.Location, contents.Length);
                    range = Formatter.FindLineBoundries(TextStorage.Value, range);
                    Formatter.HighlightSyntaxRegion(TextStorage.Value, range);
                }

                // Inform caller of success
                return(true);
            }
            else
            {
                // No, allow base class to handle
                return(base.PerformDragOperation(sender));
            }
        }
        async Task <NSUrlRequest> CreateRequest(HttpRequestMessage request)
        {
            var stream  = Stream.Null;
            var headers = request.Headers as IEnumerable <KeyValuePair <string, IEnumerable <string> > >;

            if (request.Content != null)
            {
                stream = await request.Content.ReadAsStreamAsync().ConfigureAwait(false);

                headers = headers.Union(request.Content.Headers).ToArray();
            }

            var nsrequest = new NSMutableUrlRequest {
                AllowsCellularAccess = true,
                CachePolicy          = DisableCaching ? NSUrlRequestCachePolicy.ReloadIgnoringCacheData : NSUrlRequestCachePolicy.UseProtocolCachePolicy,
                HttpMethod           = request.Method.ToString().ToUpperInvariant(),
                Url     = NSUrl.FromString(request.RequestUri.AbsoluteUri),
                Headers = headers.Aggregate(new NSMutableDictionary(), (acc, x) => {
                    acc.Add(new NSString(x.Key), new NSString(string.Join(GetHeaderSeparator(x.Key), x.Value)));
                    return(acc);
                })
            };

            if (stream != Stream.Null)
            {
                // HttpContent.TryComputeLength is `protected internal` :-( but it's indirectly called by headers
                var length = request.Content.Headers.ContentLength;
                if (length.HasValue && (length <= MaxInputInMemory))
                {
                    nsrequest.Body = NSData.FromStream(stream);
                }
                else
                {
                    nsrequest.BodyStream = new WrappedNSInputStream(stream);
                }
            }
            return(nsrequest);
        }
Exemple #5
0
        public Task <bool> Sideload(string filePath)
        {
            var exists = NSFileManager.DefaultManager.FileExists(filePath);

            if (exists == false)
            {
                return(Task.FromResult(true));
            }

            var tcs = new TaskCompletionSource <bool>();

            var tempPath = Path.Combine(NSFileManager.DefaultManager.GetTemporaryDirectory().AbsoluteString, Guid.NewGuid().ToString());

            NSFileManager.DefaultManager.Copy(
                NSUrl.FromString(filePath.StartsWith("file://", StringComparison.OrdinalIgnoreCase) ? filePath : "file://" + filePath),
                NSUrl.FromString(tempPath),
                out var err
                );

            if (err != null)
            {
                return(Task.FromException <bool>(new Exception(err.DebugDescription)));
            }

            MGLOfflineStorage.SharedOfflineStorage.AddContentsOfURL(
                NSUrl.FromString(tempPath),
                (NSUrl fileUrl, MGLOfflinePack[] packages, NSError error) =>
            {
                if (error != null)
                {
                    tcs.TrySetException(new Exception(error.UserInfo.DebugDescription));
                    return;
                }
                tcs.TrySetResult(true);
            });

            return(tcs.Task);
        }
        void HandleSelectUpload(object sender, UIButtonEventArgs args)
        {
            this.sheet.Dismissed -= this.HandleSelectUpload;
            this.sheet            = null;

            string localFilename = args.ButtonIndex <= 3 ? GetLocalPathForImage(args.ButtonIndex + 1) : null;
            var    filename      = Path.GetFileName(localFilename);
            var    hostUrl       = NSUrl.FromString($"http://{AppDelegate.HOST_ADDRESS}:{AppDelegate.HOST_PORT}/{filename}");

            Console.WriteLine($"Host URL: {hostUrl}");

            var request = new NSMutableUrlRequest(hostUrl)
            {
                HttpMethod = "PUT"
            };

            var keys    = new object[] { "Content-Type" };
            var objects = new object[] { "image/png" };

            request.Headers = NSDictionary.FromObjectsAndKeys(objects, keys);

            this.Manager.CreateFileUpload(request, localFilename);
        }
Exemple #7
0
        protected virtual NSUrlRequest CreateRequest(TaskConfiguration config)
        {
            var url     = NSUrl.FromString(config.Uri);
            var request = new NSMutableUrlRequest(url)
            {
                HttpMethod           = config.HttpMethod,
                AllowsCellularAccess = config.UseMeteredConnection
            };

            if (!String.IsNullOrWhiteSpace(config.PostData))
            {
                request.Body = NSData.FromString(config.PostData);
            }

            foreach (var header in config.Headers)
            {
                request.Headers.SetValueForKey(
                    new NSString(header.Value),
                    new NSString(header.Key)
                    );
            }
            return(request);
        }
        public static bool CheckForLocationPermissionGranted(UIViewController vc)
        {
            if (vc == null)
            {
                return(false);
            }

            if (CoreLocation.CLLocationManager.Status != CoreLocation.CLAuthorizationStatus.AuthorizedAlways && CoreLocation.CLLocationManager.Status != CoreLocation.CLAuthorizationStatus.AuthorizedWhenInUse)
            {
                UIAlertController alertController = UIAlertController.Create(Strings.Basic.error, Strings.Permissions.location_disabled, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create(Strings.Basic.settings, UIAlertActionStyle.Default, delegate
                {
                    UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(UIApplication.OpenSettingsUrlString));
                }));
                alertController.AddAction(UIAlertAction.Create(Strings.Basic.ok, UIAlertActionStyle.Cancel, delegate
                {
                    alertController.DismissViewController(true, null);
                }));
                vc.PresentViewController(alertController, true, null);
                return(false);
            }
            return(true);
        }
Exemple #9
0
        public override async Task <bool> PrintFromURLAsync(string url, PrintJobConfiguration printJobConfiguration)
        {
            bool result = false;

            try
            {
                if (PrintFromURLAsyncSupported)
                {
                    using (NSUrl nsUrl = NSUrl.FromString(url))
                    {
                        result = await PrintObjectAsync(nsUrl, printJobConfiguration);
                    }
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception ex)
            {
                await PrintStatusReporting.ReportExceptionAsync(ex);
            }
#pragma warning restore CA1031 // Do not catch general exception types

            return(result);
        }
        public void PlayAudioFile(string fileName)
        {
            /*string sFilePath = NSBundle.MainBundle.PathForResource
             *             (Path.GetFileNameWithoutExtension(fileName), Path.GetExtension(fileName));
             * var url = NSUrl.FromString(sFilePath);
             * var _player = AVAudioPlayer.FromUrl(url);
             * _player.FinishedPlaying += (object sender, AVStatusEventArgs e) =>
             * {
             * _player = null;
             * };
             * _player.Play();*/


            string sFilePath = NSBundle.MainBundle.PathForResource
                                   (Path.GetFileNameWithoutExtension(fileName), Path.GetExtension(fileName));
            var url     = NSUrl.FromString(sFilePath);
            var _player = AVAudioPlayer.FromUrl(url);

            _player.FinishedPlaying += (object sender, AVStatusEventArgs e) => {
                _player = null;
            };
            _player.Play();
        }
Exemple #11
0
        public void StartDownload(NSUrlSession session, bool allowsCellularAccess)
        {
            using (var downloadUrl = NSUrl.FromString(Url))
                using (var request = new NSMutableUrlRequest(downloadUrl)) {
                    if (Headers != null)
                    {
                        var headers = new NSMutableDictionary();
                        foreach (var header in Headers)
                        {
                            headers.SetValueForKey(
                                new NSString(header.Value),
                                new NSString(header.Key)
                                );
                        }
                        request.Headers = headers;
                    }

                    request.AllowsCellularAccess = allowsCellularAccess;

                    Task = session.CreateDownloadTask(request);
                    Task.Resume();
                }
        }
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // create a new window instance based on the screen size
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            var props   = new NSDictionary();
            var options = new NSDictionary();

            //var url = NSBundle.MainBundle.GetUrlForResource("main", "jsbundle");
            var url = NSUrl.FromString("http://localhost:8081/index.bundle?platform=ios");

            RCTRootView rootView = new RCTRootView(url, new NSString("MyReactNativeApp"), props, options);
            var         vc       = new UIViewController();

            vc.View = rootView;

            Window.RootViewController = vc;

            // make the window visible
            Window.MakeKeyAndVisible();

            return(true);
        }
        protected virtual UIViewController ConstructDefaultViCo()
        {
            var viewController = new UIViewController();

            viewController.View.BackgroundColor = (UIColor)Theme.ColorPalette.Accent;

            var webView = new UIWebView(new CoreGraphics.CGRect(0, 0, DeviceInfo.ScreenWidth, DeviceInfo.ScreenHeight));

            webView.Opaque                            = false;
            webView.BackgroundColor                   = UIColor.Clear;
            webView.ScrollView.BackgroundColor        = UIColor.Clear;
            webView.ScrollView.ScrollEnabled          = false;
            webView.ScrollView.UserInteractionEnabled = false;
            webView.UserInteractionEnabled            = false;

            var path = NSBundle.MainBundle.PathForResource("loader", "html");

            webView.LoadRequest(NSUrlRequest.FromUrl(NSUrl.FromString(path)));

            viewController.View.AddSubview(webView);

            return(viewController);
        }
        public async Task Play()
        {
            _buffering = true;
            using (var url = NSUrl.FromString(FileName))
            {
                if (_player == null)
                {
                    _playerItem = new AVPlayerItem(url);
                    _player     = AVPlayer.FromPlayerItem(_playerItem);
                }
            }

            SetupCriticalNotifications();

            do
            {
                await Task.Delay(5);
            } while (_player.Status != AVPlayerStatus.ReadyToPlay);

            _player.Play();

            _player.AutomaticallyWaitsToMinimizeStalling = true;
        }
        /// <summary>
        /// Method Name     : BtnOptionPressed
        /// Author          : Hiren Patel
        /// Creation Date   : 29 Dec 2017
        /// Purpose         : Buttons the option pressed.
        /// Revision        :
        /// <summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Event Argument</param>
        private void BtnOptionPressed_TouchUpInside(object sender, EventArgs e)
        {
            UIButton button = sender as UIButton;
            var      tag    = button.Tag;

            switch (tag)
            {
            case 4:     //Move Details
                PerformSegue("menuMoreToMoveDetails", this);
                break;

            case 3:     //Terms
                PerformSegue("menuMoreToTerms", this);
                break;

            case 2:     //About us
                using (var encoded = new NSString(string.Format("{0}", AppConstant.ABOUT_US_URL)))
                    using (var url = NSUrl.FromString(encoded))
                    {
                        if (url != null)
                        {
                            UIApplication.SharedApplication.OpenUrl(url);
                        }
                        else
                        {
                            PerformSegue("menumoreToAboutUs", this);
                        }
                    }
                break;

            case 1:     //close
                PerformSegue("menuMoreToDashboard", this);
                hideScrollviewOption();

                break;
            }
        }
Exemple #16
0
 private async Task <string> UploadToImgur(UIImage image, CancellationToken token)
 {
     try {
         NSUrlSession session;
         session = NSUrlSession.FromConfiguration(
             NSUrlSessionConfiguration.EphemeralSessionConfiguration,
             new NSUrlSessionTaskDelegate() as INSUrlSessionDelegate,
             new NSOperationQueue()
             );
         NSUrl uploadHandleUrl       = NSUrl.FromString("https://api.imgur.com/3/image");
         NSMutableUrlRequest request = new NSMutableUrlRequest(uploadHandleUrl)
         {
             HttpMethod = "POST",
             Headers    = NSDictionary.FromObjectsAndKeys(
                 new [] { "Client-ID " + APIKeys.ImgurClientID },
                 new [] { "Authorization" }
                 )
         };
         request["Content-Type"] = "text/paint";
         var    png         = image.AsPNG();
         string base64Image = png?.GetBase64EncodedString(NSDataBase64EncodingOptions.SixtyFourCharacterLineLength);
         request.Body = $"{base64Image}";
         var dataTask            = session.CreateDataTaskAsync(request);
         var dataTaskCancellable = Task.Run(async() => await dataTask, token);
         if (await Task.WhenAny(dataTaskCancellable, Task.Delay(HttpService.TimeOut)) == dataTaskCancellable)
         {
             var    dataTaskRequest = await dataTaskCancellable;
             string result          = new NSString(dataTaskRequest.Data, NSStringEncoding.UTF8);
             Regex  reg             = new Regex("link\":\"(.*?)\"");
             Match  match           = reg.Match(result);
             return(match.ToString().Replace("link\":\"", "").Replace("\"", "").Replace("\\/", "/"));
         }
     } catch {
     }
     return(null);
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // add a basemap tiled layer.
            var url        = NSUrl.FromString("http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer");
            var tiledLayer = AGSTiledMapServiceLayer.TiledMapServiceLayerWithURL(url);

            this.MapView.AddMapLayer(tiledLayer, "Basemap Tiled Layer");

            // cloud data
            var featureLayerUrl = NSUrl.FromString("http://services.arcgis.com/oKgs2tbjK6zwTdvi/arcgis/rest/services/Major_World_Cities/FeatureServer/0");
            var featureLayer    = AGSFeatureLayer.FeatureServiceLayerWithURL(featureLayerUrl, AGSFeatureLayerMode.OnDemand);

            featureLayer.OutFields = new string[] { "*" };
            this.MapView.AddMapLayer(featureLayer, "CloudData");

            // symbology
            AGSSimpleMarkerSymbol featureSymbol = AGSSimpleMarkerSymbol.SimpleMarkerSymbolWithColor(UIColor.FromRGBA(0f, 0.46f, 0.68f, 1f));

            featureSymbol.Size  = new SizeF(7, 7);
            featureSymbol.Style = AGSSimpleMarkerSymbolStyle.Circle;
            //featureSymbol.Outline
            featureLayer.Renderer = AGSSimpleRenderer.SimpleRendererWithSymbol(featureSymbol);
        }
Exemple #18
0
        public void SetupPlayer(string sFileName)
        {
            audioSession = AVAudioSession.SharedInstance();
            var error = audioSession.SetCategory(AVAudioSessionCategory.Playback);

            if (error != null)
            {
                Console.WriteLine(error);
            }
            error = audioSession.SetActive(true);
            if (error != null)
            {
                Console.WriteLine(error);
            }

            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), sFileName);
            var    url  = NSUrl.FromString(path);

            _player        = AVAudioPlayer.FromUrl(url);
            _player.Volume = 1.0f;

            _player.FinishedPlaying += PlayerFinishedPlaying;
            _player.PrepareToPlay();
        }
 void OpenBarcodeUrl(UITapGestureRecognizer openBarcodeURLGestureRecognizer)
 {
     foreach (var metadataObjectOverlayLayer in metadataObjectOverlayLayers)
     {
         var location = openBarcodeURLGestureRecognizer.LocationInView(PreviewView);
         if (metadataObjectOverlayLayer.Path.ContainsPoint(location, false))
         {
             var barcodeMetadataObject = metadataObjectOverlayLayer.MetadataObject as AVMetadataMachineReadableCodeObject;
             if (barcodeMetadataObject != null)
             {
                 var val = barcodeMetadataObject.StringValue;
                 if (!string.IsNullOrWhiteSpace(val))
                 {
                     var url       = NSUrl.FromString(val);
                     var sharedApp = UIApplication.SharedApplication;
                     if (sharedApp.CanOpenUrl(url))
                     {
                         sharedApp.OpenUrl(url);
                     }
                 }
             }
         }
     }
 }
        protected virtual NSUrlRequest CreateRequest(TaskConfiguration config)
        {
            var url     = NSUrl.FromString(config.Uri);
            var request = new NSMutableUrlRequest(url)
            {
                HttpMethod           = config.HttpMethod,
                AllowsCellularAccess = config.UseMeteredConnection
            };

            if (!String.IsNullOrWhiteSpace(config.PostData))
            {
                request.Body = NSData.FromString(config.PostData);
            }

            if (config.Headers.Any())
            {
                request.Headers = NSDictionary.FromObjectsAndKeys(
                    config.Headers.Values.ToArray(),
                    config.Headers.Keys.ToArray()
                    );
            }

            return(request);
        }
Exemple #21
0
        public bool Tweet(string twitterName)
        {
            var name = twitterName;

            if (name.StartsWith("@"))
            {
                name = name.Substring(1);
            }
            //TODO: really should use TW or Social framework
            var scheme = "twitter://user?screen_name=" + name;
            var url    = NSUrl.FromString(scheme);

            if (UIApplication.SharedApplication.CanOpenUrl(url))
            {
                UIApplication.SharedApplication.OpenUrl(url);
            }
            else
            {
                url = NSUrl.FromString("http://twitter.com/" + Uri.EscapeDataString(name));
                UIApplication.SharedApplication.OpenUrl(url);
            }

            return(true);
        }
Exemple #22
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            _webApi = new WebApi();

            ExtensionContext.SetWidgetLargestAvailableDisplayMode(NCWidgetDisplayMode.Expanded);

            _tableView = new UITableView(View.Frame, UITableViewStyle.Plain);
            _tableView.AllowsSelection    = false;
            _tableView.SeparatorStyle     = UITableViewCellSeparatorStyle.None;
            _tableView.RowHeight          = 52;
            _tableView.EstimatedRowHeight = 52;

            _source           = new WidgetTableViewSource();
            _tableView.Source = _source;

            _tapGesutre = new UITapGestureRecognizer((obj) =>
            {
                ExtensionContext.OpenUrl(NSUrl.FromString("jp.kamusoft.sample://"), null);
            });

            View.AddGestureRecognizer(_tapGesutre);
            View.AddSubview(_tableView);
        }
Exemple #23
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (sender is VideoPlayer _formsPlayer)
            {
                if (e.PropertyName == "Url")
                {
                    _video360.UpdateWithUrl(NSUrl.FromString(_formsPlayer.Url ?? string.Empty));
                }

                if (e.PropertyName == "Play")
                {
                    if (_formsPlayer.Play)
                    {
                        Play();
                    }
                    else
                    {
                        Stop();
                    }
                }
            }
        }
        public static NSUrlRequest ToNative(this HttpTransferRequest request)
        {
            var url    = NSUrl.FromString(request.Uri);
            var native = new NSMutableUrlRequest(url)
            {
                HttpMethod           = request.HttpMethod.Method,
                AllowsCellularAccess = request.UseMeteredConnection,
            };

            if (!request.PostData.IsEmpty())
            {
                native.Body = NSData.FromString(request.PostData);
            }

            if (request.Headers.Any())
            {
                native.Headers = NSDictionary.FromObjectsAndKeys(
                    request.Headers.Values.ToArray(),
                    request.Headers.Keys.ToArray()
                    );
            }

            return(native);
        }
Exemple #25
0
        private void LoadArExperienceIfRequired()
        {
            NSUrl experienceURLValidator(string URL)
            {
                if (URL.Contains("https"))
                {
                    return(NSUrl.FromString(URL));
                }
                else
                {
                    NSUrl  relativeArExperienceURL = NSUrl.FromString(currentArExperience.Path);
                    string bundleSubdirectory      = "ARchitectExamples/" + relativeArExperienceURL.RemoveLastPathComponent().AbsoluteString;
                    NSUrl  bundleArExperienceURL   = NSBundle.MainBundle.GetUrlForResource("index", "html", bundleSubdirectory);
                    return(bundleArExperienceURL);
                }
            }

            NSUrl fullArExperienceURL = experienceURLValidator(currentArExperience.Path);

            if (loadedArExperienceNavigation == null || (loadedArExperienceNavigation != null && !loadedArExperienceNavigation.OriginalURL.Equals(fullArExperienceURL)))
            {
                loadingArExperienceNavigation = architectView.LoadArchitectWorldFromURL(fullArExperienceURL);
            }
        }
Exemple #26
0
        async Task <FileUploadResponse> MakeRequest(string uploadPath, string tag, string url, IDictionary <string, string> headers, string boundary)
        {
            var request = new NSMutableUrlRequest(NSUrl.FromString(url));

            request.HttpMethod      = "POST";
            request["Accept"]       = "*/*";
            request["Content-Type"] = "multipart/form-data; boundary=" + boundary;
            uploadCompletionSource  = new TaskCompletionSource <FileUploadResponse>();

            var sessionConfiguration = CreateSessionConfiguration(headers, $"{SessionId}{uploadPath}", boundary);

            var session = NSUrlSession.FromConfiguration(sessionConfiguration, (INSUrlSessionDelegate)this, NSOperationQueue.MainQueue);

            var uploadTask = session.CreateUploadTask(request, new NSUrl(uploadPath, false));

            uploadTask.TaskDescription = $"{tag}|{uploadPath}";
            uploadTask.Priority        = NSUrlSessionTaskPriority.High;
            uploadTask.Resume();


            var retVal = await uploadCompletionSource.Task;

            return(retVal);
        }
        // line: 78
        private NSUrl FetchServiceUrl(string linkId, NSData jsonData)
        {
            NSUrl resultUrl = null;

            try
            {
                var accessCheckoutResponse = Decoder.DecodeJson <AccessCheckoutResponse>(jsonData);
                if (accessCheckoutResponse != null)
                {
                    var serviceMap = accessCheckoutResponse.Links.Endpoints.GetValueOrDefault(linkId);
                    if (serviceMap != null)
                    {
                        resultUrl = NSUrl.FromString(serviceMap.Href);
                    }
                }
            }
            catch (Exception ex)
            {
                var json = jsonData.ToString();
                Console.WriteLine($"Error parsing JSON: {json}. Exception: {ex}");
            }

            return(resultUrl);
        }
        private ApiResult <T> ApiPostCall <T>(string action_url)
        {
            var _result = new ApiResult <T>()
            {
                success = false,
                message = "",
                result  = default(T)
            };

            try
            {
                var _request = new NSMutableUrlRequest(NSUrl.FromString($"{Constants.LionApiUrl}{action_url}"));
                _request.HttpMethod = "POST";

                var _response = (NSUrlResponse)null;
                var _error    = (NSError)null;

                var _url_data = this.ApiCallAsync(_request, ref _response, ref _error);
                if (_error != null)
                {
                    NSLogHelper.NSLog($"apiPostCall error: {_error}");
                    _result.message = _error.ToString();
                }
                else
                {
                    _result = JsonConvert.DeserializeObject <ApiResult <T> >(_url_data.ToString());
                }
            }
            catch (Exception ex)
            {
                ConfigHelper.ShowConfirm("오류", "서버가 응답하지 않습니다.\n 잠시 후 다시 시도해주시기 바랍니다.", "확인");
                _result.message = ex.ToString();
            }

            return(_result);
        }
 public void QueueFile(string fileName)
 {
     if (string.IsNullOrWhiteSpace(fileName))
     {
         return;
     }
     using (var url = NSUrl.FromString(fileName))
     {
         var asset = AVAsset.FromUrl(url);
         var playerItem = AVPlayerItem.FromAsset(asset);
         if (Player == null)
         {
             Player = AVPlayer.FromPlayerItem(playerItem);
             if (Player == null)
             {
                 return;
             }
             else
             {
                 NSNotificationCenter.DefaultCenter.AddObserver(AVPlayerItem.DidPlayToEndTimeNotification, OnPlayerDidFinishPlaying, NSObject.FromObject(playerItem));
             }
         }
     }
 }
        void SetTestFeatureLayer(int index)
        {
            this.MapView.RemoveMapLayerWithName(TestFeatureLayerName);
            var url = NSUrl.FromString(FeatureLayerUrls[0]);
            var testFeatureLayer = AGSFeatureLayer.FeatureServiceLayerWithURL(url, AGSFeatureLayerMode.OnDemand);

            testFeatureLayer.OutFields = new string[] { "*" };


            var testSymbol = new AGSSimpleMarkerSymbol(UIColor.Red)
            {
                Size  = new SizeF(30, 30),
                Style = AGSSimpleMarkerSymbolStyle.Circle
            };

            testFeatureLayer.Renderer = new AGSSimpleRenderer(testSymbol);

            //testFeatureLayer.WeakInfoTemplateDelegate = new TestInfoTemplateDelegate();
            var testInfoTemplateDelegate = new TestInfoTemplateDelegate();

            testFeatureLayer.InfoTemplateDelegate = testInfoTemplateDelegate;

            this.MapView.AddMapLayer(testFeatureLayer, TestFeatureLayerName);
        }