Results 1 to 8 of 8

Thread: GDI+ questions

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    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:
    1. Public Sub DrawFigure(ByVal myFigure As Figure, ByRef g As Graphics, ByVal rotation As Integer, ByVal myPoint As Point)
    2.         Dim r As New GraphicsPath()
    3.         Dim mypen As Pen = New Drawing.Pen(Color.Black)
    4.  
    5.         'get the path
    6.         Select Case myFigure
    7.             Case Figure.ArmlessSofa
    8.                 DrawArmlessSofa(r)
    9.             Case Figure.ArmlessLove
    10.                 DrawArmlessLove(r)
    11.            ' ........



    VB Code:
    1. Private Sub DrawLAFRecLove(ByRef c As GraphicsPath)
    2.         Dim rect1 As New Rectangle(0, 0, 66, 50)
    3.         Dim rect2 As New Rectangle(10, 10, 56, 40)
    4.         Dim rect3 As New Rectangle(10, 45, 56, 5)
    5.         c.AddRectangle(rect1)
    6.         c.AddRectangle(rect2)
    7.         c.AddLine(33, 10, 33, 50)
    8.         'recfootrests
    9.         c.AddRectangle(rect3)
    10.  
    11.     End Sub
    12.     Private Sub DrawRecliner(ByRef c As GraphicsPath)
    13.         Dim rect1 As New Rectangle(0, 0, 33, 50)
    14.         Dim rect2 As New Rectangle(0, 45, 33, 5)
    15.         c.AddRectangle(rect1)
    16.         c.AddLine(0, 10, 33, 10)
    17.         c.AddRectangle(rect2)
    [/Highlight]
    Last edited by nemaroller; May 23rd, 2003 at 09:10 AM.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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>
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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.

  5. #5

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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).

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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...

  8. #8
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Good luck.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width