Ejemplo n.º 1
0
 /// <summary>
 /// Нарисовать рыбку
 /// </summary>
 public void Draw(IDrawingControl control, Graphics graphics)
 {
     if (Renderer != null)
     {
         Renderer.Render(this, control, graphics);
     }
 }
Ejemplo n.º 2
0
        public void Render(IAquariumObject obj, IDrawingControl control, Graphics graphics)
        {
            int x = obj.X - obj.SizeX / 2;
            int y = control.InvertY(obj.Y + obj.SizeY / 2);
            int sizeX = obj.SizeX;
            int sizeY = obj.SizeY;

            Image image = GetImage(obj);
            Rectangle rectangle = new Rectangle(x, y, sizeX, sizeY);
            graphics.DrawImage(image, rectangle);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Нарисовать здоровье рыбки
        /// </summary>
        public void Render(IAquariumObject obj, IDrawingControl control, Graphics graphics)
        {
            AquariumHealthDecorator healthObj = obj as AquariumHealthDecorator;
            if (healthObj != null)
            {
                int x = obj.X - obj.SizeX / 2;
                int y = control.InvertY(obj.Y + obj.SizeY / 2);

                string health = healthObj.Health.ToString();
                Font font = SystemFonts.MenuFont;

                SizeF sizeHealth = graphics.MeasureString(health, font);
                float sizeX = sizeHealth.Width;
                float sizeY = sizeHealth.Height;

                RectangleF rectangle = new RectangleF(x, y, sizeX, sizeY);

                using (SolidBrush brush = new SolidBrush(Color.Green))
                {
                    graphics.DrawString(health, SystemFonts.MenuFont, brush, rectangle);
                }
            }
        }
        /// <summary>
        /// Нарисовать здоровье
        /// </summary>
        public override void Draw(IDrawingControl control, Graphics graphics)
        {
            base.Draw(control, graphics);

            _healthRenderer.Render(this, control, graphics);
        }
 /// <summary>
 /// Нарисовать объект
 /// </summary>
 public virtual void Draw(IDrawingControl control, Graphics graphics)
 {
     _aquariumObject.Draw(control, graphics);
 }