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" }; }
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); }
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" }; }
public KeyboardLLHook(IntPtr handler, IWindowOptions options, IKeyboadHookHandler keyboadHandler) : base(WH.KEYBOARD_LL) { _handler = handler; _options = options; _keyboadHandler = keyboadHandler; HookEventHandler = OnKeyboardEvent; }
public void ApplyOptions(IWindowOptions options) { _modal = options.Modal; _window.Width = options.Width; _window.Height = options.Height; _window.Left = options.Left; _window.Top = options.Top; }
public NativeHostBase(IChromelyConfiguration config, IWindowMessageInterceptor messageInterceptor, IKeyboadHookHandler keyboadHandler) { _config = config; _options = _config?.WindowOptions ?? new WindowOptions(); _isInitialized = false; _handle = IntPtr.Zero; _messageInterceptor = messageInterceptor; _keyboadHandler = keyboadHandler; }
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; }
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" }; }
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; } }
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(); }
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" }; }
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); }
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" }; }
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); }
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); }
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); }
public DefaulKeyboadHookHandler(IChromelyConfiguration config) { _options = config?.WindowOptions ?? new WindowOptions(); }
public KeyboardLLHook(IWindowOptions options) : base(WH.KEYBOARD_LL) { _options = options; HookEventHandler = OnKeyboardEvent; }
public DefaulKeyboadHookHandler(IChromelyNativeHost nativeHost, IWindowOptions options) { _nativeHost = nativeHost; _options = options; }
public virtual void ApplyOptions(IWindowOptions options) { }