Created
September 19, 2011 13:14
-
-
Save clausjoergensen/1226468 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using System.Windows.Forms; | |
namespace WindowsFormsApplication | |
{ | |
public class MainForm : Form | |
{ | |
private IContainer components; | |
private NotifyIcon notifyIcon; | |
public MainForm() | |
{ | |
this.InitializeComponent(); | |
this.notifyIcon = new NotifyIcon(); | |
this.notifyIcon.Click += (s, e) => | |
{ | |
this.WindowState = FormWindowState.Normal; | |
this.notifyIcon.Visible = false; | |
}; | |
this.ShowInTaskbar = false; | |
this.ShowIcon = false; | |
this.Resize += (s, e) => | |
{ | |
if (this.WindowState == FormWindowState.Minimized) | |
{ | |
this.notifyIcon.Visible = true; | |
this.notifyIcon.Icon = Properties.Resources.MyNotifyIcon; | |
this.WindowState = FormWindowState.Minimized; | |
this.ShowInTaskbar = false; | |
} | |
}; | |
} | |
protected override void Dispose(bool disposing) | |
{ | |
if (disposing && (components != null)) | |
{ | |
this.components.Dispose(); | |
} | |
base.Dispose(disposing); | |
} | |
private void InitializeComponent() | |
{ | |
this.components = new Container(); | |
this.AutoScaleMode = AutoScaleMode.Font; | |
this.Text = ""; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment