private void SetBackgroundView()
        {
            var image = UIImageEx.FromIdiomBundleForBackground("Images/backgrounds/leather.jpg");

            _backgroundView       = _backgroundView ?? new UIImageView();
            _backgroundView.Image = image;
            _backgroundView.Frame = View.Frame;
            _backgroundView.UserInteractionEnabled = true;
            image.Dispose();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            AppDelegate.NavigationBar.SetBackButtonOn(this);

            SetBackgroundView(Util.IsLandscape());

            if (_view != null)
            {
                _view.Dispose();
                _view = null;
            }

            // Set up our custom ScrollView
            _view = new PieceFullView(View.Bounds);
            _view.BackgroundColor                = UIColor.Clear;
            _view.AutoresizingMask               = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            _view.ShowsVerticalScrollIndicator   = false;
            _view.ShowsHorizontalScrollIndicator = false;
            _view.BouncesZoom = true;
            _view.Delegate    = new ScrollViewDelegate();

            // Added by me (snap back does not occur on device)
            _view.UserInteractionEnabled = true;
            _view.MultipleTouchEnabled   = true;
            _view.ScrollsToTop           = false;
            _view.PagingEnabled          = false;

            View.AddSubview(_view);

            // Set up the ImageView that's going inside our scroll view
            UIImage     image = UIImageEx.FromFile(_piece.Source);
            UIImageView iv    = new UIImageView(image);

            image.Dispose();

            iv.Layer.ShadowPath      = UIBezierPath.FromRect(iv.Bounds).CGPath;
            iv.Layer.ShouldRasterize = true;
            iv.Layer.MasksToBounds   = false;
            iv.Layer.ShadowColor     = UIColor.Black.CGColor;
            iv.Layer.ShadowOpacity   = 1.0f;
            iv.Layer.ShadowRadius    = 10.0f;
            iv.Layer.ShadowOffset    = new SizeF(0f, 1f);

            // Finish the ScrollView setup
            _view.ContentSize = iv.Frame.Size;
            _view.SetChildView(iv);

            _view.MaximumZoomScale = 2.0f;
            SetMinimumZoomForCurrentFrame();
            _view.SetZoomScale(_view.MinimumZoomScale, false);
        }
Beispiel #3
0
        private static UIImage BuildLighting()
        {
            var     landscape = Util.IsLandscape();
            UIImage lighting;

            if (Util.IsPhone() && landscape)
            {
                lighting = UIImage.FromBundle("Images/gallery/lighting-iphone-Landscape.png");
            }
            else
            {
                lighting = UIImageEx.FromIdiomBundleForBackground("Images/gallery/lighting.png");
            }

            return(ImageHelper.CopyAndDispose(lighting));
        }
Beispiel #4
0
        public static UIImage GeneratePieceThumbnail(string source, float w, float h, bool rounded, bool notDetailView)
        {
            // If we're using the retina display, we need to double the resolution,
            // even though when saving the image we still use 32x as the basis
            var sw = w;
            var sh = h;

            if (DimensionSet.IsRetinaDisplay)
            {
                sw *= 2f;
                sh *= 2f;
            }

            // On the iPad, the thumbnail is rendered too large as-is
            if (DimensionSet.Idiom == UIUserInterfaceIdiom.Pad && notDetailView)
            {
                sw *= 2f;
                sh *= 2f;
                w  /= 2.5f;
                h  /= 2.5f;
            }

            var image = UIImageEx.FromFile(source);             // Don't EVER bundle cache the source file!!
            var small = ImageHelper.CropResize(image, sw, sh, CropPosition.Center);

            image.Dispose();

            UIImage thumb;

            if (rounded)
            {
                var roundThumb = ImageHelper.MakeRoundCornerImage(small, 5, 5);
                thumb = ImageHelper.ImageToFitSize(roundThumb, new SizeF(w, h));
                roundThumb.Dispose();
            }
            else
            {
                thumb = ImageHelper.ImageToFitSize(small, new SizeF(w, h));
            }
            small.Dispose();
            return(thumb);
        }
Beispiel #5
0
        public static UIImage Get(string key)
        {
            if (!_images.ContainsKey(key))
            {
                var path = Path.Combine(_path, key);

                UIImage image;
                if (File.Exists(path))
                {
                    image = UIImageEx.FromFile(path);
                }
                else
                {
                    return(null);
                }

                return(image);
            }
            return(_images[key]);
        }
        private void SetBackgroundView(bool isLandscape)
        {
            if (_backgroundView != null)
            {
                _backgroundView.Image.Dispose();
                _backgroundView.Image = null;
            }

            var bg = isLandscape ? UIImageEx.FromIdiomBundleForBackground("Images/backgrounds/leather.jpg", true) :
                     UIImageEx.FromIdiomBundleForBackground("Images/backgrounds/leather.jpg", false);

            _backgroundView       = _backgroundView ?? new UIImageView(bg);
            _backgroundView.Image = bg;
            _backgroundView.Frame = new RectangleF(0, 0, bg.Size.Width, bg.Size.Height);
            _backgroundView.UserInteractionEnabled = true;
            if (_backgroundView.Superview == null)
            {
                View.Add(_backgroundView);
            }
            bg.Dispose();
        }
Beispiel #7
0
        public static UIImage Get(string key, Func <UIImage> generate)
        {
            if (!_images.ContainsKey(key))
            {
                var path = Path.Combine(_path, key);

                UIImage image;
                if (File.Exists(path))
                {
                    image = UIImageEx.FromFile(path);
                }
                else
                {
                    image = generate();
                    Save(path, image);
                }

                return(image);
            }
            return(_images[key]);
        }
Beispiel #8
0
        public static UIImage GenerateGalleryPiece(Piece piece, float width, float height)
        {
            if (Util.IsPad())
            {
                if (Util.IsLandscape())
                {
                    // iPad Landscape
                    width  = 720;
                    height = 515;
                }
                else
                {
                    // iPad Portrait
                    width  = 440;
                    height = 605;
                }
            }
            else
            {
                if (Util.IsLandscape())
                {
                    // iPhone Landscape
                    width  = 300;
                    height = 190;
                }
                else
                {
                    // iPhone Portrait
                    width  = 200;
                    height = 275;
                }
            }

            var image = UIImageEx.FromFile(piece.Source);
            var final = ImageHelper.ImageToFitSize(image, new SizeF(width, height));

            image.Dispose();
            return(final);
        }
Beispiel #9
0
        private void SetBackgroundImage()
        {
            UIImageView toDispose = null;

            if (_imageView != null)
            {
                toDispose = _imageView;
            }

            var image = UIImageEx.FromIdiomBundleForBackground(_background);             // Cached

            _imageView       = new UIImageView(image);
            _imageView.Frame = new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height);
            _imageView.UserInteractionEnabled = true;
            this.TableView.BackgroundView     = _imageView;

            if (toDispose != null)
            {
                toDispose.Image.Dispose();
                toDispose.Image = null;
                toDispose.Dispose();
                toDispose = null;
            }
        }