2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 namespace Tizen.Applications.Notifications
20 /// Class containing common properties and methods of Notifications
23 /// A notification is a message that is displayed on the notification area.
24 /// It is created to notify information to the user through the application.
25 /// This class helps you to provide method and property for creating notification object.
27 public sealed partial class Notification
30 /// Class to help you set button on Active style of Notification
33 /// It must include a Text, an Index, an ImagePath, and an Action to be invoked when user select the button.
35 public sealed class ButtonAction : MakerBase
38 /// Gets or sets the index of Button which is appeared at Notification.
40 public ButtonIndex Index { get; set; } = ButtonIndex.None;
43 /// Gets or sets the text describing the button
45 public string Text { get; set; }
48 /// Gets or sets the image path that represent the button
50 public string ImagePath { get; set; }
53 /// Gets or sets the action which is invoked when button is clicked
56 /// If you don't set Action, nothing happens when button is clicked.
60 /// ButtonAction button = new ButtonAction
62 /// Index = ButtonIndex.First,
64 /// ImagePath = "image path",
65 /// Action = new AppControl{ ApplicationId = "org.tizen.app" };
69 /// <seealso cref="Tizen.Applications.AppControl"></seealso>
70 public AppControl Action { get; set; }
72 internal override void Make(Notification notification)
74 int enumIndex = (int)NotificationText.FirstButton + (int)Index;
76 Interop.Notification.SetText(notification.Handle, (NotificationText)enumIndex, Text, null, -1);
77 enumIndex = (int)NotificationImage.FirstButton + (int)Index;
78 Interop.Notification.SetImage(notification.Handle, (NotificationImage)enumIndex, ImagePath);
79 if (Action != null && Action.SafeAppControlHandle.IsInvalid == false)
81 Interop.Notification.SetEventHandler(notification.Handle, (int)Index, Action.SafeAppControlHandle);