ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/AnywhereTS-MSSQL/trunk/TSAdminTool/Keyboard.cs
Revision: 47
Committed: Thu Jul 12 14:29:34 2012 UTC (10 years, 10 months ago) by william
File size: 3000 byte(s)
Log Message:
+ fix compilation errors

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Windows.Forms;
5 using log4net;
6 namespace AnywhereTS
7 { // Provides support functions for client keyboards
8 static class ATSKeyboard
9 { // The input cultures for rdesktop. Each culture is languagecode_countrycode or just languagecode
10 public static string[] keyboardCode = new string[] {"ar", "hr", "cs", "da", "nl", "nl_be", "en_gb", "en_nz", "en_us", "en_in", "et", "fr", "fr_be", "fr_ca", "fr_ch", "de", "de_ch", "hu", "it", "ja", "la", "lv", "lt", "mk", "no", "pl", "pt", "pt_br", "ro", "ru", "sl", "es", "sv", "sv_fi", "th", "tr"};
11 public static string[] keyboardDescription = new string[] { "Arabic", "Croatian", "Czech", "Danish", "Dutch", "Dutch-Belgium", "English-Great Britain", "English-New Zealand", "English-United States", "English-United States International", "Estonian", "French", "French-Belgium", "French-Canada", "French-Switzerland", "German", "German-Switzerland", "Hungarian", "Italian", "Japanese", "Latin", "Latvian", "Lithuanian", "Macedonian", "Norwegian", "Polish", "Portuguise", "Portuguise-Brazil", "Romanian", "Russian", "Slovenian", "Spanish", "Swedish", "Swedish-Finland", "Thai", "Turkish" };
12
13 // Returns the default keyboard map from the windows settings on the current computer.
14 public static string DefaultKeyboardMap()
15 {
16 string windowsMap = InputLanguage.DefaultInputLanguage.Culture.Name.ToLower();
17 windowsMap.Replace("-", "_"); // Convert to Thinstation format, i.e "en_us"
18 foreach (string keyb in keyboardCode)
19 {
20 if (keyb == windowsMap)
21 {
22 return keyb; // We found a match on language and country
23 }
24 }
25 // No match on language and country
26 windowsMap = windowsMap.Substring(0, 2);
27 foreach (string keyb in keyboardCode)
28 {
29 if (keyb == windowsMap)
30 {
31 return keyb; // We found a match on language only
32 }
33 }
34 // No match, select english as default
35 return "en_us";
36
37 }
38
39 // Returns the index for an keyboard map in string form.
40 public static int KeyboardCodeToIndex(string searchKeyboardCode)
41 {
42 for (int i = 0; i <= keyboardCode.GetUpperBound(0); i++)
43 {
44 if (keyboardCode[i] == searchKeyboardCode)
45 {
46 return i;
47 }
48 }
49 // Not found
50 MessageBox.Show("Error illegal keyboard code (24552)");
51
52 using (log4net.NDC.Push(string.Format("keyboard code={0}", searchKeyboardCode)))
53 {
54 Logging.ATSAdminLog.Error("Error illegal keyboard code (24552)");
55 }
56
57 return 0;
58 }
59 }
60 }