Advertisement
Kajoj

Stoper odmierzający w przeszłość - nazwa do ustalenia

Mar 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.84 KB | None | 0 0
  1. #pragma once
  2.  
  3. namespace a {
  4.  
  5.     using namespace System;
  6.     using namespace System::ComponentModel;
  7.     using namespace System::Collections;
  8.     using namespace System::Windows::Forms;
  9.     using namespace System::Data;
  10.     using namespace System::Drawing;
  11.    
  12.     int hours = 0;
  13.     int minutes = 0;
  14.     int seconds = 0;
  15.  
  16.     int stophours = 0;
  17.     int stopminutes = 0;
  18.     int stopseconds = 0;
  19.     int stopmiliseconds = 0;
  20.  
  21.     int lastmiliseconds = 0;
  22.     int lastseconds = 0;
  23.     int terazmiliseconds = 0;
  24.     int terazseconds = 0;
  25.     /// <summary>
  26.     /// Summary for Form1
  27.     /// </summary>
  28.     public ref class Form1 : public System::Windows::Forms::Form
  29.     {
  30.     public:
  31.         Form1(void)
  32.         {
  33.             InitializeComponent();
  34.             //
  35.             //TODO: Add the constructor code here
  36.             //
  37.         }
  38.  
  39.     protected:
  40.         /// <summary>
  41.         /// Clean up any resources being used.
  42.         /// </summary>
  43.         ~Form1()
  44.         {
  45.             if (components)
  46.             {
  47.                 delete components;
  48.             }
  49.         }
  50.  
  51.     protected:
  52.     private: System::Windows::Forms::Label^  HH;
  53.     private: System::Windows::Forms::Label^  label2;
  54.     private: System::Windows::Forms::Label^  MM;
  55.     private: System::Windows::Forms::Label^  label1;
  56.     private: System::Windows::Forms::Label^  SS;
  57.     private: System::Windows::Forms::Timer^  timer1;
  58.     private: System::Windows::Forms::GroupBox^  groupBox1;
  59.     private: System::Windows::Forms::Label^  Stoper;
  60.     private: System::Windows::Forms::GroupBox^  groupBox2;
  61.     private: System::Windows::Forms::Button^  button1;
  62.     private: System::Windows::Forms::Timer^  timer2;
  63.     private: System::Windows::Forms::GroupBox^  groupBox3;
  64.     private: System::Windows::Forms::GroupBox^  groupBox4;
  65.     private: System::Windows::Forms::Label^  wzgledny3;
  66.     private: System::Windows::Forms::Label^  wzgledny1;
  67.     private: System::Windows::Forms::Label^  wzgledny2;
  68.     private: System::Windows::Forms::Label^  miedzyczas3;
  69.     private: System::Windows::Forms::Label^  miedzyczas2;
  70.     private: System::Windows::Forms::Label^  miedzyczas1;
  71.     private: System::ComponentModel::IContainer^  components;
  72.  
  73.     private:
  74.         /// <summary>
  75.         /// Required designer variable.
  76.         /// </summary>
  77.  
  78.  
  79. #pragma region Windows Form Designer generated code
  80.         /// <summary>
  81.         /// Required method for Designer support - do not modify
  82.         /// the contents of this method with the code editor.
  83.         /// </summary>
  84.         void InitializeComponent(void)
  85.         {
  86.             this->components = (gcnew System::ComponentModel::Container());
  87.             this->HH = (gcnew System::Windows::Forms::Label());
  88.             this->label2 = (gcnew System::Windows::Forms::Label());
  89.             this->MM = (gcnew System::Windows::Forms::Label());
  90.             this->label1 = (gcnew System::Windows::Forms::Label());
  91.             this->SS = (gcnew System::Windows::Forms::Label());
  92.             this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
  93.             this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
  94.             this->Stoper = (gcnew System::Windows::Forms::Label());
  95.             this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
  96.             this->groupBox4 = (gcnew System::Windows::Forms::GroupBox());
  97.             this->wzgledny3 = (gcnew System::Windows::Forms::Label());
  98.             this->wzgledny1 = (gcnew System::Windows::Forms::Label());
  99.             this->wzgledny2 = (gcnew System::Windows::Forms::Label());
  100.             this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
  101.             this->miedzyczas3 = (gcnew System::Windows::Forms::Label());
  102.             this->miedzyczas2 = (gcnew System::Windows::Forms::Label());
  103.             this->miedzyczas1 = (gcnew System::Windows::Forms::Label());
  104.             this->button1 = (gcnew System::Windows::Forms::Button());
  105.             this->timer2 = (gcnew System::Windows::Forms::Timer(this->components));
  106.             this->groupBox1->SuspendLayout();
  107.             this->groupBox2->SuspendLayout();
  108.             this->groupBox4->SuspendLayout();
  109.             this->groupBox3->SuspendLayout();
  110.             this->SuspendLayout();
  111.             //
  112.             // HH
  113.             //
  114.             this->HH->AutoSize = true;
  115.             this->HH->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  116.                 static_cast<System::Byte>(238)));
  117.             this->HH->Location = System::Drawing::Point(6, 16);
  118.             this->HH->Name = L"HH";
  119.             this->HH->Size = System::Drawing::Size(53, 38);
  120.             this->HH->TabIndex = 1;
  121.             this->HH->Text = L"00";
  122.             //
  123.             // label2
  124.             //
  125.             this->label2->AutoSize = true;
  126.             this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  127.                 static_cast<System::Byte>(238)));
  128.             this->label2->Location = System::Drawing::Point(50, 16);
  129.             this->label2->Name = L"label2";
  130.             this->label2->Size = System::Drawing::Size(26, 38);
  131.             this->label2->TabIndex = 2;
  132.             this->label2->Text = L":";
  133.             this->label2->Click += gcnew System::EventHandler(this, &Form1::label2_Click);
  134.             //
  135.             // MM
  136.             //
  137.             this->MM->AutoSize = true;
  138.             this->MM->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  139.                 static_cast<System::Byte>(238)));
  140.             this->MM->Location = System::Drawing::Point(68, 16);
  141.             this->MM->Name = L"MM";
  142.             this->MM->Size = System::Drawing::Size(53, 38);
  143.             this->MM->TabIndex = 3;
  144.             this->MM->Text = L"00";
  145.             this->MM->Click += gcnew System::EventHandler(this, &Form1::MM_Click);
  146.             //
  147.             // label1
  148.             //
  149.             this->label1->AutoSize = true;
  150.             this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  151.                 static_cast<System::Byte>(238)));
  152.             this->label1->Location = System::Drawing::Point(113, 16);
  153.             this->label1->Name = L"label1";
  154.             this->label1->Size = System::Drawing::Size(26, 38);
  155.             this->label1->TabIndex = 4;
  156.             this->label1->Text = L":";
  157.             //
  158.             // SS
  159.             //
  160.             this->SS->AutoSize = true;
  161.             this->SS->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  162.                 static_cast<System::Byte>(238)));
  163.             this->SS->Location = System::Drawing::Point(127, 16);
  164.             this->SS->Name = L"SS";
  165.             this->SS->Size = System::Drawing::Size(53, 38);
  166.             this->SS->TabIndex = 5;
  167.             this->SS->Text = L"00";
  168.             //
  169.             // timer1
  170.             //
  171.             this->timer1->Enabled = true;
  172.             this->timer1->Interval = 1000;
  173.             this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
  174.             //
  175.             // groupBox1
  176.             //
  177.             this->groupBox1->Controls->Add(this->HH);
  178.             this->groupBox1->Controls->Add(this->SS);
  179.             this->groupBox1->Controls->Add(this->label2);
  180.             this->groupBox1->Controls->Add(this->MM);
  181.             this->groupBox1->Controls->Add(this->label1);
  182.             this->groupBox1->Location = System::Drawing::Point(342, 12);
  183.             this->groupBox1->Name = L"groupBox1";
  184.             this->groupBox1->Size = System::Drawing::Size(186, 64);
  185.             this->groupBox1->TabIndex = 6;
  186.             this->groupBox1->TabStop = false;
  187.             this->groupBox1->Text = L"Zegar";
  188.             this->groupBox1->Enter += gcnew System::EventHandler(this, &Form1::groupBox1_Enter);
  189.             //
  190.             // Stoper
  191.             //
  192.             this->Stoper->AutoSize = true;
  193.             this->Stoper->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  194.                 static_cast<System::Byte>(238)));
  195.             this->Stoper->Location = System::Drawing::Point(114, 15);
  196.             this->Stoper->Name = L"Stoper";
  197.             this->Stoper->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
  198.             this->Stoper->Size = System::Drawing::Size(80, 38);
  199.             this->Stoper->TabIndex = 7;
  200.             this->Stoper->Text = L"0.00";
  201.             this->Stoper->TextAlign = System::Drawing::ContentAlignment::TopRight;
  202.             this->Stoper->Click += gcnew System::EventHandler(this, &Form1::Stoper_Click);
  203.             //
  204.             // groupBox2
  205.             //
  206.             this->groupBox2->Controls->Add(this->groupBox4);
  207.             this->groupBox2->Controls->Add(this->Stoper);
  208.             this->groupBox2->Controls->Add(this->groupBox3);
  209.             this->groupBox2->Controls->Add(this->button1);
  210.             this->groupBox2->Location = System::Drawing::Point(12, 12);
  211.             this->groupBox2->Name = L"groupBox2";
  212.             this->groupBox2->Size = System::Drawing::Size(325, 176);
  213.             this->groupBox2->TabIndex = 8;
  214.             this->groupBox2->TabStop = false;
  215.             this->groupBox2->Text = L"Stoper";
  216.             this->groupBox2->Enter += gcnew System::EventHandler(this, &Form1::groupBox2_Enter);
  217.             //
  218.             // groupBox4
  219.             //
  220.             this->groupBox4->Controls->Add(this->wzgledny3);
  221.             this->groupBox4->Controls->Add(this->wzgledny1);
  222.             this->groupBox4->Controls->Add(this->wzgledny2);
  223.             this->groupBox4->Location = System::Drawing::Point(178, 91);
  224.             this->groupBox4->Name = L"groupBox4";
  225.             this->groupBox4->Size = System::Drawing::Size(142, 79);
  226.             this->groupBox4->TabIndex = 11;
  227.             this->groupBox4->TabStop = false;
  228.             this->groupBox4->Text = L"Czas względny";
  229.             //
  230.             // wzgledny3
  231.             //
  232.             this->wzgledny3->AutoSize = true;
  233.             this->wzgledny3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  234.                 static_cast<System::Byte>(238)));
  235.             this->wzgledny3->Location = System::Drawing::Point(6, 56);
  236.             this->wzgledny3->Name = L"wzgledny3";
  237.             this->wzgledny3->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
  238.             this->wzgledny3->Size = System::Drawing::Size(40, 20);
  239.             this->wzgledny3->TabIndex = 5;
  240.             this->wzgledny3->Text = L"0.00";
  241.             this->wzgledny3->TextAlign = System::Drawing::ContentAlignment::TopRight;
  242.             //
  243.             // wzgledny1
  244.             //
  245.             this->wzgledny1->AutoSize = true;
  246.             this->wzgledny1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  247.                 static_cast<System::Byte>(238)));
  248.             this->wzgledny1->Location = System::Drawing::Point(6, 16);
  249.             this->wzgledny1->Name = L"wzgledny1";
  250.             this->wzgledny1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
  251.             this->wzgledny1->Size = System::Drawing::Size(40, 20);
  252.             this->wzgledny1->TabIndex = 3;
  253.             this->wzgledny1->Text = L"0.00";
  254.             this->wzgledny1->TextAlign = System::Drawing::ContentAlignment::TopRight;
  255.             //
  256.             // wzgledny2
  257.             //
  258.             this->wzgledny2->AutoSize = true;
  259.             this->wzgledny2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  260.                 static_cast<System::Byte>(238)));
  261.             this->wzgledny2->Location = System::Drawing::Point(6, 36);
  262.             this->wzgledny2->Name = L"wzgledny2";
  263.             this->wzgledny2->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
  264.             this->wzgledny2->Size = System::Drawing::Size(40, 20);
  265.             this->wzgledny2->TabIndex = 4;
  266.             this->wzgledny2->Text = L"0.00";
  267.             this->wzgledny2->TextAlign = System::Drawing::ContentAlignment::TopRight;
  268.             //
  269.             // groupBox3
  270.             //
  271.             this->groupBox3->Controls->Add(this->miedzyczas3);
  272.             this->groupBox3->Controls->Add(this->miedzyczas2);
  273.             this->groupBox3->Controls->Add(this->miedzyczas1);
  274.             this->groupBox3->Location = System::Drawing::Point(6, 91);
  275.             this->groupBox3->Name = L"groupBox3";
  276.             this->groupBox3->Size = System::Drawing::Size(166, 79);
  277.             this->groupBox3->TabIndex = 10;
  278.             this->groupBox3->TabStop = false;
  279.             this->groupBox3->Text = L"Czasy zapisane";
  280.             //
  281.             // miedzyczas3
  282.             //
  283.             this->miedzyczas3->AutoSize = true;
  284.             this->miedzyczas3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  285.                 static_cast<System::Byte>(238)));
  286.             this->miedzyczas3->Location = System::Drawing::Point(6, 56);
  287.             this->miedzyczas3->Name = L"miedzyczas3";
  288.             this->miedzyczas3->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
  289.             this->miedzyczas3->Size = System::Drawing::Size(40, 20);
  290.             this->miedzyczas3->TabIndex = 2;
  291.             this->miedzyczas3->Text = L"0.00";
  292.             this->miedzyczas3->TextAlign = System::Drawing::ContentAlignment::TopRight;
  293.             //
  294.             // miedzyczas2
  295.             //
  296.             this->miedzyczas2->AutoSize = true;
  297.             this->miedzyczas2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  298.                 static_cast<System::Byte>(238)));
  299.             this->miedzyczas2->Location = System::Drawing::Point(6, 36);
  300.             this->miedzyczas2->Name = L"miedzyczas2";
  301.             this->miedzyczas2->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
  302.             this->miedzyczas2->Size = System::Drawing::Size(40, 20);
  303.             this->miedzyczas2->TabIndex = 1;
  304.             this->miedzyczas2->Text = L"0.00";
  305.             this->miedzyczas2->TextAlign = System::Drawing::ContentAlignment::TopRight;
  306.             //
  307.             // miedzyczas1
  308.             //
  309.             this->miedzyczas1->AutoSize = true;
  310.             this->miedzyczas1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  311.                 static_cast<System::Byte>(238)));
  312.             this->miedzyczas1->Location = System::Drawing::Point(6, 16);
  313.             this->miedzyczas1->Name = L"miedzyczas1";
  314.             this->miedzyczas1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
  315.             this->miedzyczas1->Size = System::Drawing::Size(40, 20);
  316.             this->miedzyczas1->TabIndex = 0;
  317.             this->miedzyczas1->Text = L"0.00";
  318.             this->miedzyczas1->TextAlign = System::Drawing::ContentAlignment::TopRight;
  319.             //
  320.             // button1
  321.             //
  322.             this->button1->Location = System::Drawing::Point(114, 56);
  323.             this->button1->Name = L"button1";
  324.             this->button1->Size = System::Drawing::Size(75, 23);
  325.             this->button1->TabIndex = 9;
  326.             this->button1->Text = L"Start";
  327.             this->button1->UseVisualStyleBackColor = true;
  328.             this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
  329.             //
  330.             // timer2
  331.             //
  332.             this->timer2->Interval = 10;
  333.             this->timer2->Tick += gcnew System::EventHandler(this, &Form1::timer2_Tick);
  334.             //
  335.             // Form1
  336.             //
  337.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  338.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  339.             this->ClientSize = System::Drawing::Size(540, 191);
  340.             this->Controls->Add(this->groupBox2);
  341.             this->Controls->Add(this->groupBox1);
  342.             this->Name = L"Form1";
  343.             this->Text = L"Form1";
  344.             this->groupBox1->ResumeLayout(false);
  345.             this->groupBox1->PerformLayout();
  346.             this->groupBox2->ResumeLayout(false);
  347.             this->groupBox2->PerformLayout();
  348.             this->groupBox4->ResumeLayout(false);
  349.             this->groupBox4->PerformLayout();
  350.             this->groupBox3->ResumeLayout(false);
  351.             this->groupBox3->PerformLayout();
  352.             this->ResumeLayout(false);
  353.  
  354.             /*DateTime czas = DateTime::Now;
  355.             hours = czas.Hour;
  356.             minutes = czas.Minute;
  357.             seconds = czas.Second;
  358.             if (System::Convert::ToString(hours)->Length==1)
  359.                 HH->Text="0"+System::Convert::ToString(hours);
  360.             else
  361.                 HH->Text=System::Convert::ToString(hours);
  362.             if (System::Convert::ToString(minutes)->Length==1)
  363.                 MM->Text="0"+System::Convert::ToString(minutes);
  364.             else
  365.                 MM->Text=System::Convert::ToString(minutes);
  366.             if (System::Convert::ToString(seconds)->Length==1)
  367.                 SS->Text="0"+System::Convert::ToString(seconds);
  368.             else
  369.                 SS->Text=System::Convert::ToString(seconds);*/
  370.  
  371.         }
  372. #pragma endregion
  373.     private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
  374.                 seconds ++;
  375.                 if (seconds>=60)
  376.                 {
  377.                     seconds = 0;
  378.                     minutes ++;
  379.                 }
  380.                 if (minutes>=60)
  381.                 {
  382.                     minutes = 0;
  383.                     hours ++;
  384.                 }
  385.                 if (hours>=24)
  386.                 {
  387.                     hours = 0;
  388.                 }
  389.                 if (System::Convert::ToString(hours)->Length==1)
  390.                     HH->Text="0"+System::Convert::ToString(hours);
  391.                 else
  392.                     HH->Text=System::Convert::ToString(hours);
  393.                 if (System::Convert::ToString(minutes)->Length==1)
  394.                     MM->Text="0"+System::Convert::ToString(minutes);
  395.                 else
  396.                     MM->Text=System::Convert::ToString(minutes);
  397.                 if (System::Convert::ToString(seconds)->Length==1)
  398.                     SS->Text="0"+System::Convert::ToString(seconds);
  399.                 else
  400.                     SS->Text=System::Convert::ToString(seconds);
  401.              }
  402. private: System::Void MM_Click(System::Object^  sender, System::EventArgs^  e) {
  403.          }
  404. private: System::Void label2_Click(System::Object^  sender, System::EventArgs^  e) {
  405.          }
  406. private: System::Void groupBox1_Enter(System::Object^  sender, System::EventArgs^  e) {
  407.          }
  408. private: System::Void Stoper_Click(System::Object^  sender, System::EventArgs^  e) {
  409.          }
  410. private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  411.              timer2->Enabled = true;
  412.              button1->Text = "Zapisz";
  413.              DateTime visualsuck = DateTime::Now;
  414.              lastmiliseconds = visualsuck.Millisecond;
  415.              lastseconds = visualsuck.Second;
  416.          }
  417. private: System::Void groupBox2_Enter(System::Object^  sender, System::EventArgs^  e) {
  418.          }
  419. private: System::Void timer2_Tick(System::Object^  sender, System::EventArgs^  e) {
  420.                 DateTime visualsuck= DateTime::Now;
  421.                 terazmiliseconds = visualsuck.Millisecond;
  422.                 terazseconds = visualsuck.Second;
  423.                 if (terazseconds>lastseconds)
  424.                 {
  425.                     stopmiliseconds=stopmiliseconds+(terazmiliseconds+1000)-lastmiliseconds;
  426.                 }
  427.                 else
  428.                 {
  429.                     stopmiliseconds=stopmiliseconds+terazmiliseconds-lastmiliseconds;
  430.                 }
  431.                 if (stopmiliseconds>=1000)
  432.                 {
  433.                     stopmiliseconds = stopmiliseconds-1000;
  434.                     stopseconds ++;
  435.                 }
  436.                 if (stopseconds>=60)
  437.                 {
  438.                     stopseconds = 0;
  439.                     stopminutes ++;
  440.                 }
  441.                 if (stopminutes>=60)
  442.                 {
  443.                     stopminutes = 0;
  444.                     stophours ++;
  445.                 }
  446.                 if (stophours>=24)
  447.                 {
  448.                     stophours = 0;
  449.                 }
  450.                 if (stopminutes>0)
  451.                 {
  452.                     if(stophours>0)
  453.                     {
  454.                         Stoper->Text = System::Convert::ToString(stophours)+":"+System::Convert::ToString(stopminutes)+":"+System::Convert::ToString(stopseconds)+"."+System::Convert::ToString(stopmiliseconds);
  455.                     }
  456.                     else
  457.                     {
  458.                         Stoper->Text = System::Convert::ToString(stopminutes)+":"+System::Convert::ToString(stopseconds)+"."+System::Convert::ToString(stopmiliseconds);
  459.                     }
  460.                 }
  461.                 else
  462.                 {
  463.                     Stoper->Text = System::Convert::ToString(stopseconds)+"."+System::Convert::ToString(stopmiliseconds);
  464.                 }
  465.          }
  466. };
  467.  
  468.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement