Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / TextPageSample.cs
1 using Tizen.NUI;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Utility;
4
5 using System;
6 using System.IO;
7 using Tizen.System;
8
9 namespace Tizen.NUI.Samples
10 {
11     public class TextPageSample : IExample
12     {
13         private TextLabel label;
14         private View root;
15
16         public string LoadTerms()
17         {
18             string terms = null;
19             var filename = "res/pl_PL.txt";
20
21             try {
22                 terms = File.ReadAllText(filename);
23             } catch (Exception e) {
24                 Tizen.Log.Debug("oobe", $"Unable to load terms: {e.Message}");
25                 return null;
26             }
27             return terms;
28         }
29
30
31         public void Activate()
32         {
33             Window window = NUIApplication.GetDefaultWindow();
34
35             label = new TextLabel();
36             label.Size = new Size(300, 700);
37             label.PointSize = 11.0f;
38             label.MultiLine = true;
39
40             TextPageUtil util = new TextPageUtil();
41             int pageCount = util.SetText( label, LoadTerms() );
42             Tizen.Log.Error("NUI", $"pageCount: {pageCount}\n");
43             label.Text = util.GetText(1);
44             window.Add(label);
45         }
46
47         public void Deactivate()
48         {
49             if (root != null)
50             {
51                 NUIApplication.GetDefaultWindow().Remove(root);
52                 root.Dispose();
53             }
54         }
55     }
56 }