GGG

//屏幕高度

int ScreenH = 1080;

this.Location = new Point(this.Location.X, ScreenH - this.Height - 20);

//关闭本窗体,打开主窗体

this.Hide();

FrmQQMain frmQQMain = new FrmQQMain();

frmQQMain.ShowDialog();

//鼠标进入时,变成红色

label1.ForeColor = Color.Red;

//鼠标离开时,背景变透明

pictureBox1.BackColor = Color.Transparent;

//颜色浅灰半透明

picShrink.BackColor = Color.FromArgb(50,200,200,200);

//鼠标进入时,切换另一张图片

picLogin.BackgroundImage = Properties.Resources.iconqq;

//鼠标拖动窗体方法

bool isDrag;

Point ClickPoint;

private void Frm1_MouseDown(object sender, MouseEventArgs e)

{

isDrag = true;

ClickPoint = new Point(e.X ,e.Y );

}

    private void Frm1_MouseMove(object sender, MouseEventArgs e)
{
if (isDrag == true)
this.Location = new Point(this .Location .X +e.X -ClickPoint .X
,this .Location .Y +e.Y -ClickPoint .Y );
ClickPoint.X = e.X;
ClickPoint.Y = e.Y;
} private void Frm1_MouseUp(object sender, MouseEventArgs e)
{
isDrag = false;
}

//随机出现按钮方法

Random r = new Random();

button2.Location = new Point(r.Next ()%(this .Width -button2 .Width )

,r .Next ()%(this.ClientSize .Height -button2 .Height ));

//打开资源管理器(click事件中)

OpenFileDialog ofd=new openfiledialog();//初始化打开文件夹类

ofd.ShowDialog();//显示资源管理器

//显示图片

(click事件外)image imgOriginal;//定义一张图片

(click事件里) string strFileName = ofd.FileName;//获取该位置的文件名

imgOriginal = Image.FromFile(strFileName);//获取选取的图片

pictureBox1.BackgroundImage = imgOriginal;//显示图片

//图片底片化(click事件里)

bitmap bmp=new bitmap(imgoriginal);//从现有的图像初始化位图类

for(int i=0;i<bmp.width;i++)

{

for(int j=0;j<bmp.height;j++)

{

color c=bmp.getpixel(i,j);//获得原来像素点颜色

color cafter=color.fromargb(255-c.r,255-c.g,255-c.b);//改变

bmp.setpixel(i,j,cafter); //设置回去

}

}

picturebox2.backgroundimage=bmp;

//保存修改后的图片(click事件中)

savefiledialog sfd=new savefiledialog();//初始化保存类

sfd.showdialog();//重载显示资源管理器界面

picturebox2.backgroundimage.save(sfd.filename+".jpg");//获取控件中的背景图片AAA

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace DamonQQ

{

public partial class FrmLogin : Form

{

public FrmLogin()

{

InitializeComponent();

}

    private void pictureBox6_Click(object sender, EventArgs e)
{ } private void textBox3_TextChanged(object sender, EventArgs e)
{ } private void checkBox2_CheckedChanged(object sender, EventArgs e)
{ } private void Form1_Load(object sender, EventArgs e)
{
//屏幕的高度
int ScreenH=1080;
this.Location = new Point(this.Location.X, ScreenH - this.Height - 20);
} private void label1_Click(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e)
{
//关闭本窗体,打开qq好友窗体
this.Hide();
FrmQQMain frmQQMain = new FrmQQMain();
frmQQMain.ShowDialog();
} private void pictureBox8_Click(object sender, EventArgs e)
{
//关闭本窗体,打开QQ设置窗体
this.Hide();
QQsetup QQsetup = new QQsetup();
QQsetup.ShowDialog(); } private void pictureBox9_Click(object sender, EventArgs e)
{ } private void pictureBox10_Click(object sender, EventArgs e)
{
this.Close();
} private void label1_MouseEnter(object sender, EventArgs e)
{
//鼠标进入时,标签变成黑色
lblFoundCode.ForeColor = Color.Black; } private void label1_MouseLeave(object sender, EventArgs e)
{
//鼠标离开时,标签变成灰色
lblFoundCode.ForeColor = Color.Gray;
} private void checkBox2_MouseEnter(object sender, EventArgs e)
{
//鼠标进入时,标签变成黑色
chkRemember.ForeColor = Color.Black;
} private void checkBox2_MouseLeave(object sender, EventArgs e)
{
//鼠标离开时,标签变成灰色
chkRemember.ForeColor = Color.Gray;
} private void checkBox1_MouseEnter(object sender, EventArgs e)
{
//鼠标进入时,标签变成黑色
chkAutoLogin.ForeColor = Color.Black;
} private void checkBox1_MouseLeave(object sender, EventArgs e)
{
//鼠标离开时,标签变成灰色
chkAutoLogin.ForeColor = Color.Gray;
} private void label2_MouseEnter(object sender, EventArgs e)
{
//鼠标进入时,标签变成黑色
lblRegister.ForeColor = Color.Black;
} private void label2_MouseLeave(object sender, EventArgs e)
{ //鼠标离开时,标签变成灰色
lblRegister.ForeColor = Color.Gray;
} private void pictureBox10_MouseEnter(object sender, EventArgs e)
{
//鼠标进入时 图片背景变红
picClose.BackColor = Color.Red;
} private void pictureBox10_MouseLeave(object sender, EventArgs e)
{
picClose.BackColor = Color.Transparent;
} private void pictureBox9_MouseEnter(object sender, EventArgs e)
{
//颜色浅灰色半透明
picShrink.BackColor = Color.FromArgb(50, 200, 200, 200); } private void pictureBox9_MouseLeave(object sender, EventArgs e)
{
picShrink.BackColor = Color.Transparent;
} private void pictureBox2_MouseEnter(object sender, EventArgs e)
{
//变成蓝色小企鹅
picLogin.BackgroundImage = Properties.Resources.iconqq;//此处应为蓝色 } private void pictureBox5_MouseEnter(object sender, EventArgs e)
{
picLoginTail.BackgroundImage = Properties.Resources.down_en;
} private void pictureBox5_MouseLeave(object sender, EventArgs e)
{
picLoginTail.BackgroundImage = Properties.Resources.down_dis;
} bool isDrag;//是否拖动窗体
Point clickPoint;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
isDrag = true;
clickPoint = new Point(e.X, e.Y);
}
// Point movePoint;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (isDrag ==true )
this.Location = new Point(this.Location.X + e.X - clickPoint.X,
this.Location .Y +e.Y -clickPoint .Y );
clickPoint .X =e.X ;
clickPoint .Y =e.Y ;
} private void Form1_MouseUp(object sender, MouseEventArgs e)
{
isDrag = false;
} bool isMoveout;
bool isMoveback;
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
//加号弹出
timer1.Enabled = true;
isMoveout = true;
} private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
//加号弹回 isMoveout = false ;
isMoveback = true;
} private void timer1_Tick(object sender, EventArgs e)
{
if (isMoveout)
{
picMultiUser.Location = new Point(picMultiUser.Location.X + 10, picMultiUser.Location.Y);
if (picMultiUser.Location.X >= 277)
{
timer1.Enabled = false;
return;
}
}
else
{
picMultiUser.Location = new Point(picMultiUser.Location.X - 10, picMultiUser.Location.Y); if (picMultiUser.Location.X <= 178)
{
timer1.Enabled = false;
return;
}
}
} private void picSet_MouseEnter(object sender, EventArgs e)
{
picSet.BackColor = Color.FromArgb(50, 200, 200, 200);
} private void picSet_MouseLeave(object sender, EventArgs e)
{
picSet.BackColor = Color.Transparent;
} private void picQuickMark_MouseEnter(object sender, EventArgs e)
{
picQuickMark.BackgroundImage = Properties.Resources.tdcode1;
} private void picLoginTail_Click(object sender, EventArgs e)
{ } private void picQuickMark_Click(object sender, EventArgs e)
{
//关闭本窗体,打开二维码窗体
this.Hide();
QuickMark QuickMark = new QuickMark();
QuickMark.ShowDialog();
} private void picQuickMark_MouseLeave(object sender, EventArgs e)
{
picQuickMark.BackgroundImage = Properties.Resources.tdcode;
} private void picKeyboard_MouseEnter(object sender, EventArgs e)
{
picKeyboard.BackgroundImage = Properties.Resources.keyboard1;
} private void picKeyboard_MouseLeave(object sender, EventArgs e)
{
picKeyboard.BackgroundImage = Properties.Resources.keyboard;
} private void picMultiUser_Click(object sender, EventArgs e)
{ } private void lblRegister_Click(object sender, EventArgs e)
{ } private void picKeyboard_Click(object sender, EventArgs e)
{ } }

}

BBB

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace DamonResign

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

    private void pictureBox1_Click(object sender, EventArgs e)
{ } private void pictureBox1_Click_1(object sender, EventArgs e)
{ } private void button2_MouseMove(object sender, MouseEventArgs e)
{ } private void label4_Click(object sender, EventArgs e)
{ } private void button2_Click(object sender, EventArgs e)
{ } private void button2_MouseEnter(object sender, EventArgs e)
{
Random r = new Random();
button2.Location = new Point(r.Next() % (this.Width - button2.Width),
r.Next() % (this.ClientSize.Height - button2.Height));
} private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form2 form2 = new Form2 ();
form2.ShowDialog();
} private void Form1_Load(object sender, EventArgs e)
{ } }
}

CCC

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.IO;

namespace DamonMusic

{

public partial class Form1 : Form

{

private String[] songs;

private String[] lyrics;

private String[] pics;

private int songPointer = 0;

    private Label[] lyricLabels = new Label[100];

    public Form1()
{
InitializeComponent();
} // type = 1 下一首 type = -1 上一首
private int checkBound(int songPointer, int type){
Boolean arrivedMaximum = false;
Boolean arrivedMinimum = false;
if(type == 1)
songPointer += 1;
else{
songPointer -= 1;
}
if (songPointer == songs.Length) {
arrivedMaximum = true;
}
if (songPointer == -1)
{
arrivedMinimum = true;
}
if (arrivedMaximum) {
songPointer = 0;
}
if (arrivedMinimum) {
songPointer = songs.Length - 1;
}
return songPointer;
} private void Form1_Load(object sender, EventArgs e)
{
songs = Directory.GetFiles("song", "*.mp3");
lyrics = Directory.GetFiles("lyric", "*.lrc");
pics = Directory.GetFiles("image", "*.jpg");
//相对路径
if (songs.Length != 0){
axWindowsMediaPlayer1.URL = songs[songPointer];
LyricFiles lyricFiles = new LyricFiles();
lyricFiles.LoadLyric(lyrics[songPointer]);
int yStep = 0;
for (int i = 0; i < lyricFiles.lstLyric.Count; i++)
{
Label lblLyric = new Label();
lblLyric.Size = new System.Drawing.Size(500, 30);
lblLyric.BackColor = Color.Transparent;
lblLyric.ForeColor = Color.White;
lblLyric.Font = new System.Drawing.Font("微软雅黑", 14);
lblLyric.Text = lyricFiles.lstLyric[i].strLyric;
lblLyric.Location = new Point(60, yStep);
yStep += 40;
lyricLabels[i] = lblLyric;
this.Controls.Add(lblLyric);
}
this.BackgroundImage = Image.FromFile(pics[songPointer]);
//songPointer = checkBound(songPointer,1); }
else axWindowsMediaPlayer1.URL = null; axWindowsMediaPlayer1.Ctlcontrols.stop(); //初始化 准备工作
pnlControlBar.BackColor = Color.FromArgb(127, 200, 200, 200); } private void pictureBox1_Click(object sender, EventArgs e)
{ } private void pictureBox2_Click(object sender, EventArgs e)
{ } bool isplay = false;
private void pictureBox9_Click(object sender, EventArgs e)
{ isplay = !isplay;
//播放歌曲
if (isplay)
{
lblShowDuration.Text = axWindowsMediaPlayer1.currentMedia.durationString;
axWindowsMediaPlayer1.Ctlcontrols.play();
picPlay.BackgroundImage = Properties.Resources.pause_circle_o;
}
else//暂停播放
{
axWindowsMediaPlayer1.Ctlcontrols.pause();
picPlay.BackgroundImage=Properties.Resources.play_circle_o;
} //LyricFiles lyricFiles = new LyricFiles();
//lyricFiles.LoadLyric("lyric/音阙诗听-红昭愿.lrc");
//int yStep = 0;
//for (int i = 0; i < lyricFiles.lstLyric.Count; i++)
//{
// Label lblLyric = new Label();
// lblLyric.Size = new System.Drawing.Size(500, 30);
// lblLyric.BackColor = Color.Transparent;
// lblLyric.ForeColor=Color .White ;
// lblLyric.Font=new System .Drawing .Font ("微软雅黑",14);
// lblLyric.Text = lyricFiles.lstLyric[i].strLyric;
// lblLyric.Location = new Point (60,yStep );
// yStep +=40;
// lyricLabels[labelPointer] = lblLyric;
// labelPointer += 1;
// this.Controls.Add(lblLyric);
//} //int currentLyricLine;
//for (int i = 0; i < lyricFiles.lstLyric.Count; i++)
//{
// if (axWindowsMediaPlayer1.Ctlcontrols.currentPosition > lyricFiles.lstLyric[currentLyricLine].totSecond)
//{
// for (int j = 0; j < lstLbl.Count; j++)
//{
// if (j == currentLyricLine)
//{
// lstLbl[j].ForeColor = Color.Yellow;
// lstLbl[j ].Font=new Font ("微软雅黑",18);
// }
//else
//{
// lstLbl[j].ForeColor = Color.White ;
//lstLbl[j ].Font=new Font ("微软雅黑",10);
//}
//}
//currentLyricLine ++;
//}
//}
//lstLbl[j].Location=new Point(lstLbl[j].Location.X,LstLbl[j].Location.Y+20); //lyricFiles.lstLyric[1]; //打开文件
// Encoding encode = Encoding.GetEncoding("GB2312");
// FileStream fs=new FileStream ("音阙诗听-红昭愿.lrc",FileMode .Open );
// StreamReader sr=new StreamReader (fs,encode );
//
// string line = sr.ReadLine();
// //操作文件
// //richTextBox1.Text = sr.ReadToEnd();
// //关闭文件
// sr.Close();
// fs.Close();
} private void pictureBox10_Click(object sender, EventArgs e)
{
isplay = true; for (int i = 0; i < 100; i++)
{
if (lyricLabels[i] == null) {
continue;
}
this.Controls.Remove(lyricLabels[i]);
} songPointer = checkBound(songPointer, 1);
axWindowsMediaPlayer1.URL = songs[songPointer];
axWindowsMediaPlayer1.Ctlcontrols.play();
picPlay.BackgroundImage = Properties.Resources.pause_circle_o; LyricFiles lyricFiles = new LyricFiles();
lyricFiles.LoadLyric(lyrics[songPointer]);
int yStep = 0;
for (int i = 0; i < lyricFiles.lstLyric.Count; i++)
{
Label lblLyric = new Label();
lblLyric.Size = new System.Drawing.Size(500, 30);
lblLyric.BackColor = Color.Transparent;
lblLyric.ForeColor = Color.White;
lblLyric.Font = new System.Drawing.Font("微软雅黑", 14);
lblLyric.Text = lyricFiles.lstLyric[i].strLyric;
lblLyric.Location = new Point(60, yStep);
yStep += 40;
lyricLabels[i] = lblLyric;
this.Controls.Add(lblLyric);
} this.BackgroundImage = Image.FromFile(pics[songPointer]);
} private void pictureBox8_Click(object sender, EventArgs e)
{
isplay = true; for (int i = 0; i < 100; i++)
{
if (lyricLabels[i] == null)
{
continue;
}
this.Controls.Remove(lyricLabels[i]);
} songPointer = checkBound(songPointer, -1);
axWindowsMediaPlayer1.URL = songs[songPointer];
axWindowsMediaPlayer1.Ctlcontrols.play();
picPlay.BackgroundImage = Properties.Resources.pause_circle_o; LyricFiles lyricFiles = new LyricFiles();
lyricFiles.LoadLyric(lyrics[songPointer]);
int yStep = 0;
for (int i = 0; i < lyricFiles.lstLyric.Count; i++)
{
Label lblLyric = new Label();
lblLyric.Size = new System.Drawing.Size(500, 30);
lblLyric.BackColor = Color.Transparent;
lblLyric.ForeColor = Color.White;
lblLyric.Font = new System.Drawing.Font("微软雅黑", 14);
lblLyric.Text = lyricFiles.lstLyric[i].strLyric;
lblLyric.Location = new Point(60, yStep);
yStep += 40;
lyricLabels[i] = lblLyric;
this.Controls.Add(lblLyric);
}
this.BackgroundImage = Image.FromFile(pics[songPointer]);
}
}

}

DDD

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace ImageProcessDamon

{

public partial class Form1 : Form

{

//图像处理主界面

public Form1()

{

InitializeComponent();

}

    Image imgOriginal;

    //打开一张图片
private void btnOpenimage_Click(object sender, EventArgs e)
{ OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); string strFileName = ofd.FileName; imgOriginal = Image.FromFile(strFileName);
pictureBox1 .BackgroundImage = imgOriginal;
}
//底片处理
private void button2_Click(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap( imgOriginal); for (int i = 0; i < bmp.Width ; i++)
{
for (int j = 0; j < bmp.Height ; j ++)
{
//获得原来像素点颜色
Color c = bmp.GetPixel(i , j);
//改变
Color cAfter = Color.FromArgb(255 - c.R, 255 - c.G, 255 - c.B);
//设置回去
bmp.SetPixel(i, j, cAfter);
}
}
picAfter.BackgroundImage = bmp;
}
//灰度化
private void button2_Click_1(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(imgOriginal); for (int i = 0; i < bmp.Width; i++)
{
for (int j = 0; j < bmp.Height; j++)
{
//获得原来像素点颜色
Color c = bmp.GetPixel(i, j);
//改变
int gray = (c.R + c.G + c.B) / 3;
Color cAfter = Color.FromArgb(gray ,gray ,gray );
//设置回去
bmp.SetPixel(i, j, cAfter);
}
}
picAfter.BackgroundImage = bmp;
} private void btnSave_Click(object sender, EventArgs e)
{
//保存图片
SaveFileDialog sfd = new SaveFileDialog();
sfd.ShowDialog(); picAfter.BackgroundImage.Save (sfd .FileName +".bmp");
} private void Form1_Load(object sender, EventArgs e)
{ } private void pictureBox1_Click(object sender, EventArgs e)
{ } private void button3_Click(object sender, EventArgs e)
{ //以浮雕效果显示图像
try
{
int Height = this.pictureBox1.BackgroundImage.Height;
int Width = this.pictureBox1.BackgroundImage.Width;
Bitmap newBitmap = new Bitmap(Width, Height);
Bitmap oldBitmap = (Bitmap)this.pictureBox1.BackgroundImage;
Color pixel1, pixel2;
for (int x = 0; x < Width - 1; x++)
{
for (int y = 0; y < Height - 1; y++)
{
int r = 0, g = 0, b = 0;
pixel1 = oldBitmap.GetPixel(x, y);
pixel2 = oldBitmap.GetPixel(x + 1, y + 1);
r = Math.Abs(pixel1.R - pixel2.R + 128);
g = Math.Abs(pixel1.G - pixel2.G + 128);
b = Math.Abs(pixel1.B - pixel2.B + 128);
if (r > 255)
r = 255;
if (r < 0)
r = 0;
if (g > 255)
g = 255;
if (g < 0)
g = 0;
if (b > 255)
b = 255;
if (b < 0)
b = 0;
newBitmap.SetPixel(x, y, Color.FromArgb(r, g, b));
}
}
this.picAfter.BackgroundImage = newBitmap;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
} } private void button4_Click(object sender, EventArgs e)
{
//以锐化效果显示图像
try
{
int Height = this.pictureBox1.BackgroundImage.Height;
int Width = this.pictureBox1.BackgroundImage.Width;
Bitmap newBitmap = new Bitmap(Width, Height);
Bitmap oldBitmap = (Bitmap)this.pictureBox1.BackgroundImage;
Color pixel;
//拉普拉斯模板
int[] Laplacian = { -1, -1, -1, -1, 9, -1, -1, -1, -1 };
for (int x = 1; x < Width - 1; x++)
for (int y = 1; y < Height - 1; y++)
{
int r = 0, g = 0, b = 0;
int Index = 0;
for (int col = -1; col <= 1; col++)
for (int row = -1; row <= 1; row++)
{
pixel = oldBitmap.GetPixel(x + row, y + col); r += pixel.R * Laplacian[Index];
g += pixel.G * Laplacian[Index];
b += pixel.B * Laplacian[Index];
Index++;
}
//处理颜色值溢出
r = r > 255 ? 255 : r;
r = r < 0 ? 0 : r;
g = g > 255 ? 255 : g;
g = g < 0 ? 0 : g;
b = b > 255 ? 255 : b;
b = b < 0 ? 0 : b;
newBitmap.SetPixel(x - 1, y - 1, Color.FromArgb(r, g, b));
}
this.picAfter.BackgroundImage = newBitmap;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "信息提示");
}
}
}

}

EEE

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace Damoncreater

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

//定义绘图对象

Graphics g;

    int dashOffset;
private void Form1_Paint(object sender, PaintEventArgs e)
{ } Point clickPoint;
int w;
int h; bool isDrawRect;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{ } private void Form1_MouseMove(object sender, MouseEventArgs e)
{ } private void Form1_MouseUp(object sender, MouseEventArgs e)
{ } private void timer1_Tick(object sender, EventArgs e)
{
dashOffset++;
this.Invalidate();
} private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
//实例化绘图对象
g = e.Graphics; Pen pen = new Pen(Color.Black, 2);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
pen.DashPattern = new float[] { 4, 4 };
pen.DashOffset = dashOffset; //画一个矩形
g.DrawRectangle(pen, clickPoint.X, clickPoint.Y, w, h); Pen pen2 = new Pen(Color.White, 2);
pen2.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
pen2.DashPattern = new float[] { 4, 4 };
pen2.DashOffset = dashOffset + 4; //画一个矩形
g.DrawRectangle(pen2, clickPoint.X, clickPoint.Y, w, h); }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
isDrawRect = true;
clickPoint = new Point(e.X, e.Y);
} private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (isDrawRect)
{ w = e.X - clickPoint.X;
h = e.Y - clickPoint.Y; g = pictureBox1.CreateGraphics(); Pen pen = new Pen(Color.Black, 2);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
pen.DashPattern = new float[] { 4, 4 };
pen.DashOffset = dashOffset; //画一个矩形
g.DrawRectangle(pen, clickPoint.X, clickPoint.Y, w, h); Pen pen2 = new Pen(Color.White, 2);
pen2.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
pen2.DashPattern = new float[] { 4, 4 };
pen2.DashOffset = dashOffset + 4; //画一个矩形
g.DrawRectangle(pen2, clickPoint.X, clickPoint.Y, w, h); }
} private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
isDrawRect = false;
//矩形头像
Bitmap bmp = new Bitmap(w, h);
for (int i = 0; i < w; i++)
{
for (int j = 0; j < h; j++)
{
Color c = bmpOriginal.GetPixel(i + clickPoint.X, j + clickPoint.Y);
bmp.SetPixel(i, j, c);
}
}
pictureBox2.BackgroundImage = bmp;
//圆形头像 }
//打开图片文件
Bitmap bmpOriginal;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); string imgFileName = ofd.FileName; bmpOriginal = new Bitmap(imgFileName); pictureBox1.BackgroundImage = bmpOriginal;
} private void pictureBox2_Click(object sender, EventArgs e)
{ } private void button2_Click(object sender, EventArgs e)
{
//保存图片
SaveFileDialog sfd = new SaveFileDialog();
sfd.ShowDialog(); pictureBox2.BackgroundImage.Save(sfd.FileName + ".bmp");
} }

}

FFF

1) using System;

2) using System.Collections.Generic;

3) using System.ComponentModel;

4) using System.Data;

5) using System.Drawing;

6) using System.Linq;

7) using System.Text;

8) using System.Windows.Forms;

9) using System.Drawing.Drawing2D;

10)

11) namespace Geometry_

12) {

13) public partial class Form1 : Form

14) {

15) public Form1()

16) {

17) InitializeComponent();

18) }

19) List lstGeo = new List();

20) Graphics g;

21) bool isDraw;

22) Color frameColor = Color.Black;

23) Color fillColor = Color.Red;

24) private void Form1_Paint(object sender, PaintEventArgs e)

25) {

26) g = e.Graphics;

27) for (int i = 0; i < lstGeo.Count; i++) {

28) lstGeo[i].Draw(g);

29) }

30) }

31) private void Form1_MouseDown(object sender, MouseEventArgs e)

32) {

33) //按左键则画线

34) if (e.Button == System.Windows.Forms.MouseButtons.Left) {

35) isDraw = true;

36) }

37) //按右键则清除

38) if (e.Button == System.Windows.Forms.MouseButtons.Right)

39) {

40) lstGeo.Clear();

41) this.Invalidate();

42) }

43) //选中D的是矩形

44) if (rbtnRectangle.Checked) {

45) MyRectangle rectangle = new MyRectangle();

46) rectangle.rect.X = e.X;

47) rectangle.rect.Y = e.Y;

48) rectangle.frameColor = frameColor;

49) rectangle.fillColor = fillColor;

50) lstGeo.Add(rectangle);

51) }

52) //选?中D的ì?是o?椭a?圆2

53) else if (rbtnEllipse.Checked)

54) {

55) MyEllipse ellipse = new MyEllipse();

56) ellipse.rect.X = e.X;

57) ellipse.rect.Y = e.Y;

58) ellipse.frameColor = frameColor;

59) ellipse.fillColor = fillColor;

60) lstGeo.Add(ellipse);

61) }

62) //选中D的是自由曲线

63) else if (rbtnFreeLine.Checked)

64) {

65) MyFreeLine freeLine = new MyFreeLine();

66) freeLine.lstPoint.Add(new Point(e.X, e.Y));

67) freeLine.frameColor = frameColor;

68) lstGeo.Add(freeLine);

69) }

70) //选中D的是三角形

71) else if (rbtnTriangle.Checked) {

72) MyTriangle triangle = new MyTriangle();

73) triangle.rect.X = e.X;

74) triangle.rect.Y = e.Y;

75) triangle.frameColor = frameColor;

76) triangle.fillColor = fillColor;

77) lstGeo.Add(triangle);

78) }

79) //选中D的是多边形

80) else if (rbtnPolygon.Checked) {

81) MyPolygon polygon = new MyPolygon();

82) polygon.lstPolygon.Add(new Point(e.X, e.Y));

83) polygon.frameColor = frameColor;

84) polygon.fillColor = fillColor;

85) lstGeo.Add(polygon);

86) }

87) //选中D的是箭头

88) else if (rbtnArraw.Checked)

89) {

90) MyArrow arraw = new MyArrow();

91) arraw.rect.X = e.X;

92) arraw.rect.Y = e.Y;

93) arraw.frameColor = frameColor;

94) arraw.fillColor = fillColor;

95) lstGeo.Add(arraw);

96) }

97) }

98) private void Form1_MouseMove(object sender, MouseEventArgs e)

99) {

100) if (isDraw) {

101) if (rbtnRectangle.Checked)

102) {

103) ((MyRectangle)lstGeo[lstGeo.Count - 1]).rect.Width = e.X - ((MyRectangle)lstGeo[lstGeo.Count - 1]).rect.X;

104) ((MyRectangle)lstGeo[lstGeo.Count - 1]).rect.Height = e.Y - ((MyRectangle)lstGeo[lstGeo.Count - 1]).rect.Y;

105) }

106) else if (rbtnEllipse.Checked) {

107) ((MyEllipse)lstGeo[lstGeo.Count - 1]).rect.Width = e.X - ((MyEllipse)lstGeo[lstGeo.Count - 1]).rect.X;

108) ((MyEllipse)lstGeo[lstGeo.Count - 1]).rect.Height = e.Y - ((MyEllipse)lstGeo[lstGeo.Count - 1]).rect.Y;

109) }else if(rbtnFreeLine.Checked){

110)

111) ((MyFreeLine)lstGeo[lstGeo.Count - 1]).lstPoint.Add(new Point(e.X, e.Y));

112) }

113) else if (rbtnTriangle.Checked) {

114) ((MyTriangle)lstGeo[lstGeo.Count - 1]).rect.Width = e.X - ((MyTriangle)lstGeo[lstGeo.Count - 1]).rect.X;

115) ((MyTriangle)lstGeo[lstGeo.Count - 1]).rect.Height = e.Y - ((MyTriangle)lstGeo[lstGeo.Count - 1]).rect.Y;

116) }

117) else if (rbtnPolygon.Checked) {

118) ((MyPolygon)lstGeo[lstGeo.Count - 1]).lstPolygon.Add(new Point(e.X, e.Y));

119) }

120) else if (rbtnArraw.Checked) {

121) ((MyArrow)lstGeo[lstGeo.Count - 1]).rect.Width = e.X - ((MyArrow)lstGeo[lstGeo.Count - 1]).rect.X;

122) ((MyArrow)lstGeo[lstGeo.Count - 1]).rect.Height = e.Y - ((MyArrow)lstGeo[lstGeo.Count - 1]).rect.Y;

123) }

124) }

125) this.Invalidate();

126) }

127) private void Form1_MouseUp(object sender, MouseEventArgs e)

128) {

129) isDraw = false;

130) }

131) //选择边框颜色

132) private void btnBorderColor_Click(object sender, EventArgs e)

133) {

134) ColorDialog cd = new ColorDialog();

135) cd.ShowDialog();

136) frameColor = cd.Color;

137) }

138) //选择填充颜色

139) private void btnFillColor_Click(object sender, EventArgs e)

140) {

141) ColorDialog cd = new ColorDialog();

142) cd.ShowDialog();

143) fillColor = cd.Color;

144) }

145) private void lblInfo_Click(object sender, EventArgs e)

146) {

147)

148) }

149)

150) private void Form1_Load(object sender, EventArgs e)

151) {

152)

153) }

154) }

155) }

156)

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Drawing;

using System.Drawing.Drawing2D;

namespace Geometry_

{

//几何图源的父类

class ParentGeometry

{

public Color frameColor;//边框颜色

//int framewidth;

//public DashStyle frameDashStyle;

public Color fillColor;//填充颜色

//public Rectangle rectBox;

//绘制

public virtual void Draw(Graphics g) { }

}

//矩形

class MyRectangle : ParentGeometry {

public Rectangle rect;

//绘制

public override void Draw(Graphics g) {

Pen pen = new Pen(frameColor, 3);

SolidBrush sb = new SolidBrush(fillColor);

g.DrawRectangle(pen, rect);

g.FillRectangle(sb, rect);

}

}

//椭圆

class MyEllipse : ParentGeometry

{

public Rectangle rect;

//绘制

public override void Draw(Graphics g)

{

Pen pen = new Pen(frameColor, 3);

SolidBrush sb = new SolidBrush(fillColor);

g.DrawEllipse(pen, rect);

g.FillEllipse(sb, rect);

}

}

//三角形

class MyTriangle : ParentGeometry

{

public Rectangle rect;

public override void Draw(Graphics g)

{

Point[] points = new Point[3];

//描绘三角形的三个点的坐标

points[0] = new Point(rect.X + rect.Width / 2, rect.Y);//顶点坐标o

points[1] = new Point(rect.X, rect.Height + rect.Y);

points[2] = new Point(rect.X + rect.Width, rect.Height + rect.Y);

Pen pen = new Pen(frameColor, 3);

g.DrawPolygon(pen, points);

SolidBrush sb = new SolidBrush(fillColor);

g.FillPolygon(sb, points);

}

}

//自由曲线

class MyFreeLine : ParentGeometry {

public List lstPoint =new List();

public override void Draw(Graphics g) {

Pen pen = new Pen(frameColor, 3);

if (lstPoint.Count >= 2) {

g.DrawLines(pen, lstPoint.ToArray());

}

}

}

//多边形

class MyPolygon : ParentGeometry

{

public List lstPolygon =new List();

    public override void Draw(Graphics g)
{
Pen pen = new Pen(frameColor, 3);
if (lstPolygon.Count >= 5) {
g.DrawPolygon(pen, lstPolygon.ToArray());
}
}
}
//箭头
class MyArrow : ParentGeometry {
public Rectangle rect;
public override void Draw(Graphics g)
{
Point[] points = new Point[7];
points[4] = new Point(rect.X + rect.Width * 3 / 4, rect.Y);
points[6] = new Point(rect.X + rect.Width, rect.Y + rect.Height / 2);
points[5] = new Point(rect.X + rect.Width * 3 / 4, rect.Y + rect.Height);
points[3] = new Point(rect.X + rect.Width * 3 / 4, (rect.Y + rect.Height) * 3 / 4);
points[1] = new Point(rect.X, (rect.Y + rect.Height) * 3 / 4);
points[0] = new Point(rect.X, (rect.Y + rect.Height) / 4);
points[2] = new Point((rect.X + rect.Width) * 3 / 4, (rect.Y + rect.Height) / 4); Pen pen = new Pen(frameColor, 3);
SolidBrush sb = new SolidBrush(fillColor);
g.DrawPolygon(pen, points);
g.FillPolygon(sb, points);
}
}

}

C#桌面程序设计复习的更多相关文章

  1. C++ 面向对象程序设计复习大纲

     这是我在准备C++考试时整理的提纲,如果是通过搜索引擎搜索到这篇博客的师弟师妹,建议还是先参照PPT和课本,这个大纲也不是很准确,自己总结会更有收获,多去理解含义,不要死记硬背,否则遇到概念辨析题会 ...

  2. Java语言程序设计复习提纲

     这是我在准备Java考试时整理的提纲,如果是通过搜索引擎搜索到这篇博客的师弟师妹,建议还是先参照PPT和课本,这个大纲也不是很准确,自己总结会更有收获,多去理解含义,不要死记硬背,否则遇到概念辨析题 ...

  3. Javascript高级程序设计复习——第五章引用类型 【原创】

    5.1  Object类型 1:创建Object实例的两种方式 ①new构造法 var obj1 = new Object(); 注意大写!不传递参数时可以省略圆括号 obj1.hehe = &quo ...

  4. 面试相关的技术问题--WEB基础

    1. servlet生命周期.各个方法 和工作原理servlet的生命周期包括三个阶段,分别是:初始化阶段:调用init()方法(整个生命周期内只被调用一次)响应客户端请求阶段:service()终止 ...

  5. 如何打造一款五星级的 APP ?

    移动互联网大潮来袭!据统计,2015 年平均每天有 1000 个新的应用上架,而这些应用的现状可以说是鱼龙混杂,同是每个人的眼光.品味.意识和利益都不同,因此每人眼中的应用也是不同的.在巨大的市场竞争 ...

  6. android项目的的目录结构

    然后我们看一下Helloword的程序目录: 我们可以看到 大致有的文件: 1. MainHelloWorld.java文件 2. R.java文件 3. android.jar文件 4. RES.L ...

  7. Java就业前景怎么样?学了后好找工作吗?

    不知道大家对Java就业前景了解多少.随着信息化的发展.IT培训受倒了越来越多人的追捧.在开发领域,JAVA培训成为了很多人的首选!JAVA应用广泛.JAVA培训就业前景良好. 眼下.尽管JAVA人才 ...

  8. Web前端开发中的MCRV模式(转)

    作者: izujian  来源: baiduux 摘要:针对前端开发中基于ajax的复杂页面开发所面临的代码规模大,难以组织和维护,代码复用性.扩展性和适应性差等问题,本文尝试以MVC思想为 基础,结 ...

  9. Java发展前景与职业方向解析

    大多数人选择Java可能只是因为听说Java前景好.Java比较好找工作.Java语言在TIOBE排行榜上一直位于前三等等之类的原因,但是Java具体好在哪里,心里却是没有什么概念的.本文为你解答学J ...

随机推荐

  1. windows 下安装perl Tk 模块

    首先,安装activeperl ,安装过程中勾选自动添加PATH环境变量,这样安装后就不需要自己手动修改PATH环境变量: 通过cmd 调出命令行窗口,输入ppm ,然后回车,就开启了perl 的包管 ...

  2. php eval函数一句话木马代码

    eval可以用来执行任何其他php代码,所以对于代码里发现了eval函数一定要小心,可能是木马 就这一句话害死人,这样任何人都可以post任何文件上来,所以要做好防范 <?php @eval($ ...

  3. win7 自带计算机(for programmer)

    打开win7的Accessories, 看到Calculator, 点击打开计算器. 可以看到32位的2进制代码:

  4. 编辑框添加灰色提示字(html+VC)

    Html中添加灰色提示字,使用属性placeholder即可! <input type="text" placeholder="要显示的文字"> 但 ...

  5. 制作SD卡启动自己编译的uboot.bin

    README for FriendlyARM Tiny4412 -----------------------------------------------------1. Build uboot ...

  6. STL 源代码剖析 算法 stl_algo.h -- search_n

    本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie search_n ------------------------------------- ...

  7. PHP-007(转)

    今天安装ecshop的时候最上面出现了一个错误提示:Strict Standards: Only variables should be passed by reference in F:\www.x ...

  8. php学习九:存取器&魔术方法

    当声明属性的时候用到了private,那么的话只能本类中才能访问此属性,其他地方无法使用,这个时候需要给外界提供一些方法来使外界访问 方法一:存取器: 可以提供一个public的方法来使外界对类里面的 ...

  9. iOS开发:iOS中图片与视频一次性多选 - v2m

    一.使用系统的Assets Library Framework这个是用来访问Photos程序中的图片和视频的库.其中几个类解释如下 ALAsset ->包含一个图片或视频的各种信息 ALAsse ...

  10. OpenGL ES2学习笔记(6)-- Line Strip和Line Loop

    Line Strip 上一篇文章画了两条线段,但是用了4个点.如果几条线段首尾相接的话,可以让OpenGL把他们当成Line Strip来画,这样就可以用n+1个点来画n条线段. 代码 import ...