VictoriaLodochkina

кр3

Apr 24th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 36.80 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.     private: System::Windows::Forms::ToolStripMenuItem^ highlightAllToolStripMenuItem;
  232.     private: System::Windows::Forms::ToolStripMenuItem^ deleteHighlightingToolStripMenuItem;
  233.     private: System::Windows::Forms::ToolStripMenuItem^ addManualFillToolStripMenuItem;
  234.  
  235.  
  236.  
  237.     private: System::ComponentModel::IContainer^ components;
  238.  
  239.     private:
  240.         /// <summary>
  241.         /// Обязательная переменная конструктора.
  242.         /// </summary>
  243.  
  244.  
  245. #pragma region Windows Form Designer generated code
  246.         /// <summary>
  247.         /// Требуемый метод для поддержки конструктора — не изменяйте
  248.         /// содержимое этого метода с помощью редактора кода.
  249.         /// </summary>
  250.         void InitializeComponent(void)
  251.         {
  252.             this->components = (gcnew System::ComponentModel::Container());
  253.             System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
  254.             this->contextMenuStrip1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
  255.             this->findProcessedPositionToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  256.             this->highlightNotProcessedToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  257.             this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
  258.             this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
  259.             this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());
  260.             this->toolStripButton3 = (gcnew System::Windows::Forms::ToolStripButton());
  261.             this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
  262.             this->fileToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
  263.             this->saveToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
  264.             this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  265.             this->clearAllToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
  266.             this->actionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  267.             this->increaseRowCountToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  268.             this->randomToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  269.             this->reduceRowCountToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  270.             this->currentRowToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  271.             this->processedPositionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  272.             this->deleteToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  273.             this->manualFillToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  274.             this->addManualFillToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  275.             this->highlightingToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  276.             this->highlightProcessedToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  277.             this->highlightDelayedPositionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  278.             this->highlightCurrentPositionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  279.             this->highlightAllToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  280.             this->deleteHighlightingToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  281.             this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
  282.             this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());
  283.             this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
  284.             this->Column1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  285.             this->Column2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  286.             this->Column3 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  287.             this->Column4 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  288.             this->contextMenuStrip1->SuspendLayout();
  289.             this->toolStrip1->SuspendLayout();
  290.             this->menuStrip1->SuspendLayout();
  291.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit();
  292.             this->SuspendLayout();
  293.             //
  294.             // contextMenuStrip1
  295.             //
  296.             this->contextMenuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {
  297.                 this->findProcessedPositionToolStripMenuItem,
  298.                     this->highlightNotProcessedToolStripMenuItem
  299.             });
  300.             this->contextMenuStrip1->Name = L"contextMenuStrip1";
  301.             this->contextMenuStrip1->Size = System::Drawing::Size(215, 48);
  302.             //
  303.             // findProcessedPositionToolStripMenuItem
  304.             //
  305.             this->findProcessedPositionToolStripMenuItem->Name = L"findProcessedPositionToolStripMenuItem";
  306.             this->findProcessedPositionToolStripMenuItem->Size = System::Drawing::Size(214, 22);
  307.             this->findProcessedPositionToolStripMenuItem->Text = L"Delete Processed Positions";
  308.             this->findProcessedPositionToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::processedPositionsToolStripMenuItem_Click);
  309.             //
  310.             // highlightNotProcessedToolStripMenuItem
  311.             //
  312.             this->highlightNotProcessedToolStripMenuItem->Name = L"highlightNotProcessedToolStripMenuItem";
  313.             this->highlightNotProcessedToolStripMenuItem->Size = System::Drawing::Size(214, 22);
  314.             this->highlightNotProcessedToolStripMenuItem->Text = L"Highlight Processed";
  315.             this->highlightNotProcessedToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::highlightProcessedToolStripMenuItem_Click);
  316.             //
  317.             // toolStrip1
  318.             //
  319.             this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  320.                 this->toolStripButton1,
  321.                     this->toolStripButton2, this->toolStripButton3
  322.             });
  323.             this->toolStrip1->Location = System::Drawing::Point(0, 24);
  324.             this->toolStrip1->Name = L"toolStrip1";
  325.             this->toolStrip1->Size = System::Drawing::Size(636, 25);
  326.             this->toolStrip1->TabIndex = 1;
  327.             this->toolStrip1->Text = L"toolStrip1";
  328.             //
  329.             // toolStripButton1
  330.             //
  331.             this->toolStripButton1->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
  332.             this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"toolStripButton1.Image")));
  333.             this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
  334.             this->toolStripButton1->Name = L"toolStripButton1";
  335.             this->toolStripButton1->Size = System::Drawing::Size(23, 22);
  336.             this->toolStripButton1->Text = L"toolStripButton1";
  337.             this->toolStripButton1->Click += gcnew System::EventHandler(this, &MyForm::saveToolStripMenuItem1_Click);
  338.             //
  339.             // toolStripButton2
  340.             //
  341.             this->toolStripButton2->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
  342.             this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"toolStripButton2.Image")));
  343.             this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Magenta;
  344.             this->toolStripButton2->Name = L"toolStripButton2";
  345.             this->toolStripButton2->Size = System::Drawing::Size(23, 22);
  346.             this->toolStripButton2->Text = L"toolStripButton2";
  347.             this->toolStripButton2->Click += gcnew System::EventHandler(this, &MyForm::manualFillToolStripMenuItem_Click);
  348.             //
  349.             // toolStripButton3
  350.             //
  351.             this->toolStripButton3->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
  352.             this->toolStripButton3->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"toolStripButton3.Image")));
  353.             this->toolStripButton3->ImageTransparentColor = System::Drawing::Color::Magenta;
  354.             this->toolStripButton3->Name = L"toolStripButton3";
  355.             this->toolStripButton3->Size = System::Drawing::Size(23, 22);
  356.             this->toolStripButton3->Text = L"toolStripButton3";
  357.             this->toolStripButton3->Click += gcnew System::EventHandler(this, &MyForm::openToolStripMenuItem_Click);
  358.             //
  359.             // menuStrip1
  360.             //
  361.             this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  362.                 this->fileToolStripMenuItem1,
  363.                     this->actionsToolStripMenuItem, this->highlightingToolStripMenuItem
  364.             });
  365.             this->menuStrip1->Location = System::Drawing::Point(0, 0);
  366.             this->menuStrip1->Name = L"menuStrip1";
  367.             this->menuStrip1->Size = System::Drawing::Size(636, 24);
  368.             this->menuStrip1->TabIndex = 2;
  369.             this->menuStrip1->Text = L"menuStrip1";
  370.             //
  371.             // fileToolStripMenuItem1
  372.             //
  373.             this->fileToolStripMenuItem1->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  374.                 this->saveToolStripMenuItem1,
  375.                     this->openToolStripMenuItem, this->clearAllToolStripMenuItem1
  376.             });
  377.             this->fileToolStripMenuItem1->Name = L"fileToolStripMenuItem1";
  378.             this->fileToolStripMenuItem1->Size = System::Drawing::Size(37, 20);
  379.             this->fileToolStripMenuItem1->Text = L"File";
  380.             //
  381.             // saveToolStripMenuItem1
  382.             //
  383.             this->saveToolStripMenuItem1->Name = L"saveToolStripMenuItem1";
  384.             this->saveToolStripMenuItem1->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::S));
  385.             this->saveToolStripMenuItem1->Size = System::Drawing::Size(180, 22);
  386.             this->saveToolStripMenuItem1->Text = L"Save";
  387.             this->saveToolStripMenuItem1->Click += gcnew System::EventHandler(this, &MyForm::saveToolStripMenuItem1_Click);
  388.             //
  389.             // openToolStripMenuItem
  390.             //
  391.             this->openToolStripMenuItem->Name = L"openToolStripMenuItem";
  392.             this->openToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::O));
  393.             this->openToolStripMenuItem->Size = System::Drawing::Size(180, 22);
  394.             this->openToolStripMenuItem->Text = L"Open";
  395.             this->openToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::openToolStripMenuItem_Click);
  396.             //
  397.             // clearAllToolStripMenuItem1
  398.             //
  399.             this->clearAllToolStripMenuItem1->Name = L"clearAllToolStripMenuItem1";
  400.             this->clearAllToolStripMenuItem1->Size = System::Drawing::Size(180, 22);
  401.             this->clearAllToolStripMenuItem1->Text = L"Clean all";
  402.             this->clearAllToolStripMenuItem1->Click += gcnew System::EventHandler(this, &MyForm::clearAllToolStripMenuItem1_Click);
  403.             //
  404.             // actionsToolStripMenuItem
  405.             //
  406.             this->actionsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(5) {
  407.                 this->increaseRowCountToolStripMenuItem,
  408.                     this->randomToolStripMenuItem, this->reduceRowCountToolStripMenuItem, this->manualFillToolStripMenuItem, this->addManualFillToolStripMenuItem
  409.             });
  410.             this->actionsToolStripMenuItem->Name = L"actionsToolStripMenuItem";
  411.             this->actionsToolStripMenuItem->Size = System::Drawing::Size(59, 20);
  412.             this->actionsToolStripMenuItem->Text = L"Actions";
  413.             //
  414.             // increaseRowCountToolStripMenuItem
  415.             //
  416.             this->increaseRowCountToolStripMenuItem->Name = L"increaseRowCountToolStripMenuItem";
  417.             this->increaseRowCountToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::I));
  418.             this->increaseRowCountToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  419.             this->increaseRowCountToolStripMenuItem->Text = L"Increase Row Count";
  420.             this->increaseRowCountToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::increaseRowCountToolStripMenuItem_Click);
  421.             //
  422.             // randomToolStripMenuItem
  423.             //
  424.             this->randomToolStripMenuItem->Name = L"randomToolStripMenuItem";
  425.             this->randomToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::R));
  426.             this->randomToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  427.             this->randomToolStripMenuItem->Text = L"Random Fill";
  428.             this->randomToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::randomToolStripMenuItem_Click);
  429.             //
  430.             // reduceRowCountToolStripMenuItem
  431.             //
  432.             this->reduceRowCountToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
  433.                 this->currentRowToolStripMenuItem,
  434.                     this->processedPositionsToolStripMenuItem, this->deleteToolStripMenuItem
  435.             });
  436.             this->reduceRowCountToolStripMenuItem->Name = L"reduceRowCountToolStripMenuItem";
  437.             this->reduceRowCountToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  438.             this->reduceRowCountToolStripMenuItem->Text = L"Reduce Row Count";
  439.             this->reduceRowCountToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::reduceRowCountToolStripMenuItem_Click);
  440.             //
  441.             // currentRowToolStripMenuItem
  442.             //
  443.             this->currentRowToolStripMenuItem->Name = L"currentRowToolStripMenuItem";
  444.             this->currentRowToolStripMenuItem->Size = System::Drawing::Size(178, 22);
  445.             this->currentRowToolStripMenuItem->Text = L"Current Row";
  446.             this->currentRowToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::currentRowToolStripMenuItem_Click);
  447.             //
  448.             // processedPositionsToolStripMenuItem
  449.             //
  450.             this->processedPositionsToolStripMenuItem->Name = L"processedPositionsToolStripMenuItem";
  451.             this->processedPositionsToolStripMenuItem->Size = System::Drawing::Size(178, 22);
  452.             this->processedPositionsToolStripMenuItem->Text = L"Processed Positions";
  453.             this->processedPositionsToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::processedPositionsToolStripMenuItem_Click);
  454.             //
  455.             // deleteToolStripMenuItem
  456.             //
  457.             this->deleteToolStripMenuItem->Name = L"deleteToolStripMenuItem";
  458.             this->deleteToolStripMenuItem->Size = System::Drawing::Size(178, 22);
  459.             this->deleteToolStripMenuItem->Text = L"Delete";
  460.             this->deleteToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::deleteToolStripMenuItem_Click);
  461.             //
  462.             // manualFillToolStripMenuItem
  463.             //
  464.             this->manualFillToolStripMenuItem->Name = L"manualFillToolStripMenuItem";
  465.             this->manualFillToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::M));
  466.             this->manualFillToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  467.             this->manualFillToolStripMenuItem->Text = L"Manual Fill";
  468.             this->manualFillToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::manualFillToolStripMenuItem_Click);
  469.             //
  470.             // addManualFillToolStripMenuItem
  471.             //
  472.             this->addManualFillToolStripMenuItem->Name = L"addManualFillToolStripMenuItem";
  473.             this->addManualFillToolStripMenuItem->Size = System::Drawing::Size(216, 22);
  474.             this->addManualFillToolStripMenuItem->Text = L"Add Manual Fill";
  475.             this->addManualFillToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::addManualFillToolStripMenuItem_Click);
  476.             //
  477.             // highlightingToolStripMenuItem
  478.             //
  479.             this->highlightingToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(5) {
  480.                 this->highlightProcessedToolStripMenuItem,
  481.                     this->highlightDelayedPositionsToolStripMenuItem, this->highlightCurrentPositionsToolStripMenuItem, this->highlightAllToolStripMenuItem,
  482.                     this->deleteHighlightingToolStripMenuItem
  483.             });
  484.             this->highlightingToolStripMenuItem->Name = L"highlightingToolStripMenuItem";
  485.             this->highlightingToolStripMenuItem->Size = System::Drawing::Size(86, 20);
  486.             this->highlightingToolStripMenuItem->Text = L"Highlighting";
  487.             //
  488.             // highlightProcessedToolStripMenuItem
  489.             //
  490.             this->highlightProcessedToolStripMenuItem->Name = L"highlightProcessedToolStripMenuItem";
  491.             this->highlightProcessedToolStripMenuItem->Size = System::Drawing::Size(231, 22);
  492.             this->highlightProcessedToolStripMenuItem->Text = L"Highlight Processed Positions";
  493.             this->highlightProcessedToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::highlightProcessedToolStripMenuItem_Click);
  494.             //
  495.             // highlightDelayedPositionsToolStripMenuItem
  496.             //
  497.             this->highlightDelayedPositionsToolStripMenuItem->Name = L"highlightDelayedPositionsToolStripMenuItem";
  498.             this->highlightDelayedPositionsToolStripMenuItem->Size = System::Drawing::Size(231, 22);
  499.             this->highlightDelayedPositionsToolStripMenuItem->Text = L"Highlight Delayed Positions";
  500.             this->highlightDelayedPositionsToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::highlightDelayedPositionsToolStripMenuItem_Click);
  501.             //
  502.             // highlightCurrentPositionsToolStripMenuItem
  503.             //
  504.             this->highlightCurrentPositionsToolStripMenuItem->Name = L"highlightCurrentPositionsToolStripMenuItem";
  505.             this->highlightCurrentPositionsToolStripMenuItem->Size = System::Drawing::Size(231, 22);
  506.             this->highlightCurrentPositionsToolStripMenuItem->Text = L"Highlight Current Positions";
  507.             this->highlightCurrentPositionsToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::highlightCurrentPositionsToolStripMenuItem_Click);
  508.             //
  509.             // highlightAllToolStripMenuItem
  510.             //
  511.             this->highlightAllToolStripMenuItem->Name = L"highlightAllToolStripMenuItem";
  512.             this->highlightAllToolStripMenuItem->Size = System::Drawing::Size(231, 22);
  513.             this->highlightAllToolStripMenuItem->Text = L"Highlight All";
  514.             this->highlightAllToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::highlightAllToolStripMenuItem_Click);
  515.             //
  516.             // deleteHighlightingToolStripMenuItem
  517.             //
  518.             this->deleteHighlightingToolStripMenuItem->Name = L"deleteHighlightingToolStripMenuItem";
  519.             this->deleteHighlightingToolStripMenuItem->Size = System::Drawing::Size(231, 22);
  520.             this->deleteHighlightingToolStripMenuItem->Text = L"Delete Highlighting";
  521.             this->deleteHighlightingToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::deleteHighlightingToolStripMenuItem_Click);
  522.             //
  523.             // openFileDialog1
  524.             //
  525.             this->openFileDialog1->FileName = L"openFileDialog1";
  526.             //
  527.             // dataGridView1
  528.             //
  529.             this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  530.             this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(4) {
  531.                 this->Column1,
  532.                     this->Column2, this->Column3, this->Column4
  533.             });
  534.             this->dataGridView1->ContextMenuStrip = this->contextMenuStrip1;
  535.             this->dataGridView1->Location = System::Drawing::Point(99, 69);
  536.             this->dataGridView1->Name = L"dataGridView1";
  537.             this->dataGridView1->Size = System::Drawing::Size(446, 177);
  538.             this->dataGridView1->TabIndex = 3;
  539.             //
  540.             // Column1
  541.             //
  542.             this->Column1->HeaderText = L"Name";
  543.             this->Column1->Name = L"Column1";
  544.             //
  545.             // Column2
  546.             //
  547.             this->Column2->HeaderText = L"Date";
  548.             this->Column2->Name = L"Column2";
  549.             //
  550.             // Column3
  551.             //
  552.             this->Column3->HeaderText = L"Problem";
  553.             this->Column3->Name = L"Column3";
  554.             //
  555.             // Column4
  556.             //
  557.             this->Column4->HeaderText = L"Status";
  558.             this->Column4->Name = L"Column4";
  559.             //
  560.             // MyForm
  561.             //
  562.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  563.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  564.             this->ClientSize = System::Drawing::Size(636, 287);
  565.             this->Controls->Add(this->dataGridView1);
  566.             this->Controls->Add(this->toolStrip1);
  567.             this->Controls->Add(this->menuStrip1);
  568.             this->MainMenuStrip = this->menuStrip1;
  569.             this->Name = L"MyForm";
  570.             this->Text = L"MyForm";
  571.             this->contextMenuStrip1->ResumeLayout(false);
  572.             this->toolStrip1->ResumeLayout(false);
  573.             this->toolStrip1->PerformLayout();
  574.             this->menuStrip1->ResumeLayout(false);
  575.             this->menuStrip1->PerformLayout();
  576.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit();
  577.             this->ResumeLayout(false);
  578.             this->PerformLayout();
  579.  
  580.         }
  581. #pragma endregion
  582.  
  583.  
  584. private: System::Void increaseRowCountToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  585.     dataGridView1->RowCount++;
  586. }
  587.  
  588.        void fill_grid(std::vector<Information>& list) {
  589.            size_t sz = list.size();
  590.            dataGridView1->RowCount = sz;
  591.            for (size_t i = 0; i < sz; i++)
  592.            {
  593.                dataGridView1->Rows[i]->Cells[0]->Value = gcnew System::String(list[i].Name.c_str());
  594.                dataGridView1->Rows[i]->Cells[1]->Value = gcnew System::String(list[i].Date.c_str());
  595.                dataGridView1->Rows[i]->Cells[2]->Value = gcnew System::String(list[i].Problem.c_str());
  596.                dataGridView1->Rows[i]->Cells[3]->Value = gcnew System::String(list[i].Status.c_str());
  597.            }
  598. }
  599. void fill_list_by_grid(std::vector<Information>& list, int& manual_filling) {
  600.     size_t sz = dataGridView1->RowCount;
  601.     sz -= manual_filling;
  602.     list.clear();
  603.     list.resize(sz);
  604.     for (size_t i = 0; i < sz; i++)
  605.            {
  606.                list[i].Name = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[0]->Value->ToString());
  607.                list[i].Date = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[1]->Value->ToString());
  608.                list[i].Problem = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[2]->Value->ToString());
  609.                list[i].Status = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[3]->Value->ToString());
  610.            }
  611. }
  612. private: System::Void randomToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  613.     manual_filling = 0;
  614.     int n = dataGridView1->RowCount;
  615.     std::vector<Information> list(n);
  616.     randFill(list);
  617.     fill_grid(list);
  618. }
  619. private: System::Void reduceRowCountToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  620.     dataGridView1->RowCount--;
  621. }
  622.  
  623. private: System::Void currentRowToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  624.     int n = dataGridView1->RowCount;
  625.     std::vector<Information> list(n);
  626.     fill_list_by_grid(list, manual_filling);
  627.     int in = dataGridView1->CurrentRow->Index;
  628.     del_from_vector(list, in);      
  629.     fill_grid(list);
  630.     //fill_list_by_grid(list, manual_filling);
  631. }
  632.  
  633.        void fill_list_by_grid_manual(std::vector<Information>& list, int& manual_filling) {
  634.            size_t sz = dataGridView1->RowCount;
  635.            sz--;
  636.            list.clear();
  637.            list.resize(sz);
  638.            for (size_t i = 0; i < sz; i++)
  639.            {
  640.                //if (msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[0]->Value->ToString()) !=" ")
  641.                list[i].Name = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[0]->Value->ToString());
  642.               // if (msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[1]->Value->ToString()) != " ")
  643.                list[i].Date = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[1]->Value->ToString());
  644.                //if (msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[2]->Value->ToString()) != " ")
  645.                list[i].Problem = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[2]->Value->ToString());
  646.               // if (msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[3]->Value->ToString()) != " ")
  647.                list[i].Status = msclr::interop::marshal_as<std::string>(dataGridView1->Rows[i]->Cells[3]->Value->ToString());
  648.            }
  649.        }
  650.  
  651. private: System::Void manualFillToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  652.     //manual_filling = 1;
  653.     int n = dataGridView1->RowCount;
  654.     //n -= manual_filling;
  655.     std::vector<Information> list(n);
  656.     fill_list_by_grid_manual(list, manual_filling);
  657.     for (int i = 0; i < dataGridView1->RowCount; i++) {
  658.         if (dataGridView1->Rows[i]->Cells[0]->Value == L"") {
  659.             //del_from_vector(list, n - 1);  
  660.             del_from_vector(list, i); //Удалять только пустую строку
  661.         }
  662.     }
  663.     fill_grid(list);
  664. }
  665.  
  666. private: System::Void deleteToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  667.     dataGridView1->RowCount--;
  668. }
  669.  
  670. private: System::Void saveToolStripMenuItem1_Click(System::Object^ sender, System::EventArgs^ e) {
  671.     int n = dataGridView1->RowCount;
  672.     n -= manual_filling;
  673.     std::vector<Information> list(n);
  674.     fill_list_by_grid(list, manual_filling); /////////////!!!!!!!!!!!!!!!!!!!!мб на одну запись меньше
  675.     saveFileDialog1->ShowDialog();
  676.     std::string path = msclr::interop::marshal_as<std::string>(saveFileDialog1->FileName);
  677.     save_list_to_file(path, list);
  678. }
  679. private: System::Void openToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  680.     openFileDialog1->ShowDialog();
  681.     std::string path = msclr::interop::marshal_as<std::string>(openFileDialog1->FileName);
  682.     std::vector<Information> list;
  683.     load_list_from_file(path, list);
  684.     dataGridView1->RowCount = list.size();
  685.     fill_grid(list);///трабл мб с единицей
  686. }
  687.  
  688. private: System::Void processedPositionsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  689.     /*int n = dataGridView1->RowCount;
  690.     std::vector<Information> list(n);
  691.     fill_list_by_grid(list, manual_filling);
  692.     for (int i = 0; i < list.size(); i++)
  693.     {
  694.         if (list[i].Status == "обработано")
  695.         {
  696.             del_from_vector(list, i);
  697.         }
  698.     }
  699.     fill_grid(list);*/
  700.     int n = dataGridView1->RowCount;
  701.     std::vector<Information> list(n);
  702.     fill_list_by_grid(list, manual_filling);
  703.     for (int i = 0; i < dataGridView1->ColumnCount; i++)
  704.     {
  705.         for (int j = 0; j < dataGridView1->RowCount; j++)
  706.         {
  707.             if (dataGridView1->Rows[j]->Cells[3]->Value->ToString() == "обработано")
  708.             {              
  709.                 fill_list_by_grid(list, manual_filling);
  710.                 del_from_vector(list, j);
  711.                 fill_grid(list);
  712.             }
  713.         }
  714.     }
  715.     fill_grid(list);
  716. }
  717.        private: System::Void highlightProcessedToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  718.            int n = dataGridView1->RowCount;
  719.            std::vector<Information> list(n);
  720.            fill_list_by_grid(list, manual_filling);
  721.            for (int i = 0; i < dataGridView1->ColumnCount; i++)
  722.            {
  723.                for (int j = 0; j < dataGridView1->RowCount; j++)
  724.                {
  725.                    if (dataGridView1->Rows[j]->Cells[3]->Value->ToString() == "обработано")
  726.                    {
  727.                        dataGridView1->Rows[j]->Cells[i]->Style->BackColor = Drawing::Color::Green;
  728.                    }
  729.                }
  730.            }
  731.            fill_grid(list);
  732.        }
  733. private: System::Void highlightDelayedPositionsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  734.     int n = dataGridView1->RowCount;
  735.     std::vector<Information> list(n);
  736.     fill_list_by_grid(list, manual_filling);
  737.     for (int i = 0; i < dataGridView1->ColumnCount; i++)
  738.     {
  739.         for (int j = 0; j < dataGridView1->RowCount; j++)
  740.         {
  741.             if (dataGridView1->Rows[j]->Cells[3]->Value->ToString() == "отложено")
  742.             {
  743.                 dataGridView1->Rows[j]->Cells[i]->Style->BackColor = Drawing::Color::Violet;
  744.             }
  745.         }
  746.     }
  747.     fill_grid(list);
  748. }
  749. private: System::Void highlightCurrentPositionsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  750.     int n = dataGridView1->RowCount;
  751.     std::vector<Information> list(n);
  752.     fill_list_by_grid(list, manual_filling);
  753.     for (int i = 0; i < dataGridView1->ColumnCount; i++)
  754.     {
  755.         for (int j = 0; j < dataGridView1->RowCount; j++)
  756.         {
  757.             if (dataGridView1->Rows[j]->Cells[3]->Value->ToString() == "в процессе")
  758.             {
  759.                 dataGridView1->Rows[j]->Cells[i]->Style->BackColor = Drawing::Color::Cyan;        
  760.             }
  761.         }
  762.     }
  763.     fill_grid(list);
  764. }
  765. private: System::Void addNewManualPositionToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  766.     //manual_filling = 1;
  767.     int n = dataGridView1->RowCount;
  768.     //n -= manual_filling;
  769.     std::vector<Information> list(n);
  770.     fill_list_by_grid_manual(list, manual_filling);
  771.     fill_grid(list);
  772. }
  773. private: System::Void highlightAllToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  774.     int n = dataGridView1->RowCount;
  775.     std::vector<Information> list(n);
  776.     fill_list_by_grid(list, manual_filling);
  777.     for (int i = 0; i < dataGridView1->ColumnCount; i++)
  778.     {
  779.         for (int j = 0; j < dataGridView1->RowCount; j++)
  780.         {
  781.             if (dataGridView1->Rows[j]->Cells[3]->Value->ToString() == "в процессе")
  782.             {
  783.                 dataGridView1->Rows[j]->Cells[i]->Style->BackColor = Drawing::Color::Cyan;        
  784.             }
  785.         }
  786.         for (int j = 0; j < dataGridView1->RowCount; j++)
  787.         {
  788.             if (dataGridView1->Rows[j]->Cells[3]->Value->ToString() == "отложено")
  789.             {
  790.                 dataGridView1->Rows[j]->Cells[i]->Style->BackColor = Drawing::Color::Violet;        
  791.             }
  792.         }
  793.         for (int j = 0; j < dataGridView1->RowCount; j++)
  794.         {
  795.             if (dataGridView1->Rows[j]->Cells[3]->Value->ToString() == "обработано")
  796.             {
  797.                 dataGridView1->Rows[j]->Cells[i]->Style->BackColor = Drawing::Color::Green;        
  798.             }
  799.         }
  800.  
  801.     }
  802.     fill_grid(list);
  803. }
  804. private: System::Void deleteHighlightingToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  805.     int n = dataGridView1->RowCount;
  806.     std::vector<Information> list(n);
  807.     fill_list_by_grid(list, manual_filling);
  808.     for (int i = 0; i < dataGridView1->ColumnCount; i++)
  809.     {
  810.         for (int j = 0; j < dataGridView1->RowCount; j++)
  811.         {
  812.             dataGridView1->Rows[j]->Cells[i]->Style->BackColor = Drawing::SystemColors::ControlLightLight;        
  813.         }
  814.     }
  815.     fill_grid(list);
  816. }
  817.  
  818. private: System::Void addManualFillToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  819.     int n = dataGridView1->RowCount;
  820.     std::vector<Information> list(n+1);
  821.     fill_list_by_grid_manual(list, manual_filling);
  822.     fill_grid(list);
  823. }
  824. private: System::Void clearAllToolStripMenuItem1_Click(System::Object^ sender, System::EventArgs^ e) {
  825.  
  826.     int n = dataGridView1->RowCount;
  827.     std::vector<Information> list(n);
  828.     fill_list_by_grid(list, manual_filling);
  829.     for (int i = 1; i < n; i++) {
  830.         del_from_vector(list, i);
  831.     }
  832.     list[0].Name = "";
  833.     list[0].Date = "";
  834.     list[0].Problem = "";
  835.     list[0].Status = "";
  836.     fill_grid(list);
  837. }
  838. };
  839. }
Add Comment
Please, Sign In to add comment