当前位置:网站首页>Example of multipoint alarm clock
Example of multipoint alarm clock
2022-06-22 08:10:00 【shixch】

Save the alarm clock
private void button4_Click_1(object sender, EventArgs e) // Save alarm clock to text file
{
// take listView Save contents of as TXT Format
string[] arr = new string[lstList.Items.Count];
for (int i = 0; i < lstList.Items.Count; i++)
{
string s = "";
int len = lstList.Items[0].SubItems.Count;
for (int j = 1; j < len; j++)
{
// Use a comma as a delimiter If There are children that contain commas Something is going wrong
s += lstList.Items[i].SubItems[j].Text + ",";
}
if (s.EndsWith(","))
s = s.Substring(0, s.Length - 1);
arr[i] = s;
}
// Save to file
File.WriteAllLines(conf, arr);
}
Call in alarm clock
private void button5_Click(object sender, EventArgs e)
{
// Read data from text to listView among
string[] array = File.ReadAllLines(conf);
lstList.Items.Clear();
for (int i = 0; i < array.Length; i++)
{
if (array[i].Length > 0)// Do not add blank lines
{
ListViewItem listviewItem = new ListViewItem();
string s = array[i].ToString();
// There is no judgment on whether the format meets the requirements , If the content is changed to another format, an exception will occur
string[] arr = s.Split(',');
listviewItem.Text = (i + 1).ToString();
// listviewItem.Text = arr[0];
listviewItem.SubItems.Add(arr[0]);
listviewItem.SubItems.Add(arr[1]);
listviewItem.SubItems.Add(arr[2]);
lstList.Items.Add(listviewItem);
}
}
Add the time
private void Add_Click(object sender, EventArgs e)
{
if (txtMsg.Text.Trim().Replace(" ", "") == "")
{
MessageBox.Show(" Note cannot be null ");
return;
}
int i = lstList.Items.Count + 1;
ListViewItem listItem = lstList.Items.Add(i.ToString()); //((lstList.Items.Count + 1).ToString().Trim());
listItem.SubItems.Add(dtboxTime.Value.ToString("HH:mm:ss")); // listItem.SubItems.Add(dtboxTime.Value.ToString("HH:mm:ss"));
listItem.SubItems.Add(txtMsg.Text);
listItem.SubItems.Add("");
txtMsg.Text = "";
}
Delete selected time
private void button1_Click_1(object sender, EventArgs e)
{
for (int i = lstList.SelectedItems.Count - 1; i >= 0; i--)
{
ListViewItem item = lstList.SelectedItems[i];
lstList.Items.Remove(item);
}
}
Timing judgment
private void timer1_Tick(object sender, EventArgs e)
{
for (int i = 0; i < lstList.Items.Count; i++)
{
if (m_TodayDate.ToString("yyyyMMdd") != DateTime.Now.ToString("yyyyMMdd"))
{
for (int n = 0; n < lstList.Items.Count; n++)
{
lstList.Items[n].SubItems[3].Text = "";
}
m_TodayDate = DateTime.Now;
}
string timeString = lstList.Items[i].SubItems[1].Text;
timeString = DateTime.Now.ToString("yyyy/MM/dd") + " " + timeString;
if (DateTime.Parse(timeString) <= DateTime.Now)
{
if (lstList.Items[i].SubItems[3].Text != "Y")
{
lstList.Items[i].SubItems[3].Text = "Y";
ts = lstList.Items[i].SubItems[2].Text;
speak.Sp_T(ts);
}
}
}
Reading function
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Speech.Synthesis;
using System.Globalization;
namespace alarm clock
{
class Speedch_T
{
private SpeechSynthesizer speech = new SpeechSynthesizer();
public void Sp_T(string phrase)
{
#region Can only read numbers and English
//string text = textBox1.Text;
//if (text.Trim().Length != 0)
//{
// speech.Rate = 5;// The speed
// speech.SelectVoice("Microsoft Lili");// Set up announcer ( chinese )
// //speech.SelectVoice("Microsoft Anna"); // english
// speech.Volume = 100; // The volume
// speech.SpeakAsync(textBox1.Text);// Phonics reading methods
//}
#endregion
#region Can read Chinese
SpeechSynthesizer speech = new SpeechSynthesizer();
CultureInfo keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).FirstOrDefault();
if (neededVoice == null)
{
phrase = "Unsupported Language";
}
else if (!neededVoice.Enabled)
{
phrase = "Voice Disabled";
}
else
{
speech.SelectVoice(neededVoice.VoiceInfo.Name);
}
speech.Speak(phrase);
#endregion
}
}
}
Form code
private void Form1_Load(object sender, EventArgs e)
{
dtboxTime.Value = DateTime.Now;
timer1.Enabled = true;
m_TodayDate = DateTime.Now;
}
Class declaration
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Media;
using System.Text;
using System.Windows.Forms;
public System.Media.SoundPlayer music = new SoundPlayer(Directory.GetCurrentDirectory() + "\\ Jiang Zi teeth - alarm clock .wav");
DateTime m_TodayDate;
string conf = "test.txt";
Speedch_T speak = new Speedch_T();
string ts;```
边栏推荐
- 【Oracle 数据库】奶妈式教程 day13 日期函数
- 什么是分布式事务
- Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - identify the emergence of the new K line
- Invalid applet margin right, text overflow?
- Asynchronous sending and receiving of message passing based concurrent programming (MPI)
- Node red sends wechat official account message (template message)
- SVN 提交子文件夹问题
- Docker install redis
- 将数组中的数逆序存放
- (8) Sequence stack and chain stack
猜你喜欢

Easyui数据表实现增删改

MySQL 8.0 under Linux forgets the password

Use of keepalived high availability cluster
![[Oracle database] mammy tutorial day13 date function](/img/ca/90aaa682ec393b1531060377276ca6.png)
[Oracle database] mammy tutorial day13 date function

MySQL transactions

Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - common functions of MQL language

Maptalks: basic operation and wms/wmts map service loading

OSI and tcp/ip
![[songhongkang MySQL database] [advanced chapter] [07] MySQL storage engine](/img/47/62ad1e661e015438c40574f533d8f1.png)
[songhongkang MySQL database] [advanced chapter] [07] MySQL storage engine

QT QtableView的使用示例
随机推荐
The significance of code coverage testing to programming white and its application
Mt4/mql4 getting started to mastering EA tutorial lesson 8 - common functions of MQL language (VIII) - common time function
(8) Sequence stack and chain stack
模电实验——实验一 晶体管共射极单管放大器
Postgresql源码(56)可扩展类型分析ExpandedObject/ExpandedRecord
Summary of basic knowledge of Oracle database SQL statement III: data operation language (DQL)
QT 自定义组合控件(类提升功能)
(9) Sequential queue and stack queue
(9)顺序队列与栈队列
MySQL master-slave replication
Detailed explanation of subnet mask
JSON usage example
【宋红康 MySQL数据库 】【高级篇】【06】MySQL的逻辑架构
Node red sends wechat official account message (template message)
Master data management system
swagger中的枚举、自定义类型和swaggerignore
mysql截取字符串CS0000_1中_后面的字符
0基础自学stm32(野火)——什么是寄存器?
【Oracle 数据库】奶妈式教程day15 DDL、DML、索引、视图、序列、死锁这一篇就够了
Easyui数据表实现增删改