零散英语,C#一些零散的东西


二维数组:int[,] arr = new int[100, 100];

图片操作

图片数组:Image[] img = new Image[100];
给图片赋值(配图):
for (int i = 0; i < 20; i++)
{
img[i] = (Image)Bitmap.FromFile("Images0\\" + (i + 1).ToString() + ".bmp");
}
画图:
private void Draw(Graphics g, Image scrImg, int PicX, int PicY)
{
g.DrawImage(scrImg, new Point(PicX, PicY));
}
private void Form1_Paint(object sender, EventArgs e)
{
g_g = this.CreateGraphics();
}
Draw(g_g, back[0], 0, 0);

随机数:

Random r = new Random();
k = r.Next(15);
画壁画刷:
Brush br = new SolidBrush(this.BackColor);
g_g.FillRectangle(new SolidBrush(this.BackColor), new Rectangle(0, 0, 800, 800));//画刷填涂
g_g.DrawRectangle(br, new Rectangle(coutx * 33, couty * 35, 33, 35));

打开文件:

OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "文本文件|*.txt|所有文件|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
零散英语,C#一些零散的东西

浏览文件夹:

零散英语,C#一些零散的东西
零散英语,C#一些零散的东西

文件详情:

零散英语,C#一些零散的东西

Music 类打包:

class Music
{
[DllImport("winmm.dll")]
private static extern int mciSendString
(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName
(
[MarshalAs(UnmanagedType.LPTStr)] string path,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
int shortPathLength
);
public void Play(string FileName)
{
StringBuilder shortPathTemp = new StringBuilder(255);
int result = GetShortPathName(FileName, shortPathTemp, shortPathTemp.Capacity);
string ShortPath = shortPathTemp.ToString();
mciSendString("open " + ShortPath + " alias song", "", 0, 0);
mciSendString("play song", "", 0, 0);
}
public void Stop()
{
mciSendString("stop song", "", 0, 0);
}
public void Pause()
{
mciSendString("pause song", "", 0, 0);
}
public void Close()
{
mciSendString("close song", "", 0, 0);
}
}
用法:
public Music music = new Music();
music.Play("Sounds\\bg-01.mid");



枚举:

public enum Direction
{
None = 0,
East = 1,
South = 2,
West = 4,
North = 3,
Middle = 5,
}
用法:
Direction d = new Direction();
d=Direction.East;
int i=1;
d=( Direction)i;

TODO用法

视图----任务列表
//TODO:
零散英语,C#一些零散的东西
通过TODO:可以增加标签,以便迅速找到该位置。同时如果有位置可扩展功能也可做标签。如上图,如果让胜利的图样炫一点,只要点那个标签便可找到那个位置加以增加

皮肤控件

零散英语,C#一些零散的东西 零散英语,C#一些零散的东西
零散英语,C#一些零散的东西
在构造函数设置其皮肤文件即可

简单的文本文件读写:

写文件
StreamWriter writer = null;
string filepath = "gate.dat";
if (File.Exists(filepath))
{
File.Delete(filepath);
writer = File.CreateText(filepath);
}
else
{
writer = File.CreateText(filepath);
}
writer.WriteLine("嘎嘎,写成功了");
writer.Close();
读文件
StreamReader sr = new StreamReader("gate.dat");
String line = "";
line = sr.ReadLine();//可以用for循环读取的
sr.Close();

9.17

数据库配置文件

  1. 添加配置文件
    Tags: 

    延伸阅读

最新评论

发表评论