Brush Constructor Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Johnny J.

    #1

    Brush Constructor Question

    I've got an inherited control where I want the user to be able to specify a
    color property. Using that color, I'm drawing a line

    private m_UserDefinedCo lor as Color

    .....

    Dim g as Graphics=this.C reateGraphics
    Dim myPen as Pen = new Pen(m_UserDefin edColor)
    g.DrawLine(myPe n, X1, Y, X2 - 1, Y)

    Then I want to draw a triangle filled with the same color. I set the point
    and do:

    g.FillPolygon(B rushes.Red, leftTriangle);

    Because I can't figure out how to create a Brush that has the userdefined
    color.

    It's not possible to do: myBrush as Brush = new Brush(m_UserDef inedColor)

    How do you specify the Brush Color in this case?

    Cheers,

    Johnny J.


  • rowe_newsgroups

    #2
    Re: Brush Constructor Question

    On Sep 10, 11:40 am, "Johnny J." <j...@altcom.se wrote:
    I've got an inherited control where I want the user to be able to specify a
    color property. Using that color, I'm drawing a line
    >
    private m_UserDefinedCo lor as Color
    >
    ....
    >
    Dim g as Graphics=this.C reateGraphics
    Dim myPen as Pen = new Pen(m_UserDefin edColor)
    g.DrawLine(myPe n, X1, Y, X2 - 1, Y)
    >
    Then I want to draw a triangle filled with the same color. I set the point
    and do:
    >
    g.FillPolygon(B rushes.Red, leftTriangle);
    >
    Because I can't figure out how to create a Brush that has the userdefined
    color.
    >
    It's not possible to do: myBrush as Brush = new Brush(m_UserDef inedColor)
    >
    How do you specify the Brush Color in this case?
    >
    Cheers,
    >
    Johnny J.
    IIRC you have to use one of the "other" brush objects (Solid,
    Gradient, etc)

    Something like:

    Dim b As Brush = New SolidBrush(m_Us erDefinedColor)

    Thanks,

    Seth Rowe

    Comment

    • Johnny J.

      #3
      Re: Brush Constructor Question

      Thanks Seth

      That solved the problem.

      Cheers,
      Johnny J.



      "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
      news:1189439007 .979711.173700@ 57g2000hsv.goog legroups.com...
      On Sep 10, 11:40 am, "Johnny J." <j...@altcom.se wrote:
      >I've got an inherited control where I want the user to be able to specify
      >a
      >color property. Using that color, I'm drawing a line
      >>
      >private m_UserDefinedCo lor as Color
      >>
      >....
      >>
      >Dim g as Graphics=this.C reateGraphics
      >Dim myPen as Pen = new Pen(m_UserDefin edColor)
      >g.DrawLine(myP en, X1, Y, X2 - 1, Y)
      >>
      >Then I want to draw a triangle filled with the same color. I set the
      >point
      >and do:
      >>
      >g.FillPolygon( Brushes.Red, leftTriangle);
      >>
      >Because I can't figure out how to create a Brush that has the userdefined
      >color.
      >>
      >It's not possible to do: myBrush as Brush = new Brush(m_UserDef inedColor)
      >>
      >How do you specify the Brush Color in this case?
      >>
      >Cheers,
      >>
      >Johnny J.
      >
      IIRC you have to use one of the "other" brush objects (Solid,
      Gradient, etc)
      >
      Something like:
      >
      Dim b As Brush = New SolidBrush(m_Us erDefinedColor)
      >
      Thanks,
      >
      Seth Rowe
      >

      Comment

      Working...