Created
September 26, 2013 18:40
-
-
Save RChehowski/6718664 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <iostream> | |
#include <vector> | |
#include <cstdlib> | |
#include <fstream> | |
#include <msclr\marshal_cppstd.h> | |
using namespace std; | |
namespace Shmishek { | |
using namespace System; | |
using namespace System::Reflection; | |
using namespace System::ComponentModel; | |
using namespace System::Collections; | |
using namespace System::Windows::Forms; | |
using namespace System::Data; | |
using namespace System::Drawing; | |
/// <summary> | |
/// Summary for Form1 | |
/// </summary> | |
public ref class Form1 : public System::Windows::Forms::Form | |
{ | |
public: | |
Form1(void) | |
{ | |
InitializeComponent(); | |
} | |
protected: | |
/// <summary> | |
/// Clean up any resources being used. | |
/// </summary> | |
~Form1() | |
{ | |
if (components) | |
{ | |
delete components; | |
} | |
} | |
private: | |
System::Windows::Forms::TextBox^ test_subject_name_box; | |
System::Windows::Forms::TextBox^ test_subject_surname_box; | |
System::Windows::Forms::Button^ calculate_button; | |
System::Windows::Forms::Button^ clear_form_button; | |
array<System::Windows::Forms::CheckBox^> ^check_boxes; | |
int cb_minimum; | |
int cb_maximum; | |
private: | |
/// <summary> | |
/// Required designer variable. | |
/// </summary> | |
System::ComponentModel::Container ^components; | |
#pragma region Windows Form Designer generated code | |
/// <summary> | |
/// Required method for Designer support - do not modify | |
/// the contents of this method with the code editor. | |
/// </summary> | |
void InitializeComponent(void) | |
{ | |
this->SuspendLayout(); | |
this->Reflect(); | |
} | |
#pragma endregion | |
private: | |
System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) | |
{ | |
cb_minimum = 1; | |
cb_maximum = 88; | |
check_boxes = gcnew array<System::Windows::Forms::CheckBox^>(100); | |
//! 1 - 10 | |
foreach(var cb in check_boxes) | |
{ | |
check_boxes[gear] = cb; | |
} | |
} | |
System::Void calculate_button_Click(System::Object^ sender, System::EventArgs^ e) | |
{ | |
if(test_subject_name_box->Text->Length == 0 || test_subject_surname_box->Text->Length == 0) | |
{ | |
MessageBox::Show(gcnew System::String(L"Заполните оба поля: [Имя] и [Фамилия] прежде чем приступать к рассчету метрик."), | |
gcnew System::String("Warning")); | |
return; | |
} | |
wchar_t* characteristic[] = | |
{ | |
L"1. Demonstrativity : ", | |
L"2. Stucking : ", | |
L"3. Pedantivity : ", | |
L"4. Excitable : ", | |
L"5. Hyperintimity : ", | |
L"6. Dystimity : ", | |
L"7. Anxiety : ", | |
L"8. Exaltivity : ", | |
L"9. Emotivity : ", | |
L"10. Cylotimity : ", | |
}; | |
int multipliers[10] = {2, 2, 2, 3, 3, 3, 3, 6, 3, 3}; | |
int coofs_1_pos[] = { 7, 19, 22, 29, 41, 44, 63, 66, 73, 85, 88 }; | |
int coofs_1_neg[] = { 51 }; | |
int coofs_2_pos[] = { 2, 15, 24, 34, 37, 56, 68, 78, 81 }; | |
int coofs_2_neg[] = { 12, 46, 59 }; | |
int coofs_3_pos[] = { 4, 14, 17, 26, 39, 48, 58, 61, 70, 80, 83 }; | |
int coofs_3_neg[] = { 36 }; | |
int coofs_4_pos[] = { 8, 20, 30, 42, 52, 64, 74, 86 }; | |
int coofs_4_neg = 0; | |
int coofs_5_pos[] = { 1, 11, 23, 33, 45, 55, 67, 77 }; | |
int coofs_5_neg = 0; | |
int coofs_6_pos[] = { 9, 21, 43, 75, 87 }; | |
int coofs_6_neg[] = { 31, 53, 65 }; | |
int coofs_7_pos[] = { 16, 27, 38, 49, 60, 71, 82 }; | |
int coofs_7_neg[] = { 5 }; | |
int coofs_8_pos[] = { 10, 32, 54, 76 }; | |
int coofs_8_neg = 0; | |
int coofs_9_pos[] = { 3, 13, 35, 47, 57, 69, 79 }; | |
int coofs_9_neg[] = { 25 }; | |
int coofs_10_pos[] = { 6, 18, 28, 40, 50, 62, 72, 84 }; | |
int coofs_10_neg = 0; | |
int weights[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | |
// 1 | |
for(int i = 0; i < sizeof(coofs_1_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_1_pos[i]]->Checked == true) | |
++weights[0]; | |
} | |
for(int i = 0; i < sizeof(coofs_1_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_1_neg[i]]->Checked == false) | |
++weights[0]; | |
} | |
// 2 | |
for(int i = 0; i < sizeof(coofs_2_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_2_pos[i]]->Checked == true) | |
++weights[1]; | |
} | |
for(int i = 0; i < sizeof(coofs_2_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_2_neg[i]]->Checked == false) | |
++weights[1]; | |
} | |
// 3 | |
for(int i = 0; i < sizeof(coofs_3_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_3_pos[i]]->Checked == true) | |
++weights[2]; | |
} | |
for(int i = 0; i < sizeof(coofs_3_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_3_neg[i]]->Checked == false) | |
++weights[2]; | |
} | |
// 4 | |
for(int i = 0; i < sizeof(coofs_4_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_4_pos[i]]->Checked == true) | |
++weights[3]; | |
} | |
/*for(int i = 0; i < sizeof(coofs_4_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_4_neg[i]]->Checked == false) | |
++weights[3]; | |
}*/ | |
// 5 | |
for(int i = 0; i < sizeof(coofs_5_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_5_pos[i]]->Checked == true) | |
++weights[4]; | |
} | |
/*for(int i = 0; i < sizeof(coofs_5_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_5_neg[i]]->Checked == false) | |
++weights[4]; | |
}*/ | |
// 6 | |
for(int i = 0; i < sizeof(coofs_6_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_6_pos[i]]->Checked == true) | |
++weights[5]; | |
} | |
for(int i = 0; i < sizeof(coofs_6_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_6_neg[i]]->Checked == false) | |
++weights[5]; | |
} | |
// 7 | |
for(int i = 0; i < sizeof(coofs_7_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_7_pos[i]]->Checked == true) | |
++weights[6]; | |
} | |
for(int i = 0; i < sizeof(coofs_7_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_7_neg[i]]->Checked == false) | |
++weights[6]; | |
} | |
// 8 | |
for(int i = 0; i < sizeof(coofs_8_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_8_pos[i]]->Checked == true) | |
++weights[7]; | |
} | |
/*for(int i = 0; i < sizeof(coofs_8_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_8_neg[i]]->Checked == false) | |
++weights[7]; | |
}*/ | |
// 9 | |
for(int i = 0; i < sizeof(coofs_9_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_9_pos[i]]->Checked == true) | |
++weights[8]; | |
} | |
for(int i = 0; i < sizeof(coofs_9_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_9_neg[i]]->Checked == false) | |
++weights[8]; | |
} | |
// 10 | |
for(int i = 0; i < sizeof(coofs_10_pos)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_10_pos[i]]->Checked == true) | |
++weights[9]; | |
} | |
/*for(int i = 0; i < sizeof(coofs_10_neg)/sizeof(int); ++i) | |
{ | |
if(check_boxes[coofs_10_neg[i]]->Checked == false) | |
++weights[9]; | |
}*/ | |
// multiply | |
for(int i = 0; i < 10; ++i) | |
{ | |
weights[i] *= multipliers[i]; | |
} | |
int maximumWeight = 24; | |
//! write to file | |
msclr::interop::marshal_context context; | |
std::wstring subjName = context.marshal_as<std::wstring>(test_subject_name_box->Text); | |
subjName = subjName + L" " + context.marshal_as<std::wstring>(test_subject_surname_box->Text); | |
std::wstring fileName = L"Результат " + subjName + L".txt"; | |
FILE* f = _wfopen(fileName.c_str(), L"w"); | |
fwprintf(f, L"\tResults:\n\n"); | |
for(int i = 0; i < 10; ++i) | |
{ | |
fwprintf(f, L"%s%4d [%.0f%%]\n", characteristic[i], weights[i], | |
((float)weights[i]/(float)maximumWeight) * 100.0f); | |
} | |
fwprintf(f, L"\n\nDEBUG:\n[YES] to: "); | |
for(int i = cb_minimum; i <= cb_maximum; ++i) | |
{ | |
if(check_boxes[i]->Checked) | |
fwprintf(f, L"%d ", i); | |
} | |
fwprintf(f, L"\n[NO] to: "); | |
for(int i = cb_minimum; i <= cb_maximum; ++i) | |
{ | |
if(!check_boxes[i]->Checked) | |
fwprintf(f, L"%d ", i); | |
} | |
fclose(f); | |
std::wstring success_st = L"Oперация успешно завершена, результат записан в файл: '" + fileName + L"'" + L" в папку приложения."; | |
MessageBox::Show(gcnew System::String(success_st.c_str()), | |
gcnew System::String("Success!")); | |
} | |
System::Void clear_form_button_Click(System::Object^ sender, System::EventArgs^ e) | |
{ | |
for(int i = cb_minimum; i <= cb_maximum; ++i) | |
{ | |
check_boxes[i]->Checked = false; | |
} | |
} | |
System::Void linkLabel1_LinkClicked(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e) | |
{ | |
Fox^ fox = gcnew Fox(); | |
fox->Show(); | |
this->Deflect(); | |
} | |
}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment