
Setup
트레이 아이콘을 추가하기 위해서는, 프로젝트에 참조 추가를 해야함
솔루션 탐색기에서 참조를 추가할수 있으며, "System.Windows.Forms" 을 추가하면 됨


- 만약 "System.Windows.Forms" 참조를 추가한 후 MessageBox를 사용할려면, "System.Windows.MessageBox"와 "System.Windows.Forms.MessageBox" 사이 참조가 애매하다는 에러가 뜸.
MessageBox를 사용할려면, 이 코드를 추가해야 함
cs 
Usage
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | namespace WPF {     public partial class MainWindow : Window     {         NotifyIcon ni = new NotifyIcon();         public MainWindow()         {             InitializeComponent();             System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu();    // Menu 객체             System.Windows.Forms.MenuItem item1 = new System.Windows.Forms.MenuItem();    // Menu 객체에 들어갈 각각의 menu             item1.Index = 0;             item1.Text = "Menu01";    // menu 이름             item1.Click += delegate (object click, EventArgs eClick)    // menu 의 클릭 이벤트 등록             {                 Method1();             }             System.Windows.Forms.MenuItem item2 = new System.Windows.Forms.MenuItem();    // menu 객체에 들어갈 각 menu             item2.Index = 1;             item2.Text = "Menu02";    // menu 이름             item2.Click += delegate (object click, EventArgs eClick)    // menu의 클릭 이벤트 등록             {                 Method2();             }                         menu.MenuItems.Add(item1);    // Menu 객체에 각각의 menu 등록             menu.MenuItems.Add(item2);    // Menu 객체에 각각의 menu 등록             ni.Icon = new System.Drawing.Icon(new Uri("path"));    // 아이콘 등록 1번째 방법             ni.Icon = Properties.Resources.SampleIcon;    // 아이콘 등록 2번째 방법             ni.Visible = true;             ni.DoubleClick += delegate (object senders, EventArgs args)    // Tray icon의 더블 클릭 이벤트 등록             {                 DoubleMethod();             }             ni.ContextMenu = menu;    // Menu 객체 등록             ni.Text = "WPF";    // Tray icon 이름         }     } } | cs | 
- NotifyIcon: Tray Icon 객체
- Icon: Tray Icon의 아이콘 파일
- Visible: Tray Icon 노출 여부 (True: 노출 허용 / False: 노출 불허)
- ContextMenu: Menu 객체
- Text: Tray Icon 이름
- DoubleClick: 더블 클릭 이벤트
- System.Windows.Forms.ContextMenu: Menu 객체
- menuItems.Add( ): Menu 객체에 각각의 menu 등록
- System.Windows.Forms.MenuItem: Menu 객체의 각각의 menu
- Index: menu 인덱스 ( 0 이 최상단)
- Text: menu 이름
- Click: 클릭 이벤트
'Csharp' 카테고리의 다른 글
| C# - 외부 프로그램과 링크 실행, 종료 (0) | 2019.07.22 | 
|---|---|
| WPF - 다른 파일에서 Window.xaml.cs 코드 접근 (0) | 2019.07.22 | 
| WPF - Image 가장자리 부드럽게 하기 (Antialiasing / 안티에일리어싱) (0) | 2019.07.14 | 
| WPF - Image 컴포넌트에 Uri 경로 설정 (0) | 2019.07.14 | 
| C# - 파일 읽기와 쓰기 ( 저장 ) (0) | 2019.07.07 | 
