프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Service.StationController / App.xaml.cs @ a537d79a

이력 | 보기 | 이력해설 | 다운로드 (2.2 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Configuration;
5
using System.Data;
6
using System.Linq;
7
using System.Threading.Tasks;
8
using System.Windows;
9

    
10
namespace Markus.Service.StationController
11
{
12
    /// <summary>
13
    /// App.xaml에 대한 상호 작용 논리
14
    /// </summary>
15
    public partial class App : Application
16
    {
17
        private System.Windows.Forms.NotifyIcon _notifyIcon;
18
        private bool _isExit;
19

    
20
        protected override void OnStartup(StartupEventArgs e)
21
        {
22
            base.OnStartup(e);
23
            MainWindow = new MainWindow();
24
            //MainWindow.Closing += MainWindow_Closing;
25

    
26
            //_notifyIcon = new System.Windows.Forms.NotifyIcon();
27
            //_notifyIcon.DoubleClick += (s, args) => ShowMainWindow();
28
            //_notifyIcon.Icon = Markus.Service.StationController.Properties.Resources.TRANSFER_ERROR;
29
            //_notifyIcon.Visible = true;
30

    
31
            //CreateContextMenu();
32
        }
33

    
34
        private void CreateContextMenu()
35
        {
36
            _notifyIcon.ContextMenuStrip =
37
              new System.Windows.Forms.ContextMenuStrip();
38
            _notifyIcon.ContextMenuStrip.Items.Add("MainWindow...").Click += (s, e) => ShowMainWindow();
39
            _notifyIcon.ContextMenuStrip.Items.Add("Exit").Click += (s, e) => ExitApplication();
40
        }
41

    
42
        private void ExitApplication()
43
        {
44
            _isExit = true;
45
            MainWindow.Close();
46
            _notifyIcon.Dispose();
47
            _notifyIcon = null;
48
        }
49

    
50
        private void ShowMainWindow()
51
        {
52
            if (MainWindow.IsVisible)
53
            {
54
                if (MainWindow.WindowState == WindowState.Minimized)
55
                {
56
                    MainWindow.WindowState = WindowState.Normal;
57
                }
58
                MainWindow.Activate();
59
            }
60
            else
61
            {
62
                MainWindow.Show();
63
            }
64
        }
65

    
66
        private void MainWindow_Closing(object sender, CancelEventArgs e)
67
        {
68
            if (!_isExit)
69
            {
70
                e.Cancel = true;
71
                MainWindow.Hide(); // A hidden window can be shown again, a closed one not
72
            }
73
        }
74

    
75
    }
76
}
클립보드 이미지 추가 (최대 크기: 500 MB)