/////////////////////////////////////////////////////////////////////
// Form1.h - Main Form declaration for message-passing demo //
// //
// Jim Fawcett, CSE687 - Object Oriented Design, Spring 2006 //
/////////////////////////////////////////////////////////////////////
#pragma once
#include "../SocketServer.h"
#include "../Sockets.h"
#include "../diagnostics.h"
namespace TestForm {
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 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.
///
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void) : SenderConnected(false), count(0)
{
InitializeComponent();
message_ = "a message";
pServer = new SocketServer;
pSender = new Socket;
}
protected:
///
/// Clean up any resources being used.
///
~Form1()
{
if (components)
{
delete components;
}
delete pServer;
delete pSender;
}
private: System::Windows::Forms::TextBox^ addressBox;
protected:
private: System::Windows::Forms::Button^ connectButton;
private: System::Windows::Forms::ComboBox^ localPortComboBox;
private: System::Windows::Forms::Button^ listenButton;
private: System::Windows::Forms::ComboBox^ remotePortComboBox;
private: System::Windows::Forms::TextBox^ messageTextBox;
private: System::Windows::Forms::GroupBox^ groupBox1;
private: System::Windows::Forms::GroupBox^ groupBox2;
private: System::Windows::Forms::Button^ MessageButton;
private: System::Windows::Forms::Button^ sendButton;
protected:
private:
///
/// Required designer variable.
///
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
void InitializeComponent(void)
{
this->addressBox = (gcnew System::Windows::Forms::TextBox());
this->connectButton = (gcnew System::Windows::Forms::Button());
this->localPortComboBox = (gcnew System::Windows::Forms::ComboBox());
this->listenButton = (gcnew System::Windows::Forms::Button());
this->remotePortComboBox = (gcnew System::Windows::Forms::ComboBox());
this->messageTextBox = (gcnew System::Windows::Forms::TextBox());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->sendButton = (gcnew System::Windows::Forms::Button());
this->MessageButton = (gcnew System::Windows::Forms::Button());
this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
this->groupBox1->SuspendLayout();
this->SuspendLayout();
//
// addressBox
//
this->addressBox->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast(0)));
this->addressBox->Location = System::Drawing::Point(44, 57);
this->addressBox->Name = L"addressBox";
this->addressBox->Size = System::Drawing::Size(214, 23);
this->addressBox->TabIndex = 0;
this->addressBox->Text = L"localhost";
this->addressBox->TextAlign = System::Windows::Forms::HorizontalAlignment::Center;
//
// connectButton
//
this->connectButton->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast(0)));
this->connectButton->Location = System::Drawing::Point(337, 28);
this->connectButton->Name = L"connectButton";
this->connectButton->Size = System::Drawing::Size(58, 31);
this->connectButton->TabIndex = 1;
this->connectButton->Text = L"connect";
this->connectButton->TextAlign = System::Drawing::ContentAlignment::TopCenter;
this->connectButton->UseVisualStyleBackColor = true;
this->connectButton->Click += gcnew System::EventHandler(this, &Form1::connectButton_Click);
//
// localPortComboBox
//
this->localPortComboBox->DisplayMember = L"0";
this->localPortComboBox->FlatStyle = System::Windows::Forms::FlatStyle::System;
this->localPortComboBox->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast(0)));
this->localPortComboBox->FormattingEnabled = true;
this->localPortComboBox->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"4048", L"4049", L"4050"});
this->localPortComboBox->Location = System::Drawing::Point(286, 108);
this->localPortComboBox->Name = L"localPortComboBox";
this->localPortComboBox->Size = System::Drawing::Size(59, 24);
this->localPortComboBox->TabIndex = 3;
this->localPortComboBox->Text = L"4048";
//
// listenButton
//
this->listenButton->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast(0)));
this->listenButton->Location = System::Drawing::Point(361, 103);
this->listenButton->Name = L"listenButton";
this->listenButton->Size = System::Drawing::Size(58, 31);
this->listenButton->TabIndex = 4;
this->listenButton->Text = L"listen";
this->listenButton->TextAlign = System::Drawing::ContentAlignment::TopCenter;
this->listenButton->UseVisualStyleBackColor = true;
this->listenButton->Click += gcnew System::EventHandler(this, &Form1::listenButton_Click);
//
// remotePortComboBox
//
this->remotePortComboBox->DisplayMember = L"0";
this->remotePortComboBox->FlatStyle = System::Windows::Forms::FlatStyle::System;
this->remotePortComboBox->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast(0)));
this->remotePortComboBox->FormattingEnabled = true;
this->remotePortComboBox->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"4048", L"4049", L"4050"});
this->remotePortComboBox->Location = System::Drawing::Point(286, 58);
this->remotePortComboBox->Name = L"remotePortComboBox";
this->remotePortComboBox->Size = System::Drawing::Size(59, 24);
this->remotePortComboBox->TabIndex = 3;
this->remotePortComboBox->Text = L"4048";
//
// messageTextBox
//
this->messageTextBox->AcceptsReturn = true;
this->messageTextBox->Anchor = static_cast((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->messageTextBox->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast(0)));
this->messageTextBox->Location = System::Drawing::Point(44, 197);
this->messageTextBox->Multiline = true;
this->messageTextBox->Name = L"messageTextBox";
this->messageTextBox->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
this->messageTextBox->Size = System::Drawing::Size(375, 180);
this->messageTextBox->TabIndex = 0;
//
// groupBox1
//
this->groupBox1->Controls->Add(this->sendButton);
this->groupBox1->Controls->Add(this->MessageButton);
this->groupBox1->Controls->Add(this->connectButton);
this->groupBox1->Location = System::Drawing::Point(24, 28);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(422, 122);
this->groupBox1->TabIndex = 5;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"controls";
//
// sendButton
//
this->sendButton->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast(0)));
this->sendButton->Location = System::Drawing::Point(176, 75);
this->sendButton->Name = L"sendButton";
this->sendButton->Size = System::Drawing::Size(58, 31);
this->sendButton->TabIndex = 4;
this->sendButton->Text = L"send";
this->sendButton->TextAlign = System::Drawing::ContentAlignment::TopCenter;
this->sendButton->UseVisualStyleBackColor = true;
this->sendButton->Click += gcnew System::EventHandler(this, &Form1::sendButton_Click);
//
// MessageButton
//
this->MessageButton->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast(0)));
this->MessageButton->Location = System::Drawing::Point(20, 75);
this->MessageButton->Name = L"MessageButton";
this->MessageButton->Size = System::Drawing::Size(135, 31);
this->MessageButton->TabIndex = 0;
this->MessageButton->Text = L"Message Center";
this->MessageButton->TextAlign = System::Drawing::ContentAlignment::TopCenter;
this->MessageButton->UseVisualStyleBackColor = true;
this->MessageButton->Click += gcnew System::EventHandler(this, &Form1::MessageButton_Click);
//
// groupBox2
//
this->groupBox2->Anchor = static_cast((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->groupBox2->Location = System::Drawing::Point(24, 171);
this->groupBox2->Name = L"groupBox2";
this->groupBox2->Size = System::Drawing::Size(422, 234);
this->groupBox2->TabIndex = 5;
this->groupBox2->TabStop = false;
this->groupBox2->Text = L"messages";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(474, 447);
this->Controls->Add(this->listenButton);
this->Controls->Add(this->remotePortComboBox);
this->Controls->Add(this->localPortComboBox);
this->Controls->Add(this->messageTextBox);
this->Controls->Add(this->addressBox);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->groupBox1);
this->Name = L"Form1";
this->Text = L"Comm Test Form";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->groupBox1->ResumeLayout(false);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
public:
System::Void DisplayMessage(String^ msg);
System::Void ClearMessages();
private:
System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e);
System::Void listenButton_Click(System::Object^ sender, System::EventArgs^ e);
System::Void sendButton_Click(System::Object^ sender, System::EventArgs^ e);
System::Void connectButton_Click(System::Object^ sender, System::EventArgs^ e);
System::Void MessageButton_Click(System::Object^ sender, System::EventArgs^ e);
String^ message_;
SocketServer* pServer;
Socket* pSender;
bool SenderConnected;
int count;
};
}