⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maa.cs

📁 c#精彩编程百例(源代码)
💻 CS
字号:
// 程序:maa.cs
using System;
using System.IO;
using System.Threading;
using System.WinForms;
using System.Data;
using System.Text;
public class maa
{
private static Thread secThread=new Thread(new ThreadStart(checkTime));
[sysimport(dll="winmm.dll")]
public static extern long PlaySound(String lpszName, long hModule, long dwFlags);
public static void checkTime()
{
  string [,]ss=new string[4,20];
  try
     {
      StreamReader sr=new StreamReader(new FileStream("storetime.txt",FileMode.Open,FileAccess.Read));
      int c=0;
      while(c<4)
      {
       ss[c,c]=sr.ReadLine();
       c++;
      }
     } catch(Exception e){Console.WriteLine(e);}
     int temp=0;
     for(;;)
     {
       Thread.Sleep(1000);
       if(formatDate().Equals((ss[1,1]+":00"))||formatDate().Equals((ss[1,1]+":05"))||formatDate().Equals((ss[1,1]+":10")))
       {
        PlaySound("notify.wav" ,0 ,0); 
        MessageBox.Show(ss[0,0]+"\n"+DateTime.Now.ToLongTimeString()+"\n"+"this is the time to your Breakfast","Dear..",MessageBox.OK|MessageBox.IconQuestion);
       }
       if(formatDate().Equals((ss[2,2]+":00"))||formatDate().Equals((ss[2,2]+":05"))||formatDate().Equals((ss[2,2]+":10")))
       {
        PlaySound("notify.wav" ,0 ,0); 
        MessageBox.Show(ss[0,0]+"\n"+DateTime.Now.ToLongTimeString()+"\n"+"this is the time to your Lunch","Dear..",MessageBox.OK|MessageBox.IconQuestion);
       }
       if(formatDate().Equals((ss[3,3]+":00"))||formatDate().Equals((ss[3,3]+":05"))||formatDate().Equals((ss[3,3]+":10")))
       {
        PlaySound("notify.wav" ,0 ,0); 
        MessageBox.Show(ss[0,0]+"\n"+DateTime.Now.ToLongTimeString()+"\n"+"this is the time to your Dinner","Dear..",MessageBox.OK|MessageBox.IconQuestion);
        temp++;
       }
       if(temp==11)
       {
        secThread.Abort();
        Application.Exit();
       }
      }
  }
public static String formatDate()
 {
   int m=DateTime.Now.Minute;
   int ss=DateTime.Now.Second;
   String s=DateTime.Now.Hour.ToString();
   if(m<10)
   s+=":0"+m+":"+ (ss<10 ? "0"+ss.ToString() : ss.ToString());
   else
   s+=":"+m+":"+ (ss<10 ? "0"+ss.ToString() : ss.ToString());
   return s;
 }
public static void Main(String[] a)
{
 try
   {
    secThread.Start();
   }catch (Exception e)
   {Console.WriteLine( e.ToString());}        
 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -