Beispiel #1
0
        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);
        }
Beispiel #2
0
        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;

            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 itemZero    = inFre0.At(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());
        }
Beispiel #3
0
        public FREObject InitView(FREContext ctx, uint argc, FREObject[] argv)
        {
            _airWindow = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
            if (_airWindow == Hwnd.Zero)
            {
                var e = new Exception(
                    "Cannot find AIR window to attach webView to. Ensure you init the ANE AFTER your main Sprite is initialised. " +
                    "Please see https://forum.starling-framework.org/topic/webviewane-for-osx/page/7?replies=201#post-105524 for more details");
                return(new FreException(e).RawValue);
            }

            try {
                var viewPort       = argv[1].AsRect(); //viewPort
                var inFre2         = argv[2];          //settings
                var inFre4         = argv[4];          //backgroundColor
                var cefSettingsFre = inFre2.GetProp("cef");
                var useHiDpi       = argv[5].AsBool();

                var clArr    = new FREArray(cefSettingsFre.GetProp("commandLineArgs"));
                var argsDict = new Dictionary <string, string>();

                uint i;
                for (i = 0; i < clArr.Length; ++i)
                {
                    var argFre = clArr.At(i);
                    var key    = argFre.GetProp("key").AsString();
                    var val    = argFre.GetProp("value").AsString();
                    if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(val))
                    {
                        continue;
                    }
                    argsDict.Add(key, val);
                }

                var whiteList = inFre2.GetProp("urlWhiteList").ToArrayList();
                var blackList = inFre2.GetProp("urlBlackList").ToArrayList();
                _backgroundColor = inFre4.AsColor(true);
                _scaleFactor     = useHiDpi ? WinApi.GetScaleFactor() : 1.0;

                CefView.Context = Context;
                _view           = new CefView {
                    InitialUrl            = argv[0].AsString(),
                    Background            = new SolidColorBrush(_backgroundColor),
                    X                     = Convert.ToInt32(viewPort.X * _scaleFactor),
                    Y                     = Convert.ToInt32(viewPort.Y * _scaleFactor),
                    ViewWidth             = Convert.ToInt32(viewPort.Width * _scaleFactor),
                    ViewHeight            = Convert.ToInt32(viewPort.Height * _scaleFactor),
                    RemoteDebuggingPort   = cefSettingsFre.GetProp("remoteDebuggingPort").AsInt(),
                    CachePath             = cefSettingsFre.GetProp("cachePath").AsString(),
                    CacheEnabled          = inFre2.GetProp("cacheEnabled").AsBool(),
                    LogLevel              = cefSettingsFre.GetProp("logSeverity").AsInt(),
                    BrowserSubprocessPath = cefSettingsFre.GetProp("browserSubprocessPath").AsString(),
                    ContextMenuEnabled    = cefSettingsFre.GetProp("contextMenu").GetProp("enabled").AsBool(),
                    EnableDownloads       = cefSettingsFre.GetProp("enableDownloads").AsBool(),
                    UserAgent             = inFre2.GetProp("userAgent").AsString(),
                    CommandLineArgs       = argsDict,
                    WhiteList             = whiteList,
                    BlackList             = blackList,
                    PopupBehaviour        = (PopupBehaviour)inFre2.GetProp("popup").GetProp("behaviour").AsInt(),
                    PopupDimensions       = new Tuple <int, int>(
                        inFre2.GetProp("popup").GetProp("dimensions").GetProp("width").AsInt(),
                        inFre2.GetProp("popup").GetProp("dimensions").GetProp("height").AsInt()
                        )
                };
                _view.Init();
            }
            catch (Exception e) {
                return(new FreException(e).RawValue); //return as3 error and throw in swc
            }

            var parameters = new HwndSourceParameters();

            parameters.SetPosition(_view.X, _view.Y);
            parameters.SetSize(_view.ViewWidth, _view.ViewHeight);
            parameters.ParentWindow = _airWindow;
            parameters.WindowName   = "Cef Window";
            parameters.WindowStyle  = (int)WindowStyles.WS_CHILD;
            parameters.AcquireHwndFocusInMenuMode = true;
            var source = new HwndSource(parameters)
            {
                RootVisual = _view
            };

            _cefWindow = source.Handle;

            WinApi.RegisterTouchWindow(_cefWindow, TouchWindowFlags.TWF_WANTPALM);

            return(FREObject.Zero);
        }