Showing posts with label .NET programming. Show all posts
Showing posts with label .NET programming. Show all posts

Tuesday, September 13, 2011

A Trip to the .NET Forms Library with uniPaaS 2.0

With the release of uniPaaS 2.0, the Magic Application Platform now supports the use of the Windows .NET forms library. These capabilities are delivered by .NET within “classes” that are a part of what is known as the System.Windows.Forms namespace.

Beginning with uniPaaS 2.0, the use of the .NET Forms library within a uniPaaS application is supported in both uniPaaS online (client server) and rich client tasks. After you begin a new task, you must define your .NET object in a new variable by creating a virtual variable in the Dataview Tab of the uniPaaS task. You select the .NET object type either by typing the name or using the uniPaaS selection lists to find the .NET object you want to use.

Developing with the Windows .NET forms library is much easier on the uniPaaS .NET application platform than it is in simple 3GL .NET coding languages such as C#, C++, JScript or VB.NET. uniPaaS 2.0 provides a metadata driven paradigm for application development that allows you to easily incorporate managed code from the .NET forms library along with so-called “unmanaged functionality.” This is true because the uniPaaS 2.x runtime engine is an extension of the uniPaaS 1.x runtime engine. A new .NET front-end wraps the existing C++ engine, thus enabling both .NET and unmanaged functionality in a single runtime engine. The ease-of-use comes into play in several ways:
  1. When you want to use .NET forms capabilities, you can. It is not mandatory.  Very rich applications can be designed using the core GUI capabilities within uniPaaS.
  2.      Adding .NET managed code is simplified because your overall application leverages the benefits of the uniPaaS metadata-driven platform. Low-level programming is never required.     
  3. uniPaaS’ tab and table driven interface allows you to avoid complex line-by-line scripting and coding. uniPaaS takes care of the typical programmer “housekeeping chores” so that there is less effort than normally expected to create a program.

Let’s review the seven main class categories in the Windows .NET form library:


Control, User Control and Form classes.  The Control class constitutes the majority of classes available in the System.Windows.Forms namespace. Controls are key to visibility. In other words, a control class is sued to provide the base functionality for all program controls that are displayed on a form in your application. You can think of a form as a window within your application such as a dialog box, modeless windows, Multiple Document Interface (MDI) client and parent windows.


Menu and Toolbar classes. The library also includes a category of classes for building custom toolbars and menus with your desired look and feel. ToolStrip is used for creating toolbars.  MenuStrip is used for creating menu bars.  ContextMenuStrip is used to create context menus. And StatusStrip can be used to create status bars.


Standard GUI Control classes. The Windows forms library included a number of mainstream controls for input (such as TextBox and ComboBox) display of data (such as Label and ListView) and firing of commands (such as Button).


Layout classes. The layout classes in Windows Forms help control the layout of controls on a display surface, such as a form or control. For example, the FlowLayoutPanel lays out all the controls it contains in a series, and the TableLayoutPanel provides a control for laying out data in a fixed grid. More sophisticated layouts can be managed through the SplitContainer class which is a control that divides your display area into adjustable parts.


Data and Data Binding classes.  You can also use Windows Forms to create the interfaces for binding to data sources such as databases, XML and flat files. The DataGridView is a sophisticated data control that allows for custom tables displaying information with specific  cell, row, column, and border properties. Also, the BindingNavigator and BindingSource controls allow you to develop interfaces  that navigate and work with data on a form in a standard way.


Helpful classes. It is possible to use a number of other helpful classes within the Windows Forms namespace that aid in the display of application related information in your application. Certain classes, provide Windows standard ways of displaying a ToolTip or an error (ErrorProvider).  And the Help and HelpProvider classes are useful for displaying relevant Help information to a user of your applications.


Traditional Dialog Boxes. The final category of Windows Forms classes that we’d like to discuss are common dialog boxes. Dialog boxes give your application a consistent look and feel for common and repetitive functionality such as opening or saving a file, manipulating text properties such as font, size or color, printing or any of a number of other common processes within your application. For example, the OpenFileDialog and SaveFileDialog classes display dialog boxes for opening and saving files by users. The FontDialog class provides a user dialog box set Font properties used in a particular aspect of your application. The PageSetupDialog, PrintPreviewDialog, and PrintDialog classes display well-known and easily understood functionality in a standardized way as well. In addition to the common dialog boxes, a MessageBox class is also available to create a simple box to display and retrieve data from the user.


Conclusion. In addition to all the standard classes within the System.Windows.Formsnamespace, there are of course a number of very interesting third party controls libraries that are worth exploring when you’re looking for that “something extra” or special pizzazz in your user interface. The trick is finding the right balance between uniPaaS, standard .NET and third-party controls within your application. That’s all for this trip to the library.  




Friday, August 27, 2010

Ten Secrets of Building RIA Applications using .NET Programming in uniPaaS

When most people think of .NET programming tools for RIA, they instantly think that they are going to have to get involved in learning SilverLight programming and one or more of the several languages in Visual Studio. While this may be appealing to hard core coders, those developers looking to streamline development of highly functional and interactive Rich Internet Applications now have a better way: uniPaaS RIA applications in .NET.

While this entry is titled “Ten Secrets” it should probably be entitled “Ten Fundamentals.” There is really only one secret and that is how easy it is to leverage .NET programming in a Magic RIA application. The ten concepts covered here are fundamentals of using .NET capabilities within uniPaaS.

The .NET framework provides for .NET assemblies. A .NET assembly is a logical unit of code that is available as an .exe or .dll. It contains code that the .NET framework common language runtime (CLR) executes.

1. Defining .NET Variables.
After loading a .NET assembly in uniPaaS, you will be able to work with any of its objects and methods. .NET assemblies are loaded into the Composite Resource Repository (CRR) in uniPaaS. You can then define a .NET variable for use in uniPaaS and then add the variable to a form in your RIA application and set its properties.

2. Controlling .NET Properties.

When working with .NET objects they have properties such as free-form text, numerics, or objects. The properties of a .NET object are can view and use the properties development scenarios where you need these values, such as calculations, for a display in a Verify operation so on. You can see the relationship between .NET types and uniPaaS types in the table below.

uniPaaS Type .NET Type
Numeric SByte, Byte , Int16, Uint16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Decimal, Single, Double, Float
Alpha Unicode Char, Char[], String, StringBuilder
DateDateTime
TimeDateTime, TimeSpan
LogicalBoolean
BlobByte, Byte[], Char, Char[], String, StringBuilder
VectorICollection (only from .NET to uniPaaS), IList and objects that implement Indexers through the usage of 'this' keyword. Only indexers that have integer indexes uniPaaS only converts simple vectors and not multi vectors



3. Using the DNSet() Function.

The uniPaaS DNSet() function is so named because it allows you to set the properties of a .NET (.NET=DN) object. In addition, you can directly access .NET in the expression editor with the expression prefix DotNet.

4. Use .NET Aliases.

OK, maybe this is a secret. .NET naming conventions are long and obnoxious as many of the assemblies have a very long path. uniPaaS allows you to define aliases in .NET so you can access things more easily. uniPaaS also includes a type-ahead / auto-complete capability but aliases often work better because too many .NET names have the same beginning.

5. Using .NET Methods.

Most of the .NET objects perform a variety of actions such as trigger events and run methods. When using .NET within uniPaaS, uniPaaS can respond to the .NET events and can activate .NET methods.

Just like with uniPaaS objects, a .NET object can trigger events during runtime. When using a .NET object within uniPaaS, it is possible to handle the .NET event in a very similar way to handling a uniPaaS event. This means you can handle the various methods in the .NET object.

It is not recommended to run a method where it will be evaluated often, such as in the property of a control. This will impact performance. Likewise, you should avoid using .NET methods that conflict with the internal uniPaaS methods as this will likely not yield the desired results.

At times, you will need to specify which .NET type you want uniPaaS to use since .NET allows method overloading where a .NET class has more than one method with the same name. To specify which .NET type you want uniPaaS to use, employ the DNCast() function in uniPaaS.

6. Trapping .NET Events.

As a uniPaaS developer, you are already familiar with event driven programming. With many .NET objects, you will find that they expose events that are triggered during runtime. Some common events are available in most .NET controls, such as OnMouseClick, and some others are unique to a specific control. In uniPaaS you can trap for .NET events and handle them in order to interact in specific ways with that .NET object. And of course, events can be propagated so that they can be handled by parent tasks as well.

7. Working with Constructors.

uniPaaS allows you to get or set properties and use methods and events that are published by the object. A .NET object must be instantiated to be usable.

When using .NET within uniPaaS, the instantiation of a .NET object is done automatically for all .NET objects that you placed on a form. When creating the Rich Client Display form, uniPaaS creates an instance for all of the form's .NET objects.

However, when a .NET variable is not placed on a form, it has not yet been instantiated, which means you should do so using a “constructor”. A constructor instantiates and initializes an object. Constructors are methods in which the name of the method is the same as the class itself. For example, the StringBuilder object therefore has a constructor named StringBuilder(). The Magic University course “.NET Programming with uniPaaS” will provide the guidance you need to follow in order to place a constructor properly within an application.

8. Defining a .NET Array.

A .NET array is similar to a uniPaaS vector. Therefore you will understand intuitively that an array is a variable that can hold multiple values of the same type. In contrast with uniPaaS vectors however, when working with .NET you need to predefine the number of cells, or elements that make up the array.

In uniPaaS, defining a .NET array is very similar to defining any other .NET object. To define an array in uniPaaS you simply add square brackets [] to the .NET Object Type. The size of the array, however, is declared by the object constructor.

9. Trapping Exceptions.

Error handling is essential to all forms of programming and using .NET programming in a uniPaaS application is no exception to that (pun intended). uniPaaS provides two internal functions for dealing with .NET exceptions: DNExceptionOccurred() and DNException(). By mastering the use of these functions, you will be able to trap errors and handle them appropriately.

10. Using .NET Code.

In addition to working with standard .NET objects, methods and properties, there may be times when you want to execute custom .NET code. uniPaaS allows you to write .NET
Code from within your application by using the Invoke .NET operation. uniPaaS passes the .NET code to the CLR provided as part of the .NET framework. The compiler returns the compiled code back to uniPaaS and the uniPaaS studio saves the task source code. During deployment, the compiled code is passed back to the client and executed.