?? frmshejimap.cs
字號:
?using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace PushBox
{
public partial class frmSheJiMap : Form
{
[DllImport("kernel32")]
private static extern bool WritePrivateProfileString(string section, string key, string val, string filePath);
public frmSheJiMap()
{
InitializeComponent();
}
private System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();
private PictureBox ActiveBox = new PictureBox();
private void DiBiao()
{
for (int i = 0; i < 225; i++)
{
PictureBox p = new PictureBox();
if (int.Parse((i / 15).ToString()) != 0 && (i - int.Parse((i / 15).ToString()) * 15) != 0 && int.Parse((i / 15).ToString()) != 14 && (i - int.Parse((i / 15).ToString()) * 15) != 14)
{
p.Click += new EventHandler(p_Click);
p.MouseHover += new EventHandler(p_MouseHover);
p.MouseLeave += new EventHandler(p_MouseLeave);
p.Cursor = Cursors.Hand;
}
else
{
p.Image = tsbWall.Image;
}
p.BackColor = Color.Black;
p.SizeMode = PictureBoxSizeMode.StretchImage;
p.Size = new Size(30, 30);
p.Top = int.Parse((i / 15).ToString()) * 30;
p.Left = (i - int.Parse((i / 15).ToString()) * 15) * 30;
p.Visible = true;
p.Parent = panel1;
myArrayList.Add(p);
}
}
private void frmSheJiMap_Load(object sender, EventArgs e)
{
this.Size = new Size(456,521);
this.Top = 0;
tsbLu_Click(tsbLu, null);
DiBiao();
}
private void tsbLu_Click(object sender, EventArgs e)
{
tsbLu.Checked = false;
tsbAim.Checked = false;
tsbBox.Checked = false;
tsbWall.Checked = false;
tsbPeople.Checked = false;
tsbNull.Checked = false;
((ToolStripButton)sender).Checked = true;
ActiveBox.Image = ((ToolStripButton)sender).Image;
}
private void p_Click(object sender, EventArgs e)
{
if (tsbPeople.Checked)
{
int peopleCount = 0;
for (int i = 0; i < 225; i++)
{
if (((PictureBox)myArrayList[i]).Image == tsbPeople.Image)
peopleCount++;
if (peopleCount > 0)
{
MessageBox.Show("一關(guān)中只可有一個小人出現(xiàn)!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
return;
}
}
}
((PictureBox)sender).Image = ActiveBox.Image;
}
private void p_MouseLeave(object sender, EventArgs e)
{
((PictureBox)sender).BackColor = Color.Black;
}
private void p_MouseHover(object sender, EventArgs e)
{
((PictureBox)sender).BackColor = Color.Blue;
}
private void tsbNull_Click(object sender, EventArgs e)
{
tsbLu.Checked = false;
tsbAim.Checked = false;
tsbBox.Checked = false;
tsbWall.Checked = false;
tsbPeople.Checked = false;
tsbNull.Checked = true;
ActiveBox.Image = null;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("確認要取消以上所有設(shè)計嗎?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
for (int i = 0; i < 225; i++)
{
if (int.Parse((i / 15).ToString()) != 0 && (i - int.Parse((i / 15).ToString()) * 15) != 0 && int.Parse((i / 15).ToString()) != 14 && (i - int.Parse((i / 15).ToString()) * 15) != 14)
((PictureBox)myArrayList[i]).Image = null;
}
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
int FileCount = 0;
while (true)
{
FileCount++;
if (!File.Exists(Application.StartupPath + "\\Level\\" + "Level" + FileCount.ToString() + ".hmap"))
break;
}
for (int i = 0; i < 225; i++)
{
if (((PictureBox)myArrayList[i]).Image==tsbLu.Image)
{
WritePrivateProfileString("Game", "PBox" + i.ToString(), "Lu", Application.StartupPath + "\\Level\\" + "Level" + FileCount.ToString() + ".hmap");
}
if (((PictureBox)myArrayList[i]).Image == tsbAim.Image)
{
WritePrivateProfileString("Game", "PBox" + i.ToString(), "Aim", Application.StartupPath + "\\Level\\" + "Level" + FileCount.ToString() + ".hmap");
}
if (((PictureBox)myArrayList[i]).Image == tsbWall.Image)
{
WritePrivateProfileString("Game", "PBox" + i.ToString(), "Wall", Application.StartupPath + "\\Level\\" + "Level" + FileCount.ToString() + ".hmap");
}
if (((PictureBox)myArrayList[i]).Image == tsbPeople.Image)
{
WritePrivateProfileString("Game", "PBox" + i.ToString(), "People", Application.StartupPath + "\\Level\\" + "Level" + FileCount.ToString() + ".hmap");
}
if (((PictureBox)myArrayList[i]).Image == tsbBox.Image)
{
WritePrivateProfileString("Game", "PBox" + i.ToString(), "Box", Application.StartupPath + "\\Level\\" + "Level" + FileCount.ToString() + ".hmap");
}
if (((PictureBox)myArrayList[i]).Image == null)
{
WritePrivateProfileString("Game", "PBox" + i.ToString(), "null", Application.StartupPath + "\\Level\\" + "Level" + FileCount.ToString() + ".hmap");
}
}
MessageBox.Show("已成功保存為第【★-" + FileCount.ToString() + "-★】關(guān)!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
for (int i = 0; i < 225; i++)
{
if (int.Parse((i / 15).ToString()) != 0 && (i - int.Parse((i / 15).ToString()) * 15) != 0 && int.Parse((i / 15).ToString()) != 14 && (i - int.Parse((i / 15).ToString()) * 15) != 14)
((PictureBox)myArrayList[i]).Image = null;
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -