Exemplo n.º 1
0
        public DefaultConfiguration()
        {
            AppName            = Assembly.GetEntryAssembly()?.GetName().Name;
            Platform           = ChromelyRuntime.Platform;
            AppExeLocation     = AppDomain.CurrentDomain.BaseDirectory;
            StartUrl           = "local://app/chromely.html";
            DebuggingMode      = true;
            UrlSchemes         = new List <UrlScheme>();
            CefDownloadOptions = new CefDownloadOptions();
            WindowOptions      = new WindowOptions
            {
                Title = AppName
            };

            UrlSchemes.AddRange(new List <UrlScheme>()
            {
                new UrlScheme("default-resource", "local", string.Empty, string.Empty, UrlSchemeType.Resource, false),
                new UrlScheme("default-resource", "local", string.Empty, string.Empty, UrlSchemeType.Resource, false),
                new UrlScheme("default-custom-http", "http", "chromely.com", string.Empty, UrlSchemeType.Custom, false),
                new UrlScheme("default-command-http", "http", "command.com", string.Empty, UrlSchemeType.Command, false),
                new UrlScheme("chromely-site", string.Empty, string.Empty, "https://github.com/chromelyapps/Chromely", UrlSchemeType.External, true)
            });

            ControllerAssemblies = new List <ControllerAssemblyInfo>();
            ControllerAssemblies.RegisterServiceAssembly("Chromely.External.Controllers.dll");

            CustomSettings = new Dictionary <string, string>()
            {
                ["cefLogFile"]  = "logs\\chromely.cef.log",
                ["logSeverity"] = "info",
                ["locale"]      = "en-US"
            };
        }
Exemplo n.º 2
0
        public virtual void CreateWindow(IWindowOptions options, bool debugging)
        {
            _options     = options;
            _configParam = InitParam(RunCallback,
                                     ShutdownCallback,
                                     InitCallback,
                                     CreateCallback,
                                     MovingCallback,
                                     ResizeCallback,
                                     QuitCallback);


            _configParam.centerscreen = _options.WindowState == WindowState.Normal && _options.StartCentered ? 1 : 0;
            _configParam.frameless    = _options.WindowFrameless ? 1 : 0;
            _configParam.fullscreen   = _options.WindowState == Core.Host.WindowState.Fullscreen ? 1 : 0;
            _configParam.noresize     = _options.DisableResizing ? 1 : 0;
            _configParam.nominbutton  = _options.DisableMinMaximizeControls ? 1 : 0;
            _configParam.nomaxbutton  = _options.DisableMinMaximizeControls ? 1 : 0;

            _configParam.title = _options.Title;

            _configParam.x      = _options.Position.X;
            _configParam.y      = _options.Position.Y;
            _configParam.width  = _options.Size.Width;
            _configParam.height = _options.Size.Height;

            createwindow(ref _configParam);
        }
Exemplo n.º 3
0
        public DefaultConfiguration()
        {
            AppName            = Assembly.GetEntryAssembly()?.GetName().Name;
            Platform           = ChromelyRuntime.Platform;
            AppExeLocation     = AppDomain.CurrentDomain.BaseDirectory;
            StartUrl           = "local://app/index.html";
            DebuggingMode      = true;
            UrlSchemes         = new List <UrlScheme>();
            CefDownloadOptions = new CefDownloadOptions();
            WindowOptions      = new WindowOptions();
            if (string.IsNullOrWhiteSpace(WindowOptions.Title))
            {
                WindowOptions.Title = AppName;
            }

            UrlSchemes.AddRange(new List <UrlScheme>()
            {
                new UrlScheme(DefaultSchemeName.RESOURCE, "local", string.Empty, string.Empty, UrlSchemeType.Resource, false),
                new UrlScheme(DefaultSchemeName.REQUEST, "http", "chromely.com", string.Empty, UrlSchemeType.LocalRquest, false),
                new UrlScheme(DefaultSchemeName.COMMAND, "http", "command.com", string.Empty, UrlSchemeType.Command, false),
                new UrlScheme(DefaultSchemeName.GITHUBSITE, string.Empty, string.Empty, "https://github.com/chromelyapps/Chromely", UrlSchemeType.ExternalBrowser, true)
            });

            ControllerAssemblies = new List <ControllerAssemblyInfo>();
            CustomSettings       = new Dictionary <string, string>()
            {
                ["cefLogFile"]  = "logs\\chromely.cef.log",
                ["logSeverity"] = "info",
                ["locale"]      = "en-US"
            };
        }
Exemplo n.º 4
0
 public KeyboardLLHook(IntPtr handler, IWindowOptions options, IKeyboadHookHandler keyboadHandler) : base(WH.KEYBOARD_LL)
 {
     _handler         = handler;
     _options         = options;
     _keyboadHandler  = keyboadHandler;
     HookEventHandler = OnKeyboardEvent;
 }
Exemplo n.º 5
0
 public void ApplyOptions(IWindowOptions options)
 {
     _modal = options.Modal;
      _window.Width = options.Width;
      _window.Height = options.Height;
      _window.Left = options.Left;
      _window.Top = options.Top;
 }
Exemplo n.º 6
0
        public NativeHostBase(IChromelyConfiguration config, IWindowMessageInterceptor messageInterceptor, IKeyboadHookHandler keyboadHandler)
        {
            _config  = config;
            _options = _config?.WindowOptions ?? new WindowOptions();

            _isInitialized      = false;
            _handle             = IntPtr.Zero;
            _messageInterceptor = messageInterceptor;
            _keyboadHandler     = keyboadHandler;
        }
Exemplo n.º 7
0
 public ChromelyMacHost(IChromelyConfiguration config)
 {
     _config        = config;
     _options       = _config?.WindowOptions ?? new WindowOptions();
     _appHandle     = IntPtr.Zero;
     _poolHandle    = IntPtr.Zero;
     _windowHandle  = IntPtr.Zero;
     _viewHandle    = IntPtr.Zero;
     _isInitialized = false;
 }
Exemplo n.º 8
0
 public WindowStylePlacement(IWindowOptions options)
 {
     RECT            = new Rectangle(options.Position.X, options.Position.Y, options.Size.Width, options.Size.Height);
     WindowPlacement = new WINDOWPLACEMENT();
     if (options.CustomStyle is not null &&
         options.CustomStyle.WindowStyles != 0 &&
         options.CustomStyle.WindowExStyles != 0)
     {
         Styles   = (WS)options.CustomStyle.WindowStyles;
         ExStyles = (WS_EX)options.CustomStyle.WindowExStyles;
     }
        internal MyChromelyConfiguration()
        {
            AppName        = "模块化项目管理器 Ver:" + Assembly.GetEntryAssembly()?.GetName().Version.ToString();
            Platform       = ChromelyRuntime.Platform;
            AppExeLocation = AppDomain.CurrentDomain.BaseDirectory;
            //StartUrl = "local://app/chromely.html";
            StartUrl           = "http://127.0.0.1:8080/modular-project-main/";
            DebuggingMode      = false;
            UrlSchemes         = new List <UrlScheme>();
            CefDownloadOptions = new CefDownloadOptions();
            WindowOptions      = new WindowOptions {
                RelativePathToIconFile = @"X:\Projects\modular\maker\ModularProject.Chromely\client.ico",
                Title = AppName,
                Size  = new WindowSize(1200, 700)
            };

            UrlSchemes.AddRange(new List <UrlScheme>()
            {
                new UrlScheme(DefaultSchemeName.RESOURCE, "local", string.Empty, string.Empty, UrlSchemeType.Resource, false),
                new UrlScheme(DefaultSchemeName.CUSTOM, "http", "chromely.com", string.Empty, UrlSchemeType.Custom, false),
                new UrlScheme(DefaultSchemeName.COMMAND, "http", "command.com", string.Empty, UrlSchemeType.Command, false),
                new UrlScheme(DefaultSchemeName.GITHUBSITE, string.Empty, string.Empty, "https://github.com/chromelyapps/Chromely", UrlSchemeType.External, true)
            });

            ControllerAssemblies = new List <ControllerAssemblyInfo>();

            var appDirectory           = AppDomain.CurrentDomain.BaseDirectory;
            var externalControllerFile = Path.Combine(appDirectory, "Chromely.External.Controllers.dll");

            if (File.Exists(externalControllerFile))
            {
                ControllerAssemblies.RegisterServiceAssembly("Chromely.External.Controllers.dll");
                var assemblyOptions = new AssemblyOptions(externalControllerFile, null, "app");
                UrlSchemes.Add(new UrlScheme(DefaultSchemeName.ASSEMBLYRESOURCE, "assembly", "app", string.Empty, UrlSchemeType.AssemblyResource, false, assemblyOptions));

                var mixAssemblyOptions = new AssemblyOptions(externalControllerFile, null, "appresources");
                UrlSchemes.Add(new UrlScheme(DefaultSchemeName.MIXASSEMBLYRESOURCE, "mixassembly", "app", string.Empty, UrlSchemeType.AssemblyResource, false, mixAssemblyOptions));
            }

            CustomSettings = new Dictionary <string, string>()
            {
                ["cefLogFile"]  = "logs\\chromely.cef.log",
                ["logSeverity"] = "info",
                ["locale"]      = "zh-CN"
            };
        }
Exemplo n.º 10
0
 public WindowStylePlacement(IWindowOptions options)
 {
     RECT            = new System.Drawing.Rectangle(options.Position.X, options.Position.Y, options.Size.Width, options.Size.Height);
     WindowPlacement = new WINDOWPLACEMENT();
     if (options.CustomStyle != null &&
         options.CustomStyle.WindowStyles != 0 &&
         options.CustomStyle.WindowExStyles != 0)
     {
         Styles   = (WS)options.CustomStyle.WindowStyles;
         ExStyles = (WS_EX)options.CustomStyle.WindowExStyles;
     }
     else
     {
         Styles   = NormalStyles;
         ExStyles = NormalExStyles;
     }
 }
Exemplo n.º 11
0
    public virtual void CreateWindow(IWindowOptions config, bool debugging)
    {
        _options   = config;
        _debugging = debugging;

        Init(0, null);

        var wndType = _options.WindowFrameless
            ? GtkWindowType.GtkWindowPopup
            : GtkWindowType.GtkWindowToplevel;

        _handle = CreateNewWindow((int)wndType);

        SetWindowTitle(_options.Title);
        SetAppIcon(_handle, _options.RelativePathToIconFile);
        SetWindowDefaultSize(_options.Size.Width, _options.Size.Height);

        if (_options.WindowState == WindowState.Normal && _options.StartCentered)
        {
            SetWindowPosistion((int)GtkWindowPosition.GtkWinPosCenter);
        }

        switch (_options.WindowState)
        {
        case WindowState.Normal:
            break;

        case WindowState.Maximize:
            SetWindowMaximize();
            break;

        case WindowState.Fullscreen:
            SetFullscreen();
            break;
        }

        ConnectRealizeSignal(_onRealizedDelegate, _onFreeNotify);
        ConnectSizeAllocateSignal(_onSizeAllocateDelegate, _onFreeNotify);
        ConnectResizeSignal(_onResizeDelegate, _onFreeNotify);
        ConnectDestroySignal(_onDestroyDelegate, _onFreeNotify);

        SetDefaultWindowVisual(_handle);

        ShowWindow();
    }
Exemplo n.º 12
0
        public DefaultConfiguration()
        {
            AppName            = Assembly.GetEntryAssembly()?.GetName().Name;
            Platform           = ChromelyRuntime.Platform;
            AppExeLocation     = AppDomain.CurrentDomain.BaseDirectory;
            StartUrl           = "local://app/chromely.html";
            DebuggingMode      = true;
            UrlSchemes         = new List <UrlScheme>();
            CefDownloadOptions = new CefDownloadOptions();
            WindowOptions      = new WindowOptions
            {
                Title = AppName
            };

            UrlSchemes.AddRange(new List <UrlScheme>()
            {
                new UrlScheme(DefaultSchemeName.RESOURCE, "local", string.Empty, string.Empty, UrlSchemeType.Resource, false),
                new UrlScheme(DefaultSchemeName.CUSTOM, "http", "chromely.com", string.Empty, UrlSchemeType.Custom, false),
                new UrlScheme(DefaultSchemeName.COMMAND, "http", "command.com", string.Empty, UrlSchemeType.Command, false),
                new UrlScheme(DefaultSchemeName.GITHUBSITE, string.Empty, string.Empty, "https://github.com/chromelyapps/Chromely", UrlSchemeType.External, true)
            });

            ControllerAssemblies = new List <ControllerAssemblyInfo>();

            var appDirectory           = AppDomain.CurrentDomain.BaseDirectory;
            var externalControllerFile = Path.Combine(appDirectory, "Chromely.External.Controllers.dll");

            if (File.Exists(externalControllerFile))
            {
                ControllerAssemblies.RegisterServiceAssembly("Chromely.External.Controllers.dll");
                var assemblyOptions = new AssemblyOptions(externalControllerFile, null, "app");
                UrlSchemes.Add(new UrlScheme(DefaultSchemeName.ASSEMBLYRESOURCE, "assembly", "app", string.Empty, UrlSchemeType.AssemblyResource, false, assemblyOptions));

                var mixAssemblyOptions = new AssemblyOptions(externalControllerFile, null, "appresources");
                UrlSchemes.Add(new UrlScheme(DefaultSchemeName.MIXASSEMBLYRESOURCE, "mixassembly", "app", string.Empty, UrlSchemeType.AssemblyResource, false, mixAssemblyOptions));
            }

            CustomSettings = new Dictionary <string, string>()
            {
                ["cefLogFile"]  = "logs\\chromely.cef.log",
                ["logSeverity"] = "info",
                ["locale"]      = "en-US"
            };
        }
Exemplo n.º 13
0
    public ChromelyLinuxHost(IChromelyConfiguration config)
    {
        _config    = config;
        _options   = _config?.WindowOptions ?? new WindowOptions();
        _debugging = _config == null ? false : _config.DebuggingMode;

        gdk_set_allowed_backends("x11");

        _isInitialized = false;
        _handle        = IntPtr.Zero;
        _xid           = IntPtr.Zero;

        _onRealizedDelegate     = new RealizeCallback(OnRealized);
        _onSizeAllocateDelegate = new SizeAllocateCallback(OnSizeAllocate);
        _onResizeDelegate       = new ResizeCallback(OnResize);
        _onDestroyDelegate      = new DestroyCallback(OnDestroy);

        _onFreeNotify = new GClosureNotify(FreeData);

        _onHandleErrorDelegate   = new XHandleXError(HandleError);
        _onHandleIOErrorDelegate = new XHandleXIOError(HandleIOError);
    }
Exemplo n.º 14
0
        public ChromelyConfig()
        {
            AppName        = "TestApp";
            Platform       = ChromelyRuntime.Platform;
            AppExeLocation = AppDomain.CurrentDomain.BaseDirectory;
            StartUrl       = "local://dist/index.html";
            DebuggingMode  = true;

            CefDownloadOptions = new CefDownloadOptions();
            WindowOptions      = new WindowOptions
            {
                Title                  = AppName,
                StartCentered          = true,
                Size                   = new WindowSize(1600, 900),
                RelativePathToIconFile = "chromely.ico",
                WindowFrameless        = true,
                FramelessOption        = new FramelessOption
                {
                    UseWebkitAppRegions = true
                }
            };

            UrlSchemes = new List <UrlScheme>();
            UrlSchemes.AddRange(new List <UrlScheme>()
            {
                new UrlScheme(DefaultSchemeName.RESOURCE, "local", string.Empty, string.Empty, UrlSchemeType.Resource, false),
                new UrlScheme(DefaultSchemeName.CUSTOM, "http", "chromely.com", string.Empty, UrlSchemeType.Custom, false),
                new UrlScheme(DefaultSchemeName.COMMAND, "http", "command.com", string.Empty, UrlSchemeType.Command, false)
            });

            ControllerAssemblies = new List <ControllerAssemblyInfo>();
            CustomSettings       = new Dictionary <string, string>()
            {
                ["cefLogFile"]  = "logs\\chromely.cef.log",
                ["logSeverity"] = "info",
                ["locale"]      = "en-US"
            };
        }
Exemplo n.º 15
0
 protected override void Before_each_spec()
 {
     _presenter = Create<ExampleWidgetPresenter>();
      _windowManager = Mock<IWindowManager>();
      _windowAdapter = Mock<IWindowAdapter>();
      _windowOptions = Mock<IWindowOptions>();
      _request = new Request();
      _request.SetItem("data", "test");
      SetupResult.For(_windowManager.CreateWindowFor(_presenter)).Return(_windowAdapter);
 }
Exemplo n.º 16
0
        public unsafe virtual void CreateWindow(IWindowOptions options, bool debugging)
        {
            _keyboadHandler?.SetNativeHost(this);
            _options         = options;
            _windowFrameless = _options.WindowFrameless;

            _wndProc = WndProc;
            _consoleParentInstance = GetConsoleWindow();
            _options.WindowState   = (_options.Fullscreen || _options.KioskMode) ?  WindowState.Fullscreen : _options.WindowState;
            _windoStylePlacement   = new WindowStylePlacement(_options);

            User32.WNDCLASS wcex = new User32.WNDCLASS();
            wcex.style         = User32.CS.HREDRAW | User32.CS.VREDRAW;
            wcex.lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(_wndProc);
            wcex.cbClsExtra    = 0;
            wcex.cbWndExtra    = 0;
            wcex.hIcon         = GetIconHandle();
            wcex.hCursor       = User32.LoadCursorW(IntPtr.Zero, (IntPtr)CursorResourceId.IDC_ARROW);
            wcex.hbrBackground = Gdi32.GetStockObject(Gdi32.StockObject.WHITE_BRUSH);
            wcex.lpszMenuName  = null;
            wcex.hInstance     = _consoleParentInstance;

            fixed(char *c = Chromely_WINDOW_CLASS)
            {
                wcex.lpszClassName = c;
            }

            if (User32.RegisterClassW(ref wcex) == 0)
            {
                Logger.Instance.Log.LogError("Chromelywindow registration failed");
                return;
            }

            var stylePlacement = GetWindowStylePlacement(_options.WindowState);

            var hWnd = User32.CreateWindowExW(
                stylePlacement.ExStyles,
                Chromely_WINDOW_CLASS,
                _options.Title,
                stylePlacement.Styles,
                stylePlacement.RECT.left,
                stylePlacement.RECT.top,
                stylePlacement.RECT.Width,
                stylePlacement.RECT.Height,
                IntPtr.Zero,
                IntPtr.Zero,
                _consoleParentInstance,
                null);

            if (hWnd == IntPtr.Zero)
            {
                Logger.Instance.Log.LogError("Chromelywindow creation failed");
                return;
            }

            PlaceWindow(hWnd, stylePlacement);
            InstallHooks(hWnd);
            ShowWindow(hWnd, stylePlacement.ShowCommand);
            UpdateWindow(hWnd);
            RegisterHotKeys(hWnd);
        }
Exemplo n.º 17
0
        public void CreateWindow(IWindowOptions options, bool debugging)
        {
            _options = options;
            _wndProc = WndProc;
            _consoleParentInstance = GetConsoleWindow();

            WNDCLASSEX wcex = new WNDCLASSEX();

            wcex.style         = ClassStyles.HorizontalRedraw | ClassStyles.VerticalRedraw;
            wcex.cbSize        = (uint)Marshal.SizeOf(wcex);
            wcex.lpfnWndProc   = _wndProc;
            wcex.cbClsExtra    = 0;
            wcex.cbWndExtra    = 0;
            wcex.hIcon         = GetIconHandle();
            wcex.hIconSm       = GetIconHandle();
            wcex.hCursor       = LoadCursor(IntPtr.Zero, (int)IDC_ARROW);
            wcex.hbrBackground = GetStockObject(StockObjects.WHITE_BRUSH);
            wcex.lpszMenuName  = null;
            wcex.lpszClassName = "chromelywindow";
            wcex.hInstance     = _consoleParentInstance;

            if (RegisterClassEx(ref wcex) == 0)
            {
                Logger.Instance.Log.Error("chromelywindow registration failed");
                return;
            }

            var styles = GetWindowStyles(_options.WindowState);

            WinNativeMethods.RECT rect;
            rect.Left   = _options.Position.X;
            rect.Top    = _options.Position.Y;
            rect.Right  = _options.Position.X + _options.Size.Width;
            rect.Bottom = _options.Position.Y + _options.Size.Height;

            AdjustWindowRectEx(ref rect, styles.Item1, false, styles.Item2);

            var hWnd = CreateWindowEx(styles.Item2,
                                      ClassName,
                                      _options.Title,
                                      styles.Item1,
                                      rect.Left,
                                      rect.Top,
                                      rect.Width,
                                      rect.Height,
                                      IntPtr.Zero,
                                      IntPtr.Zero,
                                      IntPtr.Zero,
                                      IntPtr.Zero);

            if (hWnd == IntPtr.Zero)
            {
                Logger.Instance.Log.Error("chromelywindow creation failed");
                return;
            }

            if (_options.KioskMode)
            {
                //// Set new window style and size.
                var windowHDC        = GetDC(hWnd);
                var fullscreenWidth  = GetDeviceCaps(windowHDC, (int)DeviceCap.HORZRES);
                var fullscreenHeight = GetDeviceCaps(windowHDC, (int)DeviceCap.VERTRES);
                ReleaseDC(hWnd, windowHDC);

                SetWindowLongPtr(hWnd, (int)WindowLongFlags.GWL_STYLE, (IntPtr)styles.Item1);
                SetWindowLongPtr(hWnd, (int)WindowLongFlags.GWL_EXSTYLE, (IntPtr)styles.Item2);

                SetWindowPos(hWnd, (IntPtr)HwndZOrder.Top, 0, 0, fullscreenWidth, fullscreenHeight,
                             SetWindowPosFlags.IgnoreZOrder | SetWindowPosFlags.FrameChanged);

                ShowWindow(hWnd, ShowWindowCommand.SW_MAXIMIZE);

                try
                {
                    this._hookID = SetHook(_hookCallback);
                }
                catch
                {
                    DetachKeyboardHook();
                }
            }
            else
            {
                // Center window if State is Normal
                if (_options.WindowState == WindowState.Normal && _options.StartCentered)
                {
                    CenterWindowToScreen(hWnd);
                }

                ShowWindow(hWnd, styles.Item3);
            }

            UpdateWindow(hWnd);
            RegisterHotKey(IntPtr.Zero, 1, (uint)KeyModifiers.Control, (uint)Keyboard.VirtualKeyStates.L);
        }
Exemplo n.º 18
0
 public DefaulKeyboadHookHandler(IChromelyConfiguration config)
 {
     _options = config?.WindowOptions ?? new WindowOptions();
 }
Exemplo n.º 19
0
 public KeyboardLLHook(IWindowOptions options) : base(WH.KEYBOARD_LL)
 {
     _options         = options;
     HookEventHandler = OnKeyboardEvent;
 }
Exemplo n.º 20
0
 public DefaulKeyboadHookHandler(IChromelyNativeHost nativeHost, IWindowOptions options)
 {
     _nativeHost = nativeHost;
     _options    = options;
 }
Exemplo n.º 21
0
 public virtual void ApplyOptions(IWindowOptions options)
 {
 }