Exemplo n.º 1
0
        /*
         * public Point Location2Pos(Point location)
         * {
         *  Point result = new Point();
         *  result.X = -1;
         *  result.Y = -1;
         *  int fields = (_startY * _totalCols) + _startX;
         *
         *  if ((location.X < _startX) || (location.Y < _startY) || (location.Y > _totalRows) || (location.X > _totalCols))
         *  {
         *      return result;
         *  }
         *  int picsPerLine=;
         *  result.X = fields % picsPerLine;
         *  result.Y = fields / picsPerLine;
         *
         *  if (result.Y > (_area.Height - 20) / (_zoom + 2))
         *  {
         *      result.X = -1;
         *      result.Y = -1;
         *  }
         *  return result;
         * }
         */
        /*     public void DrawPos(Graphics target, Point pos)
         *   {
         *       Image pic = ImageCache.LoadImg(_libraryFile);
         *       int rowCount = _startY, colCount = _startX;
         *       Point img = Location2Pos(pos);
         *       target.DrawImage(pic, new Rectangle(pos.X + 2, pos.Y + 2, _zoom, _zoom), new Rectangle(img.X * 32, img.Y * 32, 32, 32), GraphicsUnit.Pixel);
         *       return;
         *   } */

        public bool SelectTool(Point point)
        {
            Point start = Pos2Location(point);

            if ((start.X > -1) && (start.Y > -1))
            {
                Point tool = Pos2Location(start);
                _opener.Redraw(this, _area);
                _currentToolPos = start;
                if (_selectedCache != null)
                {
                    _selectedCache.Dispose();
                }
                _selectedCache = new Bitmap(_zoom, _zoom);
                Graphics target = Graphics.FromImage(_selectedCache);
                Bitmap   pic    = ImageCache.LoadImg(_libraryFile);



                target.DrawImage(pic, new Rectangle(0, 0, 32, 32), new Rectangle(_currentToolPos.X * 32, _currentToolPos.Y * 32, 32, 32), GraphicsUnit.Pixel);
                target.Dispose();
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Animate an actor
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="target"></param>
        public static void Animate(Direction direction, int x, int y, Graphics target)
        {
            Bitmap   _pic = new Bitmap(32, 32);
            Graphics temp = Graphics.FromImage(_pic);

            target.DrawImage(ImageCache.LoadImg("player.png"), new Rectangle(0, 0, 32, 32), new Rectangle(_phase * 32, (int)direction * 32, 32, 32), GraphicsUnit.Pixel);
            target.DrawImage(_pic, x, y);

            _phase += 1;
            if (_phase > 2)
            {
                _phase = 0;
            }
        }
Exemplo n.º 3
0
        public void Draw(Graphics target)
        {
            Brush white    = new SolidBrush(Color.White);
            Brush lavender = new SolidBrush(Color.Lavender);
            Brush red      = new SolidBrush(Color.Red);

            Pen whitePen = new Pen(white, 1);
            Pen redPen   = new Pen(red, 2);

            Font font = new Font("Segoe UI", 10);


            target.DrawString(_page.ToString() + "/" + _totalPages.ToString(), font, white, new Point(_area.Left + 4, _area.Top - 2));
            Bitmap pic = ImageCache.LoadImg(_libraryFile);
            int    rowCount = _startY, colCount = _startX;

            for (int y = _area.Top + 4; y < _area.Bottom - _zoom + 2 - 20; y += _zoom + 4)
            {
                for (int x = _area.Left + 4; x < _area.Right - _zoom + 2; x += _zoom + 4)
                {
                    if ((_markedToolPos.X == colCount) && (_markedToolPos.Y == rowCount))
                    {
                        target.FillRectangle(lavender, new Rectangle(x + 1, 20 + y + 1, _zoom + 2, _zoom + 2));
                        target.DrawRectangle(redPen, new Rectangle(x + 1, 20 + y + 1, _zoom + 2, _zoom + 2));
                    }
                    else
                    {
                        if ((_currentToolPos.X == colCount) && (_currentToolPos.Y == rowCount))
                        {
                            target.FillRectangle(white, new Rectangle(x + 1, 20 + y + 1, _zoom + 2, _zoom + 2));
                            target.DrawRectangle(redPen, new Rectangle(x + 1, 20 + y + 1, _zoom + 2, _zoom + 2));
                        }
                        else
                        {
                            target.DrawRectangle(whitePen, new Rectangle(x + 1, 20 + y + 1, _zoom + 2, _zoom + 2));
                        };
                    };
                    target.DrawImage(pic, new Rectangle(x + 2, 20 + y + 2, _zoom, _zoom), new Rectangle(colCount * 32, rowCount * 32, 32, 32), GraphicsUnit.Pixel);
                    colCount += 1;
                    if (colCount > _totalCols)
                    {
                        if (rowCount < _totalRows)
                        {
                            colCount  = 0;
                            rowCount += 1;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }
            ;
            whitePen.Dispose();
            font.Dispose();
            white.Dispose();
            red.Dispose();
            redPen.Dispose();

            lavender.Dispose();
            return;
        }