/// <summary>
        /// Keeps the text view data in sync with this surface.
        /// </summary>
        protected virtual void ResetArea()
        {
            RenderRects = new Rectangle[area.Width * area.Height];
            RenderCells = new Cell[area.Width * area.Height];

            int index = 0;

            for (int y = 0; y < area.Height; y++)
            {
                for (int x = 0; x < area.Width; x++)
                {
                    RenderRects[index] = font.GetRenderRect(x, y);
                    RenderCells[index] = cells[(y + area.Top) * width + (x + area.Left)];
                    index++;
                }
            }

            // TODO: Optimization by calculating AbsArea and seeing if it's diff from current, if so, don't create new RenderRects
            AbsoluteArea = new Rectangle(0, 0, area.Width * font.Size.X, area.Height * font.Size.Y);

            if (BackbufferImage != null)
            {
                BackbufferImage.Dispose();
            }
            BackbufferImage = new Bitmap(AbsoluteArea.Width, AbsoluteArea.Height);

            if (Backbuffer != null)
            {
                Backbuffer.Dispose();
            }
            Backbuffer = Graphics.FromImage(BackbufferImage);
        }
 /// <summary>
 /// 清理所有正在使用的资源。
 /// </summary>
 /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing && (components != null))
     {
         Backbuffer.Dispose();
         components.Dispose();
     }
     base.Dispose(disposing);
 }
 public void Dispose()
 {
     if (BackbufferImage != null)
     {
         BackbufferImage.Dispose();
     }
     if (Backbuffer != null)
     {
         Backbuffer.Dispose();
     }
 }
Beispiel #4
0
        // Load and Create buffer function to handle the event
        private void ctlBreakout_Load_and_CreateBackBuffer(object sender, EventArgs e)
        {
            SoundPlayer sndVoid = new SoundPlayer(ctlBreakoutLib.Properties.Resources.Void);

            sndVoid.Play();
            var parent = this.Parent;

            while (!(parent is Form))
            {
                parent = parent.Parent;
            }
            pForm = parent as Form;;
            if (Backbuffer != null)
            {
                Backbuffer.Dispose();
            }
            Backbuffer = new Bitmap(PlayGround.Width, PlayGround.Height);
        }