private FREObject GetTabDetails(FREContext ctx, uint argc, FREObject[] argv) { var tabDetails = _view.TabDetails; try { var vecTabDetails = new FREArray("com.tuarua.webview.TabDetails", tabDetails.Count, true); for (var index = 0; index < tabDetails.Count; index++) { if (!(tabDetails[index] is TabDetails tabDetail)) { continue; } var currentTabFre = new FREObject().Init("com.tuarua.webview.TabDetails", index, string.IsNullOrEmpty(tabDetail.Address) ? "" : tabDetail.Address, string.IsNullOrEmpty(tabDetail.Title) ? "" : tabDetail.Title, tabDetail.IsLoading, tabDetail.CanGoBack, tabDetail.CanGoForward, 1.0); vecTabDetails.Set((uint)index, currentTabFre); } return(vecTabDetails.RawValue); } catch (Exception e) { return(new FreException(e).RawValue); } }
public FREObject GetTabDetails(FREContext ctx, uint argc, FREObject[] argv) { var tabDetails = _view.TabDetails; try { var tmp = new FREObject().Init("Vector.<com.tuarua.webview.TabDetails>", null); var vecTabDetails = new FREArray(tmp); for (var index = 0; index < tabDetails.Count; index++) { var tabDetail = tabDetails[index] as TabDetails; if (tabDetail == null) { continue; } var currentTabFre = new FREObject().Init("com.tuarua.webview.TabDetails", index, string.IsNullOrEmpty(tabDetail.Address) ? "" : tabDetail.Address, string.IsNullOrEmpty(tabDetail.Title) ? "" : tabDetail.Title, tabDetail.IsLoading, tabDetail.CanGoBack, tabDetail.CanGoForward, 1.0); vecTabDetails.Set((uint)index, new FreObjectSharp(currentTabFre)); //TODO update FreSharp to allow FREObjects to be passed } return(vecTabDetails.RawValue); } catch (Exception e) { return(new FreException(e).RawValue); } }
private FREObject RunArrayTests(FREContext ctx, uint argc, FREObject[] argv) { Trace("***********Start Array test***********"); if (argc < 4) { return(new FreException("Not enough args").RawValue); } var airArray = new FREArray(argv[0]); var inFre1 = new FREArray(argv[1]); var inFre2 = new FREArray(argv[2]); var inFre3 = new FREArray(argv[3]); var airArrayList = airArray.AsArrayList(); Trace("Convert FREArray to ArrayList :", airArrayList.Count, airArray.Length.Equals(6) ? "✅" : "❌"); airArray.Push(77.ToFREObject(), 88); Trace("Get FREArray length after 2 appends:", airArray.Length, airArray.Length.Equals(8) ? "✅" : "❌"); airArray[0] = 123.ToFREObject(); foreach (var fre in airArray) { Trace("iterate over FREArray", fre.AsInt()); } var airVectorString = inFre1.AsStringArray(); var airVectorNumber = inFre2.AsDoubleArray(); var airVectorBoolean = inFre3.AsBoolArray(); Trace("Vector.<String> passed from AIR :", string.Join(",", airVectorString.ToArray()), string.Join(",", airVectorString.ToArray()).Equals("a,b,c,d") ? "✅" : "❌"); Trace("Vector.<Number> passed from AIR :", string.Join(",", airVectorNumber.ToArray()), string.Join(",", airVectorNumber.ToArray()).Equals("1,0.5,2,3.3") ? "✅" : "❌"); Trace("Vector.<Boolean> passed from AIR :", string.Join(",", airVectorBoolean.ToArray()), string.Join(",", airVectorBoolean.ToArray()).Equals("True,True,False,True") ? "✅" : "❌"); var newFreArray = new FREArray("Object", 5, true); Trace("New FREArray of fixed length :", newFreArray.Length, newFreArray.Length.Equals(5) ? "✅" : "❌"); airArray.Set(0, 56); var itemZero = airArray[0].AsInt(); Trace("Set item 0 of FREArray:", itemZero, itemZero.Equals(56) ? "✅" : "❌"); var marks = new[] { 99, 98, 92, 97, 95 }; return(marks.ToFREObject()); }
private FREObject RunArrayTests(FREContext ctx, uint argc, FREObject[] argv) { Trace("***********Start Array test***********"); if (argc < 4) { return(new FreException("Not enough args").RawValue); } var inFre0 = new FREArray(argv[0]); var inFre1 = new FREArray(argv[1]); var inFre2 = new FREArray(argv[2]); var inFre3 = new FREArray(argv[3]); var airArray = inFre0.ToArrayList(); var airArrayLen = inFre0.Length; inFre0[1] = 123.ToFREObject(); foreach (var fre in inFre0) { Trace("iterate over FREArray", fre.AsInt()); } var airVectorString = inFre1.AsStringArray(); var airVectorNumber = inFre2.AsDoubleArray(); var airVectorBoolean = inFre3.AsBoolArray(); Trace("Array passed from AIR:", string.Join(",", airArray.ToArray())); Trace("AIR Array length:", airArrayLen); Trace("Vector.<String> passed from AIR:", string.Join(",", airVectorString.ToArray())); Trace("Vector.<Number> passed from AIR:", string.Join(",", airVectorNumber.ToArray())); Trace("Vector.<Boolean> passed from AIR:", string.Join(",", airVectorBoolean.ToArray())); var newFreArray = new FREArray("Object", 5, true); Trace("New Array of Objects should be 5?", newFreArray.Length); var itemZero = inFre0[0]; var itemZeroVal = itemZero.AsInt(); Trace("AIR Array item 0 before change:", itemZeroVal); inFre0.Set(0, 56); var marks = new[] { 99, 98, 92, 97, 95 }; return(marks.ToFREObject()); }
private FREObject RunArrayTests(FREContext ctx, uint argc, FREObject[] argv) { Trace("***********Start Array test***********"); var inFre = new FREArray(argv[0]); var airArray = argv[0].ToArrayList(); var airArrayLen = inFre.Length; Trace("Array passed from AIR:", airArray); Trace("AIR Array length:", airArrayLen); var itemZero = inFre.At(0); var itemZeroVal = itemZero.AsInt(); Trace("AIR Array item 0 before change:", itemZeroVal); inFre.Set(0, 56); return(inFre.RawValue); }
public FREObject GetDisplayDevices(FREContext ctx, uint argc, FREObject[] argv) { var tmp = new FREObject().Init("Vector.<com.tuarua.DisplayDevice>", null); var vecDisplayDevices = new FREArray(tmp); var dd = new DisplayDevice(); dd.cb = Marshal.SizeOf(dd); _displayDeviceMap.Clear(); try { uint index = 0; uint cnt = 0; while (WinApi.EnumDisplayDevices(null, index++, ref dd, 0)) { var displayDevice = new FREObject().Init("com.tuarua.DisplayDevice", null); var displayMonitor = new FREObject().Init("com.tuarua.Monitor", null); displayDevice.SetProp("isPrimary", dd.StateFlags.HasFlag(DisplayDeviceStateFlags.PrimaryDevice)); displayDevice.SetProp("isActive", dd.StateFlags.HasFlag(DisplayDeviceStateFlags.AttachedToDesktop)); displayDevice.SetProp("isRemovable", dd.StateFlags.HasFlag(DisplayDeviceStateFlags.Removable)); displayDevice.SetProp("isVgaCampatible", dd.StateFlags.HasFlag(DisplayDeviceStateFlags.VgaCompatible)); var monitor = new DisplayDevice(); monitor.cb = Marshal.SizeOf(monitor); if (!WinApi.EnumDisplayDevices(dd.DeviceName, index - 1, ref monitor, 0)) { continue; } var dm = new Devmode(); dm.dmSize = (short)Marshal.SizeOf(dm); if (WinApi.EnumDisplaySettings(dd.DeviceName, WinApi.EnumCurrentSettings, ref dm) == 0) { continue; } var availdm = new Devmode(); availdm.dmSize = (short)Marshal.SizeOf(availdm); IList <DisplaySettings> availableDisplaySettings = new List <DisplaySettings>(); var freAvailableDisplaySettings = new FREArray(displayDevice.GetProp("availableDisplaySettings")); uint cntAvailableSettings = 0; for (var iModeNum = 0; WinApi.EnumDisplaySettings(dd.DeviceName, iModeNum, ref availdm) != 0; iModeNum++) { var settings = new DisplaySettings { Width = availdm.dmPelsWidth, Height = availdm.dmPelsHeight, BitDepth = Convert.ToInt32(availdm.dmBitsPerPel), RefreshRate = availdm.dmDisplayFrequency }; if (HasDisplaySetting(availableDisplaySettings, settings)) { continue; } availableDisplaySettings.Add(settings); var displaySettings = new FREObject().Init("com.tuarua.DisplaySettings", null); displaySettings.SetProp("width", availdm.dmPelsWidth); displaySettings.SetProp("height", availdm.dmPelsHeight); displaySettings.SetProp("refreshRate", availdm.dmDisplayFrequency); displaySettings.SetProp("bitDepth", Convert.ToInt32(availdm.dmBitsPerPel)); freAvailableDisplaySettings.Set(cntAvailableSettings, displaySettings); cntAvailableSettings++; } displayMonitor.SetProp("friendlyName", monitor.DeviceString); displayMonitor.SetProp("name", monitor.DeviceName); displayMonitor.SetProp("id", monitor.DeviceID); displayMonitor.SetProp("key", monitor.DeviceKey); displayDevice.SetProp("friendlyName", dd.DeviceString); displayDevice.SetProp("name", dd.DeviceName); displayDevice.SetProp("id", dd.DeviceID); displayDevice.SetProp("key", dd.DeviceKey); var currentDisplaySettings = new FREObject().Init("com.tuarua.DisplaySettings", null); currentDisplaySettings.SetProp("width", dm.dmPelsWidth); currentDisplaySettings.SetProp("height", dm.dmPelsHeight); currentDisplaySettings.SetProp("refreshRate", dm.dmDisplayFrequency); currentDisplaySettings.SetProp("bitDepth", Convert.ToInt32(dm.dmBitsPerPel)); displayDevice.SetProp("currentDisplaySettings", currentDisplaySettings); displayDevice.SetProp("monitor", displayMonitor); vecDisplayDevices.Set(cnt, displayDevice); _displayDeviceMap.Add(dd.DeviceKey, dd); cnt++; } } catch (Exception e) { Trace("ERROR: " + e); } return(vecDisplayDevices.RawValue); }