Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - rbelknap

Pages: 1 ... 3 4 [5]
61
Open Discussion / Re: Extending ADHMI Controls
« on: October 21, 2015, 08:47:33 AM »
Your centering trick worked great.
The code is much cleaner now.

The only thing left on my wish list is to be able to change the color of the text with properties.

I would be ok with either a short list to choose from or the full color pallet.
Hopefully you have a trick for this too.

Thanks again for all of your help.
I know this thread will come in handy for any future mods I come up with.

62
Open Discussion / Re: Extending ADHMI Controls
« on: October 21, 2015, 07:41:51 AM »
See the attached for what I have so far.

I like your solution better.
I'll integrate it and go from there.

63
Open Discussion / Re: Extending ADHMI Controls
« on: October 20, 2015, 05:47:28 PM »
I was hoping to center the text on the lamp itself.

When I'm back inthe office tomorrow I will post a pic of what I have so far.

64
Open Discussion / Re: Extending ADHMI Controls
« on: October 20, 2015, 12:00:48 PM »
ok, I have the different font working with this code.

First the Property
Code: [Select]
Private m_LightColorTextFont As System.Drawing.Font = Me.Font
    Public Property LightColorTextFont As System.Drawing.Font
        Get
            Return m_LightColorTextFont
        End Get
        Set(value As System.Drawing.Font)
            m_LightColorTextFont = value
        End Set
    End Property

and changes to the onPaint routine.
Code: [Select]

    Protected Overrides Sub OnPaint(e As PaintEventArgs)
        MyBase.OnPaint(e)
        Dim myTextSize As New SizeF
        If Me.Value = True Then
            myTextSize = e.Graphics.MeasureString(LightColorOnText, LightColorTextFont)
            CenterText(myTextSize)

            e.Graphics.DrawString(LightColorOnText, LightColorTextFont, Brushes.Black, Textx, Texty)
        Else
            myTextSize = e.Graphics.MeasureString(LightColorOffText, LightColorTextFont)
            CenterText(myTextSize)

            e.Graphics.DrawString(LightColorOffText, LightColorTextFont, Brushes.Wheat, Textx, Texty)
        End If
    End Sub

65
Open Discussion / Re: Extending ADHMI Controls
« on: October 20, 2015, 09:35:27 AM »
I went a bit beyond in playing around.

Here is what I have now.
Code: [Select]

Public Class PilotLightEx
    Inherits AdvancedHMIControls.PilotLight

    Private Textx As Single
    Private Texty As Single

    Protected Overrides Sub OnPaint(e As PaintEventArgs)
        MyBase.OnPaint(e)
        Dim myTextSize As New SizeF
        If Me.Value = True Then
            myTextSize = e.Graphics.MeasureString(LightColorOnText, Me.Font)
            CenterText(myTextSize)

            e.Graphics.DrawString(LightColorOnText, Me.Font, Brushes.Black, Textx, Texty)
        Else
            myTextSize = e.Graphics.MeasureString(LightColorOffText, Me.Font)
            CenterText(myTextSize)

            e.Graphics.DrawString(LightColorOffText, Me.Font, Brushes.Wheat, Textx, Texty)
        End If
    End Sub

    Private m_LightColorOnText As String = "ON"
    Public Property LightColorOnText As String
        Get
            Return m_LightColorOnText
        End Get
        Set(value As String)
            m_LightColorOnText = value
        End Set
    End Property

    Private m_LightColorOffText As String = "Off"
    Public Property LightColorOffText As String
        Get
            Return m_LightColorOffText
        End Get
        Set(value As String)
            m_LightColorOffText = value
        End Set
    End Property

    Private Sub CenterText(txtSize As SizeF)
        If Me.LegendPlate = LegendPlates.Large Then
            Texty = ((Me.Height * 0.68)) - (txtSize.Height / 2)
        Else
            Texty = (Me.Height * 0.59) - (txtSize.Height / 2)
        End If

        Textx = (Me.Width / 2) - (txtSize.Width / 2)
    End Sub

End Class


The height Centering code is a little hokey but effective.
I tried messing with the colors, but ran into a roadblock making the properties.
I haven't played with it yet, but would like a way for the font to be different.

I'm sure you know better ways to do this, but it does work.


66
Open Discussion / Re: Extending ADHMI Controls
« on: October 20, 2015, 07:53:39 AM »
Archie,

I appreciate the help.  This worked well for a start.

Of course I'd like to make most of that into a set of properties/states.

Let me see what I can come up with and get back to you.

I realize it won't be easy, but as I've learned over the years, most things aren't.

Thanks,

Rich

67
Open Discussion / Extending ADHMI Controls
« on: October 19, 2015, 11:39:10 AM »
I'd like to add a Label to the Pilotlight Control.

When the color changes it would display a piece of text, ie Open/Close, On/Off, Up/Down, etc.

I'm developing my first ADHMI project and like the looks of the pilot light, and would be using it for various different items.

I've written a lot of VB code over the years, but very few controls, and none in quite some time.

I tried looking for instructions on something like this, but couldn't find anything similar.

Thanks.

Pages: 1 ... 3 4 [5]