public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            if (View is GLKView)
            {
                EAGLContext.SetCurrentContext(((GLKView)View).Context);
                _videoMesh = new VideoMesh(this);

                string   mediaBundlePath = NSBundle.MainBundle.BundlePath + "/media.bundle";
                NSBundle mediaBundle     = new NSBundle(mediaBundlePath);
                _videoMesh.InitMesh(mediaBundle.PathForResource("pikkart_video", "mp4"),
                                    mediaBundle.PathForResource("pikkart_keyframe", "png"), 0, false, null);
            }
            UITapGestureRecognizer tapGesture = new UITapGestureRecognizer((obj) => {
                playOrPauseVideo();
            });

            View.AddGestureRecognizer(tapGesture);

            string[] dbNames                = { "" };
            PKTCloudRecognitionInfo info    = new PKTCloudRecognitionInfo(dbNames);
            PKTRecognitionOptions   options = new PKTRecognitionOptions(PKTRecognitionStorage.PKTLOCAL,
                                                                        PKTRecognitionMode.PKTRECOGNITION_CONTINUOS_SCAN,
                                                                        info);

            ApplyCameraGlOrientation(UIApplication.SharedApplication.StatusBarOrientation);
            StartRecognition(options, this);
        }
Esempio n. 2
0
        public RedToolbar(NSCoder coder)
            : base(coder)
        {
            if (this)
            {
                TintColor = Constants.MainColor;
                UIButton infoButton = new UIButton(UIButtonType.InfoLight);
                infoButton.TouchUpInside += ShowInfo;

                UIBarButtonItem infoBarButtonItem = new UIBarButtonItem(infoButton);
                UIBarButtonItem settingsButton    = new UIBarButtonItem(new UIImage("settings.png"), UIBarButtonItemStyle.Plain, ShowSettings);
                UIBarButtonItem autoSpacer        = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

                NSBundle assetsBundle = new NSBundle(NSBundle.MainBundle.PathForResource("GDAssets", "bundle"));

                string          path          = assetsBundle.PathForResource("SECURED_GOOD_LOGO", "png");
                UIImageView     logoImageView = new UIImageView(new UIImage(path));
                UIBarButtonItem logoItem      = new UIBarButtonItem(logoImageView);

                List <UIBarButtonItem> items = new List <UIBarButtonItem> ()
                {
                    infoBarButtonItem,
                    logoItem,
                    autoSpacer,
                    settingsButton
                };

                SetItems(items.ToArray(), false);
            }
        }
        public bool InitMesh(string movieUrl, string keyFrameUrl, int seekPosition,
                             bool autoStart, PikkartVideoPlayer videoPlayerParam)
        {
            GenerateMesh();

            if (videoPlayer == null)
            {
                videoPlayer = new PikkartVideoPlayer();
            }
            else
            {
                videoPlayer = videoPlayerParam;
            }
            CGSize dims = CGSize.Empty;

            mMovieUrl = movieUrl;
            mKeyframeTexture_GL_ID = RenderUtils.LoadTextureFromFileName(keyFrameUrl, out dims);
            keyframeAspectRatio    = (float)(dims.Height / dims.Width);
            mSeekPosition          = seekPosition;
            mAutostart             = autoStart;

            string   mediaBundlePath = NSBundle.MainBundle.BundlePath + "/media.bundle";
            NSBundle mediaBundle     = new NSBundle(mediaBundlePath);

            mIconBusyTexture_GL_ID  = RenderUtils.LoadTextureFromFileName(mediaBundle.PathForResource("busy", "png"));
            mIconPlayTexture_GL_ID  = RenderUtils.LoadTextureFromFileName(mediaBundle.PathForResource("play", "png"));
            mIconErrorTexture_GL_ID = RenderUtils.LoadTextureFromFileName(mediaBundle.PathForResource("error", "png"));

            mKeyframe_Program_GL_ID = RenderUtils.CreateProgram(VERTEX_SHADER, KEYFRAME_FRAGMENT_SHADER);
            mVideo_Program_GL_ID    = RenderUtils.CreateProgram(VERTEX_SHADER, VIDEO_FRAGMENT_SHADER);
            mVideoTexture_GL_ID     = RenderUtils.CreateVideoTexture();

            if (mVideoTexture_GL_ID != 0)
            {
                videoPlayer.TextureHandle = mVideoTexture_GL_ID;
                videoPlayer.Load(movieUrl, mAutostart, seekPosition);
            }

            return(true);
        }
Esempio n. 4
0
        public static void Initialize(NSBundle mainBundle)
        {
            System.Console.WriteLine("Initialize before UIDelegate init");
            SignIn.SharedInstance.UIDelegate = CrossGoogleClient.Current as ISignInUIDelegate;
            System.Console.WriteLine("Initialize before Delegate init");
            SignIn.SharedInstance.Delegate = CrossGoogleClient.Current as ISignInDelegate;
            System.Console.WriteLine("Initialize before Google Service Dictionary init");
            var resourcePathname = mainBundle.PathForResource("GoogleService-Info", "plist");

            System.Console.WriteLine($"GoogleClientPlugin: Google Service path: {resourcePathname} ");
            var googleServiceDictionary = NSDictionary.FromFile(resourcePathname);

            System.Console.WriteLine("Initialize before Client ID init");
            SignIn.SharedInstance.ClientID = googleServiceDictionary["CLIENT_ID"].ToString();
            System.Console.WriteLine("Initialize after Client ID init");
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NSBundle bundle   = NSBundle.MainBundle;
            var      filePath = bundle.PathForResource("DataFile", "txt");

            Console.WriteLine("FilePath: {0}", filePath);

            NSData fileData = NSData.FromFile(filePath);
            var    contents = fileData.ToString(NSStringEncoding.UTF8);

            Console.WriteLine("Contents: {0}", contents);

            sendButton.Clicked += SendButton_Clicked;
            textView.Text       = contents;

            NSNotificationCenter.DefaultCenter.AddObserver(new NSString("openFileForEdit"), HandleFileForEditNotification, (NSObject)this);
            NSNotificationCenter.DefaultCenter.AddObserver(new NSString("kShowServiceAlert"), HandleShowServiceAlertError, (NSObject)this);
        }
Esempio n. 6
0
        //#pragma mark - Accessing keyboard images.

        public UIImage _keyboardImageNamed(string name)
        {
            string resource  = new NSString(name).DeletePathExtension();
            string extension = new NSString(name).PathExtension;

            if (resource != null)
            {
                NSBundle bundle = NSBundle.FromClass(this.Class);
                if (bundle != null)
                {
                    string resourcePath = bundle.PathForResource(resource, /*ofType*/ extension);

                    return(UIImage.FromFile(resourcePath));
                }
                else
                {
                    return(UIImage.FromBundle(name));
                }
            }
            return(null);
        }
        public virtual async Task <Tuple <Stream, LoadingResult, ImageInformation> > Resolve(string identifier, TaskParameter parameters, CancellationToken token)
        {
            NSBundle bundle       = null;
            var      filename     = Path.GetFileNameWithoutExtension(identifier);
            var      tmpPath      = Path.GetDirectoryName(identifier).Trim('/');
            var      filenamePath = string.IsNullOrWhiteSpace(tmpPath) ? null : tmpPath + "/";

            foreach (var fileType in fileTypes)
            {
                string file      = null;
                var    extension = Path.HasExtension(identifier) ? Path.GetExtension(identifier) : string.IsNullOrWhiteSpace(fileType) ? string.Empty : "." + fileType;

                token.ThrowIfCancellationRequested();

                int scale = (int)ScaleHelper.Scale;
                if (scale > 1)
                {
                    while (scale > 1)
                    {
                        token.ThrowIfCancellationRequested();

                        var tmpFile = string.Format("{0}@{1}x{2}", filename, scale, extension);
                        bundle = NSBundle._AllBundles.FirstOrDefault(bu =>
                        {
                            var path = string.IsNullOrWhiteSpace(filenamePath) ?
                                       bu.PathForResource(tmpFile, null) :
                                       bu.PathForResource(tmpFile, null, filenamePath);
                            return(!string.IsNullOrWhiteSpace(path));
                        });

                        if (bundle != null)
                        {
                            file = tmpFile;
                            break;
                        }
                        scale--;
                    }
                }

                token.ThrowIfCancellationRequested();

                if (file == null)
                {
                    var tmpFile = string.Format(filename + extension);
                    file   = tmpFile;
                    bundle = NSBundle._AllBundles.FirstOrDefault(bu =>
                    {
                        var path = string.IsNullOrWhiteSpace(filenamePath) ?
                                   bu.PathForResource(tmpFile, null) :
                                   bu.PathForResource(tmpFile, null, filenamePath);

                        return(!string.IsNullOrWhiteSpace(path));
                    });
                }

                token.ThrowIfCancellationRequested();

                if (bundle != null)
                {
                    string path = !string.IsNullOrEmpty(filenamePath) ? bundle.PathForResource(file, null, filenamePath) : bundle.PathForResource(file, null);

                    var stream           = FileStore.GetInputStream(path, true);
                    var imageInformation = new ImageInformation();
                    imageInformation.SetPath(identifier);
                    imageInformation.SetFilePath(path);

                    return(new Tuple <Stream, LoadingResult, ImageInformation>(
                               stream, LoadingResult.CompiledResource, imageInformation));
                }

                token.ThrowIfCancellationRequested();

                if (string.IsNullOrEmpty(fileType))
                {
                    //Asset catalog
                    NSDataAsset asset = null;

                    try
                    {
                        await MainThreadDispatcher.Instance.PostAsync(() => asset = new NSDataAsset(filename)).ConfigureAwait(false);
                    }
                    catch (Exception) { }

                    if (asset != null)
                    {
                        token.ThrowIfCancellationRequested();
                        var stream           = asset.Data?.AsStream();
                        var imageInformation = new ImageInformation();
                        imageInformation.SetPath(identifier);
                        imageInformation.SetFilePath(null);

                        return(new Tuple <Stream, LoadingResult, ImageInformation>(
                                   stream, LoadingResult.CompiledResource, imageInformation));
                    }


                    NSImage image = null;

                    try
                    {
                        await MainThreadDispatcher.Instance.PostAsync(() => image = NSImage.ImageNamed(filename)).ConfigureAwait(false);
                    }
                    catch (Exception) { }

                    if (image != null)
                    {
                        token.ThrowIfCancellationRequested();
                        var imageRep = new NSBitmapImageRep(image.AsTiff());
                        var stream   = imageRep.RepresentationUsingTypeProperties(NSBitmapImageFileType.Png)
                                       .AsStream();
                        //var stream = image.AsPNG()?.AsStream();
                        var imageInformation = new ImageInformation();
                        imageInformation.SetPath(identifier);
                        imageInformation.SetFilePath(null);

                        return(new Tuple <Stream, LoadingResult, ImageInformation>(
                                   stream, LoadingResult.CompiledResource, imageInformation));
                    }
                }
            }

            throw new FileNotFoundException(identifier);
        }
        public virtual async Task <Tuple <Stream, LoadingResult, ImageInformation> > Resolve(string identifier, TaskParameter parameters, CancellationToken token)
        {
            NSBundle bundle       = null;
            var      filename     = Path.GetFileNameWithoutExtension(identifier);
            var      tmpPath      = Path.GetDirectoryName(identifier).Trim('/');
            var      filenamePath = string.IsNullOrWhiteSpace(tmpPath) ? null : tmpPath + "/";

            foreach (var fileType in fileTypes)
            {
                string file      = null;
                var    extension = Path.HasExtension(identifier) ? Path.GetExtension(identifier) : string.IsNullOrWhiteSpace(fileType) ? string.Empty : "." + fileType;

                token.ThrowIfCancellationRequested();

                int scale = (int)ScaleHelper.Scale;
                if (scale > 1)
                {
                    while (scale > 1)
                    {
                        token.ThrowIfCancellationRequested();

                        var tmpFile = string.Format("{0}@{1}x{2}", filename, scale, extension);
                        bundle = NSBundle._AllBundles.FirstOrDefault(bu =>
                        {
                            var path = string.IsNullOrWhiteSpace(filenamePath) ?
                                       bu.PathForResource(tmpFile, null) :
                                       bu.PathForResource(tmpFile, null, filenamePath);
                            return(!string.IsNullOrWhiteSpace(path));
                        });

                        if (bundle != null)
                        {
                            file = tmpFile;
                            break;
                        }
                        scale--;
                    }
                }

                token.ThrowIfCancellationRequested();

                if (file == null)
                {
                    var tmpFile = string.Format(filename + extension);
                    file   = tmpFile;
                    bundle = NSBundle._AllBundles.FirstOrDefault(bu =>
                    {
                        var path = string.IsNullOrWhiteSpace(filenamePath) ?
                                   bu.PathForResource(tmpFile, null) :
                                   bu.PathForResource(tmpFile, null, filenamePath);

                        return(!string.IsNullOrWhiteSpace(path));
                    });
                }

                token.ThrowIfCancellationRequested();

                if (bundle != null)
                {
                    string path = !string.IsNullOrEmpty(filenamePath) ? bundle.PathForResource(file, null, filenamePath) : bundle.PathForResource(file, null);

                    var stream           = FileStore.GetInputStream(path, true);
                    var imageInformation = new ImageInformation();
                    imageInformation.SetPath(identifier);
                    imageInformation.SetFilePath(path);

                    return(new Tuple <Stream, LoadingResult, ImageInformation>(
                               stream, LoadingResult.CompiledResource, imageInformation));
                }

                token.ThrowIfCancellationRequested();

                if (string.IsNullOrEmpty(fileType))
                {
                    //Asset catalog
                    bool tryAssetsCatalog = true;
#if __IOS__
                    if (!UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
                    {
                        tryAssetsCatalog = false;
                    }
#endif
                    if (tryAssetsCatalog)
                    {
                        NSDataAsset asset = null;

                        try
                        {
                            await ImageService.Instance.Config.MainThreadDispatcher.PostAsync(() => asset = new NSDataAsset(filename)).ConfigureAwait(false);
                        }
                        catch (Exception) { }

                        if (asset != null)
                        {
                            token.ThrowIfCancellationRequested();
                            var stream           = asset.Data?.AsStream();
                            var imageInformation = new ImageInformation();
                            imageInformation.SetPath(identifier);
                            imageInformation.SetFilePath(null);

                            return(new Tuple <Stream, LoadingResult, ImageInformation>(
                                       stream, LoadingResult.CompiledResource, imageInformation));
                        }
                    }

                    PImage image = null;

                    try
                    {
#if __IOS__
                        await ImageService.Instance.Config.MainThreadDispatcher.PostAsync(() => image = PImage.FromBundle(filename)).ConfigureAwait(false);
#elif __MACOS__
                        await ImageService.Instance.Config.MainThreadDispatcher.PostAsync(() => image = NSImage.ImageNamed(filename)).ConfigureAwait(false);
#endif
                    }
                    catch (Exception) { }

                    if (image != null)
                    {
                        token.ThrowIfCancellationRequested();

                        var stream = image.AsPngStream();

                        var imageInformation = new ImageInformation();
                        imageInformation.SetPath(identifier);
                        imageInformation.SetFilePath(null);

                        return(new Tuple <Stream, LoadingResult, ImageInformation>(
                                   stream, LoadingResult.CompiledResource, imageInformation));
                    }
                }
            }

            throw new FileNotFoundException(identifier);
        }
        public virtual async Task <Tuple <Stream, LoadingResult, ImageInformation> > Resolve(string identifier, TaskParameter parameters, CancellationToken token)
        {
            NSBundle     bundle    = null;
            string       file      = null;
            var          filename  = Path.GetFileNameWithoutExtension(identifier);
            var          extension = Path.GetExtension(identifier);
            const string pattern   = "{0}@{1}x{2}";

            foreach (var fileType in fileTypes)
            {
                token.ThrowIfCancellationRequested();

                int scale = (int)ScaleHelper.Scale;
                if (scale > 1)
                {
                    while (scale > 1)
                    {
                        token.ThrowIfCancellationRequested();

                        var tmpFile = string.Format(pattern, filename, scale, extension);
                        bundle = NSBundle._AllBundles.FirstOrDefault(bu =>
                        {
                            var path = bu.PathForResource(tmpFile, fileType);
                            return(!string.IsNullOrWhiteSpace(path));
                        });

                        if (bundle != null)
                        {
                            file = tmpFile;
                            break;
                        }
                        scale--;
                    }
                }

                token.ThrowIfCancellationRequested();

                if (file == null)
                {
                    file   = identifier;
                    bundle = NSBundle._AllBundles.FirstOrDefault(bu =>
                    {
                        var path = bu.PathForResource(file, fileType);
                        return(!string.IsNullOrWhiteSpace(path));
                    });
                }

                token.ThrowIfCancellationRequested();

                if (bundle != null)
                {
                    var path = bundle.PathForResource(file, fileType);

                    var stream           = FileStore.GetInputStream(path, true);
                    var imageInformation = new ImageInformation();
                    imageInformation.SetPath(identifier);
                    imageInformation.SetFilePath(path);

                    return(new Tuple <Stream, LoadingResult, ImageInformation>(
                               stream, LoadingResult.CompiledResource, imageInformation));
                }
            }

            //Asset catalog
            token.ThrowIfCancellationRequested();

            if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
            {
                NSDataAsset asset = null;

                try
                {
                    await MainThreadDispatcher.Instance.PostAsync(() => asset = new NSDataAsset(filename)).ConfigureAwait(false);
                }
                catch (Exception) { }

                if (asset != null)
                {
                    token.ThrowIfCancellationRequested();
                    var stream           = asset.Data?.AsStream();
                    var imageInformation = new ImageInformation();
                    imageInformation.SetPath(identifier);
                    imageInformation.SetFilePath(null);

                    return(new Tuple <Stream, LoadingResult, ImageInformation>(
                               stream, LoadingResult.CompiledResource, imageInformation));
                }
            }
            else if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                UIImage image = null;

                try
                {
                    await MainThreadDispatcher.Instance.PostAsync(() => image = UIImage.FromBundle(filename)).ConfigureAwait(false);
                }
                catch (Exception) { }

                if (image != null)
                {
                    token.ThrowIfCancellationRequested();
                    var stream           = image.AsPNG()?.AsStream();
                    var imageInformation = new ImageInformation();
                    imageInformation.SetPath(identifier);
                    imageInformation.SetFilePath(null);

                    return(new Tuple <Stream, LoadingResult, ImageInformation>(
                               stream, LoadingResult.CompiledResource, imageInformation));
                }
            }

            throw new FileNotFoundException(identifier);
        }