Results 1 to 10 of 10

Thread: [RESOLVED] Random "notch" in my user-drawn control.

  1. #1

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Resolved [RESOLVED] Random "notch" in my user-drawn control.

    I have my control here, and when the control isn't drawing selected, it has a random notch in the border(as illustrated in the attached photo). It uses a graphics path which is generally used all around so nothing changes there. Other than the fact the control is marked "selected"(which only effects the colors).


    Here's the code that generates my graphics path...
    vbnet Code:
    1. Private ReadOnly Property gp As GraphicsPath
    2.         Get
    3.             Dim output As New GraphicsPath
    4.  
    5.             output.AddArc(New Rectangle(New Point(3, 2), New Size(20, 20)), 180, 80)
    6.             output.AddArc(New Rectangle(New Point(Me.Width - 23, 2), New Size(20, 20)), 270, 80)
    7.             output.AddLine(New Point(Me.Width - 2, Me.Height - 1), New Point(2, Me.Height - 1))
    8.             output.AddLine(New Point(2, Me.Height - 1), New Point(3, 10))
    9.  
    10.             Return output
    11.         End Get
    12. End Property

    I'm hoping someone knows why this may be occurring.. It has happened before to but never was able to solve it.
    Maybe if it was less noticeable I wouldn't care, but since the notch occurs in the middle of a dark gray section really makes it stick out like a sore thumb.
    Attached Images Attached Images  
    Last edited by DavesChillaxin; Jan 26th, 2012 at 01:08 PM.
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Random "notch" in my user-drawn control.

    Hi Daves, The first thing to try is to set the Graphics.SmoothingMode to HighQuality when you draw the path. Or are you already doing that? BB

  3. #3

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: Random "notch" in my user-drawn control.

    Quote Originally Posted by boops boops View Post
    Hi Daves, The first thing to try is to set the Graphics.SmoothingMode to HighQuality when you draw the path. Or are you already doing that? BB
    Yup... this is my code for painting.

    vbnet Code:
    1. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    2.         MyBase.OnPaint(e)
    3.  
    4.         e.Graphics.SmoothingMode = SmoothingMode.HighQuality
    5.  
    6.         Using TabGradientBrush As New LinearGradientBrush(New Point(Me.Width \ 2, 0), New Point(Me.Width \ 2, Me.Height), Me.Skin.BaseColorHigh, Me.Skin.BaseColorLow)
    7.            
    8.             e.Graphics.FillPath(TabGradientBrush, gp)
    9.             e.Graphics.DrawPath(New Pen(Color.FromArgb(255, 117, 117, 117), Me.BorderThickness), gp)
    10.  
    11.             Using FontBrush As New SolidBrush(Me.Parent.ForeColor)
    12.                 Using format As New StringFormat()
    13.                     format.LineAlignment = StringAlignment.Center
    14.                     format.Alignment = TextAlignment
    15.                     format.FormatFlags = StringFormatFlags.NoWrap
    16.  
    17.                     e.Graphics.DrawString(Me.Text, Me.Font, FontBrush, New Rectangle(10,0,Me.Width-20,Me.Height), format)
    18.                 End Using
    19.             End Using
    20.         End Using
    21.  
    22.         If Image IsNot Nothing Then
    23.             e.Graphics.DrawImage(Image, Me.Width\2-ImageSize.Width\2, Me.Height\2-ImageSize.Height\2, ImageSize.Width, ImageSize.Height)
    24.             ShowClose = False
    25.         End If
    26.  
    27.         If SelfClosing AndAlso Selected AndAlso ShowClose Then
    28.             Dim s As Size = My.Resources.close16.Size
    29.             Dim p As Point = New Point(Me.Width-(s.Width+((Me.Height-s.Height)\2)),Me.Height\2-s.Height\2)
    30.  
    31.             e.Graphics.DrawImage(My.Resources.close16, p)
    32.             CloseBounds = New Rectangle(p,s)
    33.         End If
    34.     End Sub
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  4. #4
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Random "notch" in my user-drawn control.

    try painting your tabs at an int position... instead a single/double

    Kris

  5. #5
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Random "notch" in my user-drawn control.

    @daves: The lines are clearly being drawn with anti-aliasing, so I guess there was no need to mention the SmoothingMode. GDI+ is sometimes less than perfect at anti-aliasing lines which are almost exactly vertical or horizontal, although I have never noticed gaps like the ones you are getting.

    I think you need to look at how you define the path. The length of the base line and the ends of the arcs do not quite match, so that the sides are very slightly inclined. You could adjust your arithmetic to give sides which are exactly vertical. It might help if you draw the straight sides explicitly, so that you can see where the mismatch is. Alternatively, if you actually want sides which are slightly sloping, make the slope a bit more pronounced.


    @i00: GDI+ does its antialiasing with single precision so there is normally no visible difference when the SmoothingMode is set appropriately.

    BB

    EDIT: I had to pick pieces out of the code so that I could try it out. At first I thought I could reproduce the problem but later not. Maybe I made a mistake about which smoothing mode I was using. Now it's clear that the GraphicsPath is as intended and the outline of the tab is always smooth, even when the sides are at a slight angle.

    It's a remote possibility, but I wonder whether the problem is caused by drawing the tab image after the outline. In theory, there could be some stray pixels getting in front of the outline. It would be more logical anyway to draw the image before the outline.

  6. #6

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: Random "notch" in my user-drawn control.

    You know what? I just realized this is only occurring when I'm developing on an XP system(computer at work). I just checked now and none of the tabs have that notch.. It must be it, right? Would this explain this notch?
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  7. #7
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Random "notch" in my user-drawn control.

    I'm working on XP. Sorry, no notch. But it I believe GDI+ uses hardware for antialiasing so it might depend on the graphics card. BB

  8. #8

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: Random "notch" in my user-drawn control.

    Yeah this computer really isn't that out of date per-say. We just were forced to use XP because of driver issues with our laser printer. I keep noticing though I get a lot of odd behavior when on this system I am now(The XP one). For example, when drawing arcs. Not sure why but sometimes it will have this straight line that shoots out where the curve begins. Must be something with the system. Maybe the framework is out-of-date. I highly doubt my moms upgraded this computer at all.

    Thanks for your help!
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  9. #9

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: [RESOLVED] Random "notch" in my user-drawn control.

    I actually found that my transparent key was 161,160,160. My guess isthat one pixel is that color. I use these for the aero glass effect and would explain why it's not drawing that one pixel.
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  10. #10
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: [RESOLVED] Random "notch" in my user-drawn control.

    Quote Originally Posted by DavesChillaxin View Post
    I actually found that my transparent key was 161,160,160. My guess isthat one pixel is that color. I use these for the aero glass effect and would explain why it's not drawing that one pixel.
    Grrr.

    BB

Tags for this Thread

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