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

📄 form1.cs

📁 软件功主要功能: 日程安排、事件提醒、以及其他用户自定义事件
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Media;
using System.IO;
using Microsoft.Win32 ;
using System.Runtime.InteropServices;


namespace 电子便条
{
    public partial class Form1 : Form
    {
        public Form1()
        {    
            InitializeComponent();    
        }
        public string inipath= Directory .GetCurrentDirectory()+"\\Config.ini";
        
        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section,string   key, string    val, string filePath);
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string  key, string   def, StringBuilder  retval, int size, string filePath);
        [DllImport("user32.dll")]
        public static extern bool ReleaseCapture();
        [DllImport("user32.dll")]
        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
        public const int WM_SYSCOMMAND = 0x0112;
        public const int SC_MOVE = 0xF010;
        public const int HTCAPTION = 0x0002;
        private void Form1_Load(object sender, EventArgs e)
        {
            this.ClientSize = new System.Drawing.Size(375, 310);
            this.FormBorderStyle = FormBorderStyle.None;  //none borderstyle
           StringBuilder  temp = new StringBuilder(2);
          GetPrivateProfileString("SET", "sjqd", "0",temp , 2, inipath);  //Read the sjqd checked state
          int x = int.Parse (temp.ToString ());
        if (x ==1)
        {
            rgqd.Checked = true;
        }
        else
        {
            rgqd.Checked = false;
        }
       GetPrivateProfileString("SET", "qdyc", "2", temp,2, inipath); //Read the qdyc checked state
       int y = int.Parse (temp.ToString ());
        if (y == 1)
        {
           
            qdyc.Checked = true;
            this.WindowState = FormWindowState.Minimized;
        }
        else
        {
            qdyc.Checked = false;
        }
            tp.SetToolTip(mtb1, "时间为必填项 格式如: 12:03:11");
            tp.SetToolTip(mtb2, "年 月可以不填写,格式如:  2007/03/09");
            tp.SetToolTip(xq, "单击下拉菜单, 星期可不填写");
            tp.SetToolTip(tb1, "在此 输入您要提醒的事件");
            tp.SetToolTip(button5, "将所有信息另存其他地方");
            tp.SetToolTip(Open, "打开您过去存到其他地方的信息");
            tp.SetToolTip(Save, "保存到软件默认的地方");
            tp.SetToolTip (button2 ,"删除指定的一条记录 注意删除前必须选定一条信息");
            tp.SetToolTip(button1, "添加信息到隔壁框框里");
            tp.SetToolTip(button3, "切换语言(中文/英文)");
            tp.SetToolTip(button4, "点了我你,就看不见我了 想找我到任务栏!");
            tp.SetToolTip(hScrollBar1 ,"点击鼠标滑动我 很炫哦");
            tp.SetToolTip(label9, "点击我 可以迅速将当前年月、星期自动填写");

            ListViewItem listviewitem;
            string nyr, xingqi, shijian, renwu;
            
            notifyIcon.Icon = new Icon("004.ico");
            notifyIcon.Visible = true ;
            string paths ;
            paths = Directory.GetCurrentDirectory()+"\\ Bak.txt";     
            FileStream sour=new FileStream (paths ,FileMode .OpenOrCreate  ,FileAccess .ReadWrite );
           StreamReader  Myfile= new StreamReader(sour ,Encoding .Default );
          string sline="";
          ArrayList alist = new ArrayList();
            // 窗体加载时 读取信息
          while (Myfile .Peek () != -1)
          {
              sline = Myfile.ReadLine();
              nyr = sline.Substring(0, 10);
              xingqi = sline.Substring(10, 3);
              shijian = sline.Substring(13, 8);
              renwu = sline.Substring(22, sline.Length - 22);
              listviewitem = new ListViewItem(nyr);
              listviewitem.SubItems.Add(xingqi);
              listviewitem.SubItems.Add(shijian);
              listviewitem.SubItems.Add(renwu);
              listView1.Items.Add(listviewitem);
              alist.Add(sline);
          }
            string[] arrtet=new string [alist .Count ];
            alist.CopyTo(arrtet, 0);
            listBox1 .Items .AddRange (arrtet );
            Myfile.Close();
        }
        private void ReadFile(string filepath)
        {
            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(filepath, System.Text.Encoding.Default);
                string sline = "";
                System.Collections.ArrayList arrtext = new System.Collections.ArrayList();
                while (sr.Peek() != -1)
                {
                    sline = sr.ReadLine();
                    arrtext.Add(sline);
                }
                string[] arrString = new string[arrtext.Count];
                arrtext.CopyTo(arrString, 0);
                listBox1.Items .AddRange( arrString );
                sr.Close();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Open the file is Error");
            }
        }
        private void SaveFile(string filepath)
        {
            try
            {
                System.IO.StreamWriter sw = new System.IO.StreamWriter(filepath, false, Encoding.Default);
                foreach (string oneline in listBox1 .Items )
                    sw.WriteLine(oneline);
                sw.Close();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Savefile is error");
            }
        }
        private void Shows(string x, string z)
        {
            
            Show show = new Show(x);
            if (z == "English")
                show.Text = "小秘书提醒您";
            else
                show.Text = "Notice";
            show.Show();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (xq.Text != "" && mtb2.Text != "    -  -")
                {
                    MessageBox.Show("日期和星期都有值 这样做没意义!");
                }
                else
                {
                    string strmp;
                    strmp = mtb1.Text;
                    if (strmp.Length != 8)
                    {
                        MessageBox.Show("时间必须填写完整 ", "错误的时间");
                        //set the new focus
                        mtb1.Focus();
                        mtb1.SelectionStart = 0;  // set the new start enter
                        mtb1.SelectionLength = 8; // set the new strings length
                        return;
                    }
                    int myhh = int.Parse(strmp.Substring(0, 2));
                    if (myhh >= 24 || myhh < 0)
                    {
                        MessageBox.Show("hour Fomat is error", "Error");
                        mtb1.Focus();
                        mtb1.SelectionStart = 0;
                        mtb1.SelectionLength = 8;
                        return;
                    }
                    int mymm = int.Parse(strmp.Substring(3, 2));
                    if (mymm >= 60 || mymm < 0)
                    {
                        MessageBox.Show("mistuen format is error", "Error");
                        mtb1.Focus();
                        mtb1.SelectionStart = 0;
                        mtb1.SelectionLength = 8;
                        return;
                    }
                    int myss = int.Parse(strmp.Substring(6, 2));
                    if (myss >= 60 || myss < 0)
                    {
                        MessageBox.Show("second format is error", "Error");
                        mtb1.Focus();
                        mtb1.SelectionStart = 0;
                        mtb1.SelectionLength = 8;
                        return;
                    }
                    string strzz;

                    if (xq.Text == "")
                    {
                        if (button3.Text == "English")
                            strzz = "当天里       " + strmp + "-" + tb1.Text;
                        else
                            strzz = "Today     " + strmp + "-" + tb1.Text;
                    }
                    else
                    {
                        strzz = xq.Text.PadRight(10, ' ') + strmp + "-" + tb1.Text;
                    }
                    if (mtb2.Text == "    -  -")
                    {
                        strzz = "          " + strzz;
                    }
                    else
                    {
                        strzz = mtb2.Text + strzz;
                    }
                    listBox1.Items.Add(strzz);
                    tb1.Text = "";
                    mtb1.Text = "";
                    xq.Text = "";
                    mtb1.Focus();
                    mtb2.Text = "";
                    ListViewItem listviewitem;
                    listviewitem = new ListViewItem(strzz.Substring(0, 10));
                    listviewitem.SubItems.Add(strzz.Substring(10, 10));//(10, 3));
                    listviewitem.SubItems.Add(strzz.Substring(20, 8));//(13, 8));
                    listviewitem.SubItems.Add(strzz.Substring(29, strzz.Length - 29));//(22, strzz.Length - 22));
                    listView1.Items.Add(listviewitem);
                }
            }
            catch (Exception)
            { MessageBox.Show("您确定你已填入正确信息 !"); }
        }
        private void button2_Click(object sender, EventArgs e)
        {

            if (listView1.Focus())
            {
                if (listView1.Items.Count > 0)
                {
                    int x = listView1.FocusedItem.Index;
                    listView1.FocusedItem.Remove();
                    listBox1.Items.RemoveAt(x);
                }
            }
            else if (listBox1.Focus())
            {
                if (listBox1.Items.Count > 0)
                {
                    // then the system will be delete it
                    if (listBox1.SelectedItems.Count > 0)
                    {
                        int x = listBox1.SelectedIndex;
                        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                        listView1.Items.RemoveAt(x);
                    }
                }
            }
            }
        
       
   
        private void timer1_Tick(object sender, EventArgs e)
        {
            times.Text = System.DateTime.Now.ToLongTimeString();
            if (button3.Text == "English")
                label9.Text = System.DateTime.Now.ToLongDateString();
            else
                label9.Text = System.DateTime.Now.ToShortDateString();
            string weeks;
            weeks = System.DateTime.Now.DayOfWeek.ToString();
            if (button3.Text == "English")
            {
                if (weeks == "Monday")
                {
                    label3.Text = "星期一";
                }
                if (weeks == "Tuesday")
                {
                    label3.Text = "星期二";
                }
                if (weeks == "Wednesday")
                {
                    label3.Text = "星期三";

⌨️ 快捷键说明

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