Author Topic: How do I draw a Line?  (Read 2612 times)

Mvlawn

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
How do I draw a Line?
« on: March 27, 2016, 01:24:55 PM »
I would figure this should be super easy, however I can't locate a line tool. Can someone point me in the right direction?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: How do I draw a Line?
« Reply #1 on: March 27, 2016, 02:40:22 PM »
Here are 4 different methods that can be used:

Option 1 : Install Visual Basic Power Packs

https://www.microsoft.com/en-us/download/details.aspx?id=25169

Option 2 : Use a drawing program like Paint, InkScape, Adobe Illustrator, etc to draw all of the line/shapes you want in a single image. Export the drawing to a PNG file. Add the image to a Panel or make it the Form background

Option 3 : Add a Label to the form. Set the Backgound color to the line color you want. Set the width or height to the line thickness

Option 4 : Use GDI+ drawing via code. For example, add this code to your form:

   Protected Overrides Sub OnPaint(e As PaintEventArgs)
        MyBase.OnPaint(e)

        e.Graphics.DrawLine(Pens.Red, 0, 0, 100, 100)
    End Sub




Option 1 is probably the easiest, but least portable to other machines that do not have the Power Packs installed.
Option 2 is my preference because of the flexibility I can get. In the Application Showcase, I recently posted some screenshots of a press HMI that uses this technique.
Option 3 only allows vertical and hortizontal lines.
Option 4  is typically used by professional code writers and requires a reasonable amount of knowledge of GDI+

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: How do I draw a Line?
« Reply #2 on: March 27, 2016, 02:42:21 PM »

Mvlawn

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: How do I draw a Line?
« Reply #3 on: March 27, 2016, 04:13:39 PM »
Thanks for everyones help!!! I did try several of the methods, I was not able to get Godra's method to work due to an error that populated. I assume because I am running 3.99D. Any thoughts?

1>C:\Users\mvlaw\Desktop\AdvancedHMIBetaV399d\AdvancedHMIControls\PurchasedControls\LineShapeHMI.vb(98,32): error BC30002: Type 'AdvancedHMIDrivers.IComComponent' is not defined.
1>C:\Users\mvlaw\Desktop\AdvancedHMIBetaV399d\AdvancedHMIControls\PurchasedControls\LineShapeHMI.vb(99,40): error BC30002: Type 'AdvancedHMIDrivers.IComComponent' is not defined.
1>C:\Users\mvlaw\Desktop\AdvancedHMIBetaV399d\AdvancedHMIControls\PurchasedControls\LineShapeHMI.vb(103,28): error BC30002: Type 'AdvancedHMIDrivers.IComComponent' is not defined.
========== Build: 0 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: How do I draw a Line?
« Reply #4 on: March 27, 2016, 07:17:03 PM »
You got those errors since the file is intended for pre-v399d versions of AHMI.

Try renaming each of those AdvancedHMIDrivers.IComComponent to MfgControl.AdvancedHMI.Drivers.IComComponent.

I will try to post v399d file later.