public void Init(IWindow window, IWebview webview, IUiFactory windowFactory) { this.window = window ?? throw new ArgumentNullException(nameof(window)); this.webview = webview ?? throw new ArgumentNullException(nameof(webview)); this.windowFactory = windowFactory ?? throw new ArgumentNullException(nameof(windowFactory)); InitApi(); }
public CocoaWindow(WindowConfiguration config, IUiFactory windowFactory) { if (windowFactory == null) { throw new ArgumentNullException(nameof(windowFactory)); } this.config = config ?? throw new ArgumentNullException(nameof(config)); Interlocked.Increment(ref count); // need to keep the delegates around or they will get garbage collected windowShouldCloseDelegate = WindowShouldCloseCallback; windowWillCloseDelegate = WindowWillCloseCallback; Handle = AppKit.Call("NSWindow", "alloc"); var style = NSWindowStyleMask.Titled | NSWindowStyleMask.Closable | NSWindowStyleMask.Miniaturizable; if (config.CanResize) { style |= NSWindowStyleMask.Resizable; } ObjC.SendMessage( Handle, ObjC.RegisterName("initWithContentRect:styleMask:backing:defer:"), new CGRect(0, 0, config.Width, config.Height), (int)style, 2, 0); Title = config.Title; IntPtr bgColor = NSColor.FromHex(config.BackgroundColor); ObjC.Call(Handle, "setBackgroundColor:", bgColor); var contentProvider = new EmbeddedFileProvider(config.ContentAssembly, config.ContentFolder); bridge = new WebviewBridge(); webview = new CocoaWebview(config, contentProvider, bridge); ObjC.Call(Handle, "setContentView:", webview.Handle); if (config.EnableScriptInterface) { bridge.Init(this, webview, windowFactory); } if (config.UseBrowserTitle) { webview.TitleChanged += Webview_TitleChanged; bridge.TitleChanged += Webview_TitleChanged; } SetWindowDelegate(Handle); }
public WinFormsWindow(WindowConfiguration config, IUiFactory windowFactory) { if (windowFactory == null) { throw new ArgumentNullException(nameof(windowFactory)); } this.config = config ?? throw new ArgumentNullException(nameof(config)); bridge = new WebviewBridge(); var contentProvider = new EmbeddedFileProvider(config.ContentAssembly, config.ContentFolder); if (!config.ForceWindowsLegacyWebview && IsEdgeAvailable()) { webview = new WinFormsWebview(config, contentProvider, bridge); } else { string hostAddress; if (string.IsNullOrWhiteSpace(config.ExternalHost)) { server = new ContentServer(contentProvider); server.Start(); hostAddress = server.HostAddress; } else { hostAddress = config.ExternalHost; } webview = new WinFormsLegacyWebview(config, hostAddress, bridge); } webview.Control.Location = new Point(0, 0); webview.Control.Dock = DockStyle.Fill; Controls.Add(webview.Control); Text = config.Title; Width = config.Width; Height = config.Height; CanResize = config.CanResize; ColorTools.ParseHex(config.BackgroundColor, out byte r, out byte g, out byte b); BackColor = Color.FromArgb(r, g, b); if (config.EnableScriptInterface) { bridge.Init(this, webview, windowFactory); } if (config.UseBrowserTitle) { bridge.TitleChanged += Webview_TitleChanged; } SetIcon(config.Icon); }
public KeyFolderViewModel(IAppServices appServices, IUiFactory uiFactory, IDataViewModelFactory dataViewModelFactory) : base(appServices) { _uiFactory = uiFactory; _dataViewModelFactory = dataViewModelFactory; InitializeCommands(); }
public FolderViewModel(IAppServices appServices, IUiFactory uiFactory, IViewModelFactory userViewModelFactory) : base(appServices) { _userViewModelFactory = userViewModelFactory; _uiFactory = uiFactory; InitializeCommands(); SetupEvents(); }
public Form1(IUiFactory uiFactory) { InitializeComponent(); for (var i = 0; i < 10; i++) { panel.Controls.Add(uiFactory.GetCheckBox()); } panel.Controls.Add(uiFactory.GetButton()); }
public GtkWindow(WindowConfiguration config, IUiFactory windowFactory) { if (windowFactory == null) { throw new ArgumentNullException(nameof(windowFactory)); } this.config = config ?? throw new ArgumentNullException(nameof(config)); var contentProvider = new EmbeddedFileProvider(config.ContentAssembly, config.ContentFolder); bridge = new WebviewBridge(); webview = new GtkWebview(config, contentProvider, bridge); Handle = Gtk.Window.Create(GtkWindowType.Toplevel); Title = config.Title; Gtk.Window.SetResizable(Handle, config.CanResize); Gtk.Window.SetDefaultSize(Handle, config.Width, config.Height); string backgroundColor = config.BackgroundColor; if (string.IsNullOrWhiteSpace(backgroundColor)) { backgroundColor = "#FFFFFF"; } SetBackgroundColor(backgroundColor); IntPtr scroller = Gtk.Window.CreateScrolled(IntPtr.Zero, IntPtr.Zero); Gtk.Widget.ContainerAdd(Handle, scroller); Gtk.Widget.ContainerAdd(scroller, webview.Handle); // need to keep the delegates around or they will get garbage collected deleteDelegate = DeleteCallback; destroyDelegate = DestroyCallback; GLib.ConnectSignal(Handle, "delete-event", deleteDelegate, IntPtr.Zero); GLib.ConnectSignal(Handle, "destroy", destroyDelegate, IntPtr.Zero); webview.CloseRequested += Webview_CloseRequested; if (config.EnableScriptInterface) { bridge.Init(this, webview, windowFactory); } if (config.UseBrowserTitle) { webview.TitleChanged += Webview_TitleChanged; bridge.TitleChanged += Webview_TitleChanged; } SetIcon(config.Icon); }
public UserFolderViewModel( string name, string folderPath, IAppServices appServices, IUiFactory uiFactory) : base(appServices) { Name = name; FolderPath = folderPath; InitializeEvents(); _uiFactory = uiFactory; }
public Dialog(IWindow parent, IUiFactory windowFactory) { this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); this.windowFactory = windowFactory ?? throw new ArgumentNullException(nameof(windowFactory)); }
public Controller(IUiFactory uiFactory, IApi api) { _uiFactory = uiFactory; _api = api; }
public MainFormViewModel(IAppServices appServices, IUiFactory uiFactory) : base(appServices) { _uiFactory = uiFactory; InitializeCommands(); }
public MainWindowViewModel(IUiFactory uiFactory) { _uiFactory = uiFactory; InitCommands(); }