Ejemplo n.º 1
0
        public static GalleryImageView BuildGalleryPage(Piece piece, int index, int total, out RectangleF canvasFrame)
        {
            float width;
            float height;
            float gutter;

            GetGalleryArea(out width, out height, out gutter);

            // Background width is 1280
            var     backgroundImage = BuildGalleryBackground(Util.IsLandscape());
            UIImage background      = GetSeamlessBackgroundSlice(index, backgroundImage);
            var     imageView       = new GalleryImageView(background);   // UIImageView

            background.Dispose();
            backgroundImage.Dispose();

            // Add canvas
            UIImage canvas     = ImageCache.Get(GetImageKey(piece, width * 2, height * 2), () => GenerateGalleryPiece(piece, width * 2, height * 2));
            var     canvasView = new UIImageView(canvas);

            canvasView.Center = new PointF(width / 2, (height / 2) - gutter);
            canvasView.Layer.MasksToBounds = false;
            var canvasViewFrame = canvasView.Frame;

            canvasFrame = canvasViewFrame;

            // Add reflection
            float reflectionY = GetReflectionY();
            var   reflection  = GetOrGenerateReflection(piece, canvasViewFrame, canvas, reflectionY);

            canvas.Dispose();

            var reflectionFrame = new RectangleF(canvasViewFrame.X, reflectionY, reflection.Size.Width, reflection.Size.Height);
            var reflectionView  = new UIImageView(reflection);

            reflectionView.Frame         = reflectionFrame;
            reflectionView.Layer.Opacity = 0.30f;
            reflection.Dispose();

            // Add shadow
            var shadowY    = canvasViewFrame.Y + canvasViewFrame.Height - 10;
            var shadowView = new UIImageView(_shadowMask);

            shadowView.Frame = new RectangleF(canvasViewFrame.X, shadowY, canvasViewFrame.Width, _shadowMask.Size.Height);
            var shadowLeftView = new UIImageView(_shadowLeft);

            shadowLeftView.Frame = new RectangleF(canvasViewFrame.X - 3, canvasViewFrame.Y, 3, canvasViewFrame.Height);
            var shadowRightView = new UIImageView(_shadowRight);

            shadowRightView.Frame = new RectangleF(canvasViewFrame.X + canvasViewFrame.Width, canvasViewFrame.Y, 3, canvasViewFrame.Height);
            var shadowTopView = new UIImageView(_shadowTop);

            shadowTopView.Frame = new RectangleF(canvasViewFrame.X, canvasViewFrame.Y, canvasViewFrame.Width, _shadowTop.Size.Height);

            // Add image layers together
            imageView.AddSubview(shadowView);
            imageView.AddSubview(shadowLeftView);
            imageView.AddSubview(shadowRightView);
            imageView.AddSubview(canvasView);
            imageView.AddSubview(shadowTopView);
            imageView.AddSubview(reflectionView);

            var lighting     = BuildLighting();
            var lightingView = new LightImageView(lighting);

            lighting.Dispose();
            imageView.AddSubview(lightingView);
            imageView.Lights = lightingView;
            return(imageView);
        }
Ejemplo n.º 2
0
		public static GalleryImageView BuildGalleryPage(Piece piece, int index, int total, out RectangleF canvasFrame)
		{
			float width;
			float height;
			float gutter;				
			GetGalleryArea(out width, out height, out gutter);

			// Background width is 1280	
			var backgroundImage = BuildGalleryBackground(Util.IsLandscape());
			UIImage background = GetSeamlessBackgroundSlice(index, backgroundImage);
			var imageView = new GalleryImageView(background); // UIImageView
			background.Dispose();
			backgroundImage.Dispose();
			
			// Add canvas
			UIImage canvas = ImageCache.Get(GetImageKey(piece, width * 2, height * 2), ()=> GenerateGalleryPiece(piece, width * 2, height * 2));
			var canvasView = new UIImageView(canvas);
			canvasView.Center = new PointF(width / 2, (height / 2) - gutter);
			canvasView.Layer.MasksToBounds = false;
			var canvasViewFrame = canvasView.Frame;
			canvasFrame = canvasViewFrame;
							
			// Add reflection
			float reflectionY = GetReflectionY();			
			var reflection = GetOrGenerateReflection(piece, canvasViewFrame, canvas, reflectionY);
			canvas.Dispose();				
		
			var reflectionFrame = new RectangleF(canvasViewFrame.X, reflectionY, reflection.Size.Width, reflection.Size.Height);
			var reflectionView = new UIImageView(reflection);
			reflectionView.Frame = reflectionFrame;
			reflectionView.Layer.Opacity = 0.30f;
			reflection.Dispose();
			
			// Add shadow
			var shadowY = canvasViewFrame.Y + canvasViewFrame.Height - 10;
			var shadowView = new UIImageView(_shadowMask);
			shadowView.Frame = new RectangleF(canvasViewFrame.X, shadowY, canvasViewFrame.Width, _shadowMask.Size.Height);	
			var shadowLeftView = new UIImageView(_shadowLeft);
			shadowLeftView.Frame = new RectangleF(canvasViewFrame.X - 3, canvasViewFrame.Y, 3, canvasViewFrame.Height);			
			var shadowRightView = new UIImageView(_shadowRight);
			shadowRightView.Frame = new RectangleF(canvasViewFrame.X + canvasViewFrame.Width, canvasViewFrame.Y, 3, canvasViewFrame.Height);
			var shadowTopView = new UIImageView(_shadowTop);
			shadowTopView.Frame = new RectangleF(canvasViewFrame.X, canvasViewFrame.Y, canvasViewFrame.Width, _shadowTop.Size.Height);
			
			// Add image layers together
			imageView.AddSubview(shadowView);
			imageView.AddSubview(shadowLeftView);
			imageView.AddSubview(shadowRightView);
			imageView.AddSubview(canvasView);
			imageView.AddSubview(shadowTopView);
			imageView.AddSubview(reflectionView);
			
			var lighting = BuildLighting();
			var lightingView = new LightImageView(lighting);
			lighting.Dispose();
			imageView.AddSubview(lightingView);
			imageView.Lights = lightingView;
			return imageView;
		}