Author Topic: New Keypad  (Read 11845 times)

Phrog30

  • Guest
New Keypad
« on: June 17, 2017, 08:05:42 PM »
I've created a new keypad.  I've debugged to the point where I think it's usable.  If you have any suggestions or see any problems please let me know.  I tried to keep things as consistent as the original keypad.  The main differences:
1.  This keypad is easily editable
2.  PLC keypad min/max
3.  Display min/max on keypad
4.  Display current value on keypad
5.  Keypad can be dragged
6.  Doesn't use top most, which in my experience is a pain as it will block messages, etc
7.  I think it looks better (my opinion of course)

You can download here:
https://drive.google.com/open?id=0B-5kPtgWJjV9UENLOC12VFhoUzQ

James


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: New Keypad
« Reply #1 on: June 18, 2017, 10:03:09 AM »
Tell me if I am missing something, but it looks like you have the MinValue and MaxValue properties to allow nulls using "Decimal?", but in the load event handler you force it to a value anyway. Wouldn't it be easier to not allow nulls and set default values to Decimal.MinValue and Decimal.MaxValue

Phrog30

  • Guest
Re: New Keypad
« Reply #2 on: June 18, 2017, 10:37:00 AM »
I struggled with this.  If just using this with a component, like AnalogValueDisplay, it wouldn't matter.  But, what if someone calls this from code and forgets to set these values.  I wanted a fallback.  If there is a better way on that please let me know.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: New Keypad
« Reply #3 on: June 18, 2017, 02:24:09 PM »
I made a revised version with the ability to resize with a KeypadWidth property or when creating it new:

Dim kpd As New KeypadV2(300)

Phrog30

  • Guest
Re: New Keypad
« Reply #4 on: June 18, 2017, 02:27:13 PM »
Thank you sir.  I look forward to seeing it.

Phrog30

  • Guest
Re: New Keypad
« Reply #5 on: June 18, 2017, 02:42:16 PM »
I played around with it.  Thanks for the changes, while I'm still new at this, I like how you show me the correct way to do things. A few questions:
1.  When opening in the designer, it's blank.  The reason I did it the way I had, was that it makes it really easy to edit in the designer.  Am I missing something?
2.  When I called the keypad with min and max values, the minimum setting didn't work correctly, I know it worked in my version, so somehow a bug was introduced or uncovered.

James

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: New Keypad
« Reply #6 on: June 18, 2017, 02:53:02 PM »
1.  When opening in the designer, it's blank.  The reason I did it the way I had, was that it makes it really easy to edit in the designer.  Am I missing something?
More so a preference of mine to not use a UserControl and the designer when creating controls that are to be used by end users and not edited. It's lighter weight and easier to manage when its a single file. Also probably a bit of old school style programming (and new style because it has come back around) from the days of when there was not designer. The method I used to give the resizing ability would not work with the designer. It would have to be laid out in a TableLayoutPanel for the designer to be able to handle resizing.
2.  When I called the keypad with min and max values, the minimum setting didn't work correctly, I know it worked in my version, so somehow a bug was introduced or uncovered.
Very well could have been something I did. I will double check it.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: New Keypad
« Reply #7 on: June 18, 2017, 02:56:32 PM »
I tried this code:

        '* Show in a larger size
        kpd.MinValue = 0
        kpd.MaxValue = 99

        kpd.KeypadWidth = 700
        kpd.ShowDialog()

And when I enter a value out of the limits, it turns red and disables the Accept button

Phrog30

  • Guest
Re: New Keypad
« Reply #8 on: June 18, 2017, 03:56:13 PM »
I tried this code:

        '* Show in a larger size
        kpd.MinValue = 0
        kpd.MaxValue = 99

        kpd.KeypadWidth = 700
        kpd.ShowDialog()

And when I enter a value out of the limits, it turns red and disables the Accept button

When using a negative min value the correct value occurs on load, but once you hit a button the value goes to zero.  I tried several times with the same results.  This didn't happen on mine.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: New Keypad
« Reply #9 on: June 18, 2017, 04:13:45 PM »
The Setter for the AllowNegatives property was not setting the field value of m_AllowNegative:

            m_AllowNegatives = value

Is the AllowNegatives property really needed since setting MinValue to >=0 could indicate the same thing?

Phrog30

  • Guest
Re: New Keypad
« Reply #10 on: June 18, 2017, 04:38:32 PM »
The Setter for the AllowNegatives property was not setting the field value of m_AllowNegative:

            m_AllowNegatives = value

Is the AllowNegatives property really needed since setting MinValue to >=0 could indicate the same thing?

Probably not.  Again, I tried to keep this as open as possible so it can be used across the board.  Your keypad has this property as well.

Attached is an updated file.  It's a single file (at least what I consider a single file), but still allows edits in designer.  I edited the properties for allowdecimal and negative to align with your keypad.  Mine has "s" at the end, yours didn't.  I also found a few things that weren't quite correct and added the option to show current value in the white box on load or leave blank, leave blank is default.  Personally, I don't see the need for keypad width.  The current size is small enough for most displays and big enough to not fat finger.  I left the property to align with the original keypad, but it's not being used.  Perhaps one day I will be get this .NET stuff, but for now I'm just going for functional.  I know that makes real programmers cringe, but even though my code might not be standard, I still consider it simple and easy to follow.

James

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5325
    • View Profile
    • AdvancedHMI
Re: New Keypad
« Reply #11 on: June 18, 2017, 04:48:28 PM »
Personally, I don't see the need for keypad width.  The current size is small enough for most displays and big enough to not fat finger.
Many version ago the keypad was fixed at one size, but after several deployments that I can recall in which the first request was a larger keypad, the size property was added. The problem with Winforms is its resolution dependence. You may deploy on one system with a 12" screen at 800x600 in which a keypad size works well, but then you may get an 8" screen also with 800x600 in which the keypad will shrink considerably.

Phrog30

  • Guest
Re: New Keypad
« Reply #12 on: June 18, 2017, 05:19:16 PM »
I understand.  I'm looking for a panelview replacement.  If you notice FTView keypad and keyboard are all the same size, which is what I'm doing as well.  Also, we probably will never go below a 15" display.  We have no plans to use AHMI as SE or run on a desktop machine.  However, my needs and those of others will probably vary widely, so I can understand the features you have currently.

Phrog30

  • Guest
Re: New Keypad
« Reply #13 on: June 29, 2017, 08:23:37 PM »
Found a bug I missed, here is an update:

James

BlueAltezza

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: New Keypad
« Reply #14 on: February 03, 2023, 02:58:05 PM »
I know this thread is ancient, but the v3 has features my customers definitely want/need.

I got the keypad to pop up as desired, but after entering data/closing the new keypad the standard keypad pops up as usual.

Is there a way to do a global replace of the standard keypad or a way to prevent the standard keypad from appearing after the v3?


I'm also using an additional write instruction to relay the data from v3 keypad to desired tag...where the standard keypad has that built in.

Is using the additional write instruction the preferred method or is there a way to build that in?