Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.64 KB | None | 0 0
  1.  
  2.  
  3. #pragma once
  4.  
  5.  
  6. namespace Project1 {
  7.  
  8.  
  9. using namespace System;
  10. using namespace System::ComponentModel;
  11. using namespace System::Collections;
  12. using namespace System::Windows::Forms;
  13. using namespace System::Data;
  14. using namespace System::Drawing;
  15.  
  16. /// <summary>
  17. /// Summary for MyForm
  18. /// </summary>
  19. public ref class MyForm : public System::Windows::Forms::Form
  20. {
  21. public:
  22. MyForm(void)
  23. {
  24. InitializeComponent();
  25. //
  26. //TODO: Add the constructor code here
  27. //
  28. }
  29.  
  30. protected:
  31. /// <summary>
  32. /// Clean up any resources being used.
  33. /// </summary>
  34. ~MyForm()
  35. {
  36. if (components)
  37. {
  38. delete components;
  39. }
  40. }
  41. private: System::Windows::Forms::TextBox^ text_sm;
  42. private: System::Windows::Forms::TextBox^ text_dm;
  43. private: System::Windows::Forms::TextBox^ text_m;
  44. protected:
  45.  
  46.  
  47. private: System::Windows::Forms::Label^ label1;
  48. private: System::Windows::Forms::Label^ label2;
  49. private: System::Windows::Forms::Label^ label3;
  50. private: System::Windows::Forms::Label^ label4;
  51. private: System::Windows::Forms::TextBox^ gr;
  52. private: System::Windows::Forms::TextBox^ kg;
  53. private: System::Windows::Forms::TextBox^ tn;
  54.  
  55.  
  56.  
  57. private: System::Windows::Forms::Label^ label5;
  58. private: System::Windows::Forms::Label^ label6;
  59. private: System::Windows::Forms::TextBox^ sek;
  60. private: System::Windows::Forms::TextBox^ min;
  61. private: System::Windows::Forms::TextBox^ hours;
  62.  
  63.  
  64.  
  65.  
  66. private: System::Windows::Forms::Label^ label7;
  67. private: System::Windows::Forms::Label^ label8;
  68. private: System::Windows::Forms::Label^ label9;
  69. private: System::Windows::Forms::Label^ label10;
  70. private: System::Windows::Forms::Label^ label11;
  71. private: System::Windows::Forms::Label^ label12;
  72. private: System::Windows::Forms::TextBox^ grivn;
  73. private: System::Windows::Forms::TextBox^ dollar;
  74. private: System::Windows::Forms::TextBox^ evro;
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. protected:
  82.  
  83. protected:
  84.  
  85. private:
  86. /// <summary>
  87. /// Required designer variable.
  88. /// </summary>
  89. System::ComponentModel::Container ^components;
  90.  
  91. #pragma region Windows Form Designer generated code
  92. /// <summary>
  93. /// Required method for Designer support - do not modify
  94. /// the contents of this method with the code editor.
  95. /// </summary>
  96. void InitializeComponent(void)
  97. {
  98. this->text_sm = (gcnew System::Windows::Forms::TextBox());
  99. this->text_dm = (gcnew System::Windows::Forms::TextBox());
  100. this->text_m = (gcnew System::Windows::Forms::TextBox());
  101. this->label1 = (gcnew System::Windows::Forms::Label());
  102. this->label2 = (gcnew System::Windows::Forms::Label());
  103. this->label3 = (gcnew System::Windows::Forms::Label());
  104. this->label4 = (gcnew System::Windows::Forms::Label());
  105. this->gr = (gcnew System::Windows::Forms::TextBox());
  106. this->kg = (gcnew System::Windows::Forms::TextBox());
  107. this->tn = (gcnew System::Windows::Forms::TextBox());
  108. this->label5 = (gcnew System::Windows::Forms::Label());
  109. this->label6 = (gcnew System::Windows::Forms::Label());
  110. this->sek = (gcnew System::Windows::Forms::TextBox());
  111. this->min = (gcnew System::Windows::Forms::TextBox());
  112. this->hours = (gcnew System::Windows::Forms::TextBox());
  113. this->label7 = (gcnew System::Windows::Forms::Label());
  114. this->label8 = (gcnew System::Windows::Forms::Label());
  115. this->label9 = (gcnew System::Windows::Forms::Label());
  116. this->label10 = (gcnew System::Windows::Forms::Label());
  117. this->label11 = (gcnew System::Windows::Forms::Label());
  118. this->label12 = (gcnew System::Windows::Forms::Label());
  119. this->grivn = (gcnew System::Windows::Forms::TextBox());
  120. this->dollar = (gcnew System::Windows::Forms::TextBox());
  121. this->evro = (gcnew System::Windows::Forms::TextBox());
  122. this->SuspendLayout();
  123. //
  124. // text_sm
  125. //
  126. this->text_sm->Location = System::Drawing::Point(45, 44);
  127. this->text_sm->Name = L"text_sm";
  128. this->text_sm->Size = System::Drawing::Size(100, 20);
  129. this->text_sm->TabIndex = 0;
  130. this->text_sm->TextChanged += gcnew System::EventHandler(this, &MyForm::sm_changed);
  131. this->text_sm->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::sm_keypressed);
  132. //
  133. // text_dm
  134. //
  135. this->text_dm->Location = System::Drawing::Point(151, 44);
  136. this->text_dm->Name = L"text_dm";
  137. this->text_dm->Size = System::Drawing::Size(100, 20);
  138. this->text_dm->TabIndex = 0;
  139. this->text_dm->TextChanged += gcnew System::EventHandler(this, &MyForm::change_dm);
  140. this->text_dm->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::dm_keypressed);
  141. //
  142. // text_m
  143. //
  144. this->text_m->Location = System::Drawing::Point(257, 44);
  145. this->text_m->Name = L"text_m";
  146. this->text_m->Size = System::Drawing::Size(100, 20);
  147. this->text_m->TabIndex = 0;
  148. this->text_m->TextChanged += gcnew System::EventHandler(this, &MyForm::change_sm_dm);
  149. this->text_m->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::m_key_pressed);
  150. //
  151. // label1
  152. //
  153. this->label1->AutoSize = true;
  154. this->label1->Location = System::Drawing::Point(45, 25);
  155. this->label1->Name = L"label1";
  156. this->label1->Size = System::Drawing::Size(70, 13);
  157. this->label1->TabIndex = 1;
  158. this->label1->Text = L"Сантиметры";
  159. this->label1->Click += gcnew System::EventHandler(this, &MyForm::label1_Click);
  160. //
  161. // label2
  162. //
  163. this->label2->AutoSize = true;
  164. this->label2->Location = System::Drawing::Point(148, 25);
  165. this->label2->Name = L"label2";
  166. this->label2->Size = System::Drawing::Size(67, 13);
  167. this->label2->TabIndex = 1;
  168. this->label2->Text = L"Дециметры";
  169. this->label2->Click += gcnew System::EventHandler(this, &MyForm::label1_Click);
  170. //
  171. // label3
  172. //
  173. this->label3->AutoSize = true;
  174. this->label3->Location = System::Drawing::Point(254, 25);
  175. this->label3->Name = L"label3";
  176. this->label3->Size = System::Drawing::Size(41, 13);
  177. this->label3->TabIndex = 1;
  178. this->label3->Text = L"Метры";
  179. this->label3->Click += gcnew System::EventHandler(this, &MyForm::label1_Click);
  180. //
  181. // label4
  182. //
  183. this->label4->AutoSize = true;
  184. this->label4->Location = System::Drawing::Point(45, 81);
  185. this->label4->Name = L"label4";
  186. this->label4->Size = System::Drawing::Size(49, 13);
  187. this->label4->TabIndex = 2;
  188. this->label4->Text = L"Граммы";
  189. //
  190. // gr
  191. //
  192. this->gr->Location = System::Drawing::Point(45, 98);
  193. this->gr->Name = L"gr";
  194. this->gr->Size = System::Drawing::Size(100, 20);
  195. this->gr->TabIndex = 3;
  196. this->gr->TextChanged += gcnew System::EventHandler(this, &MyForm::gr_TextChanged);
  197. this->gr->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::gr_keyPressed);
  198. //
  199. // kg
  200. //
  201. this->kg->Location = System::Drawing::Point(151, 98);
  202. this->kg->Name = L"kg";
  203. this->kg->Size = System::Drawing::Size(100, 20);
  204. this->kg->TabIndex = 3;
  205. this->kg->TextChanged += gcnew System::EventHandler(this, &MyForm::kg_TextChanged);
  206. this->kg->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::kg_keyPressed);
  207. //
  208. // tn
  209. //
  210. this->tn->Location = System::Drawing::Point(257, 98);
  211. this->tn->Name = L"tn";
  212. this->tn->Size = System::Drawing::Size(100, 20);
  213. this->tn->TabIndex = 3;
  214. this->tn->TextChanged += gcnew System::EventHandler(this, &MyForm::tn_changed);
  215. this->tn->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::tn_keyPressed);
  216. //
  217. // label5
  218. //
  219. this->label5->AutoSize = true;
  220. this->label5->Location = System::Drawing::Point(148, 82);
  221. this->label5->Name = L"label5";
  222. this->label5->Size = System::Drawing::Size(73, 13);
  223. this->label5->TabIndex = 2;
  224. this->label5->Text = L"Килограммы";
  225. //
  226. // label6
  227. //
  228. this->label6->AutoSize = true;
  229. this->label6->Location = System::Drawing::Point(254, 82);
  230. this->label6->Name = L"label6";
  231. this->label6->Size = System::Drawing::Size(40, 13);
  232. this->label6->TabIndex = 2;
  233. this->label6->Text = L"Тонны";
  234. //
  235. // sek
  236. //
  237. this->sek->Location = System::Drawing::Point(45, 155);
  238. this->sek->Name = L"sek";
  239. this->sek->Size = System::Drawing::Size(100, 20);
  240. this->sek->TabIndex = 4;
  241. this->sek->TextChanged += gcnew System::EventHandler(this, &MyForm::sek_TextChanged);
  242. this->sek->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::sek_keypressed);
  243. //
  244. // min
  245. //
  246. this->min->Location = System::Drawing::Point(151, 155);
  247. this->min->Name = L"min";
  248. this->min->Size = System::Drawing::Size(100, 20);
  249. this->min->TabIndex = 4;
  250. this->min->TextChanged += gcnew System::EventHandler(this, &MyForm::mins_changed);
  251. this->min->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::mins_pressed);
  252. //
  253. // hours
  254. //
  255. this->hours->Location = System::Drawing::Point(257, 155);
  256. this->hours->Name = L"hours";
  257. this->hours->Size = System::Drawing::Size(100, 20);
  258. this->hours->TabIndex = 4;
  259. this->hours->TextChanged += gcnew System::EventHandler(this, &MyForm::hours_changed);
  260. this->hours->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::hours_keypressed);
  261. //
  262. // label7
  263. //
  264. this->label7->AutoSize = true;
  265. this->label7->Location = System::Drawing::Point(42, 133);
  266. this->label7->Name = L"label7";
  267. this->label7->Size = System::Drawing::Size(51, 13);
  268. this->label7->TabIndex = 5;
  269. this->label7->Text = L"Секунды";
  270. this->label7->Click += gcnew System::EventHandler(this, &MyForm::label7_Click);
  271. //
  272. // label8
  273. //
  274. this->label8->AutoSize = true;
  275. this->label8->Location = System::Drawing::Point(148, 133);
  276. this->label8->Name = L"label8";
  277. this->label8->Size = System::Drawing::Size(46, 13);
  278. this->label8->TabIndex = 5;
  279. this->label8->Text = L"Минуты";
  280. //
  281. // label9
  282. //
  283. this->label9->AutoSize = true;
  284. this->label9->Location = System::Drawing::Point(254, 133);
  285. this->label9->Name = L"label9";
  286. this->label9->Size = System::Drawing::Size(35, 13);
  287. this->label9->TabIndex = 5;
  288. this->label9->Text = L"Часы";
  289. //
  290. // label10
  291. //
  292. this->label10->AutoSize = true;
  293. this->label10->Location = System::Drawing::Point(48, 187);
  294. this->label10->Name = L"label10";
  295. this->label10->Size = System::Drawing::Size(45, 13);
  296. this->label10->TabIndex = 6;
  297. this->label10->Text = L"Гривны";
  298. this->label10->Click += gcnew System::EventHandler(this, &MyForm::label10_Click);
  299. //
  300. // label11
  301. //
  302. this->label11->AutoSize = true;
  303. this->label11->Location = System::Drawing::Point(148, 187);
  304. this->label11->Name = L"label11";
  305. this->label11->Size = System::Drawing::Size(54, 13);
  306. this->label11->TabIndex = 6;
  307. this->label11->Text = L"Доллары";
  308. //
  309. // label12
  310. //
  311. this->label12->AutoSize = true;
  312. this->label12->Location = System::Drawing::Point(254, 187);
  313. this->label12->Name = L"label12";
  314. this->label12->Size = System::Drawing::Size(32, 13);
  315. this->label12->TabIndex = 6;
  316. this->label12->Text = L"Евро";
  317. //
  318. // grivn
  319. //
  320. this->grivn->Location = System::Drawing::Point(45, 204);
  321. this->grivn->Name = L"grivn";
  322. this->grivn->Size = System::Drawing::Size(100, 20);
  323. this->grivn->TabIndex = 7;
  324. this->grivn->TextChanged += gcnew System::EventHandler(this, &MyForm::grivn_changed);
  325. this->grivn->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::grivn_pressed);
  326. //
  327. // dollar
  328. //
  329. this->dollar->Location = System::Drawing::Point(151, 203);
  330. this->dollar->Name = L"dollar";
  331. this->dollar->Size = System::Drawing::Size(100, 20);
  332. this->dollar->TabIndex = 7;
  333. this->dollar->TextChanged += gcnew System::EventHandler(this, &MyForm::dollar_changed);
  334. this->dollar->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::dollar_preeed);
  335. //
  336. // evro
  337. //
  338. this->evro->Location = System::Drawing::Point(257, 203);
  339. this->evro->Name = L"evro";
  340. this->evro->Size = System::Drawing::Size(100, 20);
  341. this->evro->TabIndex = 7;
  342. this->evro->TextChanged += gcnew System::EventHandler(this, &MyForm::evro_changed);
  343. this->evro->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::evro_pressed);
  344. //
  345. // MyForm
  346. //
  347. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  348. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  349. this->ClientSize = System::Drawing::Size(405, 258);
  350. this->Controls->Add(this->evro);
  351. this->Controls->Add(this->dollar);
  352. this->Controls->Add(this->grivn);
  353. this->Controls->Add(this->label12);
  354. this->Controls->Add(this->label11);
  355. this->Controls->Add(this->label10);
  356. this->Controls->Add(this->label9);
  357. this->Controls->Add(this->label8);
  358. this->Controls->Add(this->label7);
  359. this->Controls->Add(this->hours);
  360. this->Controls->Add(this->min);
  361. this->Controls->Add(this->sek);
  362. this->Controls->Add(this->tn);
  363. this->Controls->Add(this->kg);
  364. this->Controls->Add(this->gr);
  365. this->Controls->Add(this->label6);
  366. this->Controls->Add(this->label5);
  367. this->Controls->Add(this->label4);
  368. this->Controls->Add(this->label3);
  369. this->Controls->Add(this->label2);
  370. this->Controls->Add(this->label1);
  371. this->Controls->Add(this->text_m);
  372. this->Controls->Add(this->text_dm);
  373. this->Controls->Add(this->text_sm);
  374. this->Name = L"MyForm";
  375. this->Text = L"Конвертер";
  376. this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
  377. this->ResumeLayout(false);
  378. this->PerformLayout();
  379.  
  380. }
  381. #pragma endregion
  382. private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
  383. }
  384.  
  385. Boolean m_keyPressed = false;
  386. Boolean sm_keyPressed = false;
  387. Boolean dm_keyPressed = false;
  388.  
  389. Boolean gr_keyPressedflag = false;
  390. Boolean kg_keyPressedflag = false;
  391. Boolean tn_keyPressedflag = false;
  392.  
  393. Boolean min_keyPressedflag = false;
  394. Boolean sek_keyPressedflag = false;
  395. Boolean hour_keyPressedflag = false;
  396.  
  397. Boolean grivn_keyPressedflag = false;
  398. Boolean dollar_keyPressedflag = false;
  399. Boolean evro_keyPressedflag = false;
  400.  
  401.  
  402. private: System::Void change_sm_dm(System::Object^ sender, System::EventArgs^ e) {
  403. if (m_keyPressed) {
  404. m_keyPressed = false;
  405. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  406.  
  407. if (text_m->Text != ""){
  408. if (text_m->Text->IndexOf(TorZ) != text_m->Text->Length - 1){
  409. text_sm->Text = Convert::ToString(Convert::ToDouble((text_m->Text)) * 100);
  410. text_dm->Text = Convert::ToString(Convert::ToDouble((text_m->Text)) * 10);
  411. }
  412. }
  413. else
  414. {
  415. text_sm->Text = "0";
  416. text_dm->Text = "0";
  417. }
  418.  
  419. }
  420. }
  421. private: System::Void m_key_pressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  422. // Выясняем что установлено в настройках в качестве разделителя
  423. // точка или запятая
  424. m_keyPressed = true;
  425. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  426.  
  427. bool TZFound = false; // Разделительный знак найден
  428. if (Char::IsDigit(e->KeyChar) == true) return;
  429. if (e->KeyChar == (char)Keys::Back) return;
  430. if (text_m->Text->IndexOf(TorZ) != -1)
  431. TZFound = true;
  432. if (TZFound == true) { e->Handled = true; return; }
  433.  
  434. if (e->KeyChar.ToString() == TorZ) return;
  435. e->Handled = true;
  436.  
  437. }
  438. private: System::Void change_dm(System::Object^ sender, System::EventArgs^ e) {
  439. if (dm_keyPressed) {
  440. dm_keyPressed = false;
  441. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  442.  
  443. if (text_dm->Text != ""){
  444. if (text_dm->Text->IndexOf(TorZ) != text_dm->Text->Length - 1){
  445. text_m->Text = Convert::ToString(Convert::ToDouble((text_dm->Text)) / 10);
  446. text_sm->Text = Convert::ToString(Convert::ToDouble((text_dm->Text)) * 10);
  447. }
  448. }
  449. else
  450. {
  451. text_m->Text = "0";
  452. text_sm->Text = "0";
  453. }
  454. }
  455. }
  456. private: System::Void dm_keypressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  457. // Выясняем что установлено в настройках в качестве разделителя
  458. // точка или запятая
  459. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  460. dm_keyPressed = true;
  461.  
  462. bool TZFound = false; // Разделительный знак найден
  463. if (Char::IsDigit(e->KeyChar) == true) return;
  464. if (e->KeyChar == (char)Keys::Back) return;
  465. if (text_dm->Text->IndexOf(TorZ) != -1)
  466. TZFound = true;
  467. if (TZFound == true) { e->Handled = true; return; }
  468.  
  469. if (e->KeyChar.ToString() == TorZ) return;
  470. e->Handled = true;
  471.  
  472. }
  473. private: System::Void sm_changed(System::Object^ sender, System::EventArgs^ e) {
  474. if (sm_keyPressed) {
  475. sm_keyPressed = false;
  476. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  477.  
  478. if (text_sm->Text != ""){
  479. if (text_sm->Text->IndexOf(TorZ) != text_sm->Text->Length - 1){
  480. text_m->Text = Convert::ToString(Convert::ToDouble((text_sm->Text)) / 100);
  481. text_dm->Text = Convert::ToString(Convert::ToDouble((text_sm->Text)) / 10);
  482. }
  483. }
  484. else
  485. {
  486. text_m->Text = "0";
  487. text_dm->Text = "0";
  488. }
  489. }
  490. }
  491. private: System::Void sm_keypressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  492. // Выясняем что установлено в настройках в качестве разделителя
  493. // точка или запятая
  494. sm_keyPressed = true;
  495.  
  496. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  497.  
  498. bool TZFound = false; // Разделительный знак найден
  499. if (Char::IsDigit(e->KeyChar) == true) return;
  500. if (e->KeyChar == (char)Keys::Back) return;
  501. if (text_sm->Text->IndexOf(TorZ) != -1)
  502. TZFound = true;
  503. if (TZFound == true) { e->Handled = true; return; }
  504.  
  505. if (e->KeyChar.ToString() == TorZ) return;
  506. e->Handled = true;
  507. }
  508. private: System::Void tn_changed(System::Object^ sender, System::EventArgs^ e) {
  509. if (tn_keyPressedflag) {
  510. tn_keyPressedflag = false;
  511. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  512.  
  513. if (tn->Text != ""){
  514. if (tn->Text->IndexOf(TorZ) != tn->Text->Length - 1){
  515. kg->Text = Convert::ToString(Convert::ToDouble((tn->Text)) * 1000);
  516. gr->Text = Convert::ToString(Convert::ToDouble((tn->Text)) * 1000000);
  517. }
  518. }
  519. else
  520. {
  521. kg->Text = "0";
  522. gr->Text = "0";
  523. }
  524.  
  525. }
  526. }
  527. private: System::Void tn_keyPressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  528.  
  529. // Выясняем что установлено в настройках в качестве разделителя
  530. // точка или запятая
  531. tn_keyPressedflag = true;
  532.  
  533. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  534.  
  535. bool TZFound = false; // Разделительный знак найден
  536. if (Char::IsDigit(e->KeyChar) == true) return;
  537. if (e->KeyChar == (char)Keys::Back) return;
  538. if (tn->Text->IndexOf(TorZ) != -1)
  539. TZFound = true;
  540. if (TZFound == true) { e->Handled = true; return; }
  541.  
  542. if (e->KeyChar.ToString() == TorZ) return;
  543. e->Handled = true;
  544. }
  545. private: System::Void kg_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  546. if (kg_keyPressedflag) {
  547. kg_keyPressedflag = false;
  548. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  549.  
  550. if (kg->Text != ""){
  551. if (kg->Text->IndexOf(TorZ) != kg->Text->Length - 1){
  552. tn->Text = Convert::ToString(Convert::ToDouble((kg->Text)) / 1000);
  553. gr->Text = Convert::ToString(Convert::ToDouble((kg->Text)) * 1000);
  554. }
  555. }
  556. else
  557. {
  558. tn->Text = "0";
  559. gr->Text = "0";
  560. }
  561.  
  562. }
  563. }
  564. private: System::Void kg_keyPressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  565. // Выясняем что установлено в настройках в качестве разделителя
  566. // точка или запятая
  567. kg_keyPressedflag = true;
  568.  
  569. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  570.  
  571. bool TZFound = false; // Разделительный знак найден
  572. if (Char::IsDigit(e->KeyChar) == true) return;
  573. if (e->KeyChar == (char)Keys::Back) return;
  574. if (kg->Text->IndexOf(TorZ) != -1)
  575. TZFound = true;
  576. if (TZFound == true) { e->Handled = true; return; }
  577.  
  578. if (e->KeyChar.ToString() == TorZ) return;
  579. e->Handled = true;
  580. }
  581. private: System::Void gr_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  582. if (gr_keyPressedflag) {
  583. gr_keyPressedflag = false;
  584. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  585.  
  586. if (gr->Text != ""){
  587. if (gr->Text->IndexOf(TorZ) != gr->Text->Length - 1){
  588. tn->Text = Convert::ToString(Convert::ToDouble((gr->Text)) / 1000000);
  589. kg->Text = Convert::ToString(Convert::ToDouble((gr->Text)) / 1000);
  590. }
  591. }
  592. else
  593. {
  594. tn->Text = "0";
  595. kg->Text = "0";
  596. }
  597.  
  598. }
  599. }
  600. private: System::Void gr_keyPressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  601. // Выясняем что установлено в настройках в качестве разделителя
  602. // точка или запятая
  603. gr_keyPressedflag = true;
  604.  
  605. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  606.  
  607. bool TZFound = false; // Разделительный знак найден
  608. if (Char::IsDigit(e->KeyChar) == true) return;
  609. if (e->KeyChar == (char)Keys::Back) return;
  610. if (gr->Text->IndexOf(TorZ) != -1)
  611. TZFound = true;
  612. if (TZFound == true) { e->Handled = true; return; }
  613.  
  614. if (e->KeyChar.ToString() == TorZ) return;
  615. e->Handled = true;
  616. }
  617. private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
  618. }
  619. private: System::Void label7_Click(System::Object^ sender, System::EventArgs^ e) {
  620. }
  621. private: System::Void hours_changed(System::Object^ sender, System::EventArgs^ e) {
  622. if (hour_keyPressedflag) {
  623. hour_keyPressedflag = false;
  624. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  625.  
  626. if (hours->Text != ""){
  627. if (hours->Text->IndexOf(TorZ) != hours->Text->Length - 1){
  628. min->Text = Convert::ToString(Convert::ToDouble((hours->Text)) *60);
  629. sek->Text = Convert::ToString(Convert::ToDouble((hours->Text)) *3600);
  630. }
  631. }
  632. else
  633. {
  634. min->Text = "0";
  635. sek->Text = "0";
  636. }
  637.  
  638. }
  639. }
  640. private: System::Void hours_keypressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  641. // Выясняем что установлено в настройках в качестве разделителя
  642. // точка или запятая
  643. hour_keyPressedflag = true;
  644.  
  645. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  646.  
  647. bool TZFound = false; // Разделительный знак найден
  648. if (Char::IsDigit(e->KeyChar) == true) return;
  649. if (e->KeyChar == (char)Keys::Back) return;
  650. if (hours->Text->IndexOf(TorZ) != -1)
  651. TZFound = true;
  652. if (TZFound == true) { e->Handled = true; return; }
  653.  
  654. if (e->KeyChar.ToString() == TorZ) return;
  655. e->Handled = true;
  656. }
  657. private: System::Void mins_changed(System::Object^ sender, System::EventArgs^ e) {
  658. if (min_keyPressedflag) {
  659. min_keyPressedflag = false;
  660. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  661.  
  662. if (min->Text != ""){
  663. if (min->Text->IndexOf(TorZ) != min->Text->Length - 1){
  664. hours->Text = Convert::ToString(Convert::ToDouble((min->Text)) / 60);
  665. sek->Text = Convert::ToString(Convert::ToDouble((min->Text)) * 60);
  666. }
  667. }
  668. else
  669. {
  670. hours->Text = "0";
  671. sek->Text = "0";
  672. }
  673.  
  674. }
  675. }
  676. private: System::Void mins_pressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  677. // Выясняем что установлено в настройках в качестве разделителя
  678. // точка или запятая
  679. min_keyPressedflag = true;
  680.  
  681. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  682.  
  683. bool TZFound = false; // Разделительный знак найден
  684. if (Char::IsDigit(e->KeyChar) == true) return;
  685. if (e->KeyChar == (char)Keys::Back) return;
  686. if (min->Text->IndexOf(TorZ) != -1)
  687. TZFound = true;
  688. if (TZFound == true) { e->Handled = true; return; }
  689.  
  690. if (e->KeyChar.ToString() == TorZ) return;
  691. e->Handled = true;
  692. }
  693. private: System::Void sek_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  694. if (sek_keyPressedflag) {
  695. sek_keyPressedflag = false;
  696. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  697.  
  698. if (sek->Text != ""){
  699. if (sek->Text->IndexOf(TorZ) != sek->Text->Length - 1){
  700. hours->Text = Convert::ToString(Convert::ToDouble((sek->Text)) / 3600);
  701. min->Text = Convert::ToString(Convert::ToDouble((sek->Text)) / 60);
  702. }
  703. }
  704. else
  705. {
  706. hours->Text = "0";
  707. min->Text = "0";
  708. }
  709.  
  710. }
  711. }
  712. private: System::Void sek_keypressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  713. // Выясняем что установлено в настройках в качестве разделителя
  714. // точка или запятая
  715. sek_keyPressedflag = true;
  716.  
  717. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  718.  
  719. bool TZFound = false; // Разделительный знак найден
  720. if (Char::IsDigit(e->KeyChar) == true) return;
  721. if (e->KeyChar == (char)Keys::Back) return;
  722. if (sek->Text->IndexOf(TorZ) != -1)
  723. TZFound = true;
  724. if (TZFound == true) { e->Handled = true; return; }
  725.  
  726. if (e->KeyChar.ToString() == TorZ) return;
  727. e->Handled = true;
  728. }
  729. private: System::Void label10_Click(System::Object^ sender, System::EventArgs^ e) {
  730. }
  731. private: System::Void grivn_changed(System::Object^ sender, System::EventArgs^ e) {
  732. if (grivn_keyPressedflag) {
  733. grivn_keyPressedflag = false;
  734. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  735.  
  736. if (grivn->Text != ""){
  737. if (grivn->Text->IndexOf(TorZ) != grivn->Text->Length - 1){
  738. dollar->Text = Convert::ToString(Convert::ToDouble((grivn->Text)) /16);
  739. evro->Text = Convert::ToString(Convert::ToDouble((grivn->Text)) /19 );
  740. }
  741. }
  742. else
  743. {
  744. dollar->Text = "0";
  745. evro->Text = "0";
  746. }
  747.  
  748. }
  749. }
  750. private: System::Void grivn_pressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  751. // Выясняем что установлено в настройках в качестве разделителя
  752. // точка или запятая
  753. grivn_keyPressedflag = true;
  754.  
  755. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  756.  
  757. bool TZFound = false; // Разделительный знак найден
  758. if (Char::IsDigit(e->KeyChar) == true) return;
  759. if (e->KeyChar == (char)Keys::Back) return;
  760. if (grivn->Text->IndexOf(TorZ) != -1)
  761. TZFound = true;
  762. if (TZFound == true) { e->Handled = true; return; }
  763.  
  764. if (e->KeyChar.ToString() == TorZ) return;
  765. e->Handled = true;
  766. }
  767. private: System::Void dollar_changed(System::Object^ sender, System::EventArgs^ e) {
  768. if (dollar_keyPressedflag) {
  769. dollar_keyPressedflag = false;
  770. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  771.  
  772. if (dollar->Text != ""){
  773. if (dollar->Text->IndexOf(TorZ) != dollar->Text->Length - 1){
  774. grivn->Text = Convert::ToString(Convert::ToDouble((dollar->Text)) * 16);
  775. evro->Text = Convert::ToString(Convert::ToDouble((dollar->Text)) * 0.8035);
  776. }
  777. }
  778. else
  779. {
  780. grivn->Text = "0";
  781. evro->Text = "0";
  782. }
  783.  
  784. }
  785. }
  786. private: System::Void dollar_preeed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  787. // Выясняем что установлено в настройках в качестве разделителя
  788. // точка или запятая
  789. dollar_keyPressedflag = true;
  790.  
  791. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  792.  
  793. bool TZFound = false; // Разделительный знак найден
  794. if (Char::IsDigit(e->KeyChar) == true) return;
  795. if (e->KeyChar == (char)Keys::Back) return;
  796. if (dollar->Text->IndexOf(TorZ) != -1)
  797. TZFound = true;
  798. if (TZFound == true) { e->Handled = true; return; }
  799.  
  800. if (e->KeyChar.ToString() == TorZ) return;
  801. e->Handled = true;
  802. }
  803. private: System::Void evro_changed(System::Object^ sender, System::EventArgs^ e) {
  804. if (evro_keyPressedflag) {
  805. evro_keyPressedflag = false;
  806. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  807.  
  808. if (evro->Text != ""){
  809. if (evro->Text->IndexOf(TorZ) != evro->Text->Length - 1){
  810. dollar->Text = Convert::ToString(Convert::ToDouble((evro->Text)) * 1.2445);
  811. grivn->Text = Convert::ToString(Convert::ToDouble((evro->Text)) * 19);
  812. }
  813. }
  814. else
  815. {
  816. dollar->Text = "0";
  817. grivn->Text = "0";
  818. }
  819.  
  820. }
  821. }
  822. private: System::Void evro_pressed(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  823. // Выясняем что установлено в настройках в качестве разделителя
  824. // точка или запятая
  825. evro_keyPressedflag = true;
  826.  
  827. String^ TorZ = Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator; // Точка или запятая
  828.  
  829. bool TZFound = false; // Разделительный знак найден
  830. if (Char::IsDigit(e->KeyChar) == true) return;
  831. if (e->KeyChar == (char)Keys::Back) return;
  832. if (evro->Text->IndexOf(TorZ) != -1)
  833. TZFound = true;
  834. if (TZFound == true) { e->Handled = true; return; }
  835.  
  836. if (e->KeyChar.ToString() == TorZ) return;
  837. e->Handled = true;
  838. }
  839. };
  840. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement