パブリック イベント| 名前 | 説明 | |
|---|---|---|
| BalloonChanged | メッセージ バルーンを表示または非表示にしたときに発生します。 |
| Disposed | コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。 ( Component から継承されます。) |
| ResponseSubmitted | ユーザーがメッセージ バルーンのボタンまたはリンクをクリックしたときに発生します。 |
参照
構文
解説このクラスは、Windows CE の通知機能のマネージ実装を提供します。このクラスは、Pocket PC でのみサポートされています。
通知を作成したら、Visible プロパティを使用して、必要に応じて表示できます。InitialDuration プロパティは、メッセージ バルーンを最初に表示する時期を設定します。InitialDuration に 0 を設定し、Visible に true を設定した場合、メッセージ バルーンは表示されませんが、タイトル バーにアイコンが表示されます。このアイコンをクリックすると、メッセージ バルーンが再びアクティブになります。BalloonChanged イベントは、Visible プロパティでの設定やユーザーとの対話によって、バルーンが表示または非表示にされるたびに発生します。
メッセージ バルーンには、プレーンテキストだけでなく、HTML コンテンツを含むユーザー通知を作成できます。HTML は、Pocket PC の HTML コントロールによって表示されます。また、Response プロパティを使用して、ResponseSubmittedEventArgs クラスによって提供される応答文字列を解析することによって、HTML フォーム内の値に応答できます。
cmd:2 識別子
使用例通知を表示し、メッセージ バルーン内の HTML 要素を使用してユーザー入力を収集する方法を、次のコード例に示します。この例では、ボタンを使用して通知を表示していますが、通常、通知はイベントまたは処理 (タイマなど) の結果として表示されます。
この例のシナリオは、デバイスにデータをダウンロードすることを確認する通知です。メッセージ バルーンには、次の要素が含まれます。
Imports System Imports System.Windows.Forms Imports System.Drawing Imports Microsoft.WindowsCE.Forms Imports System.Reflection Imports System.Text Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form Private WithEvents Button1 As System.Windows.Forms.Button Private StatusBar1 As System.Windows.Forms.StatusBar Private WithEvents Notification1 As Microsoft.WindowsCE.Forms.Notification Public Sub New() InitializeComponent() ConfigNotification() StatusBar1.Text = "" ' Display the OK button for closing the application. Me.MinimizeBox = False End Sub Protected Overrides Sub Dispose(disposing As Boolean) MyBase.Dispose(disposing) End Sub Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.StatusBar1 = New System.Windows.Forms.StatusBar() Me.SuspendLayout() ' ' Button1 ' Me.Button1.Location = New System.Drawing.Point(6, 134) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 20 Me.Button1.Text = "Notify" ' ' StatusBar1 ' Me.StatusBar1.Location = New System.Drawing.Point(0, 246) Me.StatusBar1.Name = "StatusBar1" Me.StatusBar1.Size = New System.Drawing.Size(240, 22) Me.StatusBar1.Text = "" ' ' Form1 ' Me.ClientSize = New System.Drawing.Size(240, 268) Me.Controls.Add(StatusBar1) Me.Controls.Add(Button1) Me.Name = "Form1" Me.Text = "Notify Demo" Me.ResumeLayout(False) End Sub Shared Sub Main() Application.Run(New Form1()) End Sub Private Sub ConfigNotification() ' Create a Notification. Notification1 = New Microsoft.WindowsCE.Forms.Notification() Try 'Provide an icon for the notification to appear in the title bar when dismissed. 'Assumes an icon file is compiled with the assembly as an embedded resource. Dim asm As [Assembly] = [Assembly].GetExecutingAssembly() Notification1.Icon = New Icon(asm.GetManifestResourceStream("notify.ico"), 16, 16) Notification1.Caption = "Notification scenario - data download" ' If notification is urgent, set to true. Notification1.Critical = False ' Create the text for the notification. ' Use a StringBuilder for better performance. Dim HTMLString As New StringBuilder() HTMLString.Append("<html><body>") HTMLString.Append("<font color=""#0000FF""><b>Data ready to download</b></font>") HTMLString.Append(" <a href=""settings"">Settings</a>") HTMLString.Append("<br><form method=""GET"" action=notify>") HTMLString.Append("<SELECT NAME=""lstbx"">") HTMLString.Append("<OPTION VALUE=""0"">Start now</OPTION><OPTION VALUE=""1"">In 1 hr</OPTION>") HTMLString.Append("<OPTION VALUE=""2"">In 2 hrs</OPTION><OPTION VALUE=""3"">In 3 hrs</OPTION>") HTMLString.Append("<OPTION VALUE=""4"">In 4 hrs</OPTION></SELECT>") HTMLString.Append("<input type=checkbox name=chkbx>Notify completion") HTMLString.Append("<br><input type='submit'>") HTMLString.Append("<input type=button name='cmd:2' value='Postpone'>") HTMLString.Append("</body></html>") ' Set the Text property to the HTML string. Notification1.Text = HTMLString.ToString() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub ' Clicking the button creates a notification ' that initally displays for 20 seconds. Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click Notification1.InitialDuration = 20 Notification1.Visible = True StatusBar1.Text = "" End Sub ' You can use the BalloonChanged event ' created by tracking each time the notification is made visible. Private Sub OnBalloonChanged(obj As Object, _ balevent As BalloonChangedEventArgs) Handles Notification1.BalloonChanged If balevent.Visible = True Then ' You can add code here to add ' functionality such as user interface ' changes that should occur when ' the notification is displayed. End If End Sub ' When a ResponseSubmitted event occurs, this event handler ' parses the response to determine values in the HTML form. Private Sub OnResponseSubmitted(obj As Object, _ resevent As ResponseSubmittedEventArgs) Handles Notification1.ResponseSubmitted ' Use a StringBuilder to create a log of the response. Dim LogResponse As New StringBuilder() ' If the response contains the name specified for the action value ' of the HTML form, in this case "notify," get the value of the ' selected option from the SELECT list. An example of the ' response string would be notify?lstbx=0. If resevent.Response.Substring(0, 6) = "notify" Then Dim choice As Integer = Convert.ToInt32(resevent.Response.Substring(13, 1)) Select Case choice Case 0 LogResponse.Equals("submit") Case 1 LogResponse.Equals("opt 1") Case 2 LogResponse.Equals("opt 2") Case 3 LogResponse.Equals("opt 3") Case 4 LogResponse.Equals("opt 4") End Select ' If the checkbox in the form is checked, the response ' string could be as follows: notify?lstbx=0chkbx=on ' You can determine whether the check box is selected ' by checking whether the response ends with "on". If resevent.Response.EndsWith("on") Then LogResponse.Equals("checkbox") End If ' If the user clicked the settings link, ' log the response. This example could display ' a dialog box by activating another form. ElseIf resevent.Response = "settings" Then ' Display a settings dialog by activating ' a form named 'Settings': ' Settings.Activate LogResponse.Equals("Postponed by clicking link") ' The user needs to respond to the notification ' after checking the settings, so set the ' InitialDuration and Visible properties so ' that the icon appears in the title bar. Notification1.InitialDuration = 0 Notification1.Visible = True End If ' Display the response on the status bar. StatusBar1.Text = LogResponse.ToString() + " HTML: " + resevent.Response.ToString() End Sub End Class
using System; using System.Windows.Forms; using System.Drawing; using Microsoft.WindowsCE.Forms; using System.Reflection; using System.Text; using System.IO; namespace notificationtest { public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private System.Windows.Forms.StatusBar statusBar1; private Microsoft.WindowsCE.Forms.Notification notification1; public Form1() { InitializeComponent(); ConfigNotification(); statusBar1.Text = ""; // Display the OK button for closing the application. this.MinimizeBox = false; } protected override void Dispose(bool disposing) { base.Dispose(disposing); } private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.statusBar1 = new System.Windows.Forms.StatusBar(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(6, 134); this.button1.Name = "button1"; this.button1.TabIndex = 20; this.button1.Text = "Notify"; this.button1.Click += new System.EventHandler(this.button1_Click); // // statusBar1 // this.statusBar1.Location = new System.Drawing.Point(0, 246); this.statusBar1.Name = "statusBar1"; this.statusBar1.Size = new System.Drawing.Size(240, 22); this.statusBar1.Text = ""; // // Form1 // this.ClientSize = new System.Drawing.Size(240, 268); this.Controls.Add(this.statusBar1); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Notify Demo"; this.ResumeLayout(false); } static void Main() { Application.Run(new Form1()); } private void ConfigNotification() { // Create a Notification. notification1 = new Microsoft.WindowsCE.Forms.Notification(); try { // Provide an icon for the notification to appear in the title bar when dismissed. // Assumes an icon file is compiled with the assembly as an embedded resource. Assembly asm = Assembly.GetExecutingAssembly(); notification1.Icon = new Icon(asm.GetManifestResourceStream("notify.ico") ,16,16); notification1.Caption = "Notification scenario - data download"; // If notification is urgent, set to true. notification1.Critical = false; // Create the text for the notification. // Use a StringBuilder for better performance. StringBuilder HTMLString = new StringBuilder(); HTMLString.Append("<html><body>"); HTMLString.Append("<font color=\"#0000FF\"><b>Data ready to download</b></font>"); HTMLString.Append(" <a href=\"settings\">Settings</a>"); HTMLString.Append("<br><form method=\"GET\" action=notify>"); HTMLString.Append("<SELECT NAME=\"lstbx\">"); HTMLString.Append("<OPTION VALUE=\"0\">Start now</OPTION><OPTION VALUE=\"1\">In 1 hr</OPTION>"); HTMLString.Append("<OPTION VALUE=\"2\">In 2 hrs</OPTION><OPTION VALUE=\"3\">In 3 hrs</OPTION>"); HTMLString.Append("<OPTION VALUE=\"4\">In 4 hrs</OPTION></SELECT>"); HTMLString.Append("<input type=checkbox name=chkbx>Notify completion"); HTMLString.Append("<br><input type='submit'>"); HTMLString.Append("<input type=button name='cmd:2' value='Postpone'>"); HTMLString.Append("</body></html>"); // Set the Text property to the HTML string. notification1.Text = HTMLString.ToString(); // Add event handlers. notification1.BalloonChanged += new BalloonChangedEventHandler(OnBalloonChanged); notification1.ResponseSubmitted += new ResponseSubmittedEventHandler(OnResponseSubmitted); } catch (Exception ex) { MessageBox.Show(ex.Message); } } // Clicking the button creates a notification // that initally displays for 20 seconds. // A button is used here for demonstration purposes only; // normally, a notification is sent in response to another event. private void button1_Click(object sender, System.EventArgs e) { notification1.InitialDuration = 20; notification1.Visible = true; statusBar1.Text = ""; } // You can use the BalloonChanged event // created by tracking each time the notification is made visible. private void OnBalloonChanged(object obj, BalloonChangedEventArgs balevent) { if (balevent.Visible == true) { // You can add code here to add // functionality such as user interface // changes that should occur when // the notification is displayed. } } // When a ResponseSubmitted event occurs, this event handler // parses the response to determine values in the HTML form. private void OnResponseSubmitted(object obj, ResponseSubmittedEventArgs resevent) { // Use a StringBuilder to create a log of the response. StringBuilder LogResponse = new StringBuilder(); // If the response contains the name specified for the action value // of the HTML form, in this case "notify," get the value of the // selected option from the SELECT list. An example of the // response string would be notify?lstbx=0. if (resevent.Response.Substring(0, 6) == "notify") { int choice = Convert.ToInt32(resevent.Response.Substring(13, 1)); switch (choice) { case 0: LogResponse.Equals("submit"); break; case 1: LogResponse.Equals("opt 1"); break; case 2: LogResponse.Equals("opt 2"); break; case 3: LogResponse.Equals("opt 3"); break; case 4: LogResponse.Equals("opt 4"); break; } // If the checkbox in the form is checked, the response // string could be as follows: notify?lstbx=0chkbx=on // You can determine whether the check box is selected // by checking whether the response ends with "on". if (resevent.Response.EndsWith("on")) LogResponse.Equals("checkbox"); } // If the user clicked the settings link, // log the response. This example could display // a dialog box by activating another form. else if (resevent.Response == "settings") { // Display a settings dialog by activating // a form named 'Settings': // Settings.Activate LogResponse.Equals("Postponed by clicking link"); // The user needs to respond to the notification // after checking the settings, so set the // InitialDuration and Visible properties so // that the icon appears in the title bar. notification1.InitialDuration = 0; notification1.Visible = true; } // Display the response on the status bar. statusBar1.Text = LogResponse.ToString() + " HTML: " + resevent.Response.ToString(); } } }
継承階層
スレッド セーフ
プラットフォーム
バージョン情報
参照
構文
解説このクラスは、Smartphone または Pocket PC 以外の Windows CE デバイスではサポートされていません。
使用例Notification クラスのインスタンスを作成し、Text プロパティで設定したメッセージ バルーンに使用する HTML を定義し、さらに ResponseSubmitted イベントと BalloonChanged イベントのイベント ハンドラを設定するコード例を次に示します。このコード例は、Notification クラスのトピックで取り上げているコード例の一部分です。
.NET Framework のセキュリティ
プラットフォーム
バージョン情報
参照
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| Site | Component の ISite を取得または設定します。 ( Component から継承されます。) |
| Visible | メッセージ バルーンを表示するかどうかを示す値を取得または設定します。 |
プロテクト プロパティ
参照
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Dispose | オーバーロードされます。 Notification によって使用されているリソースを解放します。 |
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
| ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Dispose | オーバーロードされます。 オーバーライドされます。 Notification によって使用されているリソースを解放します。 |
| Finalize | Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 ( Component から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
| OnBalloonChanged | BalloonChanged イベントを発生させます。 |
| OnResponseSubmitted | ResponseSubmitted イベントを発生させます。 |
参照ユーザー通知を表示したり、通知に応答したりするための Windows CE の機能を実装します。
Notification データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| Site | Component の ISite を取得または設定します。(Component から継承されます。) |
| Visible | メッセージ バルーンを表示するかどうかを示す値を取得または設定します。 |
プロテクト プロパティ
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Dispose | オーバーロードされます。 Notification によって使用されているリソースを解放します。 |
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
| ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Dispose | オーバーロードされます。 オーバーライドされます。 Notification によって使用されているリソースを解放します。 |
| Finalize | Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 (Component から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
| OnBalloonChanged | BalloonChanged イベントを発生させます。 |
| OnResponseSubmitted | ResponseSubmitted イベントを発生させます。 |
パブリック イベント| 名前 | 説明 | |
|---|---|---|
| BalloonChanged | メッセージ バルーンを表示または非表示にしたときに発生します。 |
| Disposed | コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。(Component から継承されます。) |
| ResponseSubmitted | ユーザーがメッセージ バルーンのボタンまたはリンクをクリックしたときに発生します。 |
参照(Notification から転送)
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2023/12/17 09:22 UTC 版)
通知(つうち)とは、相手に対してものごとを知らせること。行政や司法においてこの言葉が用いられる場合、一般には相手方に意思または事実を知らせる行為、行政庁がある事項を特定または不特定多数に知らせる行為で、準法律行為である[1]。
ナンバーディスプレイ契約を行っている固定電話や携帯電話のディスプレイに、発信元の電話番号を表示させる機能のことを指す。なお、発信者側の設定によって非通知にすることが可能である。
コンピュータにおける通知は情報をユーザーに知らせることである。
メールの受信・リマインダーなど様々な情報を知らせる手段であり、パーソナルコンピュータやスマートフォンなどで利用される。Androidにおいては、通知は「アプリの UI 以外で Android が表示するメッセージ」と定義される[2]。各プラットフォーム(WindowsやAndroidなどのOSレベル、Webブラウザなどのアプリケーションレベル)で通知の仕組みが整備されている。通知を受けたユーザーは通知をタップしてアプリを起動したり、通知画面を直接操作して情報を処理したりする[2]。
通知の目的は低コストの情報取得である。通知を用いることで、ユーザーは情報を取得するためにわざわざアプリケーションを開いて自ら情報収集をおこなわなくて済む。またpush通知をおこなうことで緊急性の高い情報をリアルタイムに取得でき、緊急性の高い情報を得るために情報源を手動で監視する必要がなくなる。
通知は新しい情報(新規メッセージなど)の到着を知らせたり、思い出すべき情報を知らせる(リマインドする)ために用いられる。
通知にはPush技術(Apple Push Notification Serviceなど)を利用してpushされた情報をユーザーが受動的に割り込みで通知される方式(例: 着信音)と、通知センター等の情報集約場所からユーザーが能動的に情報をpullする方式がある。各プラットフォームで様々な通知方式が提供されており[2]、通知目的とユーザーエクスペリエンスを考慮して利用される(べきである)[3][4]。以下は通知方式の具体例である。
音・バイブレーション・ポップアップ等により、ユーザーへ強制的に通知をおこなうことができる。緊急性の高い情報を確実に届けることができる一方、頻繁なプッシュ通知はユーザーの作業へ割り込むことになる。そのため通知をオフにする機能が存在する機器もある[5][6]。