Friday, April 6, 2018

graph in VB

graph in VB


Used when creating stand-alone client-side EXEs to be distributed and ran on an end-users machine. This VB.NET Graphing Walk-through includes instructions for Visual Studio.Net developers.

Prerequisites:

It is recommended that the namespace: Gigasoft.ProEssentials.Enums be included at the top of your source code files utilizing ProEssentials. In VB.NET, use the Imports keyword. For example:

Imports Gigasoft.ProEssentials.Enums

The WinForm interfaces support adapting to changes in the parent forms font and background color. They are designed so that the grid number text size matches that of the other standard controls such as TextBox, Radio Button, and Labels. As long as you dont explicitly change the font and background color, you will be able to change the forms font size and backcolor and all controls on the form will adapt to match. Note that the default form text size of 8 points is fairly small. You may want to increase it to 9 or 10 points depending on your needs. This feature results in a very clean and professional looking user interface where the graphing control appears to be a true sibling of the other standard controls.

Our .NET interfaces currently have limited design time functionality. You will have to write a little code (simple, see below) to develop your graphing solutions. In the end, youll prefer our .NET (property, method, event) interface. 99% of your code will set simple properties.

Walk-Through:

The following information demonstrates how to create your first .NET ProEssentials implementation using the Visual Basic language. It discusses using the WinForm .NET interfaces to add interactive graphing content to your EXEs. Other examples are provided within the product/evaluation.

1) Start Visual Studio.NET and create a new project targeting a [Windows Application] using Visual Basic as your language. Accept the default name of [WindowsApplication1].

2) When the new project opens, you will be presented the design view of "Form1.vb".

Customize Toolbox... DialogAdding ProEssentials to Visual Studio.NET...

3) Installing WinForm interfaces into Visual Studio.NET

VS2005 / VS2008 Instructions

  • Under the Tools menu, select [Choose Toolbox Items...],
  • If not selected, left click the [.NET Framework Components] tab,
  • Left click the [Browse...] button and find the file "Gigasoft.ProEssentials.dll" found in the DotNet20 subdirectory where you installed ProEssentials. By default, this should be located at "C:ProEssentials6DotNet20",
  • Select the file "Gigasoft.ProEssentials.dll" and close the [Open File] dialog,
  • The [Choose Toolbox Items] dialog should now show 5 highlighted controls: Pe3do, Pego, Pepco, Pepso, and Pesgo.
  • Close the dialog and the 5 new ProEssentials components will be at the bottom of the toolbox.

VS2003 and Earlier Instructions

  • Double check that the [Windows Forms] tab on the tool box is active (Pointer, Label, should be visible)
  • Right click anywhere in the toolbox and select [Add/Remove Items... or Customize Toolbox...],
  • Left click the [.NET Framework Components] tab,
  • Left click the [Browse...] button and find the file "Gigasoft.ProEssentials.dll" found in the DotNet subdirectory where you installed ProEssentials. By default, this should be located at "C:ProEssentials6DotNet",
  • Select the file "Gigasoft.ProEssentials.dll" and close the [Open File] dialog,
  • The [Customize Toolbox] dialog should now show 5 highlighted controls: Pe3do, Pego, Pepco, Pepso, and Pesgo.
  • Close the [Customize Toolbox] dialog and the 5 new ProEssentials components will be at the bottom of the toolbox.
Form1.vb [Design]...Adding ProEssentials to a Form...
VB.NET Graph control in Visual Studio.Net

4) Double click the [Pego] tool within the toolbox. This places an instance of the Pego component within "Form1.vb". Left click bottom-right corner of control and drag down-right to fill up client area of Form1. The adjacent image shows what you see.

This represents the default state of a ProEssentials Graph. The default state has one subset with four data points. In the course of constructing your own graphs, youll set the properties PeData.Subsets andPeData.Points which define the quantity of data your graph will hold. Youll then pass data via the PeData.Y(subset, point) two dimensional property array. The following section shows example code of passing data.

ProEssentials uses the terms Subsets and Points but you can think of these as Rows and Columns. Passing data is as simple as filling each Subset with Points worth of data.

Adjusting design time settings...
VB.NET Graph component property window in Visual Studio.Net

5) We recommend setting the parent Forms versions as these properties as ProEssentials will use the parent forms settings to help facilitate a uniform look among sibling controls.

If new to Visual Basic, the (Name) property is probably the most fundamental property as its name is reflected in all code. For example, Pego1.PeData.Subsets = 1 is a line of code, and it shows how the (Name) property (Pego1) starts the line.

Form1.vb [Code]...

6) Double click Form1s Title/Caption Bar to open the code view for "Form1.vb" with default Form1_Load event initialized.

The cursor will be within the Form1_Load code section, enter the following code into this section.

You can copy and paste if you must, but hand-typing at least some of this code will really help familiarize yourself with the Gigasoft.ProEssentials namespace.

Note: adding the following Imports declaration at the top of "Form1.vb" will shorten enumeration syntax.
Imports Gigasoft.ProEssentials.Enums

Pego1.PeString.MainTitle = "Hello .NET"
Pego1.PeString.SubTitle = ""
Pego1.PeData.Subsets = 1
Pego1.PeData.Points = 6
Pego1.PeData.Y(0, 0) = 10 : Pego1.PeData.Y(0, 1) = 30
Pego1.PeData.Y(0, 2) = 20 : Pego1.PeData.Y(0, 3) = 40
Pego1.PeData.Y(0, 4) = 30 : Pego1.PeData.Y(0, 5) = 50
Pego1.PeString.PointLabels(0) = "Jan"
Pego1.PeString.PointLabels(1) = "Feb"
Pego1.PeString.PointLabels(2) = "Mar"
Pego1.PeString.PointLabels(3) = "Apr"
Pego1.PeString.PointLabels(4) = "May"
Pego1.PeString.PointLabels(5) = "June"
Pego1.PeString.SubsetLabels(0) = "Framework"
Pego1.PeString.YAxisLabel = "Microsoft"
Pego1.PeColor.SubsetColors(0) = System.Drawing.Color.Red
Pego1.PeColor.BitmapGradientMode = True
Pego1.PeColor.QuickStyle = Gigasoft.ProEssentials.Enums.QuickStyle.LightNoBorder
Pego1.PeTable.Show = Gigasoft.ProEssentials.Enums.GraphPlusTable.Both
Pego1.PeData.Precision = Gigasoft.ProEssentials.Enums.DataPrecision.NoDecimals
Pego1.PeFont.Label.Bold = True
Pego1.PePlot.Method = Gigasoft.ProEssentials.Enums.GraphPlottingMethod.Bar
Pego1.PePlot.Option.GradientBars = 8
Pego1.PeFont.FontSize = Gigasoft.ProEssentials.Enums.FontSize.Large
Pego1.PeUserInterface.HotSpot.Data = True
Pego1.PeFunction.ReinitializeResetImage()

Pego1.Refresh() call Refresh at end of initialization to force paint

7) The code above enabled the DataHotSpot event, so we should place some appropriate code in the DataHotSpot event.

Within the two drop-down combo boxes at top of code view window, select [Pego1] within the left combo box. Select [PeDataHotSpot] within the right combo box. The cursor should be within the Pego1_PeDataHotSpot event. See the red annotations in the bitmap below.

Add the following code to the Pego1_PeDataHotSpot event.

Windows.Forms.MessageBox.Show("Point " + e.PointIndex.ToString() + _
" with a value of " + Pego1.PeData.Y(0, e.PointIndex).ToString())

So, the "Form1.vb" code window should contain...

VB.Net Graph source code within Visual Studio code window.

8) Under the Project menu, select "Project Properties". From the Compile tab, select the "Advanced Compile Options..." button. Change the "Target CPU" setting to x86. This is necessary as ProEssentials contains native 32 bit portions. This setting will allow the resulting exe to run on both 32 and 64 bit systems.

9) Save and run the project. Your project will show an image as follows. Move the mouse over a bar and click to trigger the DataHotSpot event.

Run the project...Success!!!

VB.NET Graph within your graphing software!

This completes this walkthrough.

Please read the remaining sections within Chapter 2 and review the demo code and documentation thats installed with the eval/product.

Once installed, the demo program can be accessed via shortcut...

Start / All Programs / ProEssentials v6 / PeDemo

Note that our main demo is replicated in VB.NET, C#.NET, VB6, and VC6 projects all accessible from the start menu. These are great for modifying an existing demo to test potential modifications before implementing within your applications.



go to link download
download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.