Advertisement
VictoriaLodochkina

kr2

Apr 23rd, 2020
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 30.33 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <cstdlib>
  6. #include <vector>
  7. #include <algorithm>
  8. #include <ctime>
  9. #include <msclr\marshal_cppstd.h>
  10. #include <Windows.h>
  11. int manual_filling = 0;
  12. //std::string path = "text_new.dat";
  13. struct Information
  14. {
  15.     std::string Name;
  16.     std::string Date;
  17.     std::string Problem;
  18.     std::string Status;
  19.     Information(std::string = "", std::string = "", std::string = "", std::string = "");
  20. };
  21. //--------------------------
  22. Information::Information(std::string Name, std::string Date, std::string Problem, std::string Status) {
  23.     this->Name = Name;
  24.     this->Date = Date;
  25.     this->Problem = Problem;
  26.     this->Status = Status;
  27. }
  28.  
  29. std::string randName() {
  30.     size_t size = rand() % 7 + 2;
  31.     std::string s(size, ' ');
  32.     s[0] = static_cast<char>(rand() % ('2' - 'A') + 'A');
  33.     for (size_t i = 1; i < size; i++)
  34.     {
  35.         s[i] = static_cast<char>(rand() % ('z' - 'a') + 'a');
  36.     }
  37.     return s;
  38. }
  39. std::string randDate() {
  40.     size_t size = rand() % 7 + 2;
  41.     std::string s(size, ' ');
  42.     s[0] = static_cast<char>(rand() % ('2' - 'A') + 'A');
  43.     for (size_t i = 1; i < size; i++)
  44.     {
  45.         s[i] = static_cast<char>(rand() % ('z' - 'a') + 'a');
  46.     }
  47.     return s;
  48. }
  49. std::string randProblem() {
  50.     size_t size = rand() % 7 + 2;
  51.     std::string s(size, ' ');
  52.     s[0] = static_cast<char>(rand() % ('2' - 'A') + 'A');
  53.     for (size_t i = 1; i < size; i++)
  54.     {
  55.         s[i] = static_cast<char>(rand() % ('z' - 'a') + 'a');
  56.     }
  57.     return s;
  58. }
  59. std::string randStatus() {
  60.     size_t size = rand() % 7 + 2;
  61.     std::string s(size, ' ');
  62.     s[0] = static_cast<char>(rand() % ('2' - 'A') + 'A');
  63.     for (size_t i = 1; i < size; i++)
  64.     {
  65.         s[i] = static_cast<char>(rand() % ('z' - 'a') + 'a');
  66.     }
  67.     return s;
  68. }
  69.  
  70. void randFill(std::vector<Information>& list) {
  71.     srand(static_cast<unsigned int>(time(nullptr)));
  72.     for (size_t i = 0; i < list.size(); i++) {
  73.         list[i].Name = randName();
  74.         list[i].Date = randDate();
  75.         list[i].Problem = randProblem();
  76.         list[i].Status = randStatus();
  77.     }
  78. }
  79.  
  80. void del_from_vector(std::vector<Information> & list, int in) {
  81.     for (size_t k = 0; k < list.size(); k++)
  82.     {
  83.         if (k==in)
  84.         {
  85.             list.erase(list.begin() + k);
  86.         }
  87.     }
  88. }
  89.  
  90. bool save_list_to_file(std::string path, std::vector<Information> list) {
  91.     std::ofstream file;
  92.     file.open(path.c_str(), std::ios_base::binary | std::ios::out | std::ios::trunc);
  93.     if (file) {
  94.         for (size_t i = 0; i < list.size(); i++) {
  95.             size_t lnlen = list[i].Name.length();
  96.             file.write(reinterpret_cast<char*>(&lnlen), sizeof(lnlen));
  97.             file.write(list[i].Name.c_str(), static_cast<long long>(lnlen));
  98.             size_t lnlen1 = list[i].Date.length();
  99.             file.write(reinterpret_cast<char*>(&lnlen1), sizeof(lnlen1));
  100.             file.write(list[i].Date.c_str(), static_cast<long long>(lnlen1));
  101.             size_t lnlen2 = list[i].Problem.length();
  102.             file.write(reinterpret_cast<char*>(&lnlen2), sizeof(lnlen2));
  103.             file.write(list[i].Problem.c_str(), static_cast<long long>(lnlen2));
  104.             size_t lnlen3 = list[i].Status.length();
  105.             file.write(reinterpret_cast<char*>(&lnlen3), sizeof(lnlen3));
  106.             file.write(list[i].Status.c_str(), static_cast<long long>(lnlen3));
  107.         }
  108.         file.close();
  109.         return true;
  110.     }
  111.     return false;
  112. }
  113. bool load_list_from_file(std::string path, std::vector<Information>& list) {
  114.     std::ifstream file;
  115.     list.clear();
  116.     file.open(path.c_str(), std::ios::binary | std::ios::in);
  117.     if (file) {
  118.         while (!file.eof()) {
  119.             std::string Name;
  120.             size_t lnlen;
  121.             file.read(reinterpret_cast<char*>(&lnlen), sizeof(lnlen));
  122.             if (!file.fail()) {
  123.                 Name.resize(lnlen);
  124.                 file.read(&Name[0], static_cast<long long>(lnlen));
  125.  
  126.                 std::string Date;
  127.                 size_t lnlen1;
  128.                 file.read(reinterpret_cast<char*>(&lnlen1), sizeof(lnlen1));
  129.                 Date.resize(lnlen1);
  130.                 file.read(&Date[0], static_cast<long long>(lnlen1));
  131.  
  132.                 std::string Problem;
  133.                 size_t lnlen2;
  134.                 file.read(reinterpret_cast<char*>(&lnlen2), sizeof(lnlen2));
  135.                 Problem.resize(lnlen2);
  136.                 file.read(&Problem[0], static_cast<long long>(lnlen2));
  137.  
  138.                 std::string Status;
  139.                 size_t lnlen3;
  140.                 file.read(reinterpret_cast<char*>(&lnlen3), sizeof(lnlen3));
  141.                 Status.resize(lnlen3);
  142.                 file.read(&Status[0], static_cast<long long>(lnlen3));
  143.                 list.push_back(Information(Name, Date, Problem, Status));
  144.             }
  145.         }
  146.         file.close();
  147.         return true;
  148.     }
  149.     return false;
  150. }
  151.  
  152.  
  153.  
  154. namespace mypain {
  155.  
  156.     using namespace System;
  157.     using namespace System::ComponentModel;
  158.     using namespace System::Collections;
  159.     using namespace System::Windows::Forms;
  160.     using namespace System::Data;
  161.     using namespace System::Drawing;
  162.  
  163.     /// <summary>
  164.     /// Сводка для MyForm
  165.     /// </summary>
  166.     public ref class MyForm : public System::Windows::Forms::Form
  167.     {
  168.     public:
  169.         MyForm(void)
  170.         {
  171.             InitializeComponent();
  172.             //
  173.             //TODO: добавьте код конструктора
  174.             //
  175.         }
  176.  
  177.     protected:
  178.         /// <summary>
  179.         /// Освободить все используемые ресурсы.
  180.         /// </summary>
  181.         ~MyForm()
  182.         {
  183.             if (components)
  184.             {
  185.                 delete components;
  186.             }
  187.         }
  188.     private: System::Windows::Forms::ContextMenuStrip^ contextMenuStrip1;
  189.     protected:
  190.  
  191.  
  192.     private: System::Windows::Forms::ToolStrip^ toolStrip1;
  193.     private: System::Windows::Forms::MenuStrip^ menuStrip1;
  194.     private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem1;
  195.     private: System::Windows::Forms::ToolStripMenuItem^ saveToolStripMenuItem1;
  196.  
  197.  
  198.  
  199.     private: System::Windows::Forms::OpenFileDialog^ openFileDialog1;
  200.     private: System::Windows::Forms::SaveFileDialog^ saveFileDialog1;
  201.     private: System::Windows::Forms::DataGridView^ dataGridView1;
  202.     private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column1;
  203.     private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column2;
  204.     private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column3;
  205.     private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column4;
  206.     private: System::Windows::Forms::ToolStripMenuItem^ openToolStripMenuItem;
  207.  
  208.  
  209.  
  210.  
  211.  
  212.     private: System::Windows::Forms::ToolStripButton^ toolStripButton1;
  213.     private: System::Windows::Forms::ToolStripButton^ toolStripButton2;
  214.     private: System::Windows::Forms::ToolStripButton^ toolStripButton3;
  215.     private: System::Windows::Forms::ToolStripMenuItem^ actionsToolStripMenuItem;
  216.     private: System::Windows::Forms::ToolStripMenuItem^ increaseRowCountToolStripMenuItem;
  217.     private: System::Windows::Forms::ToolStripMenuItem^ randomToolStripMenuItem;
  218.     private: System::Windows::Forms::ToolStripMenuItem^ reduceRowCountToolStripMenuItem;
  219.     private: System::Windows::Forms::ToolStripMenuItem^ currentRowToolStripMenuItem;
  220.     private: System::Windows::Forms::ToolStripMenuItem^ processedPositionsToolStripMenuItem;
  221.     private: System::Windows::Forms::ToolStripMenuItem^ manualFillToolStripMenuItem;
  222.  
  223.     private: System::Windows::Forms::ToolStripMenuItem^ deleteToolStripMenuItem;
  224.     private: System::Windows::Forms::ToolStripMenuItem^ clearAllToolStripMenuItem1;
  225.     private: System::Windows::Forms::ToolStripMenuItem^ findProcessedPositionToolStripMenuItem;
  226.     private: System::Windows::Forms::ToolStripMenuItem^ highlightNotProcessedToolStripMenuItem;
  227.     private: System::Windows::Forms::ToolStripMenuItem^ highlightingToolStripMenuItem;
  228.     private: System::Windows::Forms::ToolStripMenuItem^ highlightProcessedToolStripMenuItem;
  229.     private: System::Windows::Forms::ToolStripMenuItem^ highlightDelayedPositionsToolStripMenuItem;
  230.     private: System::Windows::Forms::ToolStripMenuItem^ highlightCurrentPositionsToolStripMenuItem;
  231.  
  232.  
  233.     private: System::ComponentModel::IContainer^ components;
  234.  
  235.     private:
  236.         /// <summary>
  237.         /// Обязательная переменная конструктора.
  238.         /// </summary>
  239.  
  240.  
  241. #pragma region Windows Form Designer generated code
  242.         /// <summary>
  243.         /// Требуемый метод для поддержки конструктора — не изменяйте
  244.         /// содержимое этого метода с помощью редактора кода.
  245.         /// </summary>
  246.         void InitializeComponent(void)
  247.         {
  248.             this->components = (gcnew System::ComponentModel::Container());
  249.             System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
  250.             this->contextMenuStrip1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
  251.             this->findProcessedPositionToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  252.             this->highlightNotProcessedToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  253.             this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
  254.             this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
  255.             this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());
  256.             this->toolStripButton3 = (gcnew System::Windows::Forms::ToolStripButton());
  257.             this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
  258.             this->fileToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
  259.             this->saveToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
  260.             this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  261.             this->clearAllToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
  262.             this->actionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  263.             this->increaseRowCountToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  264.             this->randomToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  265.             this->reduceRowCountToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  266.             this->currentRowToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  267.             this->processedPositionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  268.             this->deleteToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  269.             this->manualFillToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  270.             this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
  271.             this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());
  272.             this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
  273.             this->Column1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  274.             this->Column2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  275.             this->Column3 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  276.             this->Column4 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  277.             this->highlightingToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  278.             this->highlightProcessedToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  279.             this->highlightDelayedPositionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  280.             this->highlightCurrentPositionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  281.             this->contextMenuStrip1->SuspendLayout();
  282.             this->toolStrip1->SuspendLayout();
  283.             this->menuStrip1->SuspendLayout();
  284.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit();
  285.             this->SuspendLayout();
  286.             //
  287.             // contextMenuStrip1
  288.             //
  289.             this->contextMenuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {
  290.                 this->findProcessedPositionToolStripMenuItem,
  291.                     this->highlightNotProcessedToolStripMenuItem
  292.             });
  293.             this->contextMenuStrip1->Name = L"contextMenuStrip1";
  294.             this->contextMenuStrip1->Size = System::Drawing::Size(215, 48);
  295.             //
  296.             // findProcessedPositionToolStripMenuItem
  297.             //
  298.             this->findProcessedPositionToolStripMenuItem->Name = L"findProcessedPositionToolStripMenuItem";
  299.             this->findProcessedPositionToolStripMenuItem->Size = System::Drawing::Size(214, 22);
  300.             this->findProcessedPositionToolStripMenuItem->Text = L"Delete Processed Positions";
  301.             this->findProcessedPositionToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::processedPositionsToolStripMenuItem_Click);
  302.             //
  303.             // highlightNotProcessedToolStripMenuItem
  304.             //
  305.             this->highlightNotProcessedToolStripMenuItem->Name = L"highlightNotProcessedToolStripMenuItem";
  306.             this->highlightNotProcessedToolStripMenuItem->Size = System::Drawing::Size(214, 22);
  307.             this->highlightNotProcessedToolStripMenuItem->Text = L"Highlight Not Processed";
  308.             //
  309.             // toolStrip1
  310.             //
  311.             this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  312.                 this->toolStripButton1,
  313.                     this->toolStripButton2, this->toolStripButton3
  314.             });
  315.             this->toolStrip1->Location = System::Drawing::Point(0, 24);
  316.             this->toolStrip1->Name = L"toolStrip1";
  317.             this->toolStrip1->Size = System::Drawing::Size(636, 25);
  318.             this->toolStrip1->TabIndex = 1;
  319.             this->toolStrip1->Text = L"toolStrip1";
  320.             //
  321.             // toolStripButton1
  322.             //
  323.             this->toolStripButton1->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
  324.             this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"toolStripButton1.Image")));
  325.             this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
  326.             this->toolStripButton1->Name = L"toolStripButton1";
  327.             this->toolStripButton1->Size = System::Drawing::Size(23, 22);
  328.             this->toolStripButton1->Text = L"toolStripButton1";
  329.             this->toolStripButton1->Click += gcnew System::EventHandler(this, &MyForm::saveToolStripMenuItem1_Click);
  330.             //
  331.             // toolStripButton2
  332.             //
  333.             this->toolStripButton2->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
  334.             this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"toolStripButton2.Image")));
  335.             this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Magenta;
  336.             this->toolStripButton2->Name = L"toolStripButton2";
  337.             this->toolStripButton2->Size = System::Drawing::Size(23, 22);
  338.             this->toolStripButton2->Text = L"toolStripButton2";
  339.             this->toolStripButton2->Click += gcnew System::EventHandler(this, &MyForm::manualFillToolStripMenuItem_Click);
  340.             //
  341.             // toolStripButton3
  342.             //
  343.             this->toolStripButton3->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
  344.             this->toolStripButton3->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"toolStripButton3.Image")));
  345.             this->toolStripButton3->ImageTransparentColor = System::Drawing::Color::Magenta;
  346.             this->toolStripButton3->Name = L"toolStripButton3";
  347.             this->toolStripButton3->Size = System::Drawing::Size(23, 22);
  348.             this->toolStripButton3->Text = L"toolStripButton3";
  349.             this->toolStripButton3->Click += gcnew System::EventHandler(this, &MyForm::openToolStripMenuItem_Click);
  350.             //
  351.             // menuStrip1
  352.             //
  353.             this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  354.                 this->fileToolStripMenuItem1,
  355.                     this->actionsToolStripMenuItem, this->highlightingToolStripMenuItem
  356.             });
  357.             this->menuStrip1->Location = System::Drawing::Point(0, 0);
  358.             this->menuStrip1->Name = L"menuStrip1";
  359.             this->menuStrip1->Size = System::Drawing::Size(636, 24);
  360.             this->menuStrip1->TabIndex = 2;
  361.             this->menuStrip1->Text = L"menuStrip1";
  362.             //
  363.             // fileToolStripMenuItem1
  364.             //
  365.             this->fileToolStripMenuItem1->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  366.                 this->saveToolStripMenuItem1,
  367.                     this->openToolStripMenuItem, this->clearAllToolStripMenuItem1
  368.             });
  369.             this->fileToolStripMenuItem1->Name = L"fileToolStripMenuItem1";
  370.             this->fileToolStripMenuItem1->Size = System::Drawing::Size(37, 20);
  371.             this->fileToolStripMenuItem1->Text = L"File";
  372.             //
  373.             // saveToolStripMenuItem1
  374.             //
  375.             this->saveToolStripMenuItem1->Name = L"saveToolStripMenuItem1";
  376.             this->saveToolStripMenuItem1->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::S));
  377.             this->saveToolStripMenuItem1->Size = System::Drawing::Size(180, 22);
  378.             this->saveToolStripMenuItem1->Text = L"Save";
  379.             this->saveToolStripMenuItem1->Click += gcnew System::EventHandler(this, &MyForm::saveToolStripMenuItem1_Click);
  380.             //
  381.             // openToolStripMenuItem
  382.             //
  383.             this->openToolStripMenuItem->Name = L"openToolStripMenuItem";
  384.             this->openToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::O));
  385.             this->openToolStripMenuItem->Size = System::Drawing::Size(180, 22);
  386.             this->openToolStripMenuItem->Text = L"Open";
  387.             this->openToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::openToolStripMenuItem_Click);
  388.             //
  389.             // clearAllToolStripMenuItem1
  390.             //
  391.             this->clearAllToolStripMenuItem1->Name = L"clearAllToolStripMenuItem1";
  392.             this->clearAllToolStripMenuItem1->Size = System::Drawing::Size(180, 22);
  393.             this->clearAllToolStripMenuItem1->Text = L"Clear all";
  394.             //
  395.             // actionsToolStripMenuItem
  396.             //
  397.             this->actionsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {
  398.                 this->increaseRowCountToolStripMenuItem,
  399.                     this->randomToolStripMenuItem, this->reduceRowCountToolStripMenuItem, this->manualFillToolStripMenuItem
  400.             });
  401.             this->actionsToolStripMenuItem->Name = L"actionsToolStripMenuItem";
  402.             this->actionsToolStripMenuItem->Size = System::Drawing::Size(59, 20);
  403.             this->actionsToolStripMenuItem->Text = L"Actions";
  404.             //
  405.             // increaseRowCountToolStripMenuItem
  406.             //
  407.             this->increaseRowCountToolStripMenuItem->Name = L"increaseRowCountToolStripMenuItem";
  408.             this->increaseRowCountToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::I));
  409.             this->increaseRowCountToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  410.             this->increaseRowCountToolStripMenuItem->Text = L"Increase Row Count";
  411.             this->increaseRowCountToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::increaseRowCountToolStripMenuItem_Click);
  412.             //
  413.             // randomToolStripMenuItem
  414.             //
  415.             this->randomToolStripMenuItem->Name = L"randomToolStripMenuItem";
  416.             this->randomToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::R));
  417.             this->randomToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  418.             this->randomToolStripMenuItem->Text = L"Random Fill";
  419.             this->randomToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::randomToolStripMenuItem_Click);
  420.             //
  421.             // reduceRowCountToolStripMenuItem
  422.             //
  423.             this->reduceRowCountToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  424.                 this->currentRowToolStripMenuItem,
  425.                     this->processedPositionsToolStripMenuItem, this->deleteToolStripMenuItem
  426.             });
  427.             this->reduceRowCountToolStripMenuItem->Name = L"reduceRowCountToolStripMenuItem";
  428.             this->reduceRowCountToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  429.             this->reduceRowCountToolStripMenuItem->Text = L"Reduce Row Count";
  430.             this->reduceRowCountToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::reduceRowCountToolStripMenuItem_Click);
  431.             //
  432.             // currentRowToolStripMenuItem
  433.             //
  434.             this->currentRowToolStripMenuItem->Name = L"currentRowToolStripMenuItem";
  435.             this->currentRowToolStripMenuItem->Size = System::Drawing::Size(180, 22);
  436.             this->currentRowToolStripMenuItem->Text = L"Current Row";
  437.             this->currentRowToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::currentRowToolStripMenuItem_Click);
  438.             //
  439.             // processedPositionsToolStripMenuItem
  440.             //
  441.             this->processedPositionsToolStripMenuItem->Name = L"processedPositionsToolStripMenuItem";
  442.             this->processedPositionsToolStripMenuItem->Size = System::Drawing::Size(180, 22);
  443.             this->processedPositionsToolStripMenuItem->Text = L"Processed Positions";
  444.             this->processedPositionsToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::processedPositionsToolStripMenuItem_Click);
  445.             //
  446.             // deleteToolStripMenuItem
  447.             //
  448.             this->deleteToolStripMenuItem->Name = L"deleteToolStripMenuItem";
  449.             this->deleteToolStripMenuItem->Size = System::Drawing::Size(180, 22);
  450.             this->deleteToolStripMenuItem->Text = L"Delete";
  451.             this->deleteToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::deleteToolStripMenuItem_Click);
  452.             //
  453.             // manualFillToolStripMenuItem
  454.             //
  455.             this->manualFillToolStripMenuItem->Name = L"manualFillToolStripMenuItem";
  456.             this->manualFillToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::M));
  457.             this->manualFillToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  458.             this->manualFillToolStripMenuItem->Text = L"Manual Fill";
  459.             this->manualFillToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::manualFillToolStripMenuItem_Click);
  460.             //
  461.             // openFileDialog1
  462.             //
  463.             this->openFileDialog1->FileName = L"openFileDialog1";
  464.             //
  465.             // dataGridView1
  466.             //
  467.             this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  468.             this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(4) {
  469.                 this->Column1,
  470.                     this->Column2, this->Column3, this->Column4
  471.             });
  472.             this->dataGridView1->ContextMenuStrip = this->contextMenuStrip1;
  473.             this->dataGridView1->Location = System::Drawing::Point(99, 69);
  474.             this->dataGridView1->Name = L"dataGridView1";
  475.             this->dataGridView1->Size = System::Drawing::Size(445, 150);
  476.             this->dataGridView1->TabIndex = 3;
  477.             //
  478.             // Column1
  479.             //
  480.             this->Column1->HeaderText = L"Name";
  481.             this->Column1->Name = L"Column1";
  482.             //
  483.             // Column2
  484.             //
  485.             this->Column2->HeaderText = L"Date";
  486.             this->Column2->Name = L"Column2";
  487.             //
  488.             // Column3
  489.             //
  490.             this->Column3->HeaderText = L"Problem";
  491.             this->Column3->Name = L"Column3";
  492.             //
  493.             // Column4
  494.             //
  495.             this->Column4->HeaderText = L"Status";
  496.             this->Column4->Name = L"Column4";
  497.             //
  498.             // highlightingToolStripMenuItem
  499.             //
  500.             this->highlightingToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  501.                 this->highlightProcessedToolStripMenuItem,
  502.                     this->highlightDelayedPositionsToolStripMenuItem, this->highlightCurrentPositionsToolStripMenuItem
  503.             });
  504.             this->highlightingToolStripMenuItem->Name = L"highlightingToolStripMenuItem";
  505.             this->highlightingToolStripMenuItem->Size = System::Drawing::Size(86, 20);
  506.             this->highlightingToolStripMenuItem->Text = L"Highlighting";
  507.             //
  508.             // highlightProcessedToolStripMenuItem
  509.             //
  510.             this->highlightProcessedToolStripMenuItem->Name = L"highlightProcessedToolStripMenuItem";
  511.             this->highlightProcessedToolStripMenuItem->Size = System::Drawing::Size(231, 22);
  512.             this->highlightProcessedToolStripMenuItem->Text = L"Highlight Processed Positions";
  513.             this->highlightProcessedToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::highlightProcessedToolStripMenuItem_Click);
  514.             //
  515.             // highlightDelayedPositionsToolStripMenuItem
  516.             //
  517.             this->highlightDelayedPositionsToolStripMenuItem->Name = L"highlightDelayedPositionsToolStripMenuItem";
  518.             this->highlightDelayedPositionsToolStripMenuItem->Size = System::Drawing::Size(231, 22);
  519.             this->highlightDelayedPositionsToolStripMenuItem->Text = L"Highlight Delayed Positions";
  520.             //
  521.             // highlightCurrentPositionsToolStripMenuItem
  522.             //
  523.             this->highlightCurrentPositionsToolStripMenuItem->Name = L"highlightCurrentPositionsToolStripMenuItem";
  524.             this->highlightCurrentPositionsToolStripMenuItem->Size = System::Drawing::Size(231, 22);
  525.             this->highlightCurrentPositionsToolStripMenuItem->Text = L"Highlight Current Positions";
  526.             //
  527.             // MyForm
  528.             //
  529.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  530.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  531.             this->ClientSize = System::Drawing::Size(636, 287);
  532.             this->Controls->Add(this->dataGridView1);
  533.             this->Controls->Add(this->toolStrip1);
  534.             this->Controls->Add(this->menuStrip1);
  535.             this->MainMenuStrip = this->menuStrip1;
  536.             this->Name = L"MyForm";
  537.             this->Text = L"MyForm";
  538.             this->contextMenuStrip1->ResumeLayout(false);
  539.             this->toolStrip1->ResumeLayout(false);
  540.             this->toolStrip1->PerformLayout();
  541.             this->menuStrip1->ResumeLayout(false);
  542.             this->menuStrip1->PerformLayout();
  543.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit();
  544.             this->ResumeLayout(false);
  545.             this->PerformLayout();
  546.  
  547.         }
  548. #pragma endregion
  549.  
  550.  
  551. private: System::Void increaseRowCountToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  552.     dataGridView1->RowCount++;
  553. }
  554.  
  555.        void fill_grid(std::vector<Information>& list) {
  556.            size_t sz = list.size();
  557.            dataGridView1->RowCount = sz;
  558.            for (size_t i = 0; i < sz; i++)
  559.            {
  560.                dataGridView1->Rows[i]->Cells[0]->Value = gcnew System::String(list[i].Name.c_str());
  561.                dataGridView1->Rows[i]->Cells[1]->Value = gcnew System::String(list[i].Date.c_str());
  562.                dataGridView1->Rows[i]->Cells[2]->Value = gcnew System::String(list[i].Problem.c_str());
  563.                dataGridView1->Rows[i]->Cells[3]->Value = gcnew System::String(list[i].Status.c_str());
  564.            }
  565. }
  566. void fill_list_by_grid(std::vector<Information>& list, int& manual_filling) {
  567.     size_t sz = dataGridView1->RowCount;
  568.     sz -= manual_filling;
  569.     list.clear();
  570.     list.resize(sz);
  571.     for (size_t i = 0; i < sz; i++)
  572.            {
  573.                list[i].Name = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[0]->Value->ToString());
  574.                list[i].Date = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[1]->Value->ToString());
  575.                list[i].Problem = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[2]->Value->ToString());
  576.                list[i].Status = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[3]->Value->ToString());
  577.            }
  578. }
  579. private: System::Void randomToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  580.     manual_filling = 0;
  581.     int n = dataGridView1->RowCount;
  582.     std::vector<Information> list(n);
  583.     randFill(list);
  584.     fill_grid(list);
  585. }
  586. private: System::Void reduceRowCountToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  587.     dataGridView1->RowCount--;
  588. }
  589.  
  590. private: System::Void currentRowToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  591.     int n = dataGridView1->RowCount;
  592.     std::vector<Information> list(n);
  593.     fill_list_by_grid(list, manual_filling);
  594.     int in = dataGridView1->CurrentRow->Index;
  595.     del_from_vector(list, in);      
  596.     fill_grid(list);
  597.     //fill_list_by_grid(list, manual_filling);
  598. }
  599. private: System::Void clearAllToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  600.     dataGridView1->Rows[0]->Cells[0]->Value = L""; ////////////////////////////////////////             ЕНТО ДИЧЬ
  601. }
  602.  
  603.        void fill_list_by_grid_manual(std::vector<Information>& list, int& manual_filling) {
  604.            size_t sz = dataGridView1->RowCount;
  605.            sz--;
  606.            list.clear();
  607.            list.resize(sz);
  608.            for (size_t i = 0; i < sz; i++)
  609.            {
  610.                //if (msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[0]->Value->ToString()) !=" ")
  611.                list[i].Name = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[0]->Value->ToString());
  612.               // if (msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[1]->Value->ToString()) != " ")
  613.                list[i].Date = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[1]->Value->ToString());
  614.                //if (msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[2]->Value->ToString()) != " ")
  615.                list[i].Problem = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[2]->Value->ToString());
  616.               // if (msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[3]->Value->ToString()) != " ")
  617.                list[i].Status = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[3]->Value->ToString());
  618.            }
  619.        }
  620.  
  621. private: System::Void manualFillToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  622.     //manual_filling = 1;
  623.     int n = dataGridView1->RowCount;
  624.     //n -= manual_filling;
  625.     std::vector<Information> list(n);
  626.     fill_list_by_grid_manual(list, manual_filling);
  627.  
  628.     del_from_vector(list, n-1);
  629.     fill_grid(list);
  630. }
  631.  
  632. private: System::Void deleteToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  633.     dataGridView1->RowCount--;
  634. }
  635.  
  636. private: System::Void saveToolStripMenuItem1_Click(System::Object^ sender, System::EventArgs^ e) {
  637.     int n = dataGridView1->RowCount;
  638.     n -= manual_filling;
  639.     std::vector<Information> list(n);
  640.     fill_list_by_grid(list, manual_filling); /////////////!!!!!!!!!!!!!!!!!!!!мб на одну запись меньше
  641.     saveFileDialog1->ShowDialog();
  642.     std::string path = msclr::interop::marshal_as<std::string>(saveFileDialog1->FileName);
  643.     save_list_to_file(path, list);
  644. }
  645. private: System::Void openToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  646.     openFileDialog1->ShowDialog();
  647.     std::string path = msclr::interop::marshal_as<std::string>(openFileDialog1->FileName);
  648.     std::vector<Information> list;
  649.     load_list_from_file(path, list);
  650.     dataGridView1->RowCount = list.size();
  651.     fill_grid(list);///трабл мб с единицей
  652. }
  653.  
  654. private: System::Void processedPositionsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  655.     int n = dataGridView1->RowCount;
  656.     std::vector<Information> list(n);
  657.     fill_list_by_grid(list, manual_filling);
  658.     for (int i = 0; i < list.size(); i++)
  659.     {
  660.         if (list[i].Status == "обработано")
  661.         {
  662.             del_from_vector(list, i);
  663.         }
  664.     }
  665.     fill_grid(list);
  666. }
  667.        private: System::Void highlightProcessedToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  668.            int n = dataGridView1->RowCount;
  669.            std::vector<Information> list(n);
  670.            fill_list_by_grid(list, manual_filling);
  671.            for (int i = 0; i < dataGridView1->ColumnCount; i++)
  672.            {
  673.                for (int j = 0; j < dataGridView1->RowCount; j++)
  674.                {
  675.                    if (dataGridView1->Rows[j]->Cells[3]->Value->ToString() == "обработано")
  676.                    {
  677.                        dataGridView1->Rows[j]->Cells[i]->Style->BackColor = Drawing::Color::Green;
  678.                    }
  679.                }
  680.            }
  681.            fill_grid(list);
  682.        }
  683. };
  684. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement