Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- //#pragma comment (lib, "ws2_32.lib")
- #include "wcomm.h"
- //#include <string>
- #include "pthreads/pthread.h"
- namespace Transfer_pliku_VC {
- 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;
- using namespace System::Threading;
- /// <summary>
- /// Summary for Form1
- ///
- /// WARNING: If you change the name of this class, you will need to change the
- /// 'Resource File Name' property for the managed resource compiler tool
- /// associated with all .resx files this class depends on. Otherwise,
- /// the designers will not be able to interact properly with localized
- /// resources associated with this form.
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- void runserver();
- linkLabel1->Text = "Upuść plik tutaj lub -->";
- linkLabel1->LinkColor = System::Drawing::Color::Black;
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- protected:
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::OpenFileDialog^ openFileDialog1;
- private: System::Windows::Forms::LinkLabel^ linkLabel1;
- private: System::Windows::Forms::Label^ label1;
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- System::ComponentModel::Container ^components;
- private:
- void ThreadTask()
- {
- WComm *w = new WComm();
- w->startServer(27015);
- while (true) {
- // Wait until a client connects
- w->waitForClient();
- // Work with client
- while(true)
- {
- char rec[50] = "";
- w->recvData(rec,32);w->sendData("OK");
- if(strcmp(rec,"FileSend")==0)
- {
- char fname[32] ="";
- w->fileReceive(fname);
- printf("File Received.........\n");
- }
- if(strcmp(rec,"EndConnection")==0)break;
- printf("Connection Ended......\n");
- }
- // Disconnect client
- w->closeConnection();
- }
- }
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- void InitializeComponent(void)
- {
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
- this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->SuspendLayout();
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(197, 12);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(75, 23);
- this->button1->TabIndex = 1;
- this->button1->Text = L"Wczytaj plik";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
- //
- // openFileDialog1
- //
- this->openFileDialog1->FileName = L"openFileDialog1";
- //
- // linkLabel1
- //
- this->linkLabel1->AutoSize = true;
- this->linkLabel1->Location = System::Drawing::Point(12, 17);
- this->linkLabel1->Name = L"linkLabel1";
- this->linkLabel1->Size = System::Drawing::Size(55, 13);
- this->linkLabel1->TabIndex = 2;
- this->linkLabel1->TabStop = true;
- this->linkLabel1->Text = L"linkLabel1";
- this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &Form1::linkLabel1_LinkClicked);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(13, 237);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(35, 13);
- this->label1->TabIndex = 3;
- this->label1->Text = L"label1";
- this->label1->Visible = false;
- //
- // Form1
- //
- this->AllowDrop = true;
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(284, 262);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->linkLabel1);
- this->Controls->Add(this->button1);
- this->Name = L"Form1";
- this->Text = L"Form1";
- this->DragDrop += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::Form1_DragDrop);
- this->DragEnter += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::Form1_DragEnter);
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- openFileDialog1->FileName = "";
- if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
- {
- {linkLabel1->Text = System::IO::Path::GetFileName(openFileDialog1->FileName);}
- label1->Text = openFileDialog1->FileName;
- //{linkLabel1->Text = System::IO::Path::GetFileName(files[0]);}
- }
- }
- private: System::Void linkLabel1_LinkClicked(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e) {
- if (linkLabel1->Text != "Upuść plik tutaj lub -->")
- //System::Diagnostics::Process::Start(openFileDialog1->FileName);
- System::Diagnostics::Process::Start(label1->Text);
- }
- private: System::Void Form1_DragEnter(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e) {
- // make sure they're actually dropping files (not text or anything else)
- if( e->Data->GetDataPresent(DataFormats::FileDrop, false))
- // allow them to continue
- // (without this, the cursor stays a "NO" symbol
- e->Effect = DragDropEffects::All;
- else
- e->Effect = DragDropEffects::Copy;
- }
- private: System::Void Form1_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e) {
- array<String^>^files = (array<String^>^)e->Data->GetData( DataFormats::FileDrop );
- //linkLabel1->Text = (System::String ^)e->Data->GetData(DataFormats::FileDrop);
- label1->Text = files[0];
- linkLabel1->Text = System::IO::Path::GetFileName(files[0]);
- linkLabel1->LinkColor = System::Drawing::Color::Blue;
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement