|
-
May 23rd, 2003, 09:05 AM
#1
Thread Starter
I wonder how many charact
GDI+ questions
One of the requirements for my project includes developing a form where the user can select from a pre-defined selection of furniture configurations, and drag them to the screen. (see attached form picture).
As it stands, when the user clicks one of the labels, and then clicks on the graphics area, I send a request to a function that draws the graphics onto the screen. It basically creates a new graphics path, and runs the required drawing functions depending on the figure.
It works rather well for now (2 days into it). My goal is to be able to either serialize the graphics path or the graphic space so it can be associated with an invoice, and the figure brought back up so the sales manager can see what configuration the sales rep intended and generate the proper purchase order.
The way I look at it is this, I can save the figure in one of two ways:
1) Save it as a picture (which I'm not entirely sure can be serialized), and keep a seperate file on the server which the programs can skim through and check if a picture exists that is associated with that invoice.
2) Somehow serialize the picture or graphics path into the invoice itself ( would be preferable)...
I know you can define subpaths using markers, and then there's that graphicsIterator class, and then there's (gulp) MetaFiles....
I'm not sure which one would be best. Its not necessary that the salesmanager can edit the picture, I would just have the program clear the screen and the SalesManager could redraw it the way its supposed to be.
Any ideas... thoughts... suggestions....

So what happens is: the users clicks a button, that event changes a form-level variable to the furniture selected.
ie: myFigure = Figure.SofaRecliner
Once the user clicks on the graphics area, in that click event, I send the figure and its rotation and the graphics area to a function that Select Cases the passed figure and executes the drawing functions on a temp path...
VB Code:
Public Sub DrawFigure(ByVal myFigure As Figure, ByRef g As Graphics, ByVal rotation As Integer, ByVal myPoint As Point)
Dim r As New GraphicsPath()
Dim mypen As Pen = New Drawing.Pen(Color.Black)
'get the path
Select Case myFigure
Case Figure.ArmlessSofa
DrawArmlessSofa(r)
Case Figure.ArmlessLove
DrawArmlessLove(r)
' ........
VB Code:
Private Sub DrawLAFRecLove(ByRef c As GraphicsPath)
Dim rect1 As New Rectangle(0, 0, 66, 50)
Dim rect2 As New Rectangle(10, 10, 56, 40)
Dim rect3 As New Rectangle(10, 45, 56, 5)
c.AddRectangle(rect1)
c.AddRectangle(rect2)
c.AddLine(33, 10, 33, 50)
'recfootrests
c.AddRectangle(rect3)
End Sub
Private Sub DrawRecliner(ByRef c As GraphicsPath)
Dim rect1 As New Rectangle(0, 0, 33, 50)
Dim rect2 As New Rectangle(0, 45, 33, 5)
c.AddRectangle(rect1)
c.AddLine(0, 10, 33, 10)
c.AddRectangle(rect2)
[/Highlight]
Last edited by nemaroller; May 23rd, 2003 at 09:10 AM.
-
May 23rd, 2003, 09:12 AM
#2
you dont serialize an image, you save it as an image which is why we have .Save method of the Bitmap class
You can save it perhaps with a similar file name as your invoice, save the image and include the path name to the image in your invoice file.
preferable I would save the image and invoice as wsimilar filename, just different extensions
invoice1234.jpg
invoice1234.xml
-
May 23rd, 2003, 09:18 AM
#3
oh. just realized the rest of your question. You really need to hand code a system that creates and changes perhaps an xml file that will include what pieces have been placed and their coordinated relative to the picturebox.
ie:
<image>
<imagepiece name="Chair" x="50" y="34"/>
</image>
-
May 23rd, 2003, 09:24 AM
#4
Thread Starter
I wonder how many charact
Thanks for the response Cander.
Obviously the easiest way to implement this would be to save the file as a bitmap. In reality, this is more akin to an array of vector points.... being an array of points (GraphicsPaths), it can be serialized... it would take probably 2 days vs 1 hour of coding.
But the end result would be an array of points that is internal to my Invoice class... which is good since it leaves further development or additions easier to implement.
-
May 23rd, 2003, 09:25 AM
#5
Thread Starter
I wonder how many charact
Just read your second post... yes, it would be something akin to that... of course it would be more intensive...
I would need to implement a GraphicsPath that contains Markers to define the subpaths (the furitnure item drawing) ...
I was just wondering if anyone in these forums had attempted something similiar (CAD designs...etc).
-
May 23rd, 2003, 09:36 AM
#6
If you want to get really funky, you can look into SVG. SVG is an xml based language for creating stuff like you would in flash. The document object model should allow you to move and remove elements from it. If you want to see some stuff you can do with it, go find the SVG viewer at www.adobe.com and goto
http://www.svgelves.com/create/
Espoecially look at the Planatary System written by yours trully. 
That adobe control will allow you to right click and view source of the SVG, plus it is an OCX and can be used in VB.
It may look complex, but you really should take a look at it. Some good stuff you can do
-
May 23rd, 2003, 10:10 AM
#7
Thread Starter
I wonder how many charact
Thanks for the info Cander.... I probably won't use SVG... but it gave me a swell idea on how to make my own class that would encapsulate the graphics paths and their drawing origins...
-
May 23rd, 2003, 10:12 AM
#8
Good luck.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|