Coffeehouse Thread

5 posts

Grrrr. Giving with one hand, taking with the other

Back to Forum: Coffeehouse
  • User profile image
    Andrew Davey

    <rant>
    I'm making an advanced picture box control that supports zooming and scrolling of an image. I want to do a rubber band style click-drag zoom to rectangle feature.

    OK should not be to hard. Just need to use XOR to wipe out the old rectangle then draw the new one...

    Oh wait a sec, where is the XOR setting for drawing methods of the Graphics object. Hmm, maybe it's a property... nope still can't find it. OK, google ".net graphics xor"...

    ... So anyway, it turns out the framework does NOT support any kind of altering of drawing mode. bah! So my only option now is to drop into unmanaged code and start fighting with hDCs, BitBlt and the like. Sad

    Come on Microsoft what hell is that about?!?

    I do love the .NET framework most of the time. But i get soooo mad when stuff that used to be easy (MFC had a whole object to do rubber banding in about 2 lines of code!) is suddenly a pain the a$$.

    I understand that it's a big job making one framework to rule the all - but graphics processing is quite an important bit of many apps.

    P.S. Any chance of Doc/View architecture coming back ever?
    </rant>

  • User profile image
    Andrew Davey

    After googling a bit I found this

    http://www.codeproject.com/cs/media/MixedRubberBandApp1.asp

    I'm losing track how many times CodeProject.com has saved me from hours of annoying code!

  • User profile image
    Mr.Me

    .NET does actually let you write XOR'd lines in managed code, but it doesn't call them XOR and they aren't found in the standard Graphics routines.  They are found in the System.Forms namespace in the ControlPaint class. 

    The ControlPaint class has a bunch of useful methods for building controls and hit has methods for doing XOR lines and boxes:


    [Visual Basic]
    Public Shared Sub DrawReversibleFrame( _
       ByVal rectangle As Rectangle, _
       ByVal backColor As Color, _
       ByVal style As FrameStyle _
    )

    [Visual Basic]
    Public Shared Sub DrawReversibleLine( _
       ByVal start As Point, _
       ByVal end As Point, _
       ByVal backColor As Color _
    )

    [Visual Basic]
    Public Shared Sub FillReversibleRectangle( _
       ByVal rectangle As Rectangle, _
       ByVal backColor As Color _
    )

    Hope this helps.  I've noticed that the results of the methods in the ControlPaint class are similar to the styles that the VS.NET Forms Painter uses to show resize handles, selected items, etc.

    ControlPaint Members

  • User profile image
    Andrew Davey

    OK those are fine if you only want rectangles or lines.
    However, they require having a control to paint on. What if I'm double buffering stuff on a different image, etc.

    I think we could do with the raster ops of the old GDI world.

  • User profile image
    Steve411

    "Giving with one hand, taking with the other"



    Also known as:


     "The exchange of valuable information"
                 haha

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.