Release 8.0.0.15408
[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.Components;
4 using Tizen.NUI.Wearable;
5
6 using System;
7 using System.IO;
8 using Tizen.System;
9
10 namespace Tizen.NUI.Samples
11 {
12     public class TextPageSample : IExample
13     {
14         private TextLabel label;
15         private View root;
16
17         public string LoadTerms()
18         {
19             string terms = null;
20             var filename = "res/pl_PL.txt";
21
22             try {
23                 terms = File.ReadAllText(filename);
24             } catch (Exception e) {
25                 Tizen.Log.Debug("oobe", $"Unable to load terms: {e.Message}");
26                 return null;
27             }
28             return terms;
29         }
30
31
32         public void Activate()
33         {
34             Window window = NUIApplication.GetDefaultWindow();
35
36             TextLabelStyle attr = new TextLabelStyle
37             {
38
39                 BackgroundColor = Color.Yellow,
40                 TextColor = Color.Blue,
41             };
42
43
44             label = new TextLabel(attr);
45             label.Size = new Size(300, 700);
46             label.PointSize = 11.0f;
47             label.MultiLine = true;
48
49
50             TextPageUtil util = new TextPageUtil();
51             int pageCount = util.SetText( label, LoadTerms() );
52             Tizen.Log.Error("NUI", $"pageCount: {pageCount}\n");
53             label.Text = util.GetText(1);
54             window.Add(label);
55         }
56
57         public void Deactivate()
58         {
59             if (root != null)
60             {
61                 NUIApplication.GetDefaultWindow().Remove(root);
62                 root.Dispose();
63             }
64         }
65     }
66 }