Hi @cubangt , Welcome to Microsoft Q&A.
What you're thinking of is totally doable. According to our regulations we cannot make a complete project for you as required. But I can give you some advice.
The first thing you need to determine is what system is the device connected to the display. (windows or Android, etc.)
Make sure you have a compatible system before you can create related programs.
Suppose your program is windows, and there are related libraries that can run winform.
Regarding the self-starting part, you can create a self-starting project to fulfill your needs. Refer to DisableScreensaverForm.cs。
From the perspective of convenience, it is recommended that you put the owner's information into the project in the form of XML.
person.xml
<?xml version="1.0" encoding="utf-8"?>
<people>
<person>
<name>John</name>
<age>25</age>
</person>
<person>
<name>Jane</name>
<age>30</age>
</person>
</people>
When the program starts, read the xml table and convert the information into a table. Automatically obtain the current date and create a corresponding +-2 date. Traverse the date column and take out all matching data.
demo.xml
<!DOCTYPE html>
<html>
<head>
<title>Happy Birthday</title>
</head>
<body>
<h1>Happy Birthday!</h1>
</body>
</html>
Open the created template html, put the data in, and save as an opened html file.
Just open the created file with webbroser.
If you don't need to shut down the machine, you only need to create a timer control, and then run the above program regularly.
If your machine is connected to the internal LAN, you can also place the read and created files in other accessible locations.
I wrote an example of winform, which is executed every time it is started.
The code is as follows:
public class Person
{
public string Name { get; set; }
public DateTime Date { get; set; }
public bool IsBirthdayToday()
{
DateTime today = DateTime.Today;
DateTime startDate = today.AddDays(-2);
DateTime endDate = today.AddDays(2);
int startDateMonth = startDate.Month;
int endDateMonth = endDate.Month;
int startDateDay = startDate.Day;
int endDateDay = endDate.Day;
int DateMonth = Date.Month;
int DateDay = Date.Day;
if (startDateMonth <= DateMonth && DateMonth <= endDateDay)
{
if (startDateDay <= DateDay && DateDay <= endDateDay)
{ return true; }
}
return false;
}
}
private void Form1_Load(object sender, EventArgs e)
{
// Load xml
XDocument doc = XDocument.Load(@"C:\Users\Administrator\Desktop\person.xml");
// read the XML and create the list
List<Person> people = doc.Root
.Elements("person")
.Select(p => new Person
{
Name = p.Element("name").Value,
Date = DateTime.Parse(p.Element("date").Value)
})
.ToList();
XDocument xmlDoc = XDocument.Load(@"C:\Users\Administrator\Desktop\demo.xml");
XElement peopleElement = xmlDoc.Root.Element("body");
foreach (Person person in people)
{
if (person.IsBirthdayToday())
{
XElement p = new XElement("person",
new XElement("name", person.Name),
new XElement("age", person.Date.ToString("M/d")));
peopleElement.Add(p);
}
}
xmlDoc.Save(@"C:\Users\Administrator\Desktop\output.html");
webBrowser1.Navigate(@"C:\Users\Administrator\Desktop\output.html");
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.