Files
multiboxer/DD2Switcher/Form1.cs

60 lines
1.9 KiB
C#

using System;
using System.Windows.Forms;
namespace DD2Switcher {
public partial class Form1 : Form {
private SettingsForm settingsForm;
public Form1() {
InitializeComponent();
LoadIcons();
this.Load += Form1_Load;
}
private void Form1_Load(object sender, EventArgs e) {
// Hide the form initially since we're running in system tray
this.Hide();
}
private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e) {
ShowSettings();
}
private void settingsMenuItem_Click(object sender, EventArgs e) {
ShowSettings();
}
private void exitMenuItem_Click(object sender, EventArgs e) {
Application.Exit();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
// Prevent the form from closing, just hide it
if (e.CloseReason == CloseReason.UserClosing) {
e.Cancel = true;
this.Hide();
}
}
private void ShowSettings() {
if (settingsForm == null || settingsForm.IsDisposed) {
settingsForm = new SettingsForm();
}
settingsForm.Show();
settingsForm.BringToFront();
}
private void LoadIcons() {
try {
string iconPath = System.IO.Path.Combine(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
"app.ico");
this.Icon = new System.Drawing.Icon(iconPath);
this.notifyIcon.Icon = new System.Drawing.Icon(iconPath);
} catch {
// Use default icon if custom icon not found
}
}
}
}