Exemplo n.º 1
0
 private void button4_Click(object sender, EventArgs e)                                         //恢复配置文件
 {
     writer = new StreamWriter(INI.Root + @"\Backup\Configuration.ini", false, Encoding.ASCII); //配置文件用UTF-8编码(默认编码)会无法识别。
     writer.Write(Configuration.Replace("\n", Environment.NewLine));
     writer.Close();
     MyDialog.Msg("配置文件已恢复!", 1);
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            MyError.NewRecord();

            if (textBox1.Text == "")
            {
                MyError.Set(textBox1, "!!!");
            }
            else
            {
                MyError.Clear(textBox1);
            }

            if (textBox2.Text == "")
            {
                MyError.Set(textBox2, "!!!");
            }
            else
            {
                MyError.Clear(textBox2);
            }

            if (MyError.CheckAll())
            {
                MyDialog.Msg("");
            }
        }
Exemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)//分组管理
 {
     if (Text.Contains("未知"))
     {
         MyDialog.Msg("请使用已知地点。", 2); return;
     }
     new Groups().ShowDialog();
     ReloadData();
 }
Exemplo n.º 4
0
 private void button3_Click(object sender, EventArgs e)//标签管理
 {
     if (LBGroups.Items.Count == 0)
     {
         MyDialog.Msg("请新建标签分组。", 2); return;
     }
     new LabelsUpdate(LBGroups.SelectedValue).ShowDialog();
     ReloadData();
 }
Exemplo n.º 5
0
 private void button4_Click(object sender, EventArgs e)//使用选中地点
 {
     if (LB.SelectedValue == null)
     {
         MyDialog.Msg("没有选中地点。", 2); return;
     }
     INI.SetLocationID(LB.SelectedValue);
     MyDialog.Msg("设置完成!", 1);
     this.Text = "当前地点:" + ((DataRowView)LB.SelectedItem)["LocationName"];
 }
Exemplo n.º 6
0
 private void button3_Click(object sender, EventArgs e) //下一页
 {
     if (++GVA.NowPage > GVA.TotalPages)                //超过最大页码
     {
         GVA.NowPage--;
         MyDialog.Msg("已在最后一页。", 2);
         return;
     }
     GVA.ShowData(true);
     numericUpDown1.Value = (decimal)GVA.NowPage;
 }
Exemplo n.º 7
0
 private void button2_Click(object sender, EventArgs e) //上一页
 {
     if (--GVA.NowPage < 1)                             //小于最小页码
     {
         GVA.NowPage++;
         MyDialog.Msg("已在第一页。", 2);
         return;
     }
     GVA.ShowData(true);
     numericUpDown1.Value = (decimal)GVA.NowPage;
 }
Exemplo n.º 8
0
 private void button9_Click(object sender, EventArgs e) //下一页
 {
     if (++GV.NowPage > GV.TotalPages)                  //超过最大页码
     {
         GV.NowPage--;
         MyDialog.Msg("已在最后一页。", 2);
         return;
     }
     GV.ShowData();
     SetNumericValue(GV.NowPage);
 }
Exemplo n.º 9
0
 static void Method1()
 {
     for (int i = 0; i < 5000; i++)
     {
         if (i == 1000)
         {
             MyDialog.Msg("已到1000");           //运行到这里,线程会停止并等待对话框结束
         }
         Console.WriteLine("Method 1 : " + i);
     }
 }
Exemplo n.º 10
0
 private void button8_Click(object sender, EventArgs e) //上一页
 {
     if (--GV.NowPage < 1)                              //小于最小页码
     {
         GV.NowPage++;
         MyDialog.Msg("已在第一页。", 2);
         return;
     }
     GV.ShowData();
     SetNumericValue(GV.NowPage);
 }
Exemplo n.º 11
0
 private void button1_Click(object sender, EventArgs e)//使用选中的数据库
 {
     if (listBox1.SelectedItems.Count == 0)
     {
         MyDialog.Msg("没有选中数据库。", 2); return;
     }
     temp = listBox1.SelectedItem.ToString();
     temp = temp.Substring(0, temp.IndexOf('.'));
     INI.SetDBName(temp);
     MyDialog.Msg("设置完成!即将重新登录。", 1);
     CentralForm.Logout();
 }
Exemplo n.º 12
0
 void DoSend()
 {
     cmd = textBox1.Text;
     if (cmd.Contains("ping") && cmd.Contains("-t"))
     {
         MyDialog.Msg("请去掉 -t 再执行 ping 命令。", 2); return;
     }
     Abort(true);
     thread = new Thread(new ParameterizedThreadStart(SendCmd));
     thread.Start(cmd);
     richTextBox1.Focus();
 }
Exemplo n.º 13
0
        static void T2()
        {
            /*/
             * Method2("Sophie");//一般执行
             * MyDialog.Msg("完成");
             * /*/
            Thread thread2 = new Thread(new ParameterizedThreadStart(Method2)); //定义线程(有参数)

            thread2.Start("Sophie");                                            //线程执行(有参数)
            MyDialog.Msg("完成");
            thread2.Abort();
            //*/
        }
Exemplo n.º 14
0
 private void button4_Click(object sender, EventArgs e)//删除
 {
     if (LB.SelectedValue == null)
     {
         MyDialog.Msg("没有选中记录。", 2); return;
     }
     if (MyDialog.Ask("确定要删除这条记录?"))
     {
         table.Rows.Find(LB.SelectedValue).Delete();
         LB.Update();
         ToAdd();
     }
 }
Exemplo n.º 15
0
        static void T1()
        {
            /*/
             * Method1();//一般执行
             * MyDialog.Msg("完成");
             * /*/
            Thread thread1 = new Thread(new ThreadStart(Method1)); //定义线程的方法

            thread1.Start();                                       //线程执行
            MyDialog.Msg("完成");
            thread1.Abort();                                       //只有开始过的线程才能终止,即便已经运行结束
            thread1.Abort();                                       //可再次终止,不会报错
            //*/
        }
Exemplo n.º 16
0
 private void button3_Click(object sender, EventArgs e)//删除日记本
 {
     if (LB.SelectedValue == null)
     {
         MyDialog.Msg("没有选中日记本。", 2); return;
     }
     if (MyDialog.Ask("操作将删除此日记本的所有内容,确定执行?"))
     {
         M.DeleteRecordsByGroupID(SelectedGroupID);
         table.Rows.Find(SelectedGroupID).Delete();
         LB.Update();
         ToAdd();
     }
 }
Exemplo n.º 17
0
        private void applyModePattern()//根据选项改变菜单项颜色
        {
            switch (currentMode)
            {
            case 1:
                mode1ToolStripMenuItem.BackColor = Color.LightGray;
                mode2ToolStripMenuItem.BackColor = Color.White;
                mode3ToolStripMenuItem.BackColor = Color.White;
                mode4ToolStripMenuItem.BackColor = Color.White;
                mode5ToolStripMenuItem.BackColor = Color.White;
                break;

            case 2:
                mode2ToolStripMenuItem.BackColor = Color.LightGray;
                mode1ToolStripMenuItem.BackColor = Color.White;
                mode3ToolStripMenuItem.BackColor = Color.White;
                mode4ToolStripMenuItem.BackColor = Color.White;
                mode5ToolStripMenuItem.BackColor = Color.White;
                break;

            case 3:
                mode3ToolStripMenuItem.BackColor = Color.LightGray;
                mode1ToolStripMenuItem.BackColor = Color.White;
                mode2ToolStripMenuItem.BackColor = Color.White;
                mode4ToolStripMenuItem.BackColor = Color.White;
                mode5ToolStripMenuItem.BackColor = Color.White;
                break;

            case 4:
                mode4ToolStripMenuItem.BackColor = Color.LightGray;
                mode1ToolStripMenuItem.BackColor = Color.White;
                mode2ToolStripMenuItem.BackColor = Color.White;
                mode3ToolStripMenuItem.BackColor = Color.White;
                mode5ToolStripMenuItem.BackColor = Color.White;
                break;

            case 5:
                mode5ToolStripMenuItem.BackColor = Color.LightGray;
                mode1ToolStripMenuItem.BackColor = Color.White;
                mode2ToolStripMenuItem.BackColor = Color.White;
                mode3ToolStripMenuItem.BackColor = Color.White;
                mode4ToolStripMenuItem.BackColor = Color.White;
                break;

            default:
                MyDialog.Msg("读取配置失败。\n模式代码:" + currentMode + "。\n请检查配置文件是否存在于程序根目录,\n或当中是否缺少相应的键或值。", 3);
                Environment.Exit(0);
                break;
            }
        }
Exemplo n.º 18
0
 private void button3_Click(object sender, EventArgs e)//删除选中分组
 {
     if (LB.SelectedValue == null)
     {
         MyDialog.Msg("没有选中分组。", 2); return;
     }
     if (MyDialog.Ask("操作将删除此分组下的所有标签,确定执行?"))
     {
         M.DeleteLabelsByGroupID(SelectedGroupID);
         table.Rows.Find(SelectedGroupID).Delete();
         LB.Update();
         ToAdd();
     }
 }
Exemplo n.º 19
0
 private void button3_Click(object sender, EventArgs e)//删除选中地点
 {
     if (LB.SelectedValue == null)
     {
         MyDialog.Msg("没有选中地点。", 2); return;
     }
     if (MyDialog.Ask("操作将删除此地点下的所有标签,确定执行?"))
     {
         M.DeleteAllByLocationID(SelectedLocationID);
         table.Rows.Find(SelectedLocationID).Delete();
         LB.Update();
         ToAdd();
     }
 }
Exemplo n.º 20
0
 private void button2_Click(object sender, EventArgs e)//删除标签
 {
     if (LV.CountSelectedRows == 0)
     {
         MyDialog.Msg("没有选中标签。", 2); return;
     }
     if (MyDialog.Ask("确定要删除选中的 " + LV.GetSelectedValues().Length + " 个标签?"))
     {
         foreach (string each in LV.SelectedValues)
         {
             table.Rows.Find(each).Delete();
         }
         LV.Update();
         ShowData();
     }
 }
Exemplo n.º 21
0
        static void T4()
        {
            Thread thread4 = new Thread((object obj) => //定义线程,匿名线程方法(有参数)
            {
                for (int i = 0; i < 50000; i++)
                {
                    Console.WriteLine("Method 4 : {0} - {1}", obj, i);
                }
            });

            thread4.Start("Sienna");
            MyDialog.Msg("完成");
            if (thread4.IsAlive)
            {
                thread4.Abort();
            }
        }
Exemplo n.º 22
0
 private void button2_Click(object sender, EventArgs e)//删除日记
 {
     if (GV.CountSelectedRows == 0)
     {
         MyDialog.Msg("没有选中日记。", 2); return;
     }
     if (MyDialog.Ask("你确定要删除选中的 " +
                      GV.GetSelectedValues().Length + " 篇日记?"))
     {
         foreach (string each in GV.SelectedValues)
         {
             table.Rows.Find(each).Delete();
         }
         GV.Update();
         GV.NowPage = 1;//防止总页码减少后当前页码大于总页码造成异常
         ShowData();
         SetNumericValue(1);
     }
 }
Exemplo n.º 23
0
        static void T3()
        {
            Thread thread3 = new Thread(() => //定义线程,匿名线程方法
            {
                int i = 0;
                while (true)
                {
                    Console.WriteLine("Method 3 : " + i++);
                    Thread.Sleep(100);//增加延时
                    if (i == 50000)
                    {
                        break;
                    }
                }
            });

            thread3.Start();
            MyDialog.Msg("完成");
            thread3.Abort();
        }
Exemplo n.º 24
0
 private void button1_Click(object sender, EventArgs e)//确认修改密码
 {
     temp = Global.con.ConnectionString;
     //data source=G:\NAMEIT2.mdb;provider=Microsoft.Jet.OLEDB.4.0;mode=12;Jet OleDb:DataBase Password=123
     OldPWD = temp.Substring(temp.IndexOf("Password") + "Password".Length + 1);//包括“=”占用的
     NewPWD = textBox2.Text;
     if (textBox1.Text == OldPWD)
     {
         M.AlterDBPWD(OldPWD == "" ? "null" : OldPWD, NewPWD == "" ? "null" : NewPWD);//是空密码则切换为null
     }
     else
     {
         MyDialog.Msg("验证失败。", 3);
         textBox1.Text = "";
         textBox1.Focus();
         return;
     }
     MyDialog.Msg("密码已更新!即将重新登录。", 1);
     CentralForm.Logout();
 }
Exemplo n.º 25
0
        private void button4_Click(object sender, EventArgs e)//导出日记
        {
            if (LB.SelectedValue == null)
            {
                MyDialog.Msg("没有选中日记本。", 2); return;
            }
            string    GroupName = M.GetDiaryGroupNameByID(SelectedGroupID);
            DataTable table0    = M.GetRecordsByGroupID(SelectedGroupID);
            string    Path      = INI.Root + @"\Records\" + GroupName + ".txt";

            if (File.Exists(Path))
            {
                MyDialog.Msg("Records目录下存在同名文件。", 2); return;
            }
            foreach (DataRow row in table0.Rows)
            {
                MyTextFile.Append(Path, "【" + ((DateTime)row["DateOfRecord"]).ToShortDateString() + "】\n" + row["Content"]);
            }
            MyDialog.Msg("已导出到Records目录。", 1);
        }
Exemplo n.º 26
0
        private void button4_Click(object sender, EventArgs e)//导出
        {
            if (LB.SelectedValue == null)
            {
                MyDialog.Msg("没有选中笔记本。", 2); return;
            }
            string    GroupName = M.GetNoteGroupNameByID(SelectedGroupID);
            DataTable table0    = M.GetNotesByGroupID(SelectedGroupID);
            string    DirPath   = INI.Root + @"\Records\" + GroupName;

            if (Directory.Exists(DirPath))
            {
                MyDialog.Msg("Records目录下存在同名目录。", 2); return;
            }
            Directory.CreateDirectory(DirPath);
            foreach (DataRow row in table0.Rows)
            {
                MyTextFile.Create(DirPath + "\\" + row["Title"] + ".txt", row["Content"].ToString());
            }
            MyDialog.Msg("已导出到Records目录。", 1);
        }
Exemplo n.º 27
0
 private void button2_Click(object sender, EventArgs e)//确认新建数据库
 {
     DBName = textBox3.Text.Trim();
     if (DBName == "")
     {
         MyDialog.Msg("请输入数据库名。", 2);
         textBox3.Focus();
         return;
     }
     foreach (FileInfo file in new DirectoryInfo(INI.Root).GetFiles())
     {
         if (file.Name.ToLower() == DBName.ToLower() + ".mdb")
         {
             MyDialog.Msg("根目录存在同名数据库。", 2);
             textBox3.Focus();
             return;
         }
     }
     File.Copy(INI.Root + @"\Backup\New.mdb", INI.Root + @"\" + DBName + ".mdb");
     MyModel.GetNewInstance(MyDB.GetAccessConnection(INI.Root + @"\" + DBName + ".mdb")).CreateTables();
     MyDialog.Msg("创建完成!", 1);
     textBox3.Clear();
     textBox3.Focus();
 }
Exemplo n.º 28
0
 private void 当前日记总数ToolStripMenuItem_Click(object sender, EventArgs e)//计算总数
 {
     MyDialog.Msg("这本日记共有 " + GV.DataAmount + " 篇记录。", 1);
 }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            string NewDirPath    = INI.Root + @"\WinHelper";
            string BackupPath    = INI.Root + @"\Backup";
            string NewBackupPath = NewDirPath + @"\Backup";

            if (Directory.Exists(NewDirPath))
            {
                MyDialog.Msg("根目录下已存在 WinHelper 文件夹。打包已终止。", 2); return;
            }
            Directory.CreateDirectory(NewDirPath);
            Directory.CreateDirectory(NewBackupPath);
            //============================================
            foreach (FileInfo file in new DirectoryInfo(INI.Root).GetFiles())
            {
                if (file.Name == "Hive.exe" ||                  //主程序
                    file.Name == "Notebook.exe" ||              //笔记本
                    file.Name == "Diary.exe" ||                 //日记本
                    file.Name == "ElectronicWatch.exe" ||       //电子表
                    file.Name == "TouchTypist.exe" ||           //盲打机
                    file.Name == "Reader.exe" ||                //阅读器
                    file.Name == "Labels.exe" ||                //标签簿
                    file.Name == "Anniversaries.exe" ||         //纪念簿
                    file.Name == "FastCmd.exe" ||               //快速命令

                    file.Name == "MyFrame.dll" ||               //我的框架
                    file.Name == "NAMEIT.mdb" ||                //新数据库
                    file.Name.StartsWith("v"))                  //版本文本
                {
                    file.CopyTo(NewDirPath + @"\" + file.Name); //复制到新的目录
                }
            }
            foreach (FileInfo file in new DirectoryInfo(BackupPath).GetFiles())
            {
                if (file.Name == "Commands.txt" ||      //命令簿
                    file.Name == "New.mdb" ||
                    file.Name == "Configuration.ini" || //配置文件
                    file.Name == "Manual.txt")
                {
                    file.CopyTo(NewBackupPath + @"\" + file.Name);//复制到新的Backup目录
                }
            }
            //======================================
            foreach (FileInfo file in new DirectoryInfo(INI.Root).GetFiles())//打包完成后,尽量清除垃圾
            {
                if (!file.Name.StartsWith("v") &&
                    file.Name != "NAMEIT.mdb" &&
                    file.Name != "Pack.exe" &&
                    file.Name != "Pack.pdb" &&
                    file.Name != "Pack.vshost.exe" &&
                    file.Name != "MyFrame.dll" &&
                    file.Name != "Hive.vshost.exe" &&
                    file.Name != "MyFrame.pdb")
                {
                    try
                    {
                        file.Delete();
                    }
                    catch (Exception ex)
                    {
                        MyTextFile.DoDefaultRecord(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 30
0
 private void 帮助HToolStripMenuItem_Click(object sender, EventArgs e)
 {
     MyDialog.Msg("每种模式的字体样式会自动保存。\n模式名称可以在配置文件中修改。\n将文本文档拖到窗体顶部可载入。", 1);
 }