public float ConvertScriptToPoint(string scriptValue) { float convertedValue = 0; if (scriptValue != null) { if (scriptValue.EndsWith("sp")) { convertedValue = ConvertSpToPoint(float.Parse(scriptValue.Substring(0, scriptValue.LastIndexOf("sp")), CultureInfo.InvariantCulture)); } else if (scriptValue.EndsWith("dp")) { convertedValue = ConvertDpToPoint(float.Parse(scriptValue.Substring(0, scriptValue.LastIndexOf("dp")), CultureInfo.InvariantCulture)); } else if (scriptValue.EndsWith("pt")) { 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> /// Tells whether the timer is running. /// </summary> /// <returns>Whether the timer is started or not.</returns> /// <since_tizen> 3 </since_tizen> public bool IsRunning() { if (Thread.CurrentThread.ManagedThreadId != 1) { Tizen.Log.Error("NUI", "current threadID : " + Thread.CurrentThread.ManagedThreadId); StackTrace st = new StackTrace(true); for (int i = 0; i < st.FrameCount; i++) { StackFrame sf = st.GetFrame(i); Tizen.Log.Error("NUI", " Method " + sf.GetMethod()); } } if (SwigCPtr.Handle == global::System.IntPtr.Zero || disposed) { NUILog.Error("[ERR] already disposed! can not get this done! just return here! please make sure that the handle gets free when using explicit Dispose()! For example, timer.Dispose(); timer = null; this must be done!"); return(false); } bool ret = Interop.Timer.IsRunning(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
internal void RaiseAbove(Layer target) { var parentChildren = Window.Instance.LayersChildren; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); int targetIndex = parentChildren.IndexOf(target); if (currentIndex < 0 || targetIndex < 0 || currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count) { NUILog.Error("index should be bigger than 0 and less than children of layer count"); return; } // If the currentIndex is less than the target index and the target has the same parent. if (currentIndex < targetIndex) { parentChildren.Remove(this); parentChildren.Insert(targetIndex, this); Interop.Layer.Layer_MoveAbove(swigCPtr, Layer.getCPtr(target)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } } }
static internal bool DaliVersionMatchWithNUI() { int ver1 = -1; int ver2 = -1; int ver3 = -1; try { if (NDalicManualPINVOKE.InternalAPIVersionCheck(ref ver1, ref ver2, ref ver3) == true) { if (ver1 != nuiAPIVer) { NUILog.Error($"NUI API version mismatch error! NUI API Version: ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})"); throw new System.InvalidOperationException($"NUI API version mismatch error! NUI API version should be ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})"); } } else { NUILog.Error($"NUI API version mismatch error! NUI API Version: ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})"); throw new System.InvalidOperationException($"NUI API version mismatch error! NUI API version should be ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})"); } } catch (Exception) { NUILog.Error($"NUI API version mismatch error! NUI API Version: ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})"); throw new System.InvalidOperationException($"NUI API version mismatch error! NUI API version should be ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})"); } PrintDaliNativeVersion(); return(true); }
internal static RelativeVector3 ValueCheck(RelativeVector3 relativeVector3) { if (relativeVector3.X < 0.0f) { relativeVector3.X = 0.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } else if (relativeVector3.X > 1.0f) { relativeVector3.X = 1.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } if (relativeVector3.Y < 0.0f) { relativeVector3.Y = 0.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } else if (relativeVector3.Y > 1.0f) { relativeVector3.Y = 1.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } if (relativeVector3.Z < 0.0f) { relativeVector3.Z = 0.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } else if (relativeVector3.Z > 1.0f) { relativeVector3.Z = 1.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } return(relativeVector3); }
static internal bool DaliVersionMatchWithNUI() { int ver1 = -1; int ver2 = -1; int ver3 = -1; try { if (NDalicManualPINVOKE.NativeVersionCheck(ref ver1, ref ver2, ref ver3)) { if (ver1 != daliVer1 || ver2 != daliVer2 || ver3 != daliVer3) { NUILog.Error($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali= { ver1 }.{ ver2}.{ ver3}"); throw new System.InvalidOperationException($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali={ ver1 }.{ ver2}.{ ver3}"); } } else { NUILog.Error($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali= { ver1 }.{ ver2}.{ ver3}"); throw new System.InvalidOperationException($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali={ ver1 }.{ ver2}.{ ver3}"); } } catch (Exception) { NUILog.Error($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali= { ver1 }.{ ver2}.{ ver3}"); throw new System.InvalidOperationException($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali={ ver1 }.{ ver2}.{ ver3}"); } NUILog.Debug($"version info: nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3}, dali= { ver1 }.{ ver2}.{ ver3}"); return(true); }
internal void LowerBelow(Layer target) { var parentChildren = window?.LayersChildren; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); int targetIndex = parentChildren.IndexOf(target); if (currentIndex < 0 || targetIndex < 0 || currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count) { NUILog.Error("index should be bigger than 0 and less than children of layer count"); return; } // If the currentIndex is not already the 0th index and the target has the same parent. if ((currentIndex != 0) && (targetIndex != -1) && (currentIndex > targetIndex)) { parentChildren.Remove(this); parentChildren.Insert(targetIndex, this); Interop.Layer.MoveBelow(SwigCPtr, Layer.getCPtr(target)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } } }
//[Conditional("DEBUG_ON")] static private void PrintDaliNativeVersion() { int ver1 = -1; int ver2 = -1; int ver3 = -1; NDalicManualPINVOKE.NativeVersionCheck(ref ver1, ref ver2, ref ver3); //NUILog.Debug($"DALi Version: ({ver1}.{ver2}.{ver3}), NUI API Version: ({nuiAPIVer})"); NUILog.Error($"NOT Error! Just Showing DALi Version: ({ver1}.{ver2}.{ver3}), NUI API Version: ({nuiAPIVer})"); }
//[Conditional("DEBUG_ON")] static internal void PrintDaliNativeVersion() { int ver1 = -1; int ver2 = -1; int ver3 = -1; NativeVersionCheck(ref ver1, ref ver2, ref ver3); //NUILog.Debug($"DALi Version: ({ver1}.{ver2}.{ver3}), NUI API Version: ({nuiAPIVer})"); NUILog.Error($"NOT Error! Just Showing DALi Version: ({ver1}.{ver2}.{ver3}), NUI API Version: ({nuiAPIVer})"); }
internal static float ValueCheck(float value) { float refValue = value; if (IsInvalidValue(ref refValue)) { NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. float value is {value}"); } return(refValue); }
internal static Color ValueCheck(Color color) { float r = color.R; float g = color.G; float b = color.B; float a = color.A; if (IsInvalidValue(ref r) | IsInvalidValue(ref g) | IsInvalidValue(ref b) | IsInvalidValue(ref a)) { NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. Color is {color.R}, {color.G}, {color.B}, {color.A}"); } color = new Color(r, g, b, a); return(color); }
public virtual float ConvertScriptToPixel(string scriptValue) { float convertedValue = 0; if (scriptValue != null) { if (!float.TryParse(scriptValue, NumberStyles.Any, CultureInfo.InvariantCulture, out convertedValue)) { NUILog.Error("Cannot convert the script {scriptValue}\n"); convertedValue = 0; } } return(convertedValue); }
internal static float ValueCheck(float value) { if (value < 0.0f) { value = 0.0f; NUILog.Error("The value of Parameters is invalid! Should be between [0, 1]."); } else if (value > 1.0f) { value = 1.0f; NUILog.Error("The value of Parameters is invalid! Should be between [0, 1]."); } return(value); }
internal static BaseHandle GetManagedBaseHandleFromNativePtr(IntPtr cPtr) { IntPtr refObjectPtr = NDalicPINVOKE.GetRefObjectPtr(cPtr); if (refObjectPtr != null) { // we store a dictionary of ref-obects (C++ land) to managed obects (C# land) return(GetManagedBaseHandleFromRefObject(refObjectPtr)); } else { NUILog.Error("NUI Registry RefObjectPtr is NULL!"); return(null); } }
private void OnWindowFocusedChanged2(IntPtr window, bool focusGained) { if (window == IntPtr.Zero) { NUILog.Error("OnWindowFocusedChanged() Window is null! Do nothing!"); return; } if (windowFocusChangedEventHandler2 != null) { FocusChangedEventArgs e = new FocusChangedEventArgs(); e.FocusGained = focusGained; windowFocusChangedEventHandler2(this, e); } }
internal uint GetInterval() { if (SwigCPtr.Handle == global::System.IntPtr.Zero || disposed) { NUILog.Error("[ERR] already disposed! can not get this done! just return here! please make sure that the handle gets free when using explicit Dispose()! For example, timer.Dispose(); timer = null; this must be done!"); return(0); } uint ret = Interop.Timer.GetInterval(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
private bool OnWindowTouch(IntPtr view, IntPtr touchData) { if (touchData == global::System.IntPtr.Zero) { NUILog.Error("touchData should not be null!"); return(false); } if (rootLayerTouchDataEventHandler != null) { TouchEventArgs e = new TouchEventArgs(); e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData); rootLayerTouchDataEventHandler(this, e); } return(false); }
private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent) { if (wheelEvent == global::System.IntPtr.Zero) { NUILog.Error("wheelEvent should not be null!"); return(true); } if (stageWheelHandler != null) { WheelEventArgs e = new WheelEventArgs(); e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent); stageWheelHandler(this, e); } return(true); }
internal static BaseHandle GetManagedBaseHandleFromNativePtr(BaseHandle baseHandle) { RefObject refObj = baseHandle.GetObjectPtr(); IntPtr refObjectPtr = (IntPtr)RefObject.getCPtr(refObj); if (refObjectPtr != null) { // we store a dictionary of ref-obects (C++ land) to managed obects (C# land) return(GetManagedBaseHandleFromRefObject(refObjectPtr)); } else { NUILog.Error("NUI Registry RefObjectPtr is NULL!"); return(null); } }
internal static float[] ValueCheck(float[] arr) { for (int i = 0; i < arr.Length; i++) { if (arr[i] < 0.0f) { arr[i] = 0.0f; NUILog.Error("The value of Parameters is invalid! Should be between [0, 1]."); } else if (arr[i] > 1.0f) { arr[i] = 1.0f; NUILog.Error("The value of Parameters is invalid! Should be between [0, 1]."); } } return(arr); }
internal static float[] ValueCheck(float[] arr) { if (null == arr) { throw new ArgumentNullException(nameof(arr)); } for (int i = 0; i < arr.Length; i++) { float refValue = arr[i]; if (IsInvalidValue(ref refValue)) { NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. arr[] is {arr[i]}"); arr[i] = refValue; } } return(arr); }
/// <summary> /// Sets a new interval on the timer and starts the timer.<br /> /// Cancels the previous timer.<br /> /// </summary> /// <param name="milliSec">MilliSec interval in milliseconds.</param> internal void SetInterval(uint milliSec) { NUILog.Debug($"(0x{SwigCPtr.Handle:X})SetInterval({milliSec})"); if (SwigCPtr.Handle == global::System.IntPtr.Zero || disposed) { NUILog.Error("[ERR] already disposed! can not get this done! just return here! please make sure that the handle gets free when using explicit Dispose()! For example, timer.Dispose(); timer = null; this must be done!"); return; } played = true; Interop.Timer.SetInterval(SwigCPtr, milliSec); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } }
internal static Color ValueCheck(Color color) { if (color.R < 0.0f) { color.R = 0.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } else if (color.R > 1.0f) { color.R = 1.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } if (color.G < 0.0f) { color.G = 0.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } else if (color.G > 1.0f) { color.G = 1.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } if (color.B < 0.0f) { color.B = 0.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } else if (color.B > 1.0f) { color.B = 1.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } if (color.A < 0.0f) { color.A = 0.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } else if (color.A > 1.0f) { color.A = 1.0f; NUILog.Error("The value of Result is invalid! Should be between [0, 1]."); } return(color); }
/// public void LoadFromFile(string fileName) { try { string json = System.IO.File.ReadAllText(fileName); if (json.Length > 0) { LoadFromString(json); } else { throw new global::System.InvalidOperationException("Failed to load file " + fileName); } } catch (System.Exception e) { NUILog.Error(e.Message); throw new global::System.InvalidOperationException("Failed to parse " + fileName); } }
private void OnResized(IntPtr window, IntPtr windowSize) { if (window == IntPtr.Zero) { NUILog.Error("OnResized() Window is null! Do nothing!"); return; } if (windowResizeEventHandler != null) { ResizedEventArgs e = new ResizedEventArgs(); // var val = new Uint16Pair(windowSize, false); // e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight()); // val.Dispose(); // Workaround : windowSize should be valid pointer from dali, // but currently it is fixed and is not Uint16Pair class. // will be fixed later. e.WindowSize = this.WindowSize; windowResizeEventHandler(this, e); } }