Author Topic: BarLevel Value Alignment question and position click keypad  (Read 2918 times)

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
BarLevel Value Alignment question and position click keypad
« on: December 12, 2018, 01:39:03 AM »
Hi,

is it possible to align shown value of BarLevel form to center of BarLevel, instead of right by default? My fill direction is set to right.

« Last Edit: December 15, 2018, 02:05:11 AM by betilly »

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: BarLevel Value Alignment question
« Reply #1 on: December 12, 2018, 07:02:24 AM »

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question
« Reply #2 on: December 12, 2018, 08:13:30 AM »
Thanks that is what i need. But that modification seem that if  you set fill to right, u cant change CenterValue to False again and vica versa, it is always True.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: BarLevel Value Alignment question
« Reply #3 on: December 12, 2018, 09:06:15 AM »
I tried it with version 3.99y Beta and it works when setting CenterValue to True and FillDirection to Right

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question
« Reply #4 on: December 12, 2018, 01:07:45 PM »
I have done project with 3.99x i think, i ll try update to 3.99y. But in version 3.99x looks like only when fill to right cant change align, all other options up,down works

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question
« Reply #5 on: December 13, 2018, 05:46:14 AM »
I had trouble with errors when i try to upgrade to latest AHMI version so i just changed code from BarLevelEx, delete line 69 and change  to
Code: [Select]
If m_CenterValue <> value Then
                m_CenterValue = value
                Invalidate()
            End If
now its working like a charm.
Thanks for help.

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question
« Reply #6 on: December 14, 2018, 11:15:56 AM »
Maybe this question doesnt belong in this topic, i wanna extended that when i mouse click on my BarLevel, keypad pop up and i could write to holding register. I add the code  to BarLevel, like one of post from Archi says.
What about if i  wanna click on left half of BarLevel and write to register"1" and when i click on right half of BarLevel write to register"2". Any form from AHMI which can do that? Or i must track mouse position, and  then in click handler do the job?

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #7 on: December 15, 2018, 03:06:53 PM »
Finally get it done about BarLevel click position.

Code: [Select]
Private Sub BarLevel3_MouseClick(sender As Object, e As MouseEventArgs) Handles BarLevel3.MouseClick

        kordinatax = e.X

        If kordinatax < (Var(3) / 2) Then
            BarLevel3.KeypadText = "xxxxxx"
            BarLevel3.PLCAddressKeypad = "D12000"

        ElseIf kordinatax > (Var(3) / 2) Then
            BarLevel3.KeypadText = "yyyyyy"
            BarLevel3.PLCAddressKeypad = "D12001"

        End If

Entry from keypad write in right register, but when the keypad pop up on screen the keypad text is from previous click. Any suggestions?

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #8 on: December 15, 2018, 11:31:13 PM »
Maybe try adding a line of code to the KeypadText property, to look like this:

Code: [Select]
    Public Property KeypadText() As String
        Get
            Return m_KeypadText
        End Get
        Set(ByVal value As String)
            m_KeypadText = value
            If KeypadPopUp IsNot Nothing Then KeypadPopUp.Invalidate()
        End Set
    End Property

I haven't tried it but it might work.

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #9 on: December 16, 2018, 01:42:44 AM »
I tried with adding a suggested code, but it didnt work, still the same.

Phrog30

  • Guest
Re: BarLevel Value Alignment question and position click keypad
« Reply #10 on: December 16, 2018, 09:11:29 AM »
From the previous click? So what is there when running for the first time?

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #11 on: December 16, 2018, 09:48:38 AM »
Maybe i didnt say correctly in previous post. When i start solution, when first time BarLevel is clicked text is displayed as you set under BarLevel properties keypadtext, or if you leave blank, nothing is displayed. The next time when BarLevel is clicked ,if clicked on left side of the BarLevel first time it displayed xxxxx, if on the right side it displayed yyyyy.

Phrog30

  • Guest
Re: BarLevel Value Alignment question and position click keypad
« Reply #12 on: December 16, 2018, 10:28:46 AM »
Ok, so you need to dig into the code for the keypadtext property to see how it's currently being handled. I think godra was on the right track.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #13 on: December 16, 2018, 12:12:20 PM »
What you are doing is completely custom and you need to modify the OnClick sub to look similar to this:

Code: [Select]
    '***********************************************************
    '* If label is clicked, pop up a keypad for data entry
    '***********************************************************
    Protected Overrides Sub OnClick(e As System.EventArgs)
        MyBase.OnClick(e)

        Dim ex As MouseEventArgs = e

        Dim kordinatax = ex.X

        If kordinatax < (Me.Size.Width / 2) Then
            KeypadText = "xxxxxx"
            PLCAddressKeypad = "D12000"

        ElseIf kordinatax > (Me.Size.Width / 2) Then
            KeypadText = "yyyyyy"
            PLCAddressKeypad = "D12001"
        End If

        ActivateKeypad()

    End Sub

« Last Edit: December 16, 2018, 12:14:57 PM by Godra »

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #14 on: December 17, 2018, 08:09:51 AM »
Thats my code now
Code: [Select]
'***********************************************************
    '* If labeled is clicked, pop up a keypad for data entry
    '***********************************************************
    Dim KeypadText1 As String
    Protected Overrides Sub OnClick(e As System.EventArgs)
        MyBase.OnClick(e)

        Dim ex As MouseEventArgs = e

        Dim kordinatax = ex.X


        If kordinatax < (Me.Size.Width / 2) Then
            KeypadText1 = "xxxxx"
            PLCAddressKeypad = "D12000"

        ElseIf kordinatax > (Me.Size.Width / 2) Then
            KeypadText1 = "yyyyy"
            PLCAddressKeypad = "D12001"
        End If

        If m_PLCAddressKeypad IsNot Nothing AndAlso (String.Compare(m_PLCAddressKeypad, "") <> 0) And Enabled Then
            If KeypadPopUp Is Nothing Then
                KeypadPopUp = New MfgControl.AdvancedHMI.Controls.Keypad(m_KeypadWidth)
                AddHandler KeypadPopUp.ButtonClick, AddressOf KeypadPopUp_ButtonClick
            End If
        End If
        KeypadPopUp.Text = KeypadText1
        KeypadPopUp.Value = ""
        KeypadPopUp.StartPosition = Windows.Forms.FormStartPosition.Manual
        KeypadPopUp.Location = New Point(400, 50)
        KeypadPopUp.TopMost = True
        KeypadPopUp.Show()
    End Sub

But this is for only one BarLevel on Form and it works fine. But i have multiple BarLevels in form, soo now if i click on any BarLevel its the same two texts. I need to display "xxxxx?" or "yyyyy" for BarLevel1 and "aaaaa" or "bbbbb" for BarLevel2 etc..  All locations and sizes for all BarLevels have on "MainForm". Is it possible to get all needed variables from MainForm.vb to BarLevel.vb so i can make texts for all BarLevels individualy?Or any other advice how to solve that