JustinN Posted June 28, 2004 Posted June 28, 2004 I have 2 classes (Graphics circle, Graphics Item) Than I have a form that calls these classes and code to draw on this form. what do I need to do to use this code through out my program without using all of this code. Public Class frmdraw Inherits System.Windows.Forms.Form ' enums.... Public Enum GraphicsTools As Integer CirclePen = 0 End Enum Public Enum GraphicsSizes As Integer Small = 4 Medium = 10 Large = 20 End Enum ' members..... Public GraphicsItem As New ArrayList Public GraphicTool As GraphicsTools = GraphicsTools.CirclePen Public GraphicsSize As GraphicsSizes = GraphicsSizes.Large Public GraphicColor As Color = Color.Black ' DoMousePaint - respond to a mouse movement.... Private Sub DoMousePaint(ByVal e As MouseEventArgs) ' store the new item somewhere... Dim newItem As GraphicsItem ' what tool are you using? Select Case GraphicTool ' circlepen? Case GraphicTool.CirclePen ' create a new graphics circle... Dim circle As New GraphicsCircle circle.SetPoint(e.X, e.Y, GraphicsSize, GraphicColor, True) ' store this for addition... newItem = circle End Select ' where you given an item? If Not newItem Is Nothing Then ' add it to the list... GraphicsItem.Add(newItem) 'invalidate... Invalidate() End If End Sub Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs) ' is the button down? If e.Button = MouseButtons.Left Then DoMousePaint(e) End If End Sub Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs) ' is the button down? If e.Button = MouseButtons.Left Then DoMousePaint(e) End If End Sub Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) ' go through the list... Dim item As GraphicsItem For Each item In GraphicsItem 'ask each item to draw itself item.Draw(e.Graphics) Next End Sub Quote
JustinN Posted June 28, 2004 Author Posted June 28, 2004 Maybe im going about this all wrong. I have a small form with a textbox and an add button. The user can type in a number in the textbox and then click the add button. I want this to add the number to the database (which I already can do) and then load a form in which the user can draw on. This form needs to be linked with the number that the user ented in the textbox. so that the user can select the number later and it will bring up that form with the drawing on it. What do you think?? Quote
Leaders Iceplug Posted June 28, 2004 Leaders Posted June 28, 2004 You can declare an array of forms on your main form... or use an ArrayList to collect your forms. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Mothra Posted July 20, 2004 Posted July 20, 2004 Try having the user draw in a control in the form (a picbox perhaps) and then saving the drawing as an image in the database. Then you can have a "blank" form and load the delected "drawing" into the picture box for viewing/editing, what-have-you. Quote Being smarter than you look is always better than looking smarter than you are.
Administrators PlausiblyDamp Posted July 20, 2004 Administrators Posted July 20, 2004 You could serialize the GraphicsItem ArrayList and store that in the DB - just associate it with the number the user entered. This could then be deserialized when the form is 'loaded' from the DB - if you need to keep the items editable this should work - if you just store the resulting image then you wouldn't be able to edit the items later. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.