I need someone to make an example of how to create a graphics window in VB.net 2008.
I understand the basics of how to draw a rectangle and lines etc.
What I need is an example of how to make a window that goes in a form that does the following:
1. When the application is run, the form has a graphics area within the form (not the entire form) colored white.
2. Two text boxes (not in the graphics area) for data entry used to define the start and end of a line.
3. Three text boxes (also not in the graphics area) to define the center of a circle and the radius of the circle.
3. A button that if the text boxes have dimensions in them and the user presses the button the line and circle will be drawn in the graphics area.
4. If the dimensions of the line or circle would be beyond the graphics area, the line and circle should be drawn but they should not extend beyond the graphics area. This need to work for any object drawn in the graphics area without computing the limits of the object to fit in the area.
5. A control to set the scale of the display in the graphics area so that the user can zoom in or out.
6. A control to pan the graphics area so that the user may have a close look at small area of the graphics window. This might be done with scroll bars on the borders of a window, or mouse action in the graphics area.
The idea of this project is, I have some data that I want to draw graphs of so I need a window area to draw them in. I did some experiments using basic rectangles and lines using GDI but I found that if the graph wend outside the rectangle it just drew it on the form, so I need some help to make a window to draw in.
thankssssssss
8 3083
Are you using DirectX, or just the built in Graphics object?
If it's jsut the built in graphics object (or either I suppose?), just add a Panel control to your form and do your drawing on THAT object.
Your drawing won't go outside the bounds of the Panel object.
Are you using DirectX, or just the built in Graphics object?
If it's jsut the built in graphics object (or either I suppose?), just add a Panel control to your form and do your drawing on THAT object.
Your drawing won't go outside the bounds of the Panel object.
I m not using DirectX ,..just Graphics Object..Thank u for replying
i tried your suggestion but it is not working,After that i used picture on my form but still drawing is going beyond the area of picturebox on my form.
Well, lets see some code, if you were truely drawing on the Graphics object for the child control (panel, picturebox, etc) then the drawing should not have extended past its bounds
Well thank u for replying once again ... this is my code i had done in one of module having another form that contain picture box on which i had to draw. -
Sub Column_Draw(ByVal DrawControl As Graphics, ByVal DrawStr As String)
-
Dim NMAXX,NMAXY,NMINX,NMINY As Single
-
Dim Dc,ds As DAO.Recordset
-
Dim dss As DAO.Recordset
-
Dim X, Y As Single
-
DrawControl.ScaleTransform(-1, 1)
-
DrawControl.TranslateTransform(-20, VertLineLength + 200)
-
DrawControl.RotateTransform(180)
-
Dc = CurDb.OpenRecordset("Drawdata", DAO.RecordsetTypeEnum.dbOpenDynaset)
-
ds = CurDb.OpenRecordset("Columns", DAO.RecordsetTypeEnum.dbOpenDynaset)
-
dss = CurDb.OpenRecordset("Columns", DAO.RecordsetTypeEnum.dbOpenDynaset)
-
If Not Zoom Then
-
MaxMin(ds, NMAXX, NMAXY, NMINX, NMINY)
-
'MAX = IIf(NMAXX > NMAXY, NMAXX, NMAXY)
-
If NMAXX > NMAXY Then
-
Max1 = NMAXX
-
Else
-
Max1 = NMAXY
-
End If
-
'MIN = IIf(NMINX < NMINY, NMINX, NMINY)
-
'MIN = IIf(NMINX < NMINY, NMINX, NMINY)
-
If NMINX < NMINY Then
-
Min1 = NMINX
-
Else
-
Min1 = NMINY
-
End If
-
End If
-
ds.MoveFirst()
-
While Not (ds.EOF)
-
System.Windows.Forms.Application.DoEvents()
-
If ((ds.Fields(4).Value <> "" And ds.Fields(5).Value <> "")) Then 'Condition to bypass column whose position not defined
-
X = ds.Fields(4).Value
-
Y = ds.Fields(5).Value
-
FlushDistances(ds, X, Y)
-
If StrComp(Left(ds.Fields(0).Value, 1), "C") = 0 Then
-
Select Case ds.Fields(1).Value
-
Case "H"
-
DrawControl.DrawLine(Pens.Black, CInt(X - ds.Fields(2).Value / 2), CInt(Y - ds.Fields(3).Value / 2), CInt(X + ds.Fields(2).Value / 2), CInt(Y + ds.Fields(3).Value / 2))
-
Case "L"
-
DrawControl.DrawLine(Pens.Black, CInt(X - ds.Fields(2).Value / 2), CInt(Y - ds.Fields(3).Value / 2), CInt(X + ds.Fields(2).Value / 2), CInt(Y + ds.Fields(3).Value / 2))
-
X = ds.Fields(4).Value
-
Y = ds.Fields(5).Value
-
FlushDistancesL(ds, X, Y)
-
DrawControl.DrawLine(Pens.Black, CInt(X - ds.Fields(3).Value / 2), CInt(Y - ds.Fields(17).Value / 2), CInt(X + ds.Fields(3).Value / 2), CInt(Y + ds.Fields(17).Value / 2))
-
End Select
-
Else
-
Select Case ds.Fields(1).Value
-
Case "H"
-
DrawControl.DrawRectangle(Pens.Red, CInt(X - ds.Fields(2).Value / 2), CInt(Y - ds.Fields(3).Value / 2) - CInt(X + ds.Fields(2).Value / 2), CInt(Y + ds.Fields(3).Value / 2), B)
-
End Select
-
End If
-
If Enlarge Or Main Then
-
Column_Dis(ds.Fields(4).Value + ds.Fields(2).Value / 2, ds.Fields(5).Value - ds.Fields(3).Value / 2, ds.Fields(0).Value, DrawControl)
-
End If
-
End If
-
ds.MoveNext()
-
End While
-
CurDb.Execute(Updateqery1)
-
CurDb.Execute(Updateqery2)
-
While Not Dc.EOF
-
System.Windows.Forms.Application.DoEvents()
-
DrawControl.DrawLine(Pens.Blue, CInt(Dc.Fields(4).Value), CInt(Dc.Fields(5).Value), CInt(Dc.Fields(6).Value), CInt(Dc.Fields(7).Value))
-
Dc.MoveNext()
-
End While
-
ds.Close()
-
Dc.Close()
-
End Sub
-
now my problem is that if i give a larger value than my line goes out of bounds,i want that it remains in picture box whether value is small or large and it autosize itself according to value.
Wait are you saying that the drawn line goes out of the visible area?
I thought you were saying that it leaves the control and draws on another control.
This is an entirely different issue, you should be able to resize the control based on the input lengths of the lines you wish to draw. Just compute if your line is bigger then the control can handle, and then resize it?
Wait are you saying that the drawn line goes out of the visible area?
I thought you were saying that it leaves the control and draws on another control.
This is an entirely different issue, you should be able to resize the control based on the input lengths of the lines you wish to draw. Just compute if your line is bigger then the control can handle, and then resize it?
Yes ,that is exactly what i want to say that drawn lines goes out of visible area,
it will be very helpful for me if u can let me know how to this,also if some sample codes.thanku for replying.
Sure?
How aboue this Psuedo code:
if (myline.XLength > myDrawingArea.XLength)
{
myDrawingArea.XLength = myline.XLength + 10;
}
Sure?
How aboue this Psuedo code:
if (myline.XLength > myDrawingArea.XLength)
{
myDrawingArea.XLength = myline.XLength + 10;
}
thank you for replying....
this is difficult for me understand what this pseudo code suggest.
suppose i want to draw 2 rectangles having height and width 300 and 300 and join them by a line of 8000 obviously it will go out of bounds i.e it will be outside of visible area ,i want them within picture box no matter how much is the value .plz send some sample codes in vb.net ,
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JBiagio |
last post by:
Hello All,
I am attempting to learn a bit about the GDI+ transforms and charting data and I
feel like I'm getting a handle on how the transforms work. My chart object has a
large "canvas" bitmap...
|
by: Sanjay |
last post by:
hi,
We are currently porting our project from VB6 to VB .NET.
Earlier we used to make scale transformations on objects like pictureBox ,
forms etc.Now Such transformations are made on the...
|
by: John Bailo |
last post by:
I am walking through some of the very first sample code from the book
"Beginning .NET Game Programming" from Apress. I identify his sample
code with //SC
This code puzzles me:
Graphics graph...
|
by: Pmb |
last post by:
At the moment I'm using Borland's C++
(http://www.borland.com/products/downloads/download_cbuilder.html#)
I want to be able to take an array of points and plot them on the screen. Is
there a way...
|
by: Charles A. Lackman |
last post by:
Hello,
I have created a complete PrintDocument and need to create an image from it.
How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality...
|
by: Chris Dunaway |
last post by:
The method for printing documents in .Net can be confusing, especially
for newer users. I would like to create a way to simplify this
process. My idea would be implemented using a PrintDocument...
|
by: Xah Lee |
last post by:
Of Interest:
Introduction to 3D Graphics Programing
http://xahlee.org/3d/index.html
Currently, this introduction introduces you to the graphics format of
Mathematica, and two Java Applet...
|
by: active |
last post by:
I have an image and a graphics object created (FromImage) from that image.
I need to create a new image and create a new graphics object from the new
image.
I want the new graphics object have...
|
by: DaveL |
last post by:
hello
I have a Bit map 1367 wide 32 high
this bitmap contains like 40 separate Images
32x32
I tell it the id*32 to get the approiate Image from
the source Bitmap
When i CreateGraphics()...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |