Notifying a message in Action center.
Revisão | e78b9b67ff561b8c9ac2697813317f2e5bfd119f (tree) |
---|---|
Hora | 2015-09-16 15:21:48 |
Autor | JeffyTS <JeffyTS@outl...> |
Commiter | JeffyTS |
Fixed bug.
@@ -46,7 +46,6 @@ | ||
46 | 46 | this.ClientSize = new System.Drawing.Size(284, 261); |
47 | 47 | this.Name = "MainForm"; |
48 | 48 | this.Text = "NotifyMessage"; |
49 | - this.Load += new System.EventHandler(this.MainForm_Load); | |
50 | 49 | this.ResumeLayout(false); |
51 | 50 | |
52 | 51 | } |
@@ -7,6 +7,8 @@ using System.Linq; | ||
7 | 7 | using System.Text; |
8 | 8 | using System.Threading.Tasks; |
9 | 9 | using System.Windows.Forms; |
10 | +using System.Reflection; // Add | |
11 | + | |
10 | 12 | |
11 | 13 | namespace NotifyMessage |
12 | 14 | { |
@@ -22,21 +24,29 @@ namespace NotifyMessage | ||
22 | 24 | "\r\n" + |
23 | 25 | " Option:\r\n" + |
24 | 26 | " /INFO(default) | /WARN | /ERR"; |
27 | + private const string MSG_ABOUT = "Thanks to Microsoft Corporation.\r\n" + | |
28 | + "\r\n" + | |
29 | + "This program has been developed on\r\n" + | |
30 | + " Visual Studio Community 2015\r\n" + | |
31 | + " Windows10 Professional 64bit.\r\n" + | |
32 | + "\r\n" + | |
33 | + MSG_USAGE; | |
25 | 34 | |
26 | 35 | public MainForm() |
27 | 36 | { |
28 | 37 | // Messageはここで出さないと終了処理がうまくいかない(プロセスが残る) |
29 | - if (Program.NotifyMessage == "") | |
38 | + if (Program.Message == "") | |
30 | 39 | { |
31 | - MessageBox.Show(MSG_USAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | |
32 | - Program.NotifyMessage = ""; // 消してしまう(flag代わり) | |
40 | + //MessageBox.Show(MSG_USAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | |
41 | + AboutDialog(); | |
42 | + Program.Message = ""; // 消してしまう(flag代わり) | |
33 | 43 | } |
34 | - else if (Program.NotifyMessage != "") // vmxFilePathが指定されていないときは初期化せず終了 | |
44 | + else if (Program.Message != "") // vmxFilePathが指定されていないときは初期化せず終了 | |
35 | 45 | { |
36 | 46 | InitializeComponent(); |
37 | 47 | |
38 | - this.notifyIcon_MainForm.Text = PROGRAM_NAME;// Program.NotifyMessage; | |
39 | - this.notifyIcon_MainForm.BalloonTipText = Program.NotifyMessage; | |
48 | + this.notifyIcon_MainForm.Text = PROGRAM_NAME; // Program.NotifyMessage; | |
49 | + this.notifyIcon_MainForm.BalloonTipText = Program.Message; | |
40 | 50 | this.notifyIcon_MainForm.Icon = Properties.Resources.NotifyMessageTray; |
41 | 51 | |
42 | 52 | switch (Program.msglevel) |
@@ -54,20 +64,53 @@ namespace NotifyMessage | ||
54 | 64 | this.notifyIcon_MainForm.BalloonTipIcon = ToolTipIcon.None; |
55 | 65 | break; |
56 | 66 | } |
57 | - this.notifyIcon_MainForm.ShowBalloonTip(500); | |
58 | 67 | |
59 | - //System.Threading.Thread.Sleep(10000); | |
68 | + this.notifyIcon_MainForm.ShowBalloonTip(5000); // Balloon tip 表示 | |
69 | + | |
70 | + System.Threading.Thread.Sleep(5000); | |
60 | 71 | |
61 | 72 | // Exit |
62 | 73 | this.notifyIcon_MainForm.Visible = false; // タスクトレイからアイコンを取り除く |
63 | 74 | Application.Exit(); // アプリケーション終了 |
64 | - | |
65 | 75 | } |
66 | 76 | } |
67 | 77 | |
68 | - private void MainForm_Load(object sender, EventArgs e) | |
78 | + private void AboutDialog() | |
69 | 79 | { |
80 | + string message; | |
81 | + | |
82 | + //AssemblyTitleの取得 | |
83 | + AssemblyTitleAttribute asmTitle = (AssemblyTitleAttribute)Attribute.GetCustomAttribute( | |
84 | + Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)); | |
85 | + //AssemblyDescriptionの取得 | |
86 | + AssemblyDescriptionAttribute asmDesc = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute( | |
87 | + Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)); | |
88 | + //AssemblyCompanyの取得 | |
89 | + AssemblyCompanyAttribute asmCompany = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute( | |
90 | + Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute)); | |
91 | + //AssemblyProductの取得 | |
92 | + AssemblyProductAttribute asmPrdct = (AssemblyProductAttribute)Attribute.GetCustomAttribute( | |
93 | + Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute)); | |
94 | + //AssemblyCopyrightの取得 | |
95 | + AssemblyCopyrightAttribute asmCpyrght = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute( | |
96 | + Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)); | |
97 | + //AssemblyTrademarkの取得 | |
98 | + AssemblyTrademarkAttribute asmTM = (AssemblyTrademarkAttribute)Attribute.GetCustomAttribute( | |
99 | + Assembly.GetExecutingAssembly(), typeof(AssemblyTrademarkAttribute)); | |
100 | + //バージョンの取得 | |
101 | + Assembly asm = Assembly.GetExecutingAssembly(); | |
102 | + Version ver = asm.GetName().Version; | |
70 | 103 | |
104 | + message = asmTitle.Title + "\r\n" + | |
105 | + "\r\n" + | |
106 | + asmDesc.Description + "\r\n" + | |
107 | + "\r\n" + | |
108 | + MSG_ABOUT + "\r\n" + | |
109 | + "\r\n" + | |
110 | + asmCompany.Company + "\r\n" + | |
111 | + asmPrdct.Product + " Rev. " + ver + "\r\n" + | |
112 | + asmCpyrght.Copyright + "\r\n"; | |
113 | + MessageBox.Show(message, PROGRAM_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information); | |
71 | 114 | } |
72 | 115 | } |
73 | 116 | } |
@@ -4,12 +4,13 @@ using System.Linq; | ||
4 | 4 | using System.Threading.Tasks; |
5 | 5 | using System.Windows.Forms; |
6 | 6 | |
7 | + | |
7 | 8 | namespace NotifyMessage |
8 | 9 | { |
9 | 10 | static class Program |
10 | 11 | { |
11 | 12 | // グローバル変数 |
12 | - public static string NotifyMessage = ""; | |
13 | + public static string Message = ""; | |
13 | 14 | public enum MSGLEVEL : int // MessageLevel |
14 | 15 | { |
15 | 16 | INFO = 1, |
@@ -35,16 +36,15 @@ namespace NotifyMessage | ||
35 | 36 | if (0 <= cmds[i].IndexOf("/ERR", StringComparison.OrdinalIgnoreCase)) msglevel = MSGLEVEL.ERR; |
36 | 37 | else if (0 <= cmds[i].IndexOf("/WARN", StringComparison.OrdinalIgnoreCase)) msglevel = MSGLEVEL.WARN; |
37 | 38 | else if (0 <= cmds[i].IndexOf("/INFO", StringComparison.OrdinalIgnoreCase)) msglevel = MSGLEVEL.INFO; |
38 | - else NotifyMessage = cmds[i]; | |
39 | + else Message = cmds[i]; | |
39 | 40 | } |
40 | 41 | |
41 | 42 | new MainForm(); |
42 | 43 | |
43 | - if (NotifyMessage != "") | |
44 | + if (Message != "") | |
44 | 45 | { |
45 | 46 | //Application.Run(); |
46 | 47 | } |
47 | - | |
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -6,11 +6,11 @@ using System.Runtime.InteropServices; | ||
6 | 6 | // アセンブリに関連付けられている情報を変更するには、 |
7 | 7 | // これらの属性値を変更してください。 |
8 | 8 | [assembly: AssemblyTitle("NotifyMessage")] |
9 | -[assembly: AssemblyDescription("")] | |
9 | +[assembly: AssemblyDescription("Notifiying a message in Action center.")] | |
10 | 10 | [assembly: AssemblyConfiguration("")] |
11 | 11 | [assembly: AssemblyCompany("")] |
12 | 12 | [assembly: AssemblyProduct("NotifyMessage")] |
13 | -[assembly: AssemblyCopyright("Copyright © 2015")] | |
13 | +[assembly: AssemblyCopyright("Copyright © 2015 T.S. All rights reserved")] | |
14 | 14 | [assembly: AssemblyTrademark("")] |
15 | 15 | [assembly: AssemblyCulture("")] |
16 | 16 |
@@ -1,6 +1,6 @@ | ||
1 | 1 | NotifyMessage |
2 | 2 | |
3 | - Notifiying a message in Action center. | |
3 | + Notifying a message in Action center. | |
4 | 4 | |
5 | 5 | Copyright © 2015 T.S. All rights reserved. |
6 | 6 |