Ejemplo n.º 1
0
        public static void ProcessCommand(MCSession session, Foundation.NSData data, MCPeerID peerID)
        {
            Console.WriteLine("Received command to process " + data.ToString());

            // disconnect session if needed.
            // forward to internet if available
        }
Ejemplo n.º 2
0
        public override void DidReceiveData(MCSession session, Foundation.NSData data, MCPeerID peerID)
        {
            System.Diagnostics.Debug.WriteLine("MCSessionDelegate ** DidReceiveData");
            AppDelegate.PeerHistoryMonitor[peerID.DisplayName].LastReceiveData = DateTime.UtcNow;

            DataProcessor.ProcessCommand(session, data, peerID);
        }
Ejemplo n.º 3
0
            public async Task <Byte[]> CapturePhoto(CropRatios cropRatios)
            {
                var videoConnection = StillImageOutput.ConnectionFromMediaType(AVMediaType.Video);
                var sampleBuffer    = await StillImageOutput.CaptureStillImageTaskAsync(videoConnection);

                var jpegImageAsNsData = AVCaptureStillImageOutput.JpegStillToNSData(sampleBuffer);

                UIImage imageInfo = new UIImage(jpegImageAsNsData);

                // The following code would rotate the image based on the device orientation, but currently we lock to landscape.
                //****************************************

                //UIImageOrientation? orientationToApply = null;

                //switch (GetVideoOrientationFromDevice())
                //{
                //    case AVCaptureVideoOrientation.Portrait:
                //        orientationToApply = UIImageOrientation.Right;
                //        break;
                //    case AVCaptureVideoOrientation.LandscapeLeft:
                //        orientationToApply = UIImageOrientation.Down;
                //        break;
                //    case AVCaptureVideoOrientation.LandscapeRight:
                //        orientationToApply = null;
                //        break;
                //    case AVCaptureVideoOrientation.PortraitUpsideDown:
                //        orientationToApply = UIImageOrientation.Left;
                //        break;
                //    default:
                //        break;
                //}

                //var rotatedImage = ScaleAndRotateImage(imageInfo, orientationToApply);

                //****************************************

                nfloat cropPhotoX = (nfloat)(cropRatios.LeftRatio * imageInfo.Size.Width);
                nfloat cropPhotoY = (nfloat)(cropRatios.TopRatio * imageInfo.Size.Height);

                nfloat cropPhotoWidth  = (nfloat)(imageInfo.Size.Width * (1 - (cropRatios.LeftRatio + cropRatios.RightRatio)));
                nfloat cropPhotoHeight = (nfloat)(imageInfo.Size.Height * (1 - (cropRatios.TopRatio + cropRatios.BottomRatio)));

                var croppedImage = CropImage(imageInfo, cropPhotoX, cropPhotoY, cropPhotoWidth, cropPhotoHeight);

                // Rotate after cropping since we are locking orentation to landscape. Otherwise this line should be removed.
                var rotatedImage = ScaleAndRotateImage(croppedImage, UIImageOrientation.Left);

                Byte[] imageByteArray;

                using (Foundation.NSData imageData = rotatedImage.AsPNG())
                {
                    imageByteArray = new Byte[imageData.Length];
                    System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, imageByteArray, 0, Convert.ToInt32(imageData.Length));
                }

                return(imageByteArray);
            }
            public override void EpcReceived(Foundation.NSData epc)
            {
                InvokeOnMainThread(() => {
                    var builder = new StringBuilder();
                    var buffer  = epc.Bytes;
                    var bytes   = new byte[epc.Length];
                    System.Runtime.InteropServices.Marshal.Copy(buffer, bytes, 0, bytes.Length);

                    for (UInt32 i = 0; i < bytes.Length; i++)
                    {
                        builder.Append(bytes[i].ToString("x2"));
                    }

                    this.ViewController.ReadText.Text = this.ViewController.ReadText.Text + "\n" + builder.ToString();
                });
            }
Ejemplo n.º 5
0
        public static Texture2D FromFile(GraphicsDevice graphicsDevice, Stream textureStream, int lod = 0)
        {
            Foundation.NSData nsData = Foundation.NSData.FromStream(textureStream);

            UIImage image = UIImage.LoadFromData(nsData);

            if (image == null)
            {
                throw new ContentLoadException("Error loading Texture2D Stream");
            }

            ESImage   theTexture = new ESImage(image, 1.0f, lod, graphicsDevice.PreferedFilter);
            Texture2D result     = new Texture2D(graphicsDevice, theTexture);

            return(result);
        }
        public bool MessageReceived(ushort messageId, Foundation.NSData _data)
#endif
        {
            return(Safety(() =>
            {
                byte[] data = null;
#if ANDROID
                data = _data;
#elif IOS
                data = _data.ToArray();
#endif
                logger.Log($"[R7] Packet received {messageId} -> {data.ToHexString()}");

                Debugger.Break();

                PacketReceived(this, new PacketReceivedEventArgs()
                {
                    MessageId = (short)(messageId + 10000),
                    Payload = data
                });

                return true;
            }));
        }
Ejemplo n.º 7
0
 public static NSAttributedString CreateWithRTFD(NSData rtfdData, out NSDictionary resultDocumentAttributes)
 {
     return(new NSAttributedString(rtfdData, NSAttributedStringDataType.RTFD, out resultDocumentAttributes));
 }
Ejemplo n.º 8
0
 public UnmanagedMemoryStreamWithMutableRef(NSData source) : base(source)
 {
     base_address = source.Bytes;
 }
Ejemplo n.º 9
0
 protected override void Dispose(bool disposing)
 {
     source = null;
     base.Dispose(disposing);
 }
Ejemplo n.º 10
0
 public UnmanagedMemoryStreamWithRef(NSData source) : base((byte *)source.Bytes, (long)source.Length)
 {
     this.source = source;
 }
 public virtual void SetData([Optional] NSData aData, string forKey)
 {
 }
Ejemplo n.º 12
0
        public bool CreateFile(string path, NSData data, NSFileAttributes attributes)
        {
            var dict = attributes == null ? null : attributes.ToDictionary();

            return(CreateFile(path, data, dict));
        }
Ejemplo n.º 13
0
 public void DataLoaded(NSUrlProtocol protocol, NSData data)
 {
     Messaging.void_objc_msgSend_IntPtr_IntPtr(this.Handle, Selector.GetHandle(selUrlProtocolDidLoadData_), protocol.Handle, data.Handle);
 }
 public static NSObject PropertyListWithData(NSData data, ref NSPropertyListFormat format, out NSError error)
 {
     return(PropertyListWithData(data, NSPropertyListReadOptions.Immutable, ref format, out error));
 }
Ejemplo n.º 15
0
 public static void DidReceiveMessage(GKGameSession session, string message, Foundation.NSData data, GKCloudPlayer player)
 {
 }
Ejemplo n.º 16
0
 public NSCachedURLResponse(NSURLResponse response, NSData data, Dictionary <NSObject, AnyObject> userInfo, NSURLCacheStoragePolicy storagePolicy)
 {
 }
Ejemplo n.º 17
0
 public NSCachedURLResponse(NSURLResponse response, NSData data)
 {
 }
Ejemplo n.º 18
0
 public NSData(NSData data)
 {
 }
Ejemplo n.º 19
0
 public virtual bool IsEqualToData(NSData otherData)
 {
     return(default(bool));
 }
Ejemplo n.º 20
0
 public virtual NSRange RangeOfData(NSData dataToFind, NSDataSearchOptions options, NSRange range)
 {
     return(default(NSRange));
 }
Ejemplo n.º 21
0
 public static void DidReceiveData(GKGameSession session, Foundation.NSData data, GKCloudPlayer player)
 {
 }
Ejemplo n.º 22
0
 public static NSAttributedString CreateWithHTML(NSData htmlData, out NSDictionary resultDocumentAttributes)
 {
     return(new NSAttributedString(htmlData, NSAttributedStringDataType.HTML, out resultDocumentAttributes));
 }
Ejemplo n.º 23
0
 public static void DidSaveData(GKGameSession session, GKCloudPlayer player, Foundation.NSData data)
 {
 }
Ejemplo n.º 24
0
 public static NSAttributedString CreateWithDocFormat(NSData wordDocFormat, out NSDictionary docAttributes)
 {
     return(new NSAttributedString(wordDocFormat, NSAttributedStringDataType.DocFormat, out docAttributes));
 }