Esempio n. 1
0
        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
        {
            var tabController = Window.RootViewController as UINavigationController;

            if (AppSettings.User.IsAuthenticated)
            {
                var urlCollection = url.ToString().Replace("steepshot://", string.Empty);
                var nsFileManager = new NSFileManager();
                var imageData     = nsFileManager.Contents(urlCollection);
                var sharedPhoto   = UIImage.LoadFromData(imageData);

                var inSampleSize = ImageHelper.CalculateInSampleSize(sharedPhoto.Size, Core.Constants.PhotoMaxSize, Core.Constants.PhotoMaxSize);
                var deviceRatio  = UIScreen.MainScreen.Bounds.Width / UIScreen.MainScreen.Bounds.Height;
                var x            = ((float)inSampleSize.Width - Core.Constants.PhotoMaxSize * (float)deviceRatio) / 2f;

                sharedPhoto = ImageHelper.CropImage(sharedPhoto, 0, 0, (float)inSampleSize.Width, (float)inSampleSize.Height, inSampleSize);
                var descriptionViewController = new DescriptionViewController(new List <Tuple <NSDictionary, UIImage> >()
                {
                    new Tuple <NSDictionary, UIImage>(null, sharedPhoto)
                }, "jpg");
                tabController.PushViewController(descriptionViewController, false);
            }
            else
            {
                tabController.PushViewController(new WelcomeViewController(), false);
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Opens and parses the BVH file at the specifie path.
        /// </summary>
        public BVH(string path)
        {
            var fm = new NSFileManager();

            if (path == null || !fm.FileExists(path))
            {
                throw new Exception($"Could not find file '{Path.GetFileName(path)}'.");
            }
            var data     = fm.Contents(path);
            var contents = new NSString(data, NSStringEncoding.UTF8).ToString();
            var lines    = contents.Split(new[] { Environment.NewLine, "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);

            var lineCounter = 1;             // start with first line of hierarchy, which should be ROOT

            while (true)
            {
                Roots.Add(ParseNode(lines, ref lineCounter));
                lineCounter++;
                if (!lines[lineCounter].TrimStart(' ').StartsWith("ROOT", StringComparison.InvariantCulture))
                {
                    break;
                }
            }

            if (!string.Equals(lines[lineCounter], "MOTION"))
            {
                throw new Exception($"Expected MOTION but encountered invalid line: {lines[lineCounter]}");
            }

            lineCounter  += 2;            // skip the "Frames: x" line and get "Frame Time: y"
            FrameTimeSecs = double.Parse(lines[lineCounter].Split('\t')[1]);

            lineCounter++;
            for (; lineCounter < lines.Length; lineCounter++)
            {
                var motions = lines[lineCounter]
                              .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                              .Select(double.Parse).ToList();
                for (var i = 0; i < motions.Count; i++)
                {
                    _channels.ElementAt(i).Key.Motions.Add(motions[i]);
                }
            }
        }
Esempio n. 3
0
        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
        {
            var tabController = Window.RootViewController as UINavigationController;

            Task.Delay(500).ContinueWith(_ => InvokeOnMainThread(() =>
            {
                if (BasePresenter.User.IsAuthenticated)
                {
                    var urlCollection = url.ToString().Replace("steepshot://", string.Empty).Split('%');
                    var nsFileManager = new NSFileManager();
                    var imageData     = nsFileManager.Contents(urlCollection[0]);
                    var sharedPhoto   = UIImage.LoadFromData(imageData);
                    //TODO:KOA: Test System.IO.Path.GetExtension(urlCollection[0] expected something like .jpg / .gif etc.
                    var descriptionViewController = new DescriptionViewController(sharedPhoto, System.IO.Path.GetExtension(urlCollection[0]));
                    tabController.PushViewController(descriptionViewController, true);
                }
                else
                {
                    var preLoginViewController = new PreLoginViewController();
                    tabController.PushViewController(preLoginViewController, true);
                }
            }));
            return(true);
        }