// draws into a bitmap which exists during runtime of the program// this is called once, when the form loads, and each time the form gets resized // m_Graphics points to the Bitmap m_BackBuffer private void repaint_buffer() { foreach(Cell c in m_Cells) { c.Draw(m_Graphics); } m_Grid.Draw(m_Graphics, 0,0 , m_NumCols-1,m_NumRows-1); m_Graphics.Flush(); } internal void UpdateSurface() { m_Surface.DrawImage(m_BackBuffer, 0,0); m_Surface.Flush(); } // the OnPaint method of the control private void FTable_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { UpdateSurface(); } // Draw Method of a Cell interior internal void Draw(Graphics g) { Pen backgrpen, forepen; if (bool_isSelected) { backgrpen = m_Pens[0]; forepen = m_Pens[1]; } else { backgrpen = m_Pens[2]; forepen = m_Pens[3]; } g.FillRectangle(backgrpen.Brush,m_Fillcoords); g.DrawString(_Text,m_Font,forepen.Brush,m_Rect,m_StringFormat); }//end Draw() // draws the grid lines. since every line segment can have an own color, // I have to draw the segments separately. internal void Draw(Graphics g, int column_start, int row_start, int column_end, int row_end) { for (int y=row_start; y <= 1 + row_end; ++y) for (int x=column_start; x < column_end; ++x) { LineSeg s = m_HorizSegs[x,y]; g.DrawLine(s.pen, s.x1,s.y1 , s.x2,s.y2); } for (int y=row_start; y <= row_end; ++y) for (int x=column_start; x < 1 + column_end; ++x) { LineSeg s = m_VertSegs[x,y]; g.DrawLine(s.pen, s.x1,s.y1 , s.x2,s.y2); } }
So, resizing is horribly slow, takes 1/4s or so,
and moving the window with one side across the screen border, you still notice some delay (jumpiness of movement), although there's done nothing more than drawing one shitty bitmap! (which has the size of the control)