示例#1
0
        public static CefOptions GetCefOptions(this IAppFrame frame, FrameOptions options, FrameOptions oldOptions = null, object injectObj = null)
        {
            var cefOptions = new CefOptions
            {
                ContentPath   = options.ContentPath,
                InjectObjName = injectObj == null ? null : GlobalConfig.AppOptions.InjectObjName,
                GetInjectObj  = () => injectObj
            };

            if (oldOptions == null)
            {
                cefOptions.JsDialogHandler = new CefJsDialogHandler(frame);
            }

            //todo cef加载完成后,handler不可改
            //因draggable是可改选项,所以要加上这个判断,以减少创建CefDragHandler实例数,满足此条件代表之前的窗口没有设置过
            if ((oldOptions == null || !oldOptions.Draggable) && options.Draggable)
            {
                cefOptions.DragHandler = new CefDragHandler(frame);
            }

            if (options.IsMain == true)
            {
                cefOptions.KeyboardHandler = new CefKeyboardHandler();
            }

            return(cefOptions);
        }
示例#2
0
        public FrameMiddleware(ILoggerFactory factory, IAppFrame mainFrame)
        {
            _logger    = factory.CreateLogger(this.GetType());
            _mainFrame = mainFrame;

            framesMapper = new ConcurrentDictionary <string, IAppFrame>();
        }
示例#3
0
        private IAppFrame GetFrameById(string frameId)
        {
            IAppFrame frame = _mainFrame;

            if (!string.IsNullOrEmpty(frameId) && GlobalConfig.AppOptions.MainFrameId != frameId)
            {
                framesMapper.TryGetValue(frameId, out frame);
            }

            return(frame);
        }
示例#4
0
        private void Close(AppRequest request)
        {
            request.Frame.BeforeCloing();

            var hideToTray = true;

            if (request.Data != null && request.Data.Count > 0)
            {
                hideToTray = request.Data.Value <bool>("hideToTray");
            }

            IAppFrame frame = null;

            request.Frame.CloseFrame(hideToTray ? CloseTypes.Hide2Tray : CloseTypes.CloseSelf);
            this.framesMapper.TryRemove(request.FrameId, out frame);
        }
示例#5
0
 public CefJsDialogHandler(IAppFrame target)
 {
     this._targetForm = target;
 }
示例#6
0
 public CefDragHandler(IAppFrame target)
 {
     this._targetForm = target;
 }