Beispiel #1
0
        public PathGridViewInternal(PathGridView parent, RectangleF frame)
            : base(frame)
        {
            this.mParent = parent;

            // -- Gestures
            // ---- Double tap to delete
            UITapGestureRecognizer tapGesture = new UITapGestureRecognizer (doubleTapEvent);
            tapGesture.NumberOfTapsRequired = 2;
            this.AddGestureRecognizer (tapGesture);
        }
Beispiel #2
0
        public PathGridViewInternal(PathGridView parent, RectangleF frame)
            : base(frame)
        {
            this.mParent = parent;

            // -- Gestures
            // ---- Double tap to delete
            UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(doubleTapEvent);

            tapGesture.NumberOfTapsRequired = 2;
            this.AddGestureRecognizer(tapGesture);
        }
Beispiel #3
0
        /// <summary>
        /// Create a UIView containing the game
        /// </summary>
        /// <returns>The grid.</returns>
        /// <param name="puzzle">Puzzle.</param>
        /// <param name="image">Image.</param>
        /// <param name="bitmap">Bitmap.</param>
        private UIView InitializeGrid(PuzzleData puzzle, UIImage image, Bitmap bitmap)
        {
            UIView view = null;

            // Here we create the real game view
            mPathGrid = new PathGridView(puzzle, (int)image.Size.Width, (int)image.Size.Height);
            mPathGrid.GridCompleted += GridCompleted;

            // Store it to prevent garbage collection
            view = mPathGrid.GridViewInternal;

            // Look at each pixel of the image
            CellColor[][] pixels = new CellColor[(int)image.Size.Width][];

            for (int x = 0; x < image.Size.Width; x++)
            {
                pixels [x] = new CellColor[(int)image.Size.Height];

                for (int y = 0; y < image.Size.Height; y++)
                {
                    // Get the pixel color
                    Color c = bitmap.GetPixel(x, y);

                    // Transform to generic color
                    pixels [x] [y] = new CellColor()
                    {
                        A = c.A / 255f,
                        R = c.R / 255f,
                        G = c.G / 255f,
                        B = c.B / 255f
                    };
                }
            }

            // Transfer pixel data to the internal grid
            this.mPathGrid.SetupGrid(pixels);

            return(view);
        }
Beispiel #4
0
 protected override void Dispose(bool disposing)
 {
     mParent = null;
     base.Dispose(disposing);
 }
Beispiel #5
0
 protected override void Dispose(bool disposing)
 {
     mParent = null;
     base.Dispose (disposing);
 }
        /// <summary>
        /// Create a UIView containing the game
        /// </summary>
        /// <returns>The grid.</returns>
        /// <param name="puzzle">Puzzle.</param>
        /// <param name="image">Image.</param>
        /// <param name="bitmap">Bitmap.</param>
        private UIView InitializeGrid(PuzzleData puzzle, UIImage image, Bitmap bitmap)
        {
            UIView view = null;

            // Here we create the real game view
            mPathGrid = new PathGridView (puzzle, (int)image.Size.Width, (int)image.Size.Height);
            mPathGrid.GridCompleted += GridCompleted;

            // Store it to prevent garbage collection
            view = mPathGrid.GridViewInternal;

            // Look at each pixel of the image
            CellColor[][] pixels = new CellColor[(int)image.Size.Width][];

            for (int x=0; x<image.Size.Width; x++) {

                pixels [x] = new CellColor[(int)image.Size.Height];

                for (int y=0; y<image.Size.Height; y++) {

                    // Get the pixel color
                    Color c = bitmap.GetPixel (x, y);

                    // Transform to generic color
                    pixels [x] [y] = new CellColor () {
                        A = c.A/255f,
                        R = c.R/255f,
                        G = c.G/255f,
                        B = c.B/255f
                    };

                }
            }

            // Transfer pixel data to the internal grid
            this.mPathGrid.SetupGrid (pixels);

            return view;
        }