How to adjust size of a graphics buffer

  • Thread starter Thread starter Les2011
  • Start date Start date
L

Les2011

Guest
First let me thank all who have helped me with this issue and also the links that I find very helpful.

What I have done so far in code is as follows:

Imports System.Drawing.Drawing2D
Imports System.Drawing

Public Class Form1
Dim backbuffer As New Bitmap(309, 175)

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim g As Graphics
g = Graphics.FromImage(backbuffer)
g.Clear(Color.White)
g.DrawRectangle(Pens.Blue, New Rectangle(New Point(0, 0), New Size(100, 100)))
Dim tag As String = "f(x)=12x^2-8x+2"
g.DrawString(tag, New Font("Calibri", 36, FontStyle.Regular), New SolidBrush(Color.Black), New Point)
PictureBox1.CreateGraphics.DrawImage(backbuffer, New Point(0, 0))
End Sub


What I have is a picturebox contained inside of a panel which has the scrollbars set on. Initially I want the picturebox to fit inside the panel along all four edges. Then I want to generate lines of equations of all differnet lengths and I will keep track of the longest line of the equation and do the same with tracking the hit of the final line of the equation. Once this is done I want to set my width of the picturebox, in code, to the width of the longest equation line and once it is any larger then the panel the panel will display the scrollbars so we can see the eqautions. Also I need to make sure the image stays visible when you scroll it. Since I thnk I can do the graphics initially I am still stuck on the graphics buffer part. I do not want to have excess buffer but only want to use enough to support the longest equation line. What I was thinking is I could over design the buffer then after that since I will pnow then what the widest point is somehow to resize the buffer if possible so that when I scroll the image I will not have any extra blank space in the panel. Where I have a problem is it seems according to my code that I need to Dim my buffersize before doing any of the graphics andthis is where the problem is. If somehow I can determine the exact size of the buffer I need and then set that up and then draw my equations I think I would be a very happy camper. <S> In the past Reed and TTT and others have provided me some good starting points but now I need some more direction.

ps I had a similar post in the previous post but I noticed most people I think my desire for help is over and thinking that any other questions you have need to be posted as a new category.

Thanks all of you,

Les

Continue reading...
 
Back
Top