2e20f585fef4f270fad2a6d55a8e47e7f714f632
[platform/core/csapi/tizenfx.git] / test / NUITestSample / NUIXAMLTestSample / TempTest / TempTest.cs
1 using System;
2 using System.IO;
3 using System.Reflection;
4
5 using Tizen.NUI.Binding;
6 using Tizen.NUI.Xaml;
7 using Tizen.NUI;
8 using Tizen.NUI.UIComponents;
9 using Tizen.NUI.BaseComponents;
10 using System.ComponentModel;
11
12 namespace Tizen.NUI.Examples
13 {
14     
15     // class MyAppViewModel : INotifyPropertyChanged
16     // {
17
18     //     public event PropertyChangedEventHandler PropertyChanged;
19     //     private Command _firstClick;
20     //     private int count = 0;
21         
22     //     private string[] colors = new string[] {"Black", "Blue", "Gray", "Green", "Purple", "Pink", "Red" };
23     //     public string TextColor = "Red";
24     //     public Command ChangeColor {
25     //         get {
26     //             return _firstClick ?? (_firstClick = new Command (() => {
27     //                 Console.WriteLine ("First button clicked");
28     //                 count += 1;
29     //                 TextColor = colors[count % 7];
30     //             }));
31     //         }
32     //     }
33     
34     //     public MyAppViewModel()
35     //     {
36     //     }
37
38     // }
39     class MyAppViewModel : INotifyPropertyChanged
40     {
41
42         public event PropertyChangedEventHandler PropertyChanged;
43         private Command _firstClick;
44         private int clickCounter = 0;
45         public string message;
46
47         //static readonly BindableProperty MessageProperty = BindableProperty.Create<MyAppViewModel, string> ((MyAppViewModel v) => v.Message, "- - - - - Message - - -");
48         public string Message
49         {
50             set
51             {                
52                 Console.WriteLine ("Message : {0}, {1}",message,value);
53                 if (message != value)
54                 {
55                     message = value;
56
57                     Console.WriteLine ("Message111 : {0}",message);
58
59                     if (PropertyChanged != null)
60                     {
61                         Console.WriteLine ("Message222 : {0}",message);
62                         PropertyChanged(this, 
63                             new PropertyChangedEventArgs("Message"));
64                     }
65                 }
66             }
67             get
68             {
69                 return message;
70             }
71         }
72
73         public Command ShowClickCount {
74             get {
75                 return _firstClick ?? (_firstClick = new Command (() => {
76                     Console.WriteLine ("First button clicked");
77                     clickCounter += 1;
78                     Message = "Clicked " + clickCounter.ToString() + " times";
79                 }));
80             }
81         }    
82
83         public MyAppViewModel()
84         {
85             this.message = String.Format("------test-----");
86             this.Message = String.Format("------test111-----");;
87         }
88     }
89
90
91     public class TempTest : NUIApplication
92     {
93
94         protected override void OnCreate() 
95         {
96             base.OnCreate();
97             Window window = Window.Instance;
98             window.BackgroundColor = Color.White;
99
100             TempPage myPage = new TempPage(window);
101             // myPage.InitializeComponents(myPage, typeof(TempPage));
102             Extensions.LoadFromXaml(myPage, typeof(TempPage));
103             // myPage.BindingContext = new MyAppViewModel ();
104             Console.WriteLine("==================  Set BindingContext in Application !!!! ==================");
105             myPage.SetFocus();
106         }
107
108         public static void _Main(string[] args)
109         {
110             TempTest p = new TempTest();
111             p.Run(args);
112         }
113     }
114 }