Class StringTable
StringTable is a class that returns language dependent strings from (hard-coded) string IDs. All language dependent user interface texts are processed here. CADability contains an XML file as a primary string resource, containing all user interface texts in German and English language. You can Add more strings and more languages by calling AddStrings(Stream), or by simply providing an XML file named "CADability.StringTable.xxx.xml" (where xxx stands for any language or application specific abbreviation) in the directory where CADability.dll is located.
Inheritance
Inherited Members
Namespace: CADability.UserInterface
Assembly: CADability.dll
Syntax
public class StringTable
Properties
| Improve this Doc View SourceActiveLanguage
Gets or sets the active language
Declaration
public static string ActiveLanguage { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
| Improve this Doc View SourceAddString(String, String, StringTable.Category, String)
Adds the strings of the given xml document to the string table.
Declaration
public static void AddString(string language, string resourceID, StringTable.Category cat, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | language | the language of the string |
| System.String | resourceID | the ID of the string |
| StringTable.Category | cat | |
| System.String | text | the string |
Remarks
See file "StringTable.xml" for the required xml schema.
AddStrings(Stream)
Declaration
public static void AddStrings(Stream str)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | str |
AddStrings(XmlDocument)
Declaration
public static void AddStrings(XmlDocument doc)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlDocument | doc |
Dispose()
Declaration
public static void Dispose()
GetFormattedString(String, Object[])
Returns a formatted string. The string with the ID "Name" from the string resource is formatted by substituting the {0}, {1} ... substring with the string values of the args objects. If there is a formatting error, the unformatted string will be returned.
Declaration
public static string GetFormattedString(string Name, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Name | Name or ID of the string |
| System.Object[] | args | Variable number of arguments for formatting |
Returns
| Type | Description |
|---|---|
| System.String | The formatted string |
GetLanguageNames()
Declaration
public static string[] GetLanguageNames()
Returns
| Type | Description |
|---|---|
| System.String[] |
GetSplittedStrings(String)
Returns an array of strings from the string table. The array is created from a single entry in the string table. The first character of this entry is the separator and the remaining string is splitted by this separator.
Declaration
public static string[] GetSplittedStrings(string Name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Name | Name or ID of the string |
Returns
| Type | Description |
|---|---|
| System.String[] | The exploded string |
GetString(String)
--- Depricated --- use GetString(string, Category) instead. Returns the string with the given ID in the ActiveLanguage. If the there is no appropriate entry in the ActiveLanguage then the default language is searched. If there is still no entry "missing string: "+Name is returned.
Declaration
public static string GetString(string Name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Name | Name or ID of the string |
Returns
| Type | Description |
|---|---|
| System.String | the value of the string entry |
GetString(String, StringTable.Category)
Returns the string with the given ID and the given StringTable.Categoryin the ActiveLanguage. If the there is no appropriate entry in the ActiveLanguage then the default language is searched. If there is still no entry "missing string: "+Name is returned.
Declaration
public static string GetString(string Name, StringTable.Category cat)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Name | Name or ID of the string |
| StringTable.Category | cat | the Category of the required string |
Returns
| Type | Description |
|---|---|
| System.String | the value of the string entry |
IsStringDefined(String)
Declaration
public static bool IsStringDefined(string Name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Name |
Returns
| Type | Description |
|---|---|
| System.Boolean |
SetActiveLanguage(Int32)
Declaration
public static void SetActiveLanguage(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index |
Events
| Improve this Doc View SourceActiveLanguageChangedEvent
Event which is fired when the active languae of the user interface is changed
Declaration
public static event StringTable.ActiveLanguageChangedDelegate ActiveLanguageChangedEvent
Event Type
| Type | Description |
|---|---|
| StringTable.ActiveLanguageChangedDelegate |