dcsimg
Results 1 to 4 of 4

Thread: Line Control - Resizable/Movable at Runtime

  1. #1

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Arrow Line Control - Resizable/Movable at Runtime

    My project is similar to
    JM's Manipulating GDI+ Drawings and NickThissen's Shape Editor. I haven't used their code though, I've written my own similar code. My shapes are custom controls.

    All the shapes are working fine. But I'm having trouble with line control.

    1. I've tried my own line control. But to resize/move I need to write separate code. The common code that works for all other shapes is not working.

    2. I've tried VB Powerpack 3 Line Control,but moving/resizing it in runtime is too much complicated. It is NOT a real control. (I guess) It is directly drawn over a "ShapeContainer" control. So, i have to write custom code for this too.

    Can anyone guide me how to do this for JM's code and/or NickThissen's code ? (Or any other idea)
    (I'll PM them shortly.)

    Thanks
    Last edited by iPrank; Jun 15th, 2012 at 01:43 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  2. #2

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Line Control - Resizable/Movable at Runtime

    Additional information:
    To move/resize line control, you'll need to consider the 'Angle' too. Currently I'm using 2 small pictureboxes as resize handler and drawing/erasing (directly on an image) when user drags them.
    But I don't want that. User is not allowed to modify the background image. So, I hope if we can make it as a separate control, that will be better.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Line Control - Resizable/Movable at Runtime

    A line control would typically consist of just two control points. My shape editor is not flexible enough for that unfortunately, all its shapes have four control points on a rectangular boundary. You could fake it by creating basically a rectangle shape but instead of drawing the rectangle you draw a line from the top left to the bottom right corner. That would work for slanted lines, probably gets you into trouble for perfectly horizontal or vertical lines though...

    You'll have to generalize my shape editor code to be able to work with boundaries of any number of corners (2 for lines, 3 for triangles, 4 for rectangles / circled and more for polygons). That's probably not easy but st least you have a start :P

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,707

    Re: Line Control - Resizable/Movable at Runtime

    First things first, don't use PictureBoxes for resize handles. The ControlPaint class looks after all that sort of stuff, e.g. selection rectangles, and the DrawGrabHandle method will draw proper grab handles.

    As for the question, it's going to be tricky to create a custom control. Basically all controls are rectangular by default, hence the Bounds property being a Rectangle. You can create a custom Region in special cases, e.g. round Buttons, but if you wanted a Region that encompassed just your line and you want to be able to move just one end of the line then you'd have to change the Region as you went. Not impossible but not something I'd relish.

    If it would suit your needs, it migh be better to do what I've done in my GDI+ examples in the CodeBank, i.e. use a single container, e.g. a PictureBox, and then draw your shapes directly onto that. I think that that's pretty much how a ShapeContainer works. Presumably it is transparent too. You could perhaps create a custom container for your shapes that was also transparent.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width