Example #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);
        }
        /// <summary>
        /// Use this ctor to specify a custom origin.
        /// </summary>
        /// <param name="origin">The origin to allow.</param>
        public FrameOptionsAttribute(string origin)
        {
            if (String.IsNullOrWhiteSpace(origin)) throw new ArgumentNullException("origin");

            this.options = FrameOptions.CustomOrigin;
            this.customOrigin = origin;
        }
        /// <summary>
        /// Use this ctor to specify a custom origin.
        /// </summary>
        /// <param name="origin">The origin to allow.</param>
        public FrameOptionsAttribute(string origin)
        {
            if (string.IsNullOrWhiteSpace(origin)) throw new ArgumentNullException(nameof(origin));

            _options = FrameOptions.CustomOrigin;
            CustomOrigin = origin;
        }
Example #4
0
        public AppFrame(FrameOptions options)
            : base(options?.ShowHeaderBar, AppConfiguration.GetConfig <bool>("debug.showdevtools"), options?.Resizable)
        {
            if (this.DesignMode)
            {
                return;
            }

            //todo dynamic set
            var iconPath = $"app.ico";

            if (File.Exists(iconPath))
            {
                this.Icon = new Icon(iconPath);
            }
            this.BackColor = Color.FromArgb(241, 242, 244);
            this._options  = options ?? new FrameOptions();

            Load += (sender, e) =>
            {
                ResetOptions(options);
                this.ReloadConcent = () => this.Reload();
                this.ShowTools     = () => this.ShowDevTools();
                this.CloseLocale   = () => this.CloseFrame(CloseTypes.CloseSelf);
                this.LoadCEF(this.GetCefOptions(options, injectObj: AppHoster.Instance));
            };
            ResizeEnd += (s, e) => this.ResetCentralPoint();
        }
Example #5
0
        private void ResetOptions(FrameOptions options, bool includePosition = true)
        {
            if (DesignMode)
            {
                return;
            }

            this.SuspendLayout();

            this._options = options ?? new FrameOptions();

            var miniSize = new SizeF(this._options.MinWidth * DpiRatioX, this._options.MinHeight * DpiRatioY);

            if (miniSize.Width == 0)
            {
                miniSize.Width = this._options.Width * 0.7f * DpiRatioX;
            }
            if (miniSize.Height == 0)
            {
                miniSize.Height = this._options.Height * 0.7f * DpiRatioY;
            }
            this.MinimumSize = miniSize.ToSize();
            this.MaximumSize = new SizeF(Screen.PrimaryScreen.WorkingArea.Width * DpiRatioX, Screen.PrimaryScreen.WorkingArea.Height * DpiRatioY).ToSize();
            this.ClientSize  = new SizeF(this._options.Width * DpiRatioX, (this._options.Height + this._localHeaderHeight) * DpiRatioY).ToSize();

            if (includePosition)
            {
                this.SetFormPosition();
            }

            this.Text = options.Name;
            this.ResetCentralPoint();

            this.ResumeLayout();
        }
        /// <summary>
        /// Use this ctor to specify a custom origin.
        /// </summary>
        /// <param name="origin">The origin to allow.</param>
        public FrameOptionsAttribute(string origin)
        {
            if (String.IsNullOrWhiteSpace(origin))
            {
                throw new ArgumentNullException("origin");
            }

            this.options      = FrameOptions.CustomOrigin;
            this.customOrigin = origin;
        }
Example #7
0
        public IAppFrame ShowSubForm(FrameOptions options)
        {
            AppFrame frame = null;

            this.InvokeActionSafely(() =>
            {
                frame = new AppFrame(options);
                if (options.IsModal)
                {
                    this.Enabled = false;
                    frame.Show(this);
                }
                else
                {
                    frame.Show();
                }
            });
            return(frame);
        }
Example #8
0
        public void ResetFrame(FrameOptions options)
        {
            this.InvokeActionSafely(() =>
            {
                if (options == null)
                {
                    return;
                }

                var isSameContent = options?.ContentPath == _options?.ContentPath;
                this.ChangeProps(options.Resizable);
                ResetOptions(options);

                if (!isSameContent && !string.IsNullOrEmpty(options.ContentPath))
                {
                    this.LoadCEF(this.GetCefOptions(options, this._options));
                }
            });
        }
        /// <summary>
        /// Build a DialogueScene from this ImmersiveMonologue
        /// </summary>
        public DialogueScene BuildDialogueScene()
        {
            string defaultFrameName = "f_0";

            Dictionary <string, Frame> frames = new Dictionary <string, Frame>();
            DialogueScene dialogueScene       = new DialogueScene(frames, defaultFrameName, Music);

            for (int i = 0; i < Nodes.Length; i++)
            {
                var node = Nodes[i];

                string       next    = (i == (Nodes.Length - 1)) ? "meta.return" : $"f_{i+1}";
                FrameOptions options = new FrameOptions(new Dictionary <string, object>()
                {
                    { nameof(FrameOptions.HideNameText), HideNameText },
                    { nameof(FrameOptions.VoiceOverride), node.VoiceOverride },
                    { nameof(FrameOptions.PanelHeight), node.PanelHeight != ChoicePanelHeight.Default ? node.PanelHeight : PanelHeight },
                    { nameof(FrameOptions.PanelHeightPixels), node.PanelHeightPixels }
                });

                TextFrame frame = new TextFrame(null, null, next, null, null, node.Text, node.NextText, null, default, node.AllowSkip, node.TimeToShow, node.TimeToShow > 0, null, null, options, null, dialogueScene, null, JValue.CreateNull(), null);
 /// <summary>
 /// Use this ctor to specify the FrameOptions.
 /// </summary>
 /// <param name="options">FrameOptions to use.</param>
 public FrameOptionsAttribute(FrameOptions options)
 {
     this.options = options;
 }
 /// <summary>
 /// This default ctor uses FrameOptions.Deny.
 /// </summary>
 public FrameOptionsAttribute()
 {
     this.options = FrameOptions.Deny;
 }
 /// <summary>
 /// Use this ctor to specify the FrameOptions.
 /// </summary>
 /// <param name="options">FrameOptions to use.</param>
 public FrameOptionsAttribute(FrameOptions options)
 {
     this.options = options;
 }
 /// <summary>
 /// This default ctor uses FrameOptions.Deny.
 /// </summary>
 public FrameOptionsAttribute()
 {
     this.options = FrameOptions.Deny;
 }
 /// <summary>
 /// Use this ctor to specify the FrameOptions.
 /// </summary>
 /// <param name="options">FrameOptions to use.</param>
 public FrameOptionsAttribute(FrameOptions options)
 {
     _options = options;
 }
 /// <summary>
 /// This default ctor uses FrameOptions.Deny.
 /// </summary>
 public FrameOptionsAttribute()
 {
     _options = FrameOptions.Deny;
 }
Example #16
0
 public override void DrawFrame(Rectangle rect, FrameOptions opts = null)
 {
 }