GLG Toolkit, C# Class Library  Version 4.6

This group contains miscellaneous utility methods. More...

Detailed Description

This group contains miscellaneous utility methods.

Functions

static void Bell ()
 Emits an audio beep. More...
 
static String ConcatResNames (String resource_name1, String resource_name2)
 Creates a composite resource path from two components. More...
 
static String CreateIndexedName (String template_name, int resource_index)
 Creates a string with a name of an enumerated resource. More...
 
static bool EnableTimerXforms (bool state)
 ADVANCED: Enables or disables all timer transformations defined inside GLG drawings. More...
 
static bool GetModifierState (GlgModifierType modifier)
 Returns the current state of a modifier. More...
 
Object GetNativeComponent (String resource_name, GlgComponentQueryType type)
 ADVANCED: Returns a native component used to render the viewport. More...
 
static String GetStackTraceAsString ()
 Returns current stack trace as a string. More...
 
static String GetStackTraceAsString (Exception e)
 Returns the stack trace of the specified exception as a string. More...
 
static bool IsDemo ()
 Queries the type of the GLG library. More...
 
static String Printf (String format, double value)
 C-style printf method for formatting double values. More...
 
static String Printf (String format, int value)
 C-style printf method for formatting integer values. More...
 
static String Printf (String format, String value)
 C-style printf method for formatting strings. More...
 
static double Rand (double low, double high)
 Returns a random number in the specified range. More...
 
bool SetCursorType (String resource_name, GlgCursorType cursor_type)
 Sets cursor for the viewport's drawing or one of its child viewports. More...
 
void SetFocus (String resource_name)
 Sets the keyboard focus to the object's viewport. More...
 
static bool Sleep (long millisec)
 Sleeps for the specified number of milliseconds. More...
 
static void ThrowExceptionOnError (bool user_error, bool internal_error)
 Controls displaying a stack trace on errors. More...
 

Function Documentation

◆ Bell()

static void Bell ( )
static

Emits an audio beep.

◆ ConcatResNames()

static String ConcatResNames ( String  resource_name1,
String  resource_name2 
)
static

Creates a composite resource path from two components.

This method is provided to mimic C/C++ API in cases when the C/C++ GLG code is converted to C# .

Parameters
resource_name1Specifies the first resource path component.
resource_name2Specifies the second resource path component.
Returns
Created resource path.

This method creates and returns a resource path formed by concatenating the two components with the / character between them. The method checks if a trailing / separator is already present in the first string, and adds it only if the separator is not present.

Either argument may be null, in which case the returned string will precisely equal the input value of the other argument.

Examples

The following code:

String resource_path = GlgObject.ConcatResNames( "DataGroup", "DataSample2" );
System.Console.WriteLine( "resource_path: " + resource_path );

produces the following output:

resource_path = DataGroup/DataSample2

Multiple calls to ConcatResNames may be used to create composite paths from more than two components:

String temp_name = GlgObject.ConcatResNames( "DataGroup", "DataSample2" );
String resource_path = GlgObject.ConcatResNames( temp_name, "Value" );
System.Console.WriteLine( "resource_path: " + resource_path );

producing the following output:

resource_path: DataGroup/DataSample2/Value

◆ CreateIndexedName()

static String CreateIndexedName ( String  template_name,
int  resource_index 
)
static

Creates a string with a name of an enumerated resource.

This method is provided to mimic C/C++ API in cases when the C/C++ GLG code is converted to C# .

Parameters
template_nameA character string containing the template name to be expanded. This name uses the % character to define the expansion position.
resource_indexSpecifies the number to use for expanding the % character in the template name.
Returns
Created resource name.

This method creates and returns a resource name by replacing the first (leftmost) occurrence of the % expansion character within the template name with the number corresponding to the resource_index parameter. If the template name does not contain the expansion character, the number is added to the end of the name.

Examples

The following code:

for( int i=0; i<3; ++i )
{
String name = GlgObject.CreateIndexedName( "XLabelGroup/XLabel%/String", i );
System.Console.WriteLine( "Name:" + name );
}

produces the following output:

Name: XLabelGroup/XLabel0/String
Name: XLabelGroup/XLabel1/String
Name: XLabelGroup/XLabel2/String

CreateIndexedName may be used repeatedly if a template name has more than one expansion character. For example, the following code:

String name1 = GlgObject.CreateIndexedName( "Chart%/Plots/Plot#%/Value", 4 );
String name2 = GlgObject.CreateIndexedName( name1, 3 );
System.Console.WriteLine( "Name:" + name2 );

produces the following output:

Name: Chart4/Plots/Plot#3/Value

◆ EnableTimerXforms()

static bool EnableTimerXforms ( bool  state)
static

ADVANCED: Enables or disables all timer transformations defined inside GLG drawings.

This method may be used to temporarily disable time transformation in some advanced usage scenarios, such as reparenting GlgControl components.

Parameters
stateThe new enabled state.
Returns
Previous value of the enabled state.

◆ GetModifierState()

static bool GetModifierState ( GlgModifierType  modifier)
static

Returns the current state of a modifier.

Parameters
modifierSpecifies the modifier to query, may be one of the following constants:
Returns
The current modifier state.

◆ GetNativeComponent()

Object GetNativeComponent ( String  resource_name,
GlgComponentQueryType  type 
)

ADVANCED: Returns a native component used to render the viewport.

The method provides an access to native components used to render the viewport, making it possible to set their native properties.

Parameters
resource_nameA resource path of a child viewport, or null to query the viewport the method is invoked on. The resource path is relative to the invoking object.
typeThe type of a component to retrieve:
  • WIDGET_QUERY returns the native component used to render the viewport.
  • SHELL_QUERY returns the top-level Form used to host the GLG drawing.
Returns
The retrieved native component.

◆ GetStackTraceAsString() [1/2]

static String GetStackTraceAsString ( )
static

Returns current stack trace as a string.

Returns
Stack trace string.

◆ GetStackTraceAsString() [2/2]

static String GetStackTraceAsString ( Exception  e)
static

Returns the stack trace of the specified exception as a string.

Parameters
eAn exception to generate the stack trace of.
Returns
Stack trace string.

◆ IsDemo()

static bool IsDemo ( )
static

Queries the type of the GLG library.

Returns
true if the Community Edition version of the library is used.

◆ Printf() [1/3]

static String Printf ( String  format,
double  value 
)
static

C-style printf method for formatting double values.

Parameters
formatC-style format string.
valueDouble value to be formatted.
Returns
Formatted string.

◆ Printf() [2/3]

static String Printf ( String  format,
int  value 
)
static

C-style printf method for formatting integer values.

Parameters
formatC-style format string.
valueInteger value to be formatted.
Returns
Formatted string.

◆ Printf() [3/3]

static String Printf ( String  format,
String  value 
)
static

C-style printf method for formatting strings.

Parameters
formatC-style format string.
valueString value to be formatted.
Returns
Formatted string.

◆ Rand()

static double Rand ( double  low,
double  high 
)
static

Returns a random number in the specified range.

Parameters
lowThe low limit.
highThe high limit.
Returns
Generated random number.

◆ SetCursorType()

bool SetCursorType ( String  resource_name,
GlgCursorType  cursor_type 
)

Sets cursor for the viewport's drawing or one of its child viewports.

Parameters
resource_nameA resource path of a child viewport, or null to set cursor for the viewport the method is invoked on. The resource path is relative to the invoking object.
cursor_typeOne of the system cursor types to be used:
Returns
Success or failure status.

The specified cursor will be used when the mouse moves inside the viewport the cursor is assigned to. The drawing's hierarchy must be set up in order to set cursor type.

◆ SetFocus()

void SetFocus ( String  resource_name)

Sets the keyboard focus to the object's viewport.

If the target object is a viewport, the focus is set to this viewport, otherwise the focus is set to the target object's parent viewport.

Parameters
resource_nameA resource path of a target child object, or null to use the object the method is invoked on. The resource path is relative to the invoking object.

◆ Sleep()

static bool Sleep ( long  millisec)
static

Sleeps for the specified number of milliseconds.

Parameters
millisecRequested sleep time.
Returns
Success or failure status.

◆ ThrowExceptionOnError()

static void ThrowExceptionOnError ( bool  user_error,
bool  internal_error 
)
static

Controls displaying a stack trace on errors.

Parameters
user_errorSet to true to display a stack trace on application errors, such as "Can't find resource".
internal_errorSet to true to display a stack trace on internal GLG errors.