示例#1
0
文件: Draw.cs 项目: beursken/Crawler
        /// <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;
            }
        }
示例#2
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;
        }