• 仿QQ会员右下角提示框c#实现


    为了不让大家再误会,我在这里声明,我做的是在登录后的提示,只要大家用过QQ,Q会员开通过就知道 的,

    先看一下效果吧

    说一下实现 吧,

    第一步是先把QQ会员 便当 的框给截图下来,然后放到Ps里P一下,需要做到这样就行了,看图片

    第二步,可以在上面加一 些Lable就行了,关闭按钮是两个图片,切换的方法是这样的

    代码
     //图片离开事件
            private void pictureBox1_MouseLeave(object sender, EventArgs e)
            {
                pictureBox1.BackgroundImage 
    = ClientSystem.Properties.Resources.lgintop;
            }

            
    //图片进入事件
            private void pictureBox1_MouseEnter(object sender, EventArgs e)
            {
                pictureBox1.BackgroundImage 
    = ClientSystem.Properties.Resources.lgintop1;
            }

    第三步,IP的取法我就不说了有很多,还有上面的4.0的测试这些都 是加上的新闻,只要启动浏览器就行了,

    启动的方法是

     //系统官网
            private void label7_Click(object sender, EventArgs e)
            {
                Process.Start(
    "http://www.smxzc.com/");
            }

    第四步,说一下渐变显示 的效果的处理方法

    代码
    string caozuo = "";

    //界面加载
            private void Messages_Load(object sender, EventArgs e)
            {
                
    try
                {
                    
    //让窗体加载时显示到右下角
                    int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - 255;
                    
    int y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - 161;
                    
    this.SetDesktopLocation(x, y);

                    
    //加载显示信息
                    ShowComptureInfo();

                    
    //渐变显示这里表示加载
                    caozuo = "load";
                    
    this.Opacity = 0;
                }
                
    catch (Exception)
                {

                }
            }

      caozuo有两个值一个是 load表示要向不透明方向增加量,也就是说会慢慢看清楚,还有一个close 表示要向透明方向增加量,这样会慢慢的看不到窗体

    ,我是用一个Timer来处理的

    代码
     //定时处理渐变的效果
            private void timer2_Tick(object sender, EventArgs e)
            {
                
    if (caozuo == "load")
                {
                    
    this.Opacity += 0.09;
                }
                
    else if (caozuo == "close")
                {
                    
    this.Opacity = this.Opacity - 0.09;
                    
    if (this.Opacity == 0)
                        
    this.Close();
                }
            }

     这样只要caozuo的值发生变化的时候 就会向某个方向开始增加渐变显示 的量

    当鼠标进入的时候我是这样处理的

    代码
     //进入窗体事件
            private void Messages_MouseEnter(object sender, EventArgs e)
            {
                
    //停止定时关闭
                timer1.Enabled = false;
                
    //开始渐变加载
                caozuo = "load";
            }

    这样的话就会在原来的基础上加量,也就是说如果快不显示了,当鼠标移动进入窗体时就双会慢慢的显示,当移开的时候我是这样处理的

    代码
     //窗体离开事件
            private void Messages_MouseLeave(object sender, EventArgs e)
            {
                timer1.Enabled 
    = true;
            }

      
    //定时关闭窗体
            private void timer1_Tick(object sender, EventArgs e)
            {
                timer2.Enabled 
    = true;
                caozuo 
    = "close";//关闭窗体
            }

     这样就双会启动定时关闭窗体,我的定时是6秒大家可以随便改的

    效果就是这样实现的

     因为我的窗体 是没有标题栏的这样就不能拖动了, 很不方便,拖动窗体的方法有很多,我是这样实现 的,

    代码
     private bool isMouseDown = false;
            
    private Point FormLocation;     //form的location
            private Point mouseOffset;      //鼠标的按下位置

            
    //鼠标安下
            private void Messages_MouseDown(object sender, MouseEventArgs e)
            {
                
    try
                {
                    
    if (e.Button == MouseButtons.Left)
                    {
                        isMouseDown 
    = true;
                        FormLocation 
    = this.Location;
                        mouseOffset 
    = Control.MousePosition;
                    }
                }
                
    catch (Exception)
                {

                }
            }

            
    //鼠标移动
            private void Messages_MouseMove(object sender, MouseEventArgs e)
            {
                
    try
                {
                    
    int _x = 0;
                    
    int _y = 0;
                    
    if (isMouseDown)
                    {
                        Point pt 
    = Control.MousePosition;
                        _x 
    = mouseOffset.X - pt.X;
                        _y 
    = mouseOffset.Y - pt.Y;

                        
    this.Location = new Point(FormLocation.X - _x, FormLocation.Y - _y);
                    }
                }
                
    catch (Exception)
                {

                }
            }

            
    //鼠标松开
            private void Messages_MouseUp(object sender, MouseEventArgs e)
            {
                
    try
                {
                    isMouseDown 
    = false;
                }
                
    catch (Exception)
                {

                }
            }

     关于这个内容 可以参考 我的文章

    一个拖动无标题栏窗体的方法 修正 

    http://www.cnblogs.com/sufei/archive/2010/02/04/1663830.html

     下面把我实现 的全部代码贴出来吧

    代码
    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 ClientSystem.ClientSystemServices;
    using BaseFunction;
    using System.Diagnostics;

    namespace ClientSystem
    {
        
    /// <summary>
        
    /// 提示窗体  苏飞
        
    /// </summary>
        public partial class Messages : Form
        {
            
    public Messages()
            {
                InitializeComponent();
            }
            
    //营业厅完整信息
            public OfficeInfo OfficeInfo { getset; }

            
    #region //私有变量和方法

            
    private ClientSystemServices.Service1SoapClient user = new Service1SoapClient();

            
    //显示登录用户的计算机信息
            public void ShowComptureInfo()
            {
                
    //CUP
                
    //label9.Text = ComputerInfo.GetCpuID();

                
    //硬盘
                
    //label26.Text = ComputerInfo.GetDiskID();

                
    //IP
                lblIP.Text = ComputerInfo.GetIPAddress();

                
    //上次登录IP
                lbloldIP.Text = ComputerInfo.GetIPAddress();

                
    //用户名
                lblUser.Text = OfficeInfo.ofLogin + " 商户欢迎您";

                
    //计算机名称
                
    //label21.Text = ComputerInfo.GetComputerName();

                
    //操作系统
                
    //label23.Text = ComputerInfo.GetSystemType();

                
    //当前用户
                
    //label25.Text = ComputerInfo.GetUserName();
            }

            
    #endregion

            
    //界面加载
            private void Messages_Load(object sender, EventArgs e)
            {
                
    try
                {
                    
    //让窗体加载时显示到右下角
                    int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - 255;
                    
    int y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - 161;
                    
    this.SetDesktopLocation(x, y);

                    
    //加载显示信息
                    ShowComptureInfo();

                    
    //渐变显示这里表示加载
                    caozuo = "load";
                    
    this.Opacity = 0;
                }
                
    catch (Exception)
                {

                }
            }

            
    //关闭按钮
            private void pictureBox1_Click(object sender, EventArgs e)
            {
                
    this.Close();
            }

            
    //图片离开事件
            private void pictureBox1_MouseLeave(object sender, EventArgs e)
            {
                pictureBox1.BackgroundImage 
    = ClientSystem.Properties.Resources.lgintop;
            }

            
    //图片进入事件
            private void pictureBox1_MouseEnter(object sender, EventArgs e)
            {
                pictureBox1.BackgroundImage 
    = ClientSystem.Properties.Resources.lgintop1;
            }

            
    //修改密码
            private void label6_Click(object sender, EventArgs e)
            {
                ChangePwd frm 
    = new ChangePwd();
                frm.OfficeInfo 
    = this.OfficeInfo;
                frm.Show();
            }

            
    //系统官网
            private void label7_Click(object sender, EventArgs e)
            {
                Process.Start(
    "http://www.smxzc.com/");
            }

            
    #region//拖动无标题窗体

            
    private bool isMouseDown = false;
            
    private Point FormLocation;     //form的location
            private Point mouseOffset;      //鼠标的按下位置

            
    //鼠标安下
            private void Messages_MouseDown(object sender, MouseEventArgs e)
            {
                
    try
                {
                    
    if (e.Button == MouseButtons.Left)
                    {
                        isMouseDown 
    = true;
                        FormLocation 
    = this.Location;
                        mouseOffset 
    = Control.MousePosition;
                    }
                }
                
    catch (Exception)
                {

                }
            }

            
    //鼠标移动
            private void Messages_MouseMove(object sender, MouseEventArgs e)
            {
                
    try
                {
                    
    int _x = 0;
                    
    int _y = 0;
                    
    if (isMouseDown)
                    {
                        Point pt 
    = Control.MousePosition;
                        _x 
    = mouseOffset.X - pt.X;
                        _y 
    = mouseOffset.Y - pt.Y;

                        
    this.Location = new Point(FormLocation.X - _x, FormLocation.Y - _y);
                    }
                }
                
    catch (Exception)
                {

                }
            }

            
    //鼠标松开
            private void Messages_MouseUp(object sender, MouseEventArgs e)
            {
                
    try
                {
                    isMouseDown 
    = false;
                }
                
    catch (Exception)
                {

                }
            }
            
    #endregion

            
    //定时关闭窗体
            private void timer1_Tick(object sender, EventArgs e)
            {
                timer2.Enabled 
    = true;
                caozuo 
    = "close";//关闭窗体
            }

            
    //进入窗体事件
            private void Messages_MouseEnter(object sender, EventArgs e)
            {
                
    //停止定时关闭
                timer1.Enabled = false;
                
    //开始渐变加载
                caozuo = "load";
            }

            
    //窗体离开事件
            private void Messages_MouseLeave(object sender, EventArgs e)
            {
                timer1.Enabled 
    = true;
            }

            
    string caozuo = "";

            
    //定时处理渐变的效果
            private void timer2_Tick(object sender, EventArgs e)
            {
                
    if (caozuo == "load")
                {
                    
    this.Opacity += 0.09;
                }
                
    else if (caozuo == "close")
                {
                    
    this.Opacity = this.Opacity - 0.09;
                    
    if (this.Opacity == 0)
                        
    this.Close();
                }
            }
        }
    }
  • 相关阅读:
    Python学习笔记(三)
    自己出的一套前端笔试题
    Vue 数组封装和组件data定义为函数一些猜测
    前端Mvvm QC 上传了测试版
    为什么我们的web前端变的越来越复杂
    grootJsAPI文档
    grootjs 简明教程
    深入grootJs(进阶教程)
    也议 js闭包和ie内存泄露原理
    此utf8 非彼utf8 ——谈http协议里的编码问题
  • 原文地址:https://www.cnblogs.com/jcomet/p/1700511.html
Copyright © 2020-2023  润新知