桌面应用程序设计(QQ)

一、流程

拖控件    改属性    写事件

 

各种各样的控件 CheckBox,textBox,pictureBox,Label,panel...

控件----属性(光标 Cursor
       text 文本

       font 字体

       Timer 时钟  {  Enable 是否启用;Interval  间隔(s) }

                       ......)

各种各样的属性 删除边框,改背景颜色,透明度...

Ctrl+C  Ctrl+V
Ctrl+Z(上一步)  Ctrl+Y(反撤回)


为每一个部件命名,以便写事件时方便区分。

按钮点击后会怎么样:(Click)“写事件”(属性栏的小闪电)
写事件:靠代码完成
双击进入写代码页面

MouseEnter

MouseLeave

Click

......

 

QQ登陆页面部分代码如下:

 private void lblFindPwd_MouseEnter(object sender, EventArgs e)
        {
            lblFindPwd.ForeColor = Color.Black;
        }

        private void lblFindPwd_MouseLeave(object sender, EventArgs e)
        {
            lblFindPwd.ForeColor = Color.FromArgb(166, 166, 166);
        }

②
 private void Panel1_MouseEnter(object sender, EventArgs e)
        {
            panel1.BackColor = Color.LightGray;
        }

        private void Panel1_MouseLeave(object sender, EventArgs e)
        {
            panel1.BackColor = SystemColors.Control;
        }

        private void Panel2_MouseEnter(object sender, EventArgs e)
        {
            panel2.BackColor = Color.LightGray;
        }

        private void Panel2_MouseLeave(object sender, EventArgs e)
        {
            panel2.BackColor = SystemColors.Control;
        }
    }
}
//代码与设计器颜色要一致,如果改为精确,别忘了把设计器中的背景颜色BackColor也改为精确值
 /*   private void pnlPwd_MouseEnter(object sender, EventArgs e)
        {
            pnlPwd.BackColor = Color.FromArgb(193,193,193);
        }

        private void pnlPwd_MouseLeave(object sender, EventArgs e)
        {

            pnlPwd.BackColor = Color.FromArgb(229, 229, 229);
        }

*/


        private void pnlPwd_MouseEnter(object sender, EventArgs e)
        {
            pnlPwd.BackColor = Color.FromArgb(193,193,193);
        }

        private void pnlPwd_MouseLeave(object sender, EventArgs e)
        {

            pnlPwd.BackColor = Color.FromArgb(229, 229, 229);
        }
    
        private void txtPwd_TextChanged(object sender, EventArgs e)
        {
            pnlPwd.BackColor = Color.FromArgb(18, 183, 245);
        }


       private void picProfilePhoto_MouseEnter(object sender, EventArgs e)
        {
            timer1.Enabled = true;  //F10, ---单步调试,F5: 继续执行,  FN + F10
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //100ms
            picMultiUserLogin.Location = new Point(
                            picMultiUserLogin.Location.X + 10,
                            picMultiUserLogin.Location.Y
                            );
        }//多头像加号移除
//整个移动过程,也可以用两个timer实现,这里运用if语句
        bool isMoveRight;

        public const int MOVE_STEP = 10;

        private void picProfilePhoto_MouseEnter(object sender, EventArgs e)//头像
        {
            timer1.Enabled = true;  //F10, ---单步调试,F5: 继续执行,  FN + F10

            isMoveRight = true;
        }

        private void picProfilePhoto_MouseLeave(object sender, EventArgs e)
        {
            isMoveRight = false;
        }

        //100ms, 执行
        private void timer1_Tick(object sender, EventArgs e)
        {
            if ((isMoveRight && picMultiUserLogin.Location.X <= 245)   //
                || (!isMoveRight && picMultiUserLogin.Location.X >= 200)) //
            {
                //100ms
                if (isMoveRight)
                {
                    picMultiUserLogin.Location = new Point(
                                    picMultiUserLogin.Location.X + MOVE_STEP,
                                    picMultiUserLogin.Location.Y  //头像加号
                                    );
                }
                else
                {

                    picMultiUserLogin.Location = new Point(
                                    picMultiUserLogin.Location.X - MOVE_STEP,
                                    picMultiUserLogin.Location.Y
                                    );
                }
            }
        }
    

 

posted @ 2020-03-16 05:31  nanaa  阅读(311)  评论(0编辑  收藏  举报