Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.NotificationEventListener / Tizen.Applications.NotificationEventListener / NotificationButtonActionArgsBinder.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 namespace Tizen.Applications.NotificationEventListener
18 {
19     internal static class NotificationButtonActionArgBinder
20     {
21         internal static void BindObject(NotificationEventArgs eventargs, int index)
22         {
23             string text;
24             bool isExisted = false;
25             SafeAppControlHandle appcontrol = null;
26             NotificationEventArgs.ButtonActionArgs button = new NotificationEventArgs.ButtonActionArgs();
27
28             button.Index = (ButtonIndex)index;
29
30             Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.Button_1 + index, out text);
31             if (string.IsNullOrEmpty(text) == false)
32             {
33                 isExisted = true;
34                 button.ImagePath = text;
35             }
36
37             Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.FirstButton + index, out text);
38             if (string.IsNullOrEmpty(text) == false)
39             {
40                 isExisted = true;
41                 button.Text = text;
42             }
43
44             Interop.NotificationEventListener.GetEventHandler(eventargs.Handle, index, out appcontrol);
45
46             if (appcontrol != null && appcontrol.IsInvalid == false)
47             {
48                 button.Action = new AppControl(appcontrol);
49                 isExisted = true;
50             }
51
52             if (isExisted)
53             {
54                 (eventargs.Style["Active"] as NotificationEventArgs.ActiveStyleArgs).Button.Add(button);
55             }
56         }
57     }
58 }