//---------------------------------------------------------------------------

#ifndef ChatClientMainFormH
#define ChatClientMainFormH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include "IdBaseComponent.hpp"
#include "IdComponent.hpp"
#include "IdTCPClient.hpp"
#include "IdTCPConnection.hpp"
#include <ComCtrls.hpp>
#include "IdAntiFreeze.hpp"
#include "IdAntiFreezeBase.hpp"
//---------------------------------------------------------------------------

enum TDirection
{
  dirSEND,
  dirRECV,
  dirNEITHER
};

class TfrmChatClientMain : public TForm
{
__published:  // IDE-managed Components
  TPanel *pnlBottom;
  TComboBox *lstServer;
  TLabeledEdit *ledtPort;
  TButton *btnConnect;
  TLabel *Label7;
  TLabeledEdit *ledtCommand;
  TButton *btnSend;
  TIdTCPClient *tcpClient;
  TRichEdit *mmoHistory;
  TCheckBox *chkInsertLinesAtTop;
  TIdAntiFreeze *IdAntiFreeze1;
  TStatusBar *StatusBar1;
  void __fastcall FormCreate(TObject *Sender);
  void __fastcall btnConnectClick(TObject *Sender);
  void __fastcall btnSendClick(TObject *Sender);
  void __fastcall tcpClientConnected(TObject *Sender);
  void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
  void __fastcall ledtCommandKeyPress(TObject *Sender, wchar_t &Key);

private:
  void ConnectToServer(void);
  void DisconnectFromServer(void);
  void SendCommand(const String& command);
  void UpdateOutput(const String& s, TDirection dir = dirNEITHER);

  String FClientIP;
  String FClientPort;

public:
  __fastcall TfrmChatClientMain(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TfrmChatClientMain *frmChatClientMain;
//---------------------------------------------------------------------------
#endif