📄 robotconfig.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Robotconfig.h"
#include "Approbot.h"
#include "Robot.h"
#include "mainform.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Trobotdialog *robotdialog;
//---------------------------------------------------------------------------
__fastcall Trobotdialog::Trobotdialog(TComponent* Owner)
: TForm(Owner)
{
robotchat = new TApprobot; //一个用来保存机器人属性的类对象;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::btCancelClick(TObject *Sender)
{
//AnsiString str;
//this->robotchat->RefreshRobot();
//delete robotchat;
this->Close();
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::btAboutClick(TObject *Sender)
{
ShellAbout(Handle, ("关于"+Application->Title+"#").c_str(),
("\n"+Application->Title+" Robot1.0\n\n"+"周天佑 版权所有!").c_str(),
Application->Icon->Handle);
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::tbNameChange(TObject *Sender)
{
robotchat->robotname = tbName->Text;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::RadioButtonMaleClick(TObject *Sender)
{
this->robotchat->robotsex = "男";
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::RadioButtonFemaleClick(TObject *Sender)
{
this->robotchat->robotsex = "女";
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::UpDown1Click(TObject *Sender, TUDBtnType Button)
{
this->robotchat->robotage = StrToInt(this->tbAge->Text);
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::tbAgeChange(TObject *Sender)
{
this->robotchat->robotage = StrToInt(this->tbAge->Text);
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::clbChatListcolorChange(TObject *Sender)
{
this->robotchat->chatlistcolor = this->clbChatListcolor->Color;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::clbChatFontcolorChange(TObject *Sender)
{
this->robotchat->chatfontcolor = this->clbChatFontcolor->Color;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::clbListcolorChange(TObject *Sender)
{
this->robotchat->listcolor = this->clbListcolor->Color;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::clbFontcolorChange(TObject *Sender)
{
this->robotchat->fontcolor = this->clbFontcolor->Color;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::rdblocalClick(TObject *Sender)
{
this->robotchat->uselocal = true;
this->robotchat->usemetor = false;
this->Label8->Enabled = false;
this->Label9->Enabled = false;
this->edtchatport->Enabled = false;
this->medchataddress->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::rdblongrangeClick(TObject *Sender)
{
this->Label8->Enabled = true;
this->Label9->Enabled = true;
this->edtchatport->Enabled = true;
this->medchataddress->Enabled = true;
this->rdblongrange->Checked = true;
this->robotchat->usemetor = true;
this->robotchat->uselocal = false;
this->robotchat->usemetor = true;
this->robotchat->metoraddress = this->medchataddress->Text;
this->robotchat->metorpore = StrToInt(this->edtchatport->Text);
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::FormCreate(TObject *Sender)
{
this->robotchat->RefreshRobot();
robotchat->loadfrominifiles();
this->RadioButtonFemale->Checked = true;
this->RadioButtonMale->Checked = false;
this->Label8->Enabled = false;
this->Label9->Enabled = false;
this->medchataddress->Enabled = false;
this->edtchatport->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::medchataddressChange(TObject *Sender)
{
this->robotchat->metoraddress = this->medchataddress->Text;
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::edtchatportChange(TObject *Sender)
{
this->robotchat->metorpore = StrToInt(this->edtchatport->Text);
}
//---------------------------------------------------------------------------
void __fastcall Trobotdialog::Button1Click(TObject *Sender)
{
AnsiString message;
message = this->robotchat->SetRobotString();
ShowMessage(message);
Form1->aRobot->Name = robotdialog->robotchat->robotname;
Form1->aRobot->Age = robotdialog->robotchat->robotage;
if(robotdialog->robotchat->robotsex == "男" )
Form1->aRobot->Sex = ChatRobot::Male;
else
if(robotdialog->robotchat->robotsex == "女")
Form1->aRobot->Sex = ChatRobot::Female;
else
Form1->aRobot->Sex = -1;
Form1->mbChatList->Color = robotdialog->clbChatFontcolor->Selected;
Form1->mbChatList->Font->Color = robotdialog->clbChatListcolor->Selected;
Form1->mbMyInfo->Color = robotdialog->clbListcolor->Selected;
Form1->mbMyInfo->Font->Color = robotdialog->clbFontcolor->Selected;
Form1->aRobot->Introduce();
robotdialog->robotchat->savetoinifiles();
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -