2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
20 using Tizen.NUI.BaseComponents;
22 using System.Collections.Generic;
28 /// The ContentPage class.
30 [ContentProperty("Content")]
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public class ContentPage : TemplatedPage
34 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
35 [EditorBrowsable(EditorBrowsableState.Never)]
36 public View Root {get; internal set;}
39 /// The contents of ContentPage can be added into it.
41 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
42 [EditorBrowsable(EditorBrowsableState.Never)]
43 public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(ContentPage), null, propertyChanged: (bindable, oldValue, newValue) =>
45 var self = (ContentPage)bindable;
48 self.Root.Add((View)newValue);
53 /// The contents of ContentPage can be added into it.
55 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
56 [EditorBrowsable(EditorBrowsableState.Never)]
59 get { return (View)GetValue(ContentProperty); }
60 set { SetValue(ContentProperty, value); }
64 /// Method that is called when the binding content changes.
66 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
67 [EditorBrowsable(EditorBrowsableState.Never)]
68 protected override void OnBindingContextChanged()
70 base.OnBindingContextChanged();
72 View content = Content;
73 ControlTemplate controlTemplate = ControlTemplate;
74 if (content != null && controlTemplate != null)
76 SetInheritedBindingContext(content, BindingContext);
80 internal override void OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue)
85 base.OnControlTemplateChanged(oldValue, newValue);
86 View content = Content;
87 ControlTemplate controlTemplate = ControlTemplate;
88 if (content != null && controlTemplate != null)
90 SetInheritedBindingContext(content, BindingContext);
97 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
98 [EditorBrowsable(EditorBrowsableState.Never)]
99 public ContentPage(Window win)
101 IsCreateByXaml = true;
104 Root.WidthResizePolicy = ResizePolicyType.FillToParent;
105 Root.HeightResizePolicy = ResizePolicyType.FillToParent;
111 /// The Resources property.
113 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
114 [EditorBrowsable(EditorBrowsableState.Never)]
115 public ResourceDictionary XamlResources
119 return Application.Current.XamlResources;
124 Application.Current.XamlResources = value;
129 /// To make the ContentPage instance be disposed.
131 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 protected override void Dispose(DisposeTypes type)
140 if (type == DisposeTypes.Explicit)
143 //Release your own managed resources here.
144 //You should release all of your own disposable objects here.
147 //Release your own unmanaged resources here.
148 //You should not access any managed member here except static instance.
149 //because the execution order of Finalizes is non-deterministic.
152 Window.Instance.Remove(Root);
160 /// Check whether the content is empty.
162 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
163 [EditorBrowsable(EditorBrowsableState.Never)]
168 return ( Root.ChildCount == 0 ) ? true : false;
173 /// Clear all contents from this ContentPage.
175 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
176 [EditorBrowsable(EditorBrowsableState.Never)]
177 public void ClearContent()
181 //Remove it from the window
182 Window.Instance.Remove(Root);
188 Root.WidthResizePolicy = ResizePolicyType.FillToParent;
189 Root.HeightResizePolicy = ResizePolicyType.FillToParent;
190 Window.Instance.Add(Root);
196 private EventHandler _clearEventHandler;
201 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
202 [EditorBrowsable(EditorBrowsableState.Never)]
203 public event EventHandler ClearEvent
207 _clearEventHandler += value;
211 _clearEventHandler -= value;
215 private void ClearHandler()
217 if (_clearEventHandler != null)
219 _clearEventHandler(this, null);
224 /// Users can set focus logic codes here.
226 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
227 [EditorBrowsable(EditorBrowsableState.Never)]
228 public virtual void SetFocus() { }
230 private Dictionary<string, Transition> transDictionary = new Dictionary<string, Transition>();
232 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
233 [EditorBrowsable(EditorBrowsableState.Never)]
234 public Transition GetTransition(string transitionName)
236 Transition trans = null;
237 transDictionary.TryGetValue(transitionName, out trans);
241 private void LoadTransitions()
243 foreach (string str in transitionNames)
245 string resourceName = str + ".xaml";
246 Transition trans = null;
248 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
250 string likelyResourcePath = resource + "animation/" + resourceName;
252 if (File.Exists(likelyResourcePath))
254 trans = Extensions.LoadObject<Transition>(likelyResourcePath);
258 transDictionary.Add(trans.Name, trans);
263 private string[] transitionNames;
265 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
266 [EditorBrowsable(EditorBrowsableState.Never)]
267 public string[] TransitionNames
271 return transitionNames;
275 transitionNames = value;