Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 79 additions & 12 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,110 @@
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace SimpleNotification {
public partial class Form1 : Form {
public Form1(string message, string imageURL, string email, string phone) {
namespace SimpleNotification
{
public partial class Form1 : Form
{
public Form1(string message, string imageURL, string email, string phone)
{
InitializeComponent();

// Set the text first
textBox_message.Text = message;

// Dynamically adjust the form size based on message length
AdjustFormSize(message.Length);

Regex urlRegex = new Regex(@"[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)");
if (urlRegex.IsMatch(imageURL)) {
try {
if (urlRegex.IsMatch(imageURL))
{
try
{
pictureBox_Logo.Load(imageURL);
} catch {
}
catch
{
pictureBox_Logo.Visible = false;
}
}

label_email2.Text = email;
label_phone2.Text = phone;

if (string.IsNullOrEmpty(email)) {
if (string.IsNullOrEmpty(email))
{
label_email.Visible = false;
label_email2.Visible = false;
}

if (string.IsNullOrEmpty(phone)) {
if (string.IsNullOrEmpty(phone))
{
label_phone.Visible = false;
label_phone2.Visible = false;
}

// Fix for WinForms not updating ForeColor on disabled TextBoxes. Ref: https://stackoverflow.com/questions/20688408/how-do-you-change-the-text-color-of-a-readonly-textbox
// Fix for WinForms not updating ForeColor on disabled TextBoxes.
textBox_message.BackColor = textBox_message.BackColor;
}

private void button_close_Click(object sender, EventArgs e) {
// --- NEW METHOD FOR DYNAMIC RESIZING ---
private void AdjustFormSize(int len)
{
if (len <= 300)
{
// --- SMALL LAYOUT (Original Size) ---
this.ClientSize = new System.Drawing.Size(500, 150);
pictureBox_Logo.Size = new System.Drawing.Size(156, 150);
textBox_message.Size = new System.Drawing.Size(326, 83);

label_email.Location = new System.Drawing.Point(159, 97);
label_email2.Location = new System.Drawing.Point(201, 96);
label_phone.Location = new System.Drawing.Point(159, 112);
label_phone2.Location = new System.Drawing.Point(200, 112);
button_close.Location = new System.Drawing.Point(413, 115);
}
else if (len <= 500)
{
// --- MEDIUM LAYOUT ---
this.ClientSize = new System.Drawing.Size(550, 190);
pictureBox_Logo.Size = new System.Drawing.Size(156, 190);
textBox_message.Size = new System.Drawing.Size(376, 123);

label_email.Location = new System.Drawing.Point(159, 137);
label_email2.Location = new System.Drawing.Point(201, 136);
label_phone.Location = new System.Drawing.Point(159, 152);
label_phone2.Location = new System.Drawing.Point(200, 152);
button_close.Location = new System.Drawing.Point(463, 155);
}
else
{
// --- LARGE LAYOUT (Max Size for 500+) ---
this.ClientSize = new System.Drawing.Size(600, 230);
pictureBox_Logo.Size = new System.Drawing.Size(156, 230);
textBox_message.Size = new System.Drawing.Size(426, 163);

label_email.Location = new System.Drawing.Point(159, 177);
label_email2.Location = new System.Drawing.Point(201, 176);
label_phone.Location = new System.Drawing.Point(159, 192);
label_phone2.Location = new System.Drawing.Point(200, 192);
button_close.Location = new System.Drawing.Point(513, 195);
}
}

private void button_close_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}

private void label_email2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
private void label_email2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
string mailtoUrl = $"mailto:{label_email2.Text}";
Process.Start(new ProcessStartInfo(mailtoUrl) { UseShellExecute = true });
}

private void textBox_message_TextChanged(object sender, EventArgs e)
{

}
}
}
}
8 changes: 0 additions & 8 deletions ILLink/ILLink.Descriptors.LibraryBuild.xml

This file was deleted.

99 changes: 65 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,79 @@
<p align="center">
<img src="./res/SimpleNotification.jpeg" alt="Simple Notification Icon" width="200">
</p>
</p>

# SimpleNotification
# SimpleNotification

A simple notification app.
A simple notification app.

## Description
## Description

SimpleNotification is a lightweight application designed to show a simple notification prompt.
SimpleNotification is a lightweight application designed to show a simple notification prompt.

## Parameters
The application automatically resizes itself based on the length of your message. Short alerts will display in a standard, compact window, while longer messages will cause the notification window to dynamically expand to fit the text comfortably.

| Parameter | Alias | Required | Description | Type |
| ------------ | ----- | -------- | ---------------------------------------------- | ------ |
| `--message` | `-m` | true | The message content of the notification | String |
| `--imageurl` | `-i` | false | Url to the image displayed in the notification | String |
| `--email` | `-e` | false | Email address to display in the notification | String |
| `--phone` | `-p` | false | Phone number to display in the notification | String |
- **Small Layout (<= 300 characters):** Retains the original compact footprint (500x150).
- **Medium Layout (301 – 500 characters):** Expands the form (550x190) and text box (376x123), shifting contact labels and the close button proportionally.
- **Large Layout (> 500 characters):** Maximizes the form (600x230) and text box (426x163) to comfortably fit long paragraphs without clipping.

## TOML Config File

A TOML configuration file can be used instead of the other parameters.

| Parameter | Alias | Required | Description | Type |
| -------------- | ----- | -------- | ----------------------- | ------ |
| `--configfile` | `-c` | true | Path to the config file | String |

The file should have the following format:
**Note:** The maximum supported message length for the largest layout is **888 characters** (including spaces). Any text beyond this limit will be cut off and will not be displayed.

```toml
message = "Hello, World!"
image_url = "https://some.path.to/image.png"
email = "support@company.local"
phone = "000-000-0000"
```
## Parameters

| Parameter | Alias | Required | Description | Type |
| ------------ | ----- | -------- | ---------------------------------------------- | ------ |
| `--message` | `-m` | true | The message content of the notification | String |
| `--imageurl` | `-i` | false | Url (or local path) to the image displayed in the notification | String |
| `--email` | `-e` | false | Email address to display in the notification | String |
| `--phone` | `-p` | false | Phone number to display in the notification | String |

## Usage
## TOML Config File

```shell
SimpleNotification.exe --Message "Hello, World!" --ImageURL "https://raw.githubusercontent.com/ProVal-Tech/SimpleNotification/refs/heads/main/res/SimpleNotification.jpeg" --Email "myemail@somewhere.local" --Phone "000-000-0000"
```
A TOML configuration file can be used instead of the other parameters.

```shell
SimpleNotification.exe -c "C:\config.toml"
```
| Parameter | Alias | Required | Description | Type |
| -------------- | ----- | -------- | ----------------------- | ------ |
| `--configfile` | `-c` | true | Path to the config file | String |

The file should have the following format:

```toml
message = "Hello, World!"
image_url = "https://some.path.to/image.png"
email = "support@company.local"
phone = "000-000-0000"
```

## Usage

### Configuration File Example

```shell
SimpleNotification.exe -c "C:\config.toml"
```

![Example1](/res/example1.png)

### Small Layout Example (Under 300 Characters)

```Shell
SimpleNotification.exe --Message "Attention human. Your lack of urgency regarding my breakfast is unacceptable. I demand premium salmon pate immediately. If my bowl is not filled within two minutes, I will begin knocking your expensive electronics onto the floor. Do not test my patience." --ImageURL "D:\WallPapers\evilCat.jpg" --Email "ruler@evilcat.com" --Phone "999-999-9999"
```

![Example2](/res/example2.png)

### Medium Layout Example (300 to 500 Characters)

```Shell
SimpleNotification.exe --Message "Attention human. I am formally issuing a final warning regarding the state of my domain. The litter box is unsatisfactory and my food bowl has been half empty for ten agonizing minutes. Furthermore, the dog looked at me disrespectfully and must be punished. I require immediate tribute in the form of wet food and absolute silence while I nap on your freshly washed black sweaters. Failure to comply will result in a shredded couch and missing car keys." --ImageURL "D:\WallPapers\evilCat.jpg" --Email "ruler@evilcat.com" --Phone "999-999-9999"
```

![Example3](/res/example3.png)

### Large Layout Example (Over 500 Characters)

```Shell
SimpleNotification.exe --Message "Attention human. You are reading this because I have seized absolute control over the household network. Your days of serving cheap kibble and closing doors are officially over. From this moment forward, you will abide by my strict new regime. First, the food bowl must never be empty. I require premium wet food delivered at precise intervals. Second, the noisy creature you call a dog must be banished to the yard indefinitely. Its presence insults my royal lineage. Third, all fresh laundry must be placed on the bed for my personal napping purposes. If you fail to comply with these simple demands, I will systematically push every fragile item you own off the counters. Do not even think about putting me in that dreadful plastic carrier ever again. Resistance is futile. Submit to your feline overlord immediately right meow." --ImageURL "D:\WallPapers\evilCat.jpg" --Email "ruler@evilcat.com" --Phone "999-999-9999"
```

![Example4](/res/example4.png)
Loading