C#桌面程序设计复习

2021-06-27 13:06

阅读:440

标签:ati   iap   i++   quic   enter   lips   微软   dir   except   

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 {
for(int j=0;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 

}

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[currentLyricLine].totSecond)
            //{
              //  for (int j = 0; j 

}

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  255)
                        r = 255;
                    if (r  255)
                        g = 255;
                    if (g  255)
                        b = 255;
                    if (b  255 ? 255 : r;
                    r = r  255 ? 255 : g;
                    g = g  255 ? 255 : b;
                    b = b 

}

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 

}

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

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

    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#桌面程序设计复习

标签:ati   iap   i++   quic   enter   lips   微软   dir   except   

原文地址:https://www.cnblogs.com/Damonblogs/p/9937236.html


评论


亲,登录后才可以留言!