Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Net;
  10. using shadowAPI2;
  11. using System.Collections;
  12. using System.IO;
  13. using System.Net.NetworkInformation;
  14. using Utilities;
  15. using Ini;
  16.  
  17. namespace MainForm
  18. {
  19. public partial class Form1 : Form
  20. {
  21. public Form1()
  22. {
  23. if (File.Exists(@"C:\Keybinder\NR-Keybinder\Texte.ini"))
  24. {
  25. IniFile ini = new IniFile(@"C:\Keybinder\NR-Keybinder\Texte.ini");
  26. try { textBox1.Text = ini.IniReadValue("Hotkeys", "Text1"); }
  27. catch (NullReferenceException) { }
  28. try { textBox2.Text = ini.IniReadValue("Hotkeys", "Text2"); }
  29. catch (NullReferenceException) { }
  30. try { textBox3.Text = ini.IniReadValue("Hotkeys", "Text3"); }
  31. catch (NullReferenceException) { }
  32. try { textBox4.Text = ini.IniReadValue("Hotkeys", "Text4"); }
  33. catch (NullReferenceException) { }
  34. try { textBox5.Text = ini.IniReadValue("Hotkeys", "Text5"); }
  35. catch (NullReferenceException) { }
  36. try { textBox6.Text = ini.IniReadValue("Hotkeys", "Text6"); }
  37. catch (NullReferenceException) { }
  38. try { textBox7.Text = ini.IniReadValue("Hotkeys", "Text7"); }
  39. catch (NullReferenceException) { }
  40. try { textBox8.Text = ini.IniReadValue("Hotkeys", "Text8"); }
  41. catch (NullReferenceException) { }
  42. try { textBox9.Text = ini.IniReadValue("Hotkeys", "Text9"); }
  43. catch (NullReferenceException) { }
  44. try { textBox10.Text = ini.IniReadValue("Hotkeys", "Text10"); }
  45. catch (NullReferenceException) { }
  46. }
  47. else
  48. {
  49. textBox1.Text = "";
  50. textBox2.Text = "";
  51. textBox3.Text = "";
  52. textBox4.Text = "";
  53. textBox5.Text = "";
  54. textBox6.Text = "";
  55. textBox7.Text = "";
  56. textBox8.Text = "";
  57. textBox9.Text = "";
  58. textBox10.Text = "";
  59. }
  60. InitializeComponent();
  61. globalKeyboardHook gkh = new globalKeyboardHook();
  62. gkh.HookedKeys.Add(Keys.NumPad0);
  63. gkh.HookedKeys.Add(Keys.NumPad1);
  64. gkh.HookedKeys.Add(Keys.NumPad2);
  65. gkh.HookedKeys.Add(Keys.NumPad3);
  66. gkh.HookedKeys.Add(Keys.NumPad4);
  67. gkh.HookedKeys.Add(Keys.NumPad5);
  68. gkh.HookedKeys.Add(Keys.NumPad6);
  69. gkh.HookedKeys.Add(Keys.NumPad7);
  70. gkh.HookedKeys.Add(Keys.NumPad8);
  71. gkh.HookedKeys.Add(Keys.NumPad9);
  72. gkh.KeyDown += new KeyEventHandler(gkh_KeyDown);
  73. }
  74.  
  75. public void gkh_KeyDown(object sender, KeyEventArgs e)
  76. {
  77. if (e.KeyCode == Keys.NumPad1)
  78. {
  79. if (textBox1.TextLength != 0)
  80. {
  81. Chat.GetInstance().Send(textBox1.Text);
  82. }
  83. e.Handled = true;
  84. }
  85. if (e.KeyCode == Keys.NumPad2)
  86. {
  87. if (textBox2.TextLength != 0)
  88. {
  89. Chat.GetInstance().Send(textBox2.Text);
  90. }
  91. e.Handled = true;
  92. }
  93. if (e.KeyCode == Keys.NumPad3)
  94. {
  95. if (textBox3.TextLength != 0)
  96. {
  97. Chat.GetInstance().Send(textBox3.Text);
  98. }
  99. e.Handled = true;
  100. }
  101. if (e.KeyCode == Keys.NumPad4)
  102. {
  103. if (textBox4.TextLength != 0)
  104. {
  105. Chat.GetInstance().Send(textBox4.Text);
  106. }
  107. e.Handled = true;
  108. }
  109. if (e.KeyCode == Keys.NumPad5)
  110. {
  111. if (textBox5.TextLength != 0)
  112. {
  113. Chat.GetInstance().Send(textBox5.Text);
  114. }
  115. e.Handled = true;
  116. }
  117. if (e.KeyCode == Keys.NumPad6)
  118. {
  119. if (textBox6.TextLength != 0)
  120. {
  121. Chat.GetInstance().Send(textBox6.Text);
  122. }
  123. e.Handled = true;
  124. }
  125. if (e.KeyCode == Keys.NumPad7)
  126. {
  127. if (textBox7.TextLength != 0)
  128. {
  129. Chat.GetInstance().Send(textBox7.Text);
  130. }
  131. e.Handled = true;
  132. }
  133. if (e.KeyCode == Keys.NumPad8)
  134. {
  135. if (textBox8.TextLength != 0)
  136. {
  137. Chat.GetInstance().Send(textBox8.Text);
  138. }
  139. e.Handled = true;
  140. }
  141. if (e.KeyCode == Keys.NumPad9)
  142. {
  143. if (textBox9.TextLength != 0)
  144. {
  145. Chat.GetInstance().Send(textBox9.Text);
  146. }
  147. e.Handled = true;
  148. }
  149. if (e.KeyCode == Keys.NumPad0)
  150. {
  151. if (textBox10.TextLength != 0)
  152. {
  153. Chat.GetInstance().Send(textBox10.Text);
  154. }
  155. e.Handled = true;
  156. }
  157. }
  158.  
  159. private void Form1_Load(object sender, EventArgs e)
  160. {
  161.  
  162. }
  163.  
  164. private void button1_Click(object sender, EventArgs e)
  165. {
  166. if (!System.IO.Directory.Exists(@"C:\Kebinder\NR-Keybinder"))
  167. {
  168. System.IO.Directory.CreateDirectory(@"C:\Keybinder\NR-Keybinder");
  169. }
  170. if (!System.IO.File.Exists(@"C:\Keybinder\NR-Keybinder\Texte.ini"))
  171. {
  172. System.IO.File.Create(@"C:\Keybinder\NR-Keybinder\Texte.ini");
  173. }
  174. IniFile ini = new IniFile(@"C:\Keybinder\NR-Keybinder\Texte.ini");
  175. string text1 = textBox1.Text;
  176. string text2 = textBox2.Text;
  177. string text3 = textBox3.Text;
  178. string text4 = textBox4.Text;
  179. string text5 = textBox5.Text;
  180. string text6 = textBox6.Text;
  181. string text7 = textBox7.Text;
  182. string text8 = textBox8.Text;
  183. string text9 = textBox9.Text;
  184. string text10 = textBox10.Text;
  185. try { ini.IniWriteValue("Hotkeys", "Text1", text1); ini.IniWriteValue("Hotkeys", "Text2", text2); ini.IniWriteValue("Hotkeys", "Text3", text3); ini.IniWriteValue("Hotkeys", "Text4", text4); ini.IniWriteValue("Hotkeys", "Text5", text5); ini.IniWriteValue("Hotkeys", "Text6", text6); ini.IniWriteValue("Hotkeys", "Text7", text7); ini.IniWriteValue("Hotkeys", "Text8", text8); ini.IniWriteValue("Hotkeys", "Text9", text9); ini.IniWriteValue("Hotkeys", "Text10", text10); }
  186. catch { MessageBox.Show(@"Fehler...\nDie Texte konnten nicht gespeichert werden!", "NR-Keybinder"); }
  187. MessageBox.Show("Die Texte wurden erfolgreich gespeichert!", "NR-Keybinder");
  188.  
  189. }
  190. }
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement