Ejemplo n.º 1
0
 public Window1(MainWindow mf, time timer, string mode)
 {
     nw          = 776;
     nh          = 212;
     this.mc     = mf;
     this.mtimer = timer;
     this.th     = this.mtimer.Height;
     this.tw     = this.mtimer.Width;
     InitializeComponent();
     this.slider1.Value = this.th / nh;
     if (mode == "gk")
     {
         this.radioButton1.IsChecked = true;
         this.radioButton2.IsChecked = false;
     }
     else
     {
         this.radioButton2.IsChecked = true;
         this.radioButton1.IsChecked = false;
     }
 }
Ejemplo n.º 2
0
        public MainWindow()
        {
            if (DateTime.Now.Month > 6)
            {
                gk_year = DateTime.Now.Year + 1;
            }
            else if (DateTime.Now.Month < 6)
            {
                gk_year = DateTime.Now.Year;
            }
            else if ((DateTime.Now.Month == 6) && (DateTime.Now.Day < 7))
            {
                gk_year = DateTime.Now.Year;
            }
            else
            {
                gk_year = DateTime.Now.Year + 1;
            }

            if (DateTime.Now.Month > 6)
            {
                zk_year = DateTime.Now.Year + 1;
            }
            else if (DateTime.Now.Month < 6)
            {
                zk_year = DateTime.Now.Year;
            }
            else if ((DateTime.Now.Month == 6) && (DateTime.Now.Day < 15))
            {
                zk_year = DateTime.Now.Year;
            }
            else
            {
                zk_year = DateTime.Now.Year + 1;
            }



            path            = System.Windows.Forms.Application.StartupPath + "\\settings.ini";
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
            if (!File.Exists(path))
            {
                File.Create(path).Close();
                winapi.WritePrivateProfileString("size", "sizerate", "1.0", path);
                winapi.WritePrivateProfileString("timer", "timershow", "1", path);
                winapi.WritePrivateProfileString("timer", "mode", "gk", path);
            }


            //设置计时模式
            StringBuilder mode = new StringBuilder(500);

            winapi.GetPrivateProfileString("timer", "mode", "", mode, 500, System.Windows.Forms.Application.StartupPath + "\\settings.ini");
            if (mode.ToString() == "gk")
            {
                this.countmode = "gk";
            }
            else
            {
                this.countmode = "zk";
            }

            InitializeComponent();

            //设定位置
            int swidth, sheight;

            swidth    = (int)SystemParameters.PrimaryScreenWidth;
            sheight   = (int)SystemParameters.PrimaryScreenHeight;
            this.Left = swidth - 240;
            this.Top  = 10;

            this.menu1       = new ContextMenuStrip(this.components);
            this.退出toolmenu  = new ToolStripMenuItem();
            this.关于toolmenu  = new ToolStripMenuItem();
            this.sizemenu    = new ToolStripMenuItem();
            this.showmenu    = new ToolStripMenuItem();
            this.notifyicon1 = new NotifyIcon(this.components);

            //toolmenuitem
            this.关于toolmenu.Text   = "关于";
            this.关于toolmenu.Name   = "关于toolmenu";
            this.关于toolmenu.Click += new EventHandler(this.关于_Click);
            this.退出toolmenu.Text   = "退出";
            this.退出toolmenu.Name   = "退出toolmenu";
            this.退出toolmenu.Click += new EventHandler(this.退出_Click);
            this.sizemenu.Text     = "设置";
            this.sizemenu.Name     = "sizemenu";
            this.sizemenu.Click   += new EventHandler(this.size);
            this.showmenu.Text     = "关闭倒计时";
            this.showmenu.Name     = "showmenu";
            this.showmenu.Click   += new EventHandler(this.showclick);

            //menu1
            this.menu1.Items.AddRange(new ToolStripItem[] {
                this.showmenu,
                this.sizemenu,
                this.关于toolmenu,
                this.退出toolmenu
            });
            this.menu1.Name = "menu1";

            this.notifyicon1.Icon             = Properties.Resources.ico;
            this.notifyicon1.Text             = "倒计时~姬~";
            this.notifyicon1.ContextMenuStrip = this.menu1;
            this.notifyicon1.Visible          = true;


            //设置数字
            gk_exam   = new DateTime(gk_year, 6, 7, 0, 0, 0);
            zk_exam   = new DateTime(zk_year, 6, 15, 0, 0, 0);
            n_date    = DateTime.Today;
            gk_c_date = gk_exam - n_date;
            zk_c_date = zk_exam - n_date;
            if (countmode == "gk")
            {
                numlabel.Content   = gk_c_date.Days.ToString();
                titlelabel.Content = "距离高考还有";
            }
            else
            {
                numlabel.Content   = zk_c_date.Days.ToString();
                titlelabel.Content = "距离中考还有";
            }


            timewindow = new time(this, gk_year, zk_year, countmode);
            timewindow.Show();
        }