要做一个提示信息窗口在显示器的右下角显示,让它弹出显示10秒后隐藏,隐藏时间为5分钟后再弹出,如此循环
应该怎么控制,我用的两个timer控件,每次时间不对啊
谢谢大家

解决方案 »

  1.   

    这个窗体上放个timer,设个标记是否隐藏状态并动态设置timer的时间就是了
      

  2.   


       private void Form1_Load(object sender, EventArgs e)
            {
                //localhost.Service web = new localhost.Service();
                ////web.dbcon("czq");
                //=============窗体从右下角向上弹出窗口效果================            int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
                int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;
                this.Location = new Point(x, y);//设置窗体在屏幕右下角显示
                if (web.yn() == "0")
                {
                    AnimateWindow(this.Handle, 1, AW_VER_NEGATIVE | AW_SLIDE | AW_ACTIVATE);
                }
                //=========================            DataSet dsxml = new DataSet();
                dsxml.ReadXml(Directory.GetCurrentDirectory() + "\\config.xml");
                xmlusername= dsxml.Tables[0].Rows[0]["username"].ToString();
                string xmlpassword = dsxml.Tables[0].Rows[0]["department"].ToString();
                //this.txtusername.Text ="你有"+ web.dbcon(xmlusername)+"条待办事宜";//xmlusername
                if (xmlusername != "")
                {
                    this.lbdis.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜," + web.assign(xmlusername) + "条转发处理";
                    this.button1.Enabled = false;
                    this.lbname.Text = web.getName(xmlusername) + ",你好";
                    this.panel1.Visible = false;
                    this.panel2.Visible = true;
                }
                else
                {
                    this.panel2.Visible = false;
                    this.panel1.Visible = true;
                }           
            }        private void button1_Click(object sender, EventArgs e)
            {
                
                XmlDocument doc = new XmlDocument();
                doc.Load(Directory.GetCurrentDirectory()+"\\config.xml");
                XmlNode n = doc.SelectSingleNode("/login/username");
                n.InnerText =txtusername.Text;
                n = doc.SelectSingleNode("/login/department");
                n.InnerText =txtpwd.Text;            doc.Save(Directory.GetCurrentDirectory() + "\\config.xml");
                //http://219.235.110.4:8077/
                //System.Diagnostics.Process.Start("http://219.235.110.4:8077/");        }        private void timer1_Tick(object sender, EventArgs e)
            {
                //localhost.Service web = new localhost.Service();
                //this.Close();
                this.timer1.Enabled = true;
                if (xmlusername == "")
                {
                    xmlusername = this.txtusername.Text;            }
                else
                {
                    this.lbdis.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜," + web.assign(xmlusername) + "条转发处理";
                }
                //this.txtusername.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜";//xmlusername
                //=============
                DataSet xmlname = new DataSet();
                xmlname.ReadXml(Directory.GetCurrentDirectory() + "\\config.xml");
                xmlusername = xmlname.Tables[0].Rows[0]["username"].ToString();
                //============
                if (xmlusername != "")
                {
                    //this.lbdis.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜";
                    this.button1.Enabled = false;
                }
                if(this.timer1.Interval==5000)
                {
                    this.Hide();
                    //================
                    this.timer2.Enabled = true;
                    this.timer2.Start();
                    //=================
                }
                
            }
            private void popWin()
            {
                if (this.timer2.Interval ==3100)//16000
                {
                    AnimateWindow(this.Handle, 1, AW_VER_NEGATIVE | AW_SLIDE | AW_ACTIVATE);
                }
            }        private void timer2_Tick(object sender, EventArgs e)
            {
                if (web.yn() == "0")
                {
                    if (xmlusername == "")
                    {
                        xmlusername = this.txtusername.Text;                }
                    else
                    {
                        this.lbname.Text = web.getName(xmlusername) + ",你好";
                        this.lbdis.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜," + web.assign(xmlusername) + "条转发处理";
                        this.panel1.Visible = false;
                        this.panel2.Visible = true;
                    }
                    popWin();
                    //============
                    this.timer1.Enabled = true;
                    this.timer1.Start();
                    //============
                }
                
            }              }
      

  3.   


    public partial class Form1 : Form
        {
            [DllImport("user32")]
            private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
            const int AW_HOR_POSITIVE = 0x0001;//从左到右打开窗口   
            const int AW_HOR_NEGATIVE = 0x0002;//从右到左打开窗口   
            const int AW_VER_POSITIVE = 0x0004;//从上到下打开窗口    
            const int AW_VER_NEGATIVE = 0x0008;//从下到上打开窗口   
            const int AW_CENTER = 0x0010;//看不出任何效果   
            const int AW_HIDE = 0x10000;//在窗体卸载时若想使用本函数就得加上此常量   
            const int AW_ACTIVATE = 0x20000;//在窗体通过本函数打开后,默认情况下会失去焦点,除非加上本常量    
            const int AW_SLIDE = 0x40000;//看不出任何效果    
            const int AW_BLEND = 0x80000;//淡入淡出效果            public Form1()
            {
                InitializeComponent();
            }
            string xmlusername = "";
            localhost.Service web = new localhost.Service();
            
            private void Form1_Load(object sender, EventArgs e)
            {
                //localhost.Service web = new localhost.Service();
                ////web.dbcon("czq");
                //=============窗体从右下角向上弹出窗口效果================            int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
                int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;
                this.Location = new Point(x, y);//设置窗体在屏幕右下角显示
                if (web.yn() == "0")
                {
                    AnimateWindow(this.Handle, 1, AW_VER_NEGATIVE | AW_SLIDE | AW_ACTIVATE);
                }
                //=========================            DataSet dsxml = new DataSet();
                dsxml.ReadXml(Directory.GetCurrentDirectory() + "\\config.xml");
                xmlusername= dsxml.Tables[0].Rows[0]["username"].ToString();
                string xmlpassword = dsxml.Tables[0].Rows[0]["department"].ToString();
                //this.txtusername.Text ="你有"+ web.dbcon(xmlusername)+"条待办事宜";//xmlusername
                if (xmlusername != "")
                {
                    this.lbdis.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜," + web.assign(xmlusername) + "条转发处理";
                    this.button1.Enabled = false;
                    this.lbname.Text = web.getName(xmlusername) + ",你好";
                    this.panel1.Visible = false;
                    this.panel2.Visible = true;
                }
                else
                {
                    this.panel2.Visible = false;
                    this.panel1.Visible = true;
                }           
            }        private void button1_Click(object sender, EventArgs e)
            {
                
                XmlDocument doc = new XmlDocument();
                doc.Load(Directory.GetCurrentDirectory()+"\\config.xml");
                XmlNode n = doc.SelectSingleNode("/login/username");
                n.InnerText =txtusername.Text;
                n = doc.SelectSingleNode("/login/department");
                //n.InnerText =txtpwd.Text;            doc.Save(Directory.GetCurrentDirectory() + "\\config.xml");
                //http://219.235.110.4:8077/
                //System.Diagnostics.Process.Start("http://219.235.110.4:8077/");        }        private void timer1_Tick(object sender, EventArgs e)
            {
                //localhost.Service web = new localhost.Service();
                //this.Close();
                this.timer1.Enabled = true;
                if (xmlusername == "")
                {
                    xmlusername = this.txtusername.Text;            }
                else
                {
                    this.lbdis.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜," + web.assign(xmlusername) + "条转发处理";
                }
                //this.txtusername.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜";//xmlusername
                //=============
                DataSet xmlname = new DataSet();
                xmlname.ReadXml(Directory.GetCurrentDirectory() + "\\config.xml");
                xmlusername = xmlname.Tables[0].Rows[0]["username"].ToString();
                //============
                if (xmlusername != "")
                {
                    //this.lbdis.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜";
                    this.button1.Enabled = false;
                }
                if(this.timer1.Interval==5000)
                {
                    this.Hide();
                    //================
                    this.timer1.Enabled = false;
                    this.timer2.Enabled = true;
                    this.timer2.Start();
                    //=================
                }
                
            }
            private void popWin()
            {
                if (this.timer2.Interval == 301000)//16000
                {
                    AnimateWindow(this.Handle, 1, AW_VER_NEGATIVE | AW_SLIDE | AW_ACTIVATE);
                }
            }        private void timer2_Tick(object sender, EventArgs e)
            {
                if (web.yn() == "0")
                {
                    if (xmlusername == "")
                    {
                        xmlusername = this.txtusername.Text;                }
                    else
                    {
                        this.lbname.Text = web.getName(xmlusername) + ",你好";
                        this.lbdis.Text = "你有" + web.dbcon(xmlusername) + "条待办事宜," + web.assign(xmlusername) + "条转发处理";
                        this.panel1.Visible = false;
                        this.panel2.Visible = true;
                    }
                    popWin();
                    //============
                    this.timer2.Enabled = false;
                    this.timer1.Enabled = true;
                    this.timer1.Start();
                    //============
                }
                
            }              }
      

  4.   

    很显然,楼上用来了两个timer这样是可以的,可否想想别的办法!
      

  5.   

                atim.Interval = 10;
                atim.Start();
                DateTime date = DateTime.Now;
                atim.Elapsed += (arg, e) =>
                    {
                        if (DateTime.Now.Minute >= date.AddMinutes(5).Minute)
                        {
                            
                            atim.Interval = 2500;
                            atim.Start();
                            date = DateTime.Now;                    }
                    };
      

  6.   

    放个线程,判断下,根据条件睡眠线程,比如sleep(300000)