e05d2893f0d7a11c893683f0dc30f6f18683911a
[test/tct/csharp/api.git] /
1 using Tizen.Applications;\r
2 using ElmSharp;\r
3 using Tizen;\r
4 using Tizen.Applications.Messages;\r
5 \r
6 namespace MsgPortApp1.Tizen\r
7 {\r
8     class App : CoreUIApplication\r
9     {\r
10         private static MessagePort _remotePort;\r
11         private Bundle _confirmMsg;\r
12         private static string TAG;\r
13         protected override void OnCreate()\r
14         {\r
15             base.OnCreate();\r
16             Initialize();\r
17 \r
18             _confirmMsg = new Bundle();\r
19             _confirmMsg.AddItem("ConfirmMessage", "Message is received");\r
20             TAG = "MSGPORTAPP1";\r
21 \r
22             Log.Debug(TAG, "@@@@@@@ Create");\r
23             _remotePort = new MessagePort("RemotePort", false);\r
24             Log.Debug(TAG, "@@@@@@@ MessagePort-MsgPortApp1 Create : " + _remotePort.PortName + "Trusted : " + _remotePort.Trusted);\r
25 \r
26             _remotePort.MessageReceived += MessageReceived_Callback;\r
27             _remotePort.Listen();\r
28         }\r
29 \r
30         void Initialize()\r
31         {\r
32             Window window = new Window("ElmSharpApp")\r
33             {\r
34                 AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90\r
35             };\r
36             window.BackButtonPressed += (s, e) =>\r
37             {\r
38                 Exit();\r
39             };\r
40             window.Show();\r
41 \r
42             var box = new Box(window)\r
43             {\r
44                 AlignmentX = -1,\r
45                 AlignmentY = -1,\r
46                 WeightX = 1,\r
47                 WeightY = 1,\r
48             };\r
49             box.Show();\r
50 \r
51             var bg = new Background(window)\r
52             {\r
53                 Color = Color.White\r
54             };\r
55             bg.SetContent(box);\r
56 \r
57             var conformant = new Conformant(window);\r
58             conformant.Show();\r
59             conformant.SetContent(bg);\r
60 \r
61             var label = new Label(window)\r
62             {\r
63                 Text = "Hello, Tizen",\r
64             };\r
65             label.Show();\r
66             box.PackEnd(label);\r
67         }\r
68 \r
69         private void MessageReceived_Callback(object sender, MessageReceivedEventArgs e)\r
70         {\r
71             Log.Debug(TAG, "@@@@@@@ Message Received");\r
72             Log.Debug(TAG, "@@@@@@@ App ID : " + e.Remote.AppId);\r
73             Log.Debug(TAG, "@@@@@@@ PortName : " + e.Remote.PortName);\r
74             Log.Debug(TAG, "@@@@@@@ Trusted : " + e.Remote.Trusted);\r
75             Log.Debug(TAG, "@@@@@@@ message: " + e.Message.GetItem<string>("message"));\r
76 \r
77             _remotePort.Send(_confirmMsg, "Tizen.Applications.Tests", "LocalPort");\r
78         }\r
79 \r
80         static void Main(string[] args)\r
81         {\r
82             Elementary.Initialize();\r
83             Elementary.ThemeOverlay();\r
84             App app = new App();\r
85             app.Run(args);\r
86         }\r
87     }\r
88 }\r