Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Poorly done code by Atton Risk 2015
- #include <string>
- #include <windows.h>
- #include <stdexcept>
- #include <sstream>
- #include <iomanip>
- #include <bitset>
- #include <iostream>
- #include <limits>
- #include <process.h>
- #include <msclr\marshal_cppstd.h>
- #include "bin.h"
- #pragma once
- namespace PingPhuckersGUI {
- using namespace std;
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- /// <summary>
- /// Summary for mainGUI
- /// </summary>
- public ref class mainGUI : public System::Windows::Forms::Form
- {
- public:
- mainGUI(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~mainGUI()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Button^ goButton;
- protected:
- protected:
- private: System::Windows::Forms::TextBox^ pingAddressBox;
- private: System::Windows::Forms::TextBox^ pingOutbox;
- private: System::Windows::Forms::TextBox^ pingDelayBox;
- private: System::Windows::Forms::Label^ pingL;
- private: System::Windows::Forms::Label^ pingServerDelay;
- private: System::ComponentModel::BackgroundWorker^ backgroundWorker1;
- private: System::Windows::Forms::PictureBox^ pictureBox1;
- private:
- bool sysActive;
- void setText(int data)
- {
- pingOutbox->Text = Convert::ToString(data);
- pingOutbox->Refresh();
- cout << data << endl;
- }
- void mainPingThing()
- {
- int speed(0);
- setText(runPing());
- Sleep(2500);
- }
- /// <summary>
- /// Required designer variable.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- void InitializeComponent(void)
- {
- System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(mainGUI::typeid));
- this->goButton = (gcnew System::Windows::Forms::Button());
- this->pingAddressBox = (gcnew System::Windows::Forms::TextBox());
- this->pingOutbox = (gcnew System::Windows::Forms::TextBox());
- this->pingDelayBox = (gcnew System::Windows::Forms::TextBox());
- this->pingL = (gcnew System::Windows::Forms::Label());
- this->pingServerDelay = (gcnew System::Windows::Forms::Label());
- this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
- this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
- this->SuspendLayout();
- //
- // goButton
- //
- this->goButton->Location = System::Drawing::Point(3, 110);
- this->goButton->Name = L"goButton";
- this->goButton->Size = System::Drawing::Size(85, 31);
- this->goButton->TabIndex = 0;
- this->goButton->Text = L"Go";
- this->goButton->UseVisualStyleBackColor = true;
- this->goButton->Click += gcnew System::EventHandler(this, &mainGUI::goButton_Click);
- //
- // pingAddressBox
- //
- this->pingAddressBox->Location = System::Drawing::Point(94, 110);
- this->pingAddressBox->Multiline = true;
- this->pingAddressBox->Name = L"pingAddressBox";
- this->pingAddressBox->Size = System::Drawing::Size(229, 35);
- this->pingAddressBox->TabIndex = 1;
- this->pingAddressBox->Text = L"google.com";
- this->pingAddressBox->TextChanged += gcnew System::EventHandler(this, &mainGUI::pingAddressBox_TextChanged);
- //
- // pingOutbox
- //
- this->pingOutbox->Location = System::Drawing::Point(3, 25);
- this->pingOutbox->MaxLength = 8;
- this->pingOutbox->Name = L"pingOutbox";
- this->pingOutbox->ReadOnly = true;
- this->pingOutbox->Size = System::Drawing::Size(85, 20);
- this->pingOutbox->TabIndex = 2;
- this->pingOutbox->Text = L"0";
- this->pingOutbox->TextChanged += gcnew System::EventHandler(this, &mainGUI::pingOutbox_TextChanged);
- //
- // pingDelayBox
- //
- this->pingDelayBox->Enabled = false;
- this->pingDelayBox->Location = System::Drawing::Point(3, 77);
- this->pingDelayBox->Name = L"pingDelayBox";
- this->pingDelayBox->Size = System::Drawing::Size(92, 20);
- this->pingDelayBox->TabIndex = 3;
- this->pingDelayBox->Text = L"2";
- this->pingDelayBox->Visible = false;
- this->pingDelayBox->TextChanged += gcnew System::EventHandler(this, &mainGUI::pingDelayBox_TextChanged);
- //
- // pingL
- //
- this->pingL->AutoSize = true;
- this->pingL->Location = System::Drawing::Point(0, 9);
- this->pingL->Name = L"pingL";
- this->pingL->Size = System::Drawing::Size(88, 13);
- this->pingL->TabIndex = 4;
- this->pingL->Text = L"Ping Milliseconds";
- //
- // pingServerDelay
- //
- this->pingServerDelay->AutoSize = true;
- this->pingServerDelay->Enabled = false;
- this->pingServerDelay->Location = System::Drawing::Point(0, 61);
- this->pingServerDelay->Name = L"pingServerDelay";
- this->pingServerDelay->Size = System::Drawing::Size(95, 13);
- this->pingServerDelay->TabIndex = 5;
- this->pingServerDelay->Text = L"Ping Server Delay ";
- this->pingServerDelay->Visible = false;
- //
- // pictureBox1
- //
- this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox1.Image")));
- this->pictureBox1->Location = System::Drawing::Point(112, 12);
- this->pictureBox1->Name = L"pictureBox1";
- this->pictureBox1->Size = System::Drawing::Size(196, 85);
- this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::CenterImage;
- this->pictureBox1->TabIndex = 6;
- this->pictureBox1->TabStop = false;
- //
- // backgroundWorker1
- //
- this->backgroundWorker1->WorkerReportsProgress = true;
- this->backgroundWorker1->WorkerSupportsCancellation = true;
- this->backgroundWorker1->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &mainGUI::backgroundWorker1_DoWork_1);
- //
- // mainGUI
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(96, 96);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Dpi;
- this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"$this.BackgroundImage")));
- this->ClientSize = System::Drawing::Size(329, 149);
- this->Controls->Add(this->pictureBox1);
- this->Controls->Add(this->pingServerDelay);
- this->Controls->Add(this->pingL);
- this->Controls->Add(this->pingDelayBox);
- this->Controls->Add(this->pingOutbox);
- this->Controls->Add(this->pingAddressBox);
- this->Controls->Add(this->goButton);
- this->ForeColor = System::Drawing::Color::Black;
- this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
- this->Location = System::Drawing::Point(90, 90);
- this->MaximizeBox = false;
- this->MinimizeBox = false;
- this->Name = L"mainGUI";
- this->ShowIcon = false;
- this->ShowInTaskbar = false;
- this->StartPosition = System::Windows::Forms::FormStartPosition::Manual;
- this->Text = L"PingPhuckers";
- this->TopMost = true;
- this->Load += gcnew System::EventHandler(this, &mainGUI::mainGUI_Load);
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void mainGUI_Load(System::Object^ sender, System::EventArgs^ e)
- {
- // This is when the gui loads lol
- cout << "GUI OPEN" << std::endl;
- sysActive = false;
- load();
- }
- private: System::Void goButton_Click(System::Object^ sender, System::EventArgs^ e)
- {
- String ^ Delay = pingDelayBox->Text;
- String ^ Site = pingAddressBox->Text;
- string theDelay(msclr::interop::marshal_as<std::string>(Delay));
- string theSite(msclr::interop::marshal_as<std::string>(Site));
- int intDelay(atoi(theDelay.c_str()));
- setData(theSite,intDelay);
- if (!sysActive)
- {
- backgroundWorker1->RunWorkerAsync(1);
- Sleep(1000);
- sysActive = true;
- cout << "Go" << endl;
- }
- else if (sysActive)
- {
- backgroundWorker1->CancelAsync();
- Sleep(1000);
- sysActive = false;
- cout << "Stop" << endl;
- }
- //TimerTime->Stop;
- }
- // Holders
- private: System::Void pingAddressBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {}
- private: System::Void pingOutbox_TextChanged(System::Object^ sender, System::EventArgs^ e) {}
- private: System::Void pingDelayBox_TextChanged(System::Object^ sender, System::EventArgs^ e) {}
- /*
- private: System::Void backgroundWorker1_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e)
- {
- }
- */
- private: System::Void backgroundWorker1_DoWork_1(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e)
- {
- while (sysActive)
- {
- if (backgroundWorker1->CancellationPending) //if it was cancelled
- {
- e->Cancel = true;
- break;
- }
- if (!sysActive) //if the progress bar value reached maximum
- {
- break;
- }
- int data = runPing();
- //backgroundWorker1->ReportProgress(0, Convert::ToString(data));
- backgroundWorker1->ReportProgress(0,data.ToString());
- Sleep(1000);
- }
- }
- void backgroundWorker1_ProgressChanged(Object^ sender,ProgressChangedEventArgs^ e)
- {
- auto textData = e->UserState;
- pingOutbox->Text = textData.ToString();
- // Not necessary. The UI will update itself if the main thread is responding.
- pingOutbox->Refresh();
- cout << "MEEP" << endl;
- }
- };
- }
Add Comment
Please, Sign In to add comment