实例介绍
【实例简介】C# 拼图 游戏
【实例截图】
【核心代码】
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
using AgentServerObjects;
using AgentObjects;
using System.Threading;
namespace 拼图游戏
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.IContainer components;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.PictureBox pictureBox5;
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.PictureBox pictureBox7;
private System.Windows.Forms.PictureBox pictureBox8;
private System.Windows.Forms.PictureBox pictureBox9;
private System.Windows.Forms.PictureBox pictureBox10;
private AxMediaPlayer.AxMediaPlayer axMediaPlayer1;
private System.Windows.Forms.PictureBox pictureBox0;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Label label4;
private AxMediaPlayer.AxMediaPlayer axMediaPlayer2;
static Form1 form1=new Form1();
Image [][]pictureArrays=new Image[5][];
int indexPictures=0;
private System.Windows.Forms.Label label1;
bool []selectedPictureBoxs=new bool[9];
string []pictureBoxNames=new string[5];
Point []startPosition=new Point[11];
//private System.ComponentModel.IContainer components;
bool ok;
int pic0Width,pic0Height;
private System.Windows.Forms.Label label5;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
//Image temp;
MyInitializeComponent();
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
#region My owner code
private void MyInitializeComponent()
{
pictureBoxNames[0]="魔兽争霸";
pictureBoxNames[1]="娜可露露";
pictureBoxNames[2]="娜可露露(带狼)";
pictureBoxNames[3]="娜可露露(带鹰)";
pictureBoxNames[4]="仙剑";
for(int i=0;i<5;i )
{
pictureArrays[i]=new Image[10];
}
//初始化“魔兽图片"
pictureArrays[0][0]=Image.FromFile(@"..\..\img\魔兽\warcraft.bmp");
pictureArrays[0][1]=Image.FromFile(@"..\..\img\魔兽\warcraft1.bmp");
pictureArrays[0][2]=Image.FromFile(@"..\..\img\魔兽\warcraft2.bmp");
pictureArrays[0][3]=Image.FromFile(@"..\..\img\魔兽\warcraft3.bmp");
pictureArrays[0][4]=Image.FromFile(@"..\..\img\魔兽\warcraft4.bmp");
pictureArrays[0][5]=Image.FromFile(@"..\..\img\魔兽\warcraft5.bmp");
pictureArrays[0][6]=Image.FromFile(@"..\..\img\魔兽\warcraft6.bmp");
pictureArrays[0][7]=Image.FromFile(@"..\..\img\魔兽\warcraft7.bmp");
pictureArrays[0][8]=Image.FromFile(@"..\..\img\魔兽\warcraft8.bmp");
pictureArrays[0][9]=Image.FromFile(@"..\..\img\魔兽\warcraft9.bmp");
//初始化"娜可露露图片"
pictureArrays[1][0]=Image.FromFile(@"..\..\img\娜可露露\娜可露露.jpg");
pictureArrays[1][1]=Image.FromFile(@"..\..\img\娜可露露\娜可露露1.jpg");
pictureArrays[1][2]=Image.FromFile(@"..\..\img\娜可露露\娜可露露2.jpg");
pictureArrays[1][3]=Image.FromFile(@"..\..\img\娜可露露\娜可露露3.jpg");
pictureArrays[1][4]=Image.FromFile(@"..\..\img\娜可露露\娜可露露4.jpg");
pictureArrays[1][5]=Image.FromFile(@"..\..\img\娜可露露\娜可露露5.jpg");
pictureArrays[1][6]=Image.FromFile(@"..\..\img\娜可露露\娜可露露6.jpg");
pictureArrays[1][7]=Image.FromFile(@"..\..\img\娜可露露\娜可露露7.jpg");
pictureArrays[1][8]=Image.FromFile(@"..\..\img\娜可露露\娜可露露8.jpg");
pictureArrays[1][9]=Image.FromFile(@"..\..\img\娜可露露\娜可露露9.jpg");
//初始化"娜可露露(带狼)"
pictureArrays[2][0]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼).jpg");
pictureArrays[2][1]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼1.jpg");
pictureArrays[2][2]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼2.jpg");
pictureArrays[2][3]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼3.jpg");
pictureArrays[2][4]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼4.jpg");
pictureArrays[2][5]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼5.jpg");
pictureArrays[2][6]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼6.jpg");
pictureArrays[2][7]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼7.jpg");
pictureArrays[2][8]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼8.jpg");
pictureArrays[2][9]=Image.FromFile(@"..\..\img\娜可露露(带狼)\娜可露露(带狼9.jpg");
//初始化"娜可露露(带鹰)"
pictureArrays[3][0]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰).jpg");
pictureArrays[3][1]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)1.jpg");
pictureArrays[3][2]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)2.jpg");
pictureArrays[3][3]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)3.jpg");
pictureArrays[3][4]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)4.jpg");
pictureArrays[3][5]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)5.jpg");
pictureArrays[3][6]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)6.jpg");
pictureArrays[3][7]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)7.jpg");
pictureArrays[3][8]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)8.jpg");
pictureArrays[3][9]=Image.FromFile(@"..\..\img\娜可露露(带鹰)\娜可露露(带鹰)9.jpg");
//初始化"仙剑"图像
pictureArrays[4][0]=Image.FromFile(@"..\..\img\仙剑\仙剑.bmp");
pictureArrays[4][1]=Image.FromFile(@"..\..\img\仙剑\仙剑1.bmp");
pictureArrays[4][2]=Image.FromFile(@"..\..\img\仙剑\仙剑2.bmp");
pictureArrays[4][3]=Image.FromFile(@"..\..\img\仙剑\仙剑3.bmp");
pictureArrays[4][4]=Image.FromFile(@"..\..\img\仙剑\仙剑4.bmp");
pictureArrays[4][5]=Image.FromFile(@"..\..\img\仙剑\仙剑5.bmp");
pictureArrays[4][6]=Image.FromFile(@"..\..\img\仙剑\仙剑6.bmp");
pictureArrays[4][7]=Image.FromFile(@"..\..\img\仙剑\仙剑7.bmp");
pictureArrays[4][8]=Image.FromFile(@"..\..\img\仙剑\仙剑8.bmp");
pictureArrays[4][9]=Image.FromFile(@"..\..\img\仙剑\仙剑9.bmp");
pic0Width=pictureBox0.Width;
pic0Height=pictureBox0.Height;
}
#endregion
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox();
this.pictureBox7 = new System.Windows.Forms.PictureBox();
this.pictureBox8 = new System.Windows.Forms.PictureBox();
this.pictureBox9 = new System.Windows.Forms.PictureBox();
this.pictureBox10 = new System.Windows.Forms.PictureBox();
this.axMediaPlayer1 = new AxMediaPlayer.AxMediaPlayer();
this.pictureBox0 = new System.Windows.Forms.PictureBox();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.axMediaPlayer2 = new AxMediaPlayer.AxMediaPlayer();
this.label5 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.axMediaPlayer1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axMediaPlayer2)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(112, 112);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 5;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click = new System.EventHandler(this.pictureBox1_Click);
//
// pictureBox2
//
this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(112, 0);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(112, 112);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox2.TabIndex = 6;
this.pictureBox2.TabStop = false;
this.pictureBox2.Click = new System.EventHandler(this.pictureBox2_Click);
//
// pictureBox3
//
this.pictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
this.pictureBox3.Location = new System.Drawing.Point(224, 0);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(112, 112);
this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox3.TabIndex = 7;
this.pictureBox3.TabStop = false;
this.pictureBox3.Click = new System.EventHandler(this.pictureBox3_Click);
//
// pictureBox4
//
this.pictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
this.pictureBox4.Location = new System.Drawing.Point(0, 112);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(112, 112);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox4.TabIndex = 8;
this.pictureBox4.TabStop = false;
this.pictureBox4.Click = new System.EventHandler(this.pictureBox4_Click);
//
// pictureBox5
//
this.pictureBox5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox5.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox5.Image")));
this.pictureBox5.Location = new System.Drawing.Point(112, 112);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(112, 112);
this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox5.TabIndex = 9;
this.pictureBox5.TabStop = false;
this.pictureBox5.Click = new System.EventHandler(this.pictureBox5_Click);
//
// pictureBox6
//
this.pictureBox6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox6.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox6.Image")));
this.pictureBox6.Location = new System.Drawing.Point(224, 112);
this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.Size = new System.Drawing.Size(112, 112);
this.pictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox6.TabIndex = 10;
this.pictureBox6.TabStop = false;
this.pictureBox6.Click = new System.EventHandler(this.pictureBox6_Click);
//
// pictureBox7
//
this.pictureBox7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox7.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox7.Image")));
this.pictureBox7.Location = new System.Drawing.Point(0, 224);
this.pictureBox7.Name = "pictureBox7";
this.pictureBox7.Size = new System.Drawing.Size(112, 112);
this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox7.TabIndex = 11;
this.pictureBox7.TabStop = false;
this.pictureBox7.Click = new System.EventHandler(this.pictureBox7_Click);
//
// pictureBox8
//
this.pictureBox8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox8.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox8.Image")));
this.pictureBox8.Location = new System.Drawing.Point(112, 224);
this.pictureBox8.Name = "pictureBox8";
this.pictureBox8.Size = new System.Drawing.Size(112, 112);
this.pictureBox8.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox8.TabIndex = 12;
this.pictureBox8.TabStop = false;
this.pictureBox8.Click = new System.EventHandler(this.pictureBox8_Click);
//
// pictureBox9
//
this.pictureBox9.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox9.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox9.Image")));
this.pictureBox9.Location = new System.Drawing.Point(224, 224);
this.pictureBox9.Name = "pictureBox9";
this.pictureBox9.Size = new System.Drawing.Size(112, 112);
this.pictureBox9.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox9.TabIndex = 13;
this.pictureBox9.TabStop = false;
this.pictureBox9.Click = new System.EventHandler(this.pictureBox9_Click);
//
// pictureBox10
//
this.pictureBox10.BackColor = System.Drawing.Color.Black;
this.pictureBox10.Location = new System.Drawing.Point(224, 336);
this.pictureBox10.Name = "pictureBox10";
this.pictureBox10.Size = new System.Drawing.Size(112, 112);
this.pictureBox10.TabIndex = 14;
this.pictureBox10.TabStop = false;
this.pictureBox10.Click = new System.EventHandler(this.pictureBox10_Click);
//
// axMediaPlayer1
//
this.axMediaPlayer1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.axMediaPlayer1.Location = new System.Drawing.Point(0, 344);
this.axMediaPlayer1.Name = "axMediaPlayer1";
this.axMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMediaPlayer1.OcxState")));
this.axMediaPlayer1.Size = new System.Drawing.Size(96, 112);
this.axMediaPlayer1.TabIndex = 15;
this.axMediaPlayer1.Visible = false;
this.axMediaPlayer1.EndOfStream = new AxMediaPlayer._MediaPlayerEvents_EndOfStreamEventHandler(this.axMediaPlayer1_EndOfStream);
//
// pictureBox0
//
this.pictureBox0.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(0)), ((System.Byte)(64)));
this.pictureBox0.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox0.Image")));
this.pictureBox0.Location = new System.Drawing.Point(336, 0);
this.pictureBox0.Name = "pictureBox0";
this.pictureBox0.Size = new System.Drawing.Size(144, 136);
this.pictureBox0.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox0.TabIndex = 4;
this.pictureBox0.TabStop = false;
this.pictureBox0.Click = new System.EventHandler(this.pictureBox0_Click);
//
// button4
//
this.button4.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.button4.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(0)), ((System.Byte)(64)));
this.button4.ForeColor = System.Drawing.Color.LawnGreen;
this.button4.Image = ((System.Drawing.Image)(resources.GetObject("button4.Image")));
this.button4.Location = new System.Drawing.Point(344, 192);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(56, 23);
this.button4.TabIndex = 16;
this.button4.Text = "上一幅";
this.button4.Click = new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.button5.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(0)), ((System.Byte)(64)));
this.button5.ForeColor = System.Drawing.Color.Lime;
this.button5.Image = ((System.Drawing.Image)(resources.GetObject("button5.Image")));
this.button5.Location = new System.Drawing.Point(416, 192);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(56, 23);
this.button5.TabIndex = 19;
this.button5.Text = "下一幅";
this.button5.Click = new System.EventHandler(this.button5_Click);
//
// label3
//
this.label3.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.ForeColor = System.Drawing.Color.Aqua;
this.label3.Location = new System.Drawing.Point(368, 256);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(100, 32);
this.label3.TabIndex = 20;
this.label3.Text = "魔兽争霸 ";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.ForeColor = System.Drawing.Color.Aqua;
this.label2.Location = new System.Drawing.Point(352, 232);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 32);
this.label2.TabIndex = 18;
this.label2.Text = "图片名称: ";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// button1
//
this.button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.button1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button1.BackgroundImage")));
this.button1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
this.button1.Location = new System.Drawing.Point(368, 384);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "自动拼图";
this.button1.Click = new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.button2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(0)));
this.button2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button2.BackgroundImage")));
this.button2.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
this.button2.Location = new System.Drawing.Point(368, 352);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 24);
this.button2.TabIndex = 2;
this.button2.Text = "玩新游戏";
this.button2.Click = new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.button3.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.button3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button3.BackgroundImage")));
this.button3.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(128)), ((System.Byte)(128)));
this.button3.Location = new System.Drawing.Point(368, 416);
this.button3.Name = "button3";
this.button3.TabIndex = 3;
this.button3.Text = "下次再玩";
this.button3.Click = new System.EventHandler(this.button3_Click);
//
// label1
//
this.label1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(255)), ((System.Byte)(255)));
this.label1.Location = new System.Drawing.Point(360, 152);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 32);
this.label1.TabIndex = 21;
this.label1.Text = "选择你自己 喜欢的图片";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.label4.BackColor = System.Drawing.Color.Transparent;
this.label4.ForeColor = System.Drawing.Color.Lime;
this.label4.Location = new System.Drawing.Point(344, 296);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(128, 48);
this.label4.TabIndex = 22;
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// axMediaPlayer2
//
this.axMediaPlayer2.Location = new System.Drawing.Point(0, 344);
this.axMediaPlayer2.Name = "axMediaPlayer2";
this.axMediaPlayer2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMediaPlayer2.OcxState")));
this.axMediaPlayer2.Size = new System.Drawing.Size(96, 112);
this.axMediaPlayer2.TabIndex = 23;
this.axMediaPlayer2.Visible = false;
//
// label5
//
this.label5.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.label5.BackColor = System.Drawing.Color.Transparent;
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label5.Font = new System.Drawing.Font("宋体", 21.75F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label5.ForeColor = System.Drawing.Color.Lime;
this.label5.Location = new System.Drawing.Point(8, 344);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(208, 72);
this.label5.TabIndex = 24;
this.label5.Text = "已走步数: 0";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(0)), ((System.Byte)(64)));
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(480, 452);
this.Controls.Add(this.label5);
this.Controls.Add(this.axMediaPlayer2);
this.Controls.Add(this.label4);
this.Controls.Add(this.label1);
this.Controls.Add(this.axMediaPlayer1);
this.Controls.Add(this.pictureBox10);
this.Controls.Add(this.pictureBox9);
this.Controls.Add(this.pictureBox8);
this.Controls.Add(this.pictureBox7);
this.Controls.Add(this.pictureBox6);
this.Controls.Add(this.pictureBox5);
this.Controls.Add(this.pictureBox4);
this.Controls.Add(this.pictureBox3);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.pictureBox0);
this.Controls.Add(this.button4);
this.Controls.Add(this.button5);
this.Controls.Add(this.label2);
this.Controls.Add(this.label3);
this.Controls.Add(this.button1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button3);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Resize = new System.EventHandler(this.Form1_Resize);
this.Load = new System.EventHandler(this.Form1_Load);
this.Paint = new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
this.MouseEnter = new System.EventHandler(this.Form1_MouseEnter);
((System.ComponentModel.ISupportInitialize)(this.axMediaPlayer1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axMediaPlayer2)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(form1);
}
private void button3_Click(object sender, System.EventArgs e)
{
this.Close();
Application.Exit();
}
#region Form1_Paint and Form1_Load code
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
//画背面版
/*Brush brush=new SolidBrush(Color.Black);
Graphics g=e.Graphics;
Point[] point=new Point[10];
int unitLength=Convert.ToInt32((form1.Width-pictureBox0.Width-7)/3);
int index=0;
int x=0,y=0;
for(int i=0;i<3;i )
{
for(int j=0;j<3;j )
{
point[index].X=x;
point[index].Y=y;
x =unitLength;index ;
}
y =unitLength;
x=0;
}
point[9].X=2*unitLength;
point[9].Y=3*unitLength;
for(int i=0;i<10;i )
g.FillRectangle(brush,point[i].X,point[i].Y,unitLength,unitLength);
brush.Dispose();
g.Dispose(); */
}
private void Form1_Load(object sender, System.EventArgs e)
{
//显示动画小人
AgentServer Srv=new AgentServer();
IAgentEx SrvEx;
SrvEx=(IAgentEx)Srv;
int dwCharID=0,dwReqID=0;
String strAgentCharacterFile=null;
SrvEx.Load(strAgentCharacterFile,out dwCharID,out dwReqID);
IAgentCharacterEx CharacterEx=null;
//dwCharID=3;dwReqID=0;
SrvEx.GetCharacterEx(dwCharID,out CharacterEx);
//CharacterEx.SetPosition(400,80);变大
//CharacterEx.SetSize(500,500);
CharacterEx.SetPosition(680,420);
CharacterEx.Show(0,out dwReqID);
CharacterEx.Play("Greet",out dwReqID); //start:
CharacterEx.Play("MoveLeft",out dwReqID);
CharacterEx.Play("Acknowledge",out dwReqID);
CharacterEx.Play("LookDown",out dwReqID);
CharacterEx.Play("Sad",out dwReqID);
CharacterEx.Play("Alert",out dwReqID);
CharacterEx.Play("LookDownBlink",out dwReqID);
//CharacterEx.Play("Serch",out dwReqID);CharacterEx.Play("Announce",out dwReqID);CharacterEx.Play("LookUp",out dwReqID);CharacterEx.Play("StartListening",out dwReqID); CharacterEx.Play("Blink",out dwReqID);CharacterEx.Play("LookUpBlink",out dwReqID);CharacterEx.Play("StopListening",out dwReqID);CharacterEx.Play("Confused",out dwReqID);CharacterEx.Play("LookLeft",out dwReqID);CharacterEx.Play("Suggest",out dwReqID);CharacterEx.Play("Congratulate",out dwReqID); CharacterEx.Play("LookLeftBlink",out dwReqID);CharacterEx.Play("Surprised",out dwReqID);CharacterEx.Play("Decline",out dwReqID);CharacterEx.Play("LookRight",out dwReqID);CharacterEx.Play("Think",out dwReqID);CharacterEx.Play("DontRecognize",out dwReqID);CharacterEx.Play("LookRightBlink",out dwReqID);CharacterEx.Play("Wave",out dwReqID);CharacterEx.Play("Explain",out dwReqID);CharacterEx.Play("MoveDown",out dwReqID);CharacterEx.Play("Write",out dwReqID);CharacterEx.Play("GestureDown",out dwReqID);CharacterEx.Play("MoveUp",out dwReqID);CharacterEx.Play("Processing",out dwReqID); CharacterEx.Play("GestureUp",out dwReqID); CharacterEx.Play("MoveRight",out dwReqID); CharacterEx.Play("Reading",out dwReqID); CharacterEx.Play("GestureLeft",out dwReqID); CharacterEx.Play("Searching",out dwReqID); CharacterEx.Play("GestureRight",out dwReqID);CharacterEx.Play("Pleased",out dwReqID);CharacterEx.Play("Writing",out dwReqID);CharacterEx.Play("GetAttention",out dwReqID);CharacterEx.Play("Read",out dwReqID); CharacterEx.Play("RestPose",out dwReqID);
CharacterEx.Play("Greet",out dwReqID);
axMediaPlayer1.FileName=@"..\..\sound\onestop.mid";
//记录开始图片位置
startPosition[1].X=pictureBox1.Left; startPosition[1].Y=pictureBox1.Top;
startPosition[2].X=pictureBox2.Left; startPosition[2].Y=pictureBox2.Top;
startPosition[3].X=pictureBox3.Left; startPosition[3].Y=pictureBox3.Top;
startPosition[4].X=pictureBox4.Left; startPosition[4].Y=pictureBox4.Top;
startPosition[5].X=pictureBox5.Left; startPosition[5].Y=pictureBox5.Top;
startPosition[6].X=pictureBox6.Left; startPosition[6].Y=pictureBox6.Top;
startPosition[7].X=pictureBox7.Left; startPosition[7].Y=pictureBox7.Top;
startPosition[8].X=pictureBox8.Left; startPosition[8].Y=pictureBox8.Top;
startPosition[9].X=pictureBox9.Left; startPosition[9].Y=pictureBox9.Top;
startPosition[10].X=pictureBox10.Left; startPosition[10].Y=pictureBox10.Top;
//timer1.Enabled=false;
}
#endregion
private void ChangePicture()
{
pictureBox0.Image=pictureArrays[indexPictures][0];
pictureBox1.Image=pictureArrays[indexPictures][1];
pictureBox2.Image=pictureArrays[indexPictures][2];
pictureBox3.Image=pictureArrays[indexPictures][3];
pictureBox4.Image=pictureArrays[indexPictures][4];
pictureBox5.Image=pictureArrays[indexPictures][5];
pictureBox6.Image=pictureArrays[indexPictures][6];
pictureBox7.Image=pictureArrays[indexPictures][7];
pictureBox8.Image=pictureArrays[indexPictures][8];
pictureBox9.Image=pictureArrays[indexPictures][9];
}
private void button4_Click(object sender, System.EventArgs e)
{
if(indexPictures==0)
indexPictures=4;
else
indexPictures--;
ChangePicture();
label3.Text=pictureBoxNames[indexPictures];
}
private void button5_Click(object sender, System.EventArgs e)
{
if(indexPictures==4)
indexPictures=0;
else
indexPictures ;
ChangePicture();
label3.Text=pictureBoxNames[indexPictures];
}
private void RestoreSelectedPictureBoxStatus()
{
for(int i=0;i<9;i )
{
selectedPictureBoxs[i]=false;
}
}
private int GetSelectedPicturebox()
{
for(int i=0;i<9;i )
{
if(selectedPictureBoxs[i]==true)
return i;
}
return -1;
}
private void RestorePictureBoxBorderStype()
{
pictureBox1.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox2.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox3.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox4.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox5.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox6.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox7.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox8.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox9.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
}
private void WrongSound()
{
axMediaPlayer2.FileName=@"..\..\sound\wrong.wav";
}
private void RightSound()
{
axMediaPlayer2.FileName=@"..\..\sound\right.wav";
}
#region PictureBox(1~~~10)_Click
private void pictureBox1_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox1.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox1.Location.Y)==112)
sign=1;
if(pictureBox1.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox1.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[0]==true)
{
pictureBox1.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[0]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox1.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[0]=true;
}
private void pictureBox2_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox2.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox2.Location.Y)==112)
sign=1;
if(pictureBox2.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox2.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[1]==true)
{
pictureBox2.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[1]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox2.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[1]=true;
}
private void pictureBox3_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox3.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox3.Location.Y)==112)
sign=1;
if(pictureBox3.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox3.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[2]==true)
{
pictureBox3.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[2]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox3.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[2]=true;
}
private void pictureBox4_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox4.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox4.Location.Y)==112)
sign=1;
if(pictureBox4.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox4.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[3]==true)
{
pictureBox4.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[3]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox4.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[3]=true;
}
private void pictureBox5_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox5.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox5.Location.Y)==112)
sign=1;
if(pictureBox5.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox5.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[4]==true)
{
pictureBox5.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[4]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox5.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[4]=true;
}
private void pictureBox6_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox6.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox6.Location.Y)==112)
sign=1;
if(pictureBox6.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox6.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[5]==true)
{
pictureBox6.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[5]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox6.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[5]=true;
}
private void pictureBox7_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox7.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox7.Location.Y)==112)
sign=1;
if(pictureBox7.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox7.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[6]==true)
{
pictureBox7.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[6]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox7.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[6]=true;
}
private void pictureBox8_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox8.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox8.Location.Y)==112)
sign=1;
if(pictureBox8.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox8.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[7]==true)
{
pictureBox8.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[7]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox8.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[7]=true;
}
private void pictureBox9_Click(object sender, System.EventArgs e)
{
label4.Text="";
int sign=0;
if(pictureBox9.Left==pictureBox10.Left&&Math.Abs(pictureBox10.Location.Y-pictureBox9.Location.Y)==112)
sign=1;
if(pictureBox9.Location.Y==pictureBox10.Location.Y&&Math.Abs(pictureBox10.Location.X-pictureBox9.Location.X)==112)
sign=1;
if(sign==0)
{
WrongSound();
label4.Text="不能移动此图片!!!";
return;
}
if(selectedPictureBoxs[8]==true)
{
pictureBox9.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
selectedPictureBoxs[8]=false; return;
}
RestoreSelectedPictureBoxStatus();
RestorePictureBoxBorderStype();
pictureBox9.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
selectedPictureBoxs[8]=true;
}
public int buShu=0;
private void pictureBox10_Click(object sender, System.EventArgs e)
{
label4.Text="";
int index=GetSelectedPicturebox();
if(index==-1)
{
WrongSound();
label4.Text="请选择要移动的图片!!!";
return;
}
//显示步数变量加1
this.buShu ;
this.label5.Text="已走步数: " buShu.ToString();
Point point=new Point();
point.X=pictureBox10.Location.X;
point.Y=pictureBox10.Location.Y;
switch(index)
{
case 0: pictureBox10.Left=pictureBox1.Location.X; pictureBox10.Top=pictureBox1.Location.Y; pictureBox1.Left=point.X; pictureBox1.Top=point.Y; pictureBox1.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[0]=false;break;
case 1: pictureBox10.Left=pictureBox2.Location.X; pictureBox10.Top=pictureBox2.Location.Y; pictureBox2.Left=point.X; pictureBox2.Top=point.Y; pictureBox2.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[1]=false;break;
case 2: pictureBox10.Left=pictureBox3.Location.X; pictureBox10.Top=pictureBox3.Location.Y; pictureBox3.Left=point.X; pictureBox3.Top=point.Y; pictureBox3.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[2]=false;break;
case 3: pictureBox10.Left=pictureBox4.Location.X; pictureBox10.Top=pictureBox4.Location.Y; pictureBox4.Left=point.X; pictureBox4.Top=point.Y; pictureBox4.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[3]=false;break;
case 4: pictureBox10.Left=pictureBox5.Location.X; pictureBox10.Top=pictureBox5.Location.Y; pictureBox5.Left=point.X; pictureBox5.Top=point.Y; pictureBox5.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[4]=false;break;
case 5: pictureBox10.Left=pictureBox6.Location.X; pictureBox10.Top=pictureBox6.Location.Y; pictureBox6.Left=point.X; pictureBox6.Top=point.Y; pictureBox6.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[5]=false;break;
case 6: pictureBox10.Left=pictureBox7.Location.X; pictureBox10.Top=pictureBox7.Location.Y; pictureBox7.Left=point.X; pictureBox7.Top=point.Y; pictureBox7.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[6]=false;break;
case 7: pictureBox10.Left=pictureBox8.Location.X; pictureBox10.Top=pictureBox8.Location.Y; pictureBox8.Left=point.X; pictureBox8.Top=point.Y; pictureBox8.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[7]=false;break;
case 8: pictureBox10.Left=pictureBox9.Location.X; pictureBox10.Top=pictureBox9.Location.Y; pictureBox9.Left=point.X; pictureBox9.Top=point.Y; pictureBox9.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;selectedPictureBoxs[8]=false;break;
}
RightSound();
if(pictureBox10.Left==224&&pictureBox10.Top==224)
return;
OK();
}
#endregion
private void pictureBox0_Click(object sender, System.EventArgs e)
{
label4.Text="玩好了,赏你一首好听的歌!!!";
axMediaPlayer2.FileName=@"..\..\sound\kitbighead.WAV";
}
private void Form1_MouseEnter(object sender, System.EventArgs e)
{
label4.Text="Welcome to picture game.";
}
private void RestoreStartPosion()
{
pictureBox1.Left=startPosition[1].X;pictureBox1.Top=startPosition[1].Y;
pictureBox2.Left=startPosition[2].X;pictureBox2.Top=startPosition[2].Y;
pictureBox3.Left=startPosition[3].X;pictureBox3.Top=startPosition[3].Y;
pictureBox4.Left=startPosition[4].X;pictureBox4.Top=startPosition[4].Y;
pictureBox5.Left=startPosition[5].X;pictureBox5.Top=startPosition[5].Y;
pictureBox6.Left=startPosition[6].X;pictureBox6.Top=startPosition[6].Y;
pictureBox7.Left=startPosition[7].X;pictureBox7.Top=startPosition[7].Y;
pictureBox8.Left=startPosition[8].X;pictureBox8.Top=startPosition[8].Y;
pictureBox9.Left=startPosition[9].X;pictureBox9.Top=startPosition[9].Y;
pictureBox10.Left=startPosition[10].X;pictureBox10.Top=startPosition[10].Y;
}
private void button2_Click(object sender, System.EventArgs e)
{
//将所走的步数恢复至零
this.buShu=0;
this.label5.Text="已走步数: " buShu.ToString();
RestoreStartPosion();
Random random=new Random();
int [][]orderArray=new int[3][];
orderArray[0]=new int[3]{1,2,3};
orderArray[1]=new int[3]{4,5,6};
orderArray[2]=new int[3]{7,8,9};
int temp;
do
{
for(int i=random.Next(10);i>=-10;i--)
{
//行旋转(1,2)
temp=orderArray[0][0];orderArray[0][0]=orderArray[0][1];orderArray[0][1]=orderArray[0][2];orderArray[0][2]=temp;
temp=orderArray[1][0];orderArray[1][0]=orderArray[1][1];orderArray[1][1]=orderArray[1][2];orderArray[1][2]=temp;
//列旋转(1,2)
temp=orderArray[0][0];orderArray[0][0]=orderArray[1][0];orderArray[1][0]=orderArray[2][0];orderArray[2][0]=temp;
temp=orderArray[0][1];orderArray[0][1]=orderArray[1][1];orderArray[1][1]=orderArray[2][1];orderArray[2][1]=temp;
}
}while((orderArray[0][0]==1&&orderArray[0][1]==2&&orderArray[0][2]==3&&orderArray[1][0]==4&&orderArray[1][1]==5&&orderArray[1][2]==6&&orderArray[2][0]==7&&orderArray[2][1]==8));
int k=1;
for(int i=0;i<3;i )
for(int j=0;j<3;j )
{
switch(orderArray[i][j])
{
case 1: pictureBox1.Location=startPosition[k ];break;
case 2: pictureBox2.Location=startPosition[k ];break;
case 3: pictureBox3.Location=startPosition[k ];break;
case 4: pictureBox4.Location=startPosition[k ];break;
case 5: pictureBox5.Location=startPosition[k ];break;
case 6: pictureBox6.Location=startPosition[k ];break;
case 7: pictureBox7.Location=startPosition[k ];break;
case 8: pictureBox8.Location=startPosition[k ];break;
case 9: pictureBox9.Location=startPosition[k ];break;
}
}
axMediaPlayer1.PlayCount=10;
axMediaPlayer1.Visible=false;
axMediaPlayer2.FileName=@"..\..\sound\kitbighead.WAV";
//timer1.Enabled=true;
}
private void button1_Click(object sender, System.EventArgs e)
{
//将所走的步数恢复至零
this.buShu=0;
this.label5.Text="已走步数: " buShu.ToString();
label4.Text="玩好了,赏你一首好听的歌!!!";
//timer1.Enabled=false;
RestoreStartPosion();
}
private bool JudgeOk()
{
if(pictureBox1.Left==startPosition[1].X&&pictureBox1.Top==startPosition[1].Y
&&pictureBox2.Left==startPosition[2].X&&pictureBox2.Top==startPosition[2].Y
&&pictureBox3.Left==startPosition[3].X&&pictureBox3.Top==startPosition[3].Y
&&pictureBox4.Left==startPosition[4].X&&pictureBox4.Top==startPosition[4].Y
&&pictureBox5.Left==startPosition[5].X&&pictureBox5.Top==startPosition[5].Y
&&pictureBox6.Left==startPosition[6].X&&pictureBox6.Top==startPosition[6].Y
&&pictureBox7.Left==startPosition[7].X&&pictureBox7.Top==startPosition[7].Y
&&pictureBox8.Left==startPosition[8].X&&pictureBox8.Top==startPosition[8].Y
&&pictureBox9.Left==startPosition[9].X&&pictureBox9.Top==startPosition[9].Y
&&pictureBox10.Left==startPosition[10].X&&pictureBox10.Top==startPosition[10].Y)
{
return true;
}
return false;
}
private void OK()
{
ok=JudgeOk();
if(ok==true)
{
label4.Text="恭喜你,赏你一首 ~忆江南~...";
axMediaPlayer1.PlayCount=1;
axMediaPlayer1.FileName=@"..\..\sound\忆江南.mid";
axMediaPlayer1.Visible=false;
ok=false;
}
}
private void axMediaPlayer1_EndOfStream(object sender, AxMediaPlayer._MediaPlayerEvents_EndOfStreamEvent e)
{
try
{
Random ran=new Random();
if(ran.Next(10)%2==1)
axMediaPlayer1.FileName=@"..\..\sound\onestop.mid";
else
axMediaPlayer1.FileName=@"..\..\sound\激光年代结束音乐.mid";
label4.Text="Very good !!! 要不要再来一次?";
axMediaPlayer1.Visible=false;
}
catch
{}
}
private void Form1_Resize(object sender, System.EventArgs e)
{
if(this.WindowState==System.Windows.Forms.FormWindowState.Maximized)
{
pictureBox0.Width*=2;
pictureBox0.Height*=2;
}
if(this.WindowState==System.Windows.Forms.FormWindowState.Normal)
{
pictureBox0.Width=pic0Width;
pictureBox0.Height=pic0Height;
}
if(this.WindowState==System.Windows.Forms.FormWindowState.Minimized)
{
pictureBox0.Width=pic0Width;
pictureBox0.Height=pic0Height;
}
//显示步数位置
//this.label5.Left=this.pictureBox7.Left;
//this.label5.Top=this.pictureBox7.Bottom;;
}
}
}
好例子网口号:伸出你的我的手 — 分享!
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论