{ typeof(RelativeVector4), new RelativeVector4TypeConverter() },
};
+ //Modification for NUI XAML : user defined converter for DynamicResource can be added
+ static internal Dictionary<Type, TypeConverter> UserCustomConvertTypes = new Dictionary<Type, TypeConverter>
+ {
+ };
+
// more or less the encoding of this, without the need to reflect
// http://msdn.microsoft.com/en-us/library/y5b434w4.aspx
static readonly Dictionary<Type, Type[]> SimpleConvertTypes = new Dictionary<Type, Type[]>
{
value = typeConverterTo.ConvertFromInvariantString(value.ToString());
}
+ else if (UserCustomConvertTypes.TryGetValue(type, out typeConverterTo) && typeConverterTo.CanConvertFrom(valueType))
+ {
+ //Modification for NUI XAML : user defined converter for DynamicResource can be added
+ value = typeConverterTo.ConvertFromInvariantString(value.ToString());
+ }
else if (!ReturnTypeInfo.IsAssignableFrom(valueType.GetTypeInfo()))
{
var cast = type.GetImplicitConversionOperator(fromType: valueType, toType: type)
parts = value.Split(',');
if (parts.Length == 3)
{
- return new Position(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
- Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
- Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture));
+ int x = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[0].Trim());
+ int y = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[1].Trim());
+ int z = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[2].Trim());
+ return new Position(x, y, z);
}
}
string[] parts = value.Split(',');
if (parts.Length == 3)
{
- return new Size(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
- Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
- Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture));
+ int x = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[0].Trim());
+ int y = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[1].Trim());
+ int z = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[2].Trim());
+ return new Size(x, y, z);
}
}
string[] parts = value.Split(',');
if (parts.Length == 2)
{
- return new Size2D(Int32.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
- Int32.Parse(parts[1].Trim(), CultureInfo.InvariantCulture));
+ int x = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[0].Trim());
+ int y = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[1].Trim());
+ return new Size2D(x, y);
}
}
using System.Collections.Generic;
using System.Reflection;
using Tizen.NUI.StyleSheets;
+using System.ComponentModel;
namespace Tizen.NUI.Binding
{
public IList<Setter> Setters { get; }
- internal IList<TriggerBase> Triggers
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public IList<TriggerBase> Triggers
{
get { return _triggers ?? (_triggers = new AttachedCollection<TriggerBase>()); }
}
*
*/
using System;
+using System.Collections.Generic;
using System.ComponentModel;
+using System.IO;
using System.Runtime.InteropServices;
using Tizen.NUI.Binding;
+using Tizen.NUI.Xaml;
namespace Tizen.NUI.BaseComponents
{
}
}
+
+ private Dictionary<string, Transition> transDictionary = new Dictionary<string, Transition>();
+
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Transition GetTransition(string transitionName)
+ {
+ Transition trans = null;
+ transDictionary.TryGetValue(transitionName, out trans);
+ return trans;
+ }
+
+ private void LoadTransitions()
+ {
+ foreach (string str in transitionNames)
+ {
+ string resourceName = str + ".xaml";
+ Transition trans = null;
+
+ string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+
+ string likelyResourcePath = resource + "animation/" + resourceName;
+
+ if (File.Exists(likelyResourcePath))
+ {
+ trans = Extensions.LoadObject<Transition>(likelyResourcePath);
+ }
+ if (trans)
+ {
+ transDictionary.Add(trans.Name, trans);
+ }
+ }
+ }
+
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string[] TransitionNames
+ {
+ get
+ {
+ return transitionNames;
+ }
+ set
+ {
+ transitionNames = value;
+ LoadTransitions();
+ }
+ }
+ private string[] transitionNames;
+
internal class BackgroundResourceLoadedEventArgs : EventArgs
{
private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
/// <since_tizen> 3 </since_tizen>
public void SetCustomAlgorithm(ICustomFocusAlgorithm arg0)
{
- _customAlgorithmInterfaceWrapper = new CustomAlgorithmInterfaceWrapper();
- _customAlgorithmInterfaceWrapper.SetFocusAlgorithm(arg0);
+ if(arg0 != null)
+ {
+ _customAlgorithmInterfaceWrapper = new CustomAlgorithmInterfaceWrapper();
+ _customAlgorithmInterfaceWrapper.SetFocusAlgorithm(arg0);
- Interop.NDalic.SetCustomAlgorithm(swigCPtr, CustomAlgorithmInterface.getCPtr(_customAlgorithmInterfaceWrapper));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ Interop.NDalic.SetCustomAlgorithm(swigCPtr, CustomAlgorithmInterface.getCPtr(_customAlgorithmInterfaceWrapper));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ else
+ {
+ Interop.NDalic.SetCustomAlgorithm(swigCPtr, new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FocusManager obj)
--- /dev/null
+/*
+ * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+
+namespace Tizen.NUI
+{
+
+ /// <summary>
+ /// GraphicsTypeConverter class to convert types.
+ /// </summary>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class GraphicsTypeConverter
+ {
+
+ private const float defaultDpi = 160.0f;
+
+ /// <summary>
+ /// </summary>
+ /// <returns>Convert script to px</returns>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual float ConvertScriptToPixel(string scriptValue)
+ {
+ float convertedValue = 0;
+ if (scriptValue.EndsWith("dp"))
+ {
+ convertedValue = ConvertToPixel(float.Parse(scriptValue.Substring(0, scriptValue.LastIndexOf("dp")), CultureInfo.InvariantCulture));
+ }
+ else if (scriptValue.EndsWith("px"))
+ {
+ convertedValue = float.Parse(scriptValue.Substring(0, scriptValue.LastIndexOf("px")), CultureInfo.InvariantCulture);
+ }
+ else
+ {
+ if (!float.TryParse(scriptValue, NumberStyles.Any, CultureInfo.InvariantCulture, out convertedValue))
+ {
+ NUILog.Error("Cannot convert the script {scriptValue}\n");
+ convertedValue = 0;
+ }
+ }
+ return convertedValue;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns>Convert other type to px</returns>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual float ConvertToPixel(float value)
+ {
+ return value * (Window.Instance.Dpi.X / defaultDpi);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns>Convert px to other type</returns>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual float ConvertFromPixel(float value)
+ {
+ return value * (defaultDpi / Window.Instance.Dpi.X);
+ }
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System.ComponentModel;
+
+namespace Tizen.NUI
+{
+
+ /// <summary>
+ /// GraphicsTypeManager class to manage various types.
+ /// </summary>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class GraphicsTypeManager
+ {
+
+ /// <summary>
+ /// Creates private GraphicsTypeManager object.
+ /// </summary>
+ /// <since_tizen> 5 </since_tizen>
+ private GraphicsTypeManager()
+ {
+ _typeConverter = new GraphicsTypeConverter();
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns>Returns Singleton instance of GraphicsTypeManager</returns>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static GraphicsTypeManager Instance
+ {
+ get
+ {
+ if (_graphicsTypeManager == null)
+ {
+ _graphicsTypeManager = new GraphicsTypeManager();
+ }
+
+ return _graphicsTypeManager;
+ }
+
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns>Set Custom GraphicsTypeConverter</returns>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetTypeConverter(GraphicsTypeConverter typeConverter)
+ {
+ _typeConverter = typeConverter;
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns>Convert script to px</returns>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public float ConvertScriptToPixel(string scriptValue)
+ {
+ return _typeConverter.ConvertScriptToPixel(scriptValue);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns>Convert other type to px</returns>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual float ConvertToPixel(float value)
+ {
+ return _typeConverter.ConvertToPixel(value);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <returns>Convert px to other type</returns>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual float ConvertFromPixel(float value)
+ {
+ return _typeConverter.ConvertFromPixel(value);
+ }
+
+ internal void RegisterCustomConverterForDynamicResourceBinding(global::System.Type type, Tizen.NUI.Binding.TypeConverter userConverter)
+ {
+ if (Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.ContainsKey(type) == false)
+ {
+ Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.Add(type, userConverter);
+ }
+ //NUILog.Error($"user custom converter ditionary count={Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.Count}");
+ }
+
+ private volatile static GraphicsTypeManager _graphicsTypeManager;
+ private GraphicsTypeConverter _typeConverter;
+ }
+
+}
\ No newline at end of file
using Tizen.NUI.BaseComponents;
using System.ComponentModel;
using System.Runtime.InteropServices;
+using Tizen.NUI.Binding;
namespace Tizen.NUI
{
}
}
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ResourceDictionary XamlResources
+ {
+ get
+ {
+ return Application.Current.XamlResources;
+ }
+ set
+ {
+ Application.Current.XamlResources = value;
+ }
+ }
+
/// From the Container base class.
/// <summary>
string[] parts = value.Split(',');
if (parts.Length == 2)
{
- return new Position2D(int.Parse(parts[0].Trim()), int.Parse(parts[1].Trim()));
+ int x = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[0].Trim());
+ int y = (int)GraphicsTypeManager.Instance.ConvertScriptToPixel(parts[1].Trim());
+ return new Position2D(x, y);
}
}