Visual Studio integration

136 views
Skip to first unread message

luka...@gmail.com

unread,
Jul 1, 2014, 11:07:38 AM7/1/14
to glg...@googlegroups.com
Hello everybody, i have downloaded glg community edition and installed it but i dont know how to use the different controls in visual studio 2012 can you help me please ? 

glg_devel

unread,
Jul 1, 2014, 5:05:25 PM7/1/14
to glg...@googlegroups.com
GLG controls (GLG widgets) are GLG drawings which can be used as individual components.You can also compose a custom HMI panel containing multiple controls and other dynamic graphics using the GLG Builder, which is saved as a single drawing file (.g file).

A GLG drawing is integrated into an application using one of the provided native containers for the selected programming environment: a C# User Control, an MFC custom control, a Java bean, etc. A drawing can contain a single widget or multiple controls and other graphics. The GLG API of native containers provide methods for animating the drawing with real-time data and handling user interaction.

The GLG Builder and Animation Tutorial provides a good starting point for information on editing / creating drawings in the GLG Builder. The tutorial may be found on-line, in both HTML and PDF formats:
    http://www.genlogic.com/doc_html/glgtut.html
    http://www.genlogic.com/doc_html/glgtut.pdf

GLG programming examples provide samples of integration of GLG into an application and may be found in the following directories under the GLG installation directory:

C# :   examples_csharp.NET directory
  
README.txt  in this directory provides a description of all available examples. An example of the GLG controls usage (dials, meters, gauges) may be found in the examples_csharp.NET/Controls directory.

MFC / C++ :   examples_mfc directory

An example of the GLG controls usage (dials, meters, gauges) in an MFC environment may be found in examples_mfc/controls directory.

VB.NET :   examples_vbnet_ocx directory

An example of the GLG controls usage in VB.NET may be found in examples_vbnet_ocx/controls directory.

smart...@gmail.com

unread,
Jun 1, 2015, 7:12:57 AM6/1/15
to glg...@googlegroups.com
This does not really answer the question that I have (similar to this one).
  • I am using C# Visual Studio
  • I understand and have been through the GLG builder Tutorials
  • I can also Run the Demos and view the example code.
  • Both look very powerful and ideal for my application.
  • I am a novice in C# and Visual Studio.
I can't find any description (step-by-step) on how to link/import the GLG Builder (*.g) file into my project.
I can see the "using GenLogic;" in the cs code examples... This will include it...
But I am assuming that I need to add something and include/reference it in my existing C# sln project folder.
I see in the examples that there is a file "Glg.NetCE.dll" in the application folder. Is this all that is required (why this particular file)?
How does the sln address/include this file (if necessary).
I was expecting an option to import a GLG toolbox entry into my project, and then drag that into my windows form. The GLG toolbox would contain the GLG builder (*.g) output file that I created.
How do I draw/place the GLG drawing (*.g) output widget in my existing C# application?

I have searched all your tutorials and the web, but no one seems to explain this vital/fundamental step. It is probably obvious to some... But not the novice like me. I have been struggling for a number of days with this vital step/... How???

1) Can I drag/place my GNG builder (*.g) output drawing Widget into my existing C# form? How do I do it?
2) How to I add the GLG library to my C# sln project?
3) I would like this in step-by-step instructions.
4) Is there any Youtube type help tutorials on this basic process?

If I can't get a logical answer on this, I will continue searching for competitor's graphics plugin for my C# application, your one fits my need well. But there are plenty of others out there..... I suspect others have done the same...

Thanks... 

smart...@gmail.com

unread,
Jun 1, 2015, 7:18:24 AM6/1/15
to glg...@googlegroups.com
I seem to only find this small bit of help (not really answering my questions above):

Loading a Drawing into a C#/.NET program or GLG .NET Control

To use a drawing with a C#/.NET program and GLG .NET Control, it must contain a viewport named "$Widget". This viewport will be displayed when the drawing is loaded.

GlgControl has properties that define the drawing file to be displayed in the control. Setting one of these properties loads the drawing and displays it in the control's window. The control also has methods that allow to load the drawing from a file on demand under the program's control.

To load the drawing into the GlgControl, set its DrawingFile property to load and display the drawing from a file. Use theDrawingURL property to load a drawing from a URL.

To load the drawing into a C# program, you can also use the LoadWidget method of the GlgObject class or the LoadWidgetmethod of the GlgControl.


glg_support

unread,
Jun 1, 2015, 10:00:15 PM6/1/15
to glg...@googlegroups.com
The following steps can be used to add a GLG .NET control to a form and display
a GLG drawing (.g file) in the control:

1. Copy <glg_dir>/lib/Glg.NetCE.dll to your project directory.

2. Add a reference to Glg.NetCE.dll in your project:
- In the Visual Studio Solution Explorer,  right-click on References, Add Reference.
- Click on the Browse tab.
- Select Glg.NetCE.dll and click OK.

Glg.NetCE should appear in the References list in your project.

3. Add a GLG  control to a Form using Form Designer.

Bring Form Designer (right-click on Form1.cs in the Solution Explorer, View Designer).

Add GLG .NET control to a Toolbox:
- Click on the Toolbox icon to open a Toolbox
- Right-click on the General, Choose Items
- Click on the Browse button, select Glg.NetCE.dll from your project directory and
  click on Open. Click on the OK button to close the dialog.
- In the Toolbox window, under General category, you should see GlgControl as a
  GLG .NET component. Click on the GlgControl to select it, and add it to a form
  by click+drag+release. Size and position the control inside a form as needed.

3. Specify a GLG drawing file to be displayed in the control.

- Copy a GLG drawing file created in the GLG Builder to your project directory.
- In the Form Designer, right-click on the GlgControl and bring its Properties.
- Select DrawingFile property and set it to the file name of your GLG drawing file (.g file),
  using a full file path. The specified GLG drawing should appear in the GLG control
  in the Form Designer.

Alternatively, DrawingFile property can be set in the application code, as shown in the
GLG examples. This method is recommended for better portability and will eliminate
the need to use an absolute file path in the Form Designer.

4. Build and run the application.

- In the Solution Explorer, click on your project, and bring its Properties.
- Select the Build tab.
- Under Configuration, select All Configurations.
- Set the Output path to '.\' (current directory). This step is used for convenience, which will
   create the application executable (.exe) in the project directory instead of bin/Debug or
   bin\Release,  and will eliminate the need to copy .g file to bin/Release and bin/Debug.
- Build Solution.
- Run the application (Debug, Start Without Debugging). A GLG control with a GLG drawing
  should be displayed in a form.




 

smart...@gmail.com

unread,
Jun 2, 2015, 5:00:20 AM6/2/15
to glg...@googlegroups.com
This is just what I needed... It all works now except...

When I run the code I get an error:

Carnot open <C:.....<path>...chart2.g> for reading. 

It can find the file cause the Windows form the opens with the file in it. 

The path exists.. I can cut and past into windows explorer and and GNG editor toolkit opens OK.

What is wrong? 

smart...@gmail.com

unread,
Jun 3, 2015, 5:43:53 AM6/3/15
to glg...@googlegroups.com
... A bit more searching an I found the obvious issue that the code in tire example:
            // Assign GLG drawing name to be displayed in the GLG control.  
            String drawing_name = "chart2.g";
            String drawing_file = Path.Combine( Application.StartupPath, drawing_name );
is pointing to the the "....bin\Debug"  folder. So I added the drawing file into this folder as well, and that fixed it...

I guess I don't quite understand the point you wrote in the last step:
- In the Solution Explorer, click on your project, and bring its Properties.
- Select the Build tab.
- Under Configuration, select All Configurations.
- Set the Output path to '.\' (current directory). This step is used for convenience, which will
   create the application executable (.exe) in the project directory instead of bin/Debug or
   bin\Release,  and will eliminate the need to copy .g file to bin/Release and bin/Debug.
I did this, but it still needs to be added to the bin\Debug folder (because of the above lines I guess)...

Anyway I am off the ground now... All I need to know is how to fly this thing and I'll be right now..

PS: my project is the dash board of my Electric Car conversion (Public Facebook Page: SmartArseEV
The Problem is I am a hardware guy in desperate need of some graphics software for my Dashboard. Your Library looks ideal.

Anyway: Problem solved, and I guess the same for many others.

A suggestion would be to show how to do this (set up the C sharp dot net project on YouTube.... Anyway .. Thanks... and keep up the good work...


glg_support

unread,
Jun 3, 2015, 12:41:27 PM6/3/15
to glg...@googlegroups.com
Setting the DrawingFile property programmatically as shown in the GLG examples (and shown in your posting) using a relative path is a recommended way to assign a drawing file name for the GLG control, as opposed to using an absolute path in the Visual Studio Designer.

However, using the absolute path should also work, unless there is a typo or an issue with access  privileges. For example, the following works correctly using absolute drawing file path:
  C:\Test - project directory
  C:\Test\animation.g - GLG drawing file
  C:\Test\Glg.NetCE.dll - GLG .NET library
  C:\Test\bin\Debug\Test.exe - application executable

The Form contains a GLG .NET control named glgControl1, with DrawingFile property set to 'C:\Test\animation.g'. When starting the executable Test.exe from C:\Test\bin\Debug, the animation.g drawing should be displayed correctly in the control.

With that said, although the method of setting the DrawingFile property in the Form Designer using an absolute path should work correctly, it is not recommended to use this method. It is recommended to do it in the application code using a relative path.

Regarding your question about Build project settings:

If the Output path is set to 'bin\Debug' for a Debug configuration (which is a default setting), the executable (.exe) will be created in the bin\Debug directory. It means that if you set DrawingFile in the application code, using Path.Combine( Application.StartupPath, drawing_name ), your GLG drawing (chart2.g) should be present in 'bin\Debug' directory.

Likewise, for a Release configuration, "chart2.g" should be present in bin\Release directory. It means that "chart2.g" should be
copied to 2 directories, i.e. bin\Debug as well as bin\Release.

However, if you change Project Build setting so that Output path is set to '.\', the application executable (.exe) will be placed in the current project directory, for either Debug or Release configuration. It means that you can have only one copy of "chart2.g", which will reside in the project directory; you will not have to copy "chart2.g" to bin\Debug and bin\Release.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages