form1.h

来自「《VC++2005编程实例》第一章的源代码」· C头文件 代码 · 共 429 行 · 第 1/2 页

H
429
字号
			this->radioButton3->TabStop = true;
			this->radioButton3->Text = L"解释";
			this->radioButton3->UseVisualStyleBackColor = true;
			this->radioButton3->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton3_CheckedChanged);
			// 
			// radioButton2
			// 
			this->radioButton2->AutoSize = true;
			this->radioButton2->Location = System::Drawing::Point(16, 43);
			this->radioButton2->Name = L"radioButton2";
			this->radioButton2->Size = System::Drawing::Size(47, 16);
			this->radioButton2->TabIndex = 1;
			this->radioButton2->TabStop = true;
			this->radioButton2->Text = L"惊讶";
			this->radioButton2->UseVisualStyleBackColor = true;
			this->radioButton2->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton2_CheckedChanged);
			// 
			// radioButton1
			// 
			this->radioButton1->AutoSize = true;
			this->radioButton1->Location = System::Drawing::Point(16, 21);
			this->radioButton1->Name = L"radioButton1";
			this->radioButton1->Size = System::Drawing::Size(47, 16);
			this->radioButton1->TabIndex = 0;
			this->radioButton1->TabStop = true;
			this->radioButton1->Text = L"祝贺";
			this->radioButton1->UseVisualStyleBackColor = true;
			this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton1_CheckedChanged);
			// 
			// groupBox2
			// 
			this->groupBox2->Controls->Add(this->button1);
			this->groupBox2->Controls->Add(this->checkBox1);
			this->groupBox2->Controls->Add(this->axAgent1);
			this->groupBox2->Controls->Add(this->richTextBox1);
			this->groupBox2->Location = System::Drawing::Point(12, 91);
			this->groupBox2->Name = L"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(366, 82);
			this->groupBox2->TabIndex = 2;
			this->groupBox2->TabStop = false;
			this->groupBox2->Text = L"设置默林精灵说话内容";
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(264, 53);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(96, 23);
			this->button1->TabIndex = 2;
			this->button1->Text = L"演示说话效果";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// checkBox1
			// 
			this->checkBox1->AutoSize = true;
			this->checkBox1->Checked = true;
			this->checkBox1->CheckState = System::Windows::Forms::CheckState::Checked;
			this->checkBox1->Location = System::Drawing::Point(264, 23);
			this->checkBox1->Name = L"checkBox1";
			this->checkBox1->Size = System::Drawing::Size(96, 16);
			this->checkBox1->TabIndex = 1;
			this->checkBox1->Text = L"隐藏默林精灵";
			this->checkBox1->UseVisualStyleBackColor = true;
			this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
			// 
			// richTextBox1
			// 
			this->richTextBox1->Location = System::Drawing::Point(7, 21);
			this->richTextBox1->Name = L"richTextBox1";
			this->richTextBox1->Size = System::Drawing::Size(251, 55);
			this->richTextBox1->TabIndex = 0;
			this->richTextBox1->Text = L"欢迎大家学习Visual C++ 2005编程新技术";
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(390, 186);
			this->Controls->Add(this->groupBox2);
			this->Controls->Add(this->groupBox1);
			this->Name = L"Form1";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"演示设置动画精灵默林动作";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->axAgent1))->EndInit();
			this->groupBox1->ResumeLayout(false);
			this->groupBox1->PerformLayout();
			this->groupBox2->ResumeLayout(false);
			this->groupBox2->PerformLayout();
			this->ResumeLayout(false);

		}
#pragma endregion

	public:   AgentObjects::Agent^ MyController ;
	public:   AgentObjects::IAgentCtlCharacter^ MyCharacter ;
	//初始化精灵对象
	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
			 try
			 {
				 MyController=gcnew AgentObjects::AgentClass();
				 MyController->Connected=true;
				 MyController->Characters->Load("merlin",Application::StartupPath+"\\merlin.acs");
				 MyCharacter=MyController->Characters->Character("merlin");
				 MyCharacter->MoveTo(System::Convert::ToInt16(Location.X + 300), System::Convert::ToInt16(Location.Y + 80), nullptr);   
			 }
			 catch(Exception^ MyEx)
			 {
				 MessageBox::Show(MyEx->Message,"信息提示",MessageBoxButtons::OK,MessageBoxIcon::Information);
			 }
			 }
	//祝贺
	private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton1->Checked)
			{
			    this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("Congratulate");
			}
		}
	//惊讶
	private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton2->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("Surprised");
			}
		 }
	 //解释
	private: System::Void radioButton3_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton3->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("Explain");
			}
		 }
	 //称赞
	private: System::Void radioButton4_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton4->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("Congratulate_2");
			}
		 }
	 //注意
	private: System::Void radioButton5_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton5->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("GetAttentionReturn");
			}
		 }
	 //挥手
	private: System::Void radioButton6_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton6->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("Wave");
			}
		 }
	 //广播
	private: System::Void radioButton7_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton7->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("Announce");
			}
		 }
	 //写字
	private: System::Void radioButton8_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton8->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("Write");
			}
		 }
	 //建议
	private: System::Void radioButton9_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton9->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Play("Suggest");
			}
		 }
	 //反对
	private: System::Void radioButton10_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->radioButton10->Checked)
			{
				this->MyCharacter->StopAll(nullptr);                
				this->MyCharacter->Play("DontRecognize");
			}
		 }
	 //隐藏默林精灵
	private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			if (this->checkBox1->Checked)
			{
				this->MyCharacter->StopAll(nullptr);
				this->MyCharacter->Hide(nullptr);
			}
			else
				this->MyCharacter->Show(nullptr);
		 }
	 //演示说话效果
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 if (this->richTextBox1->Text == String::Empty)
			{
				MessageBox::Show("请输入说话内容!", "信息提示", MessageBoxButtons::OK, MessageBoxIcon::Information);
				return;
			}
			MyCharacter->Speak(this->richTextBox1->Text, nullptr);
		 }
};
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?