private void frmMain_Shown(object sender, EventArgs e) { if (!SimpleApp.IsElevated()) { MessageBox.Show("Run as administrator to modify registry values.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); btnApply.Enabled = false; } }
private void btnApply_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtX.Text + txtY.Text)) { return; } int width; int height; if (int.TryParse(txtX.Text, out width) && int.TryParse(txtY.Text, out height)) { SimpleApp.SetResolution(width, height); this.Text = $"{Application.ProductName} ({width}x{height})"; MessageBox.Show("Done!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Wrong values.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RegisterViews() { SimpleApp.RegisterView(typeof(MainView), typeof(MainViewModel)); SimpleApp.RegisterView(typeof(SecondView), typeof(SecondViewModel)); }
static void InitializeCefRuntime() { if (!IsSupportedByThisPlatform()) { return; } if (isCefRuntimeInitialized) { Log.Error("UIWebBrowser: InitializeCefRuntime: The CefRuntime is already initialized."); return; } if (SystemSettings.CurrentPlatform == SystemSettings.Platform.Windows) { NativeLibraryManager.PreLoadLibrary(Path.Combine("CefGlue", "libcef")); } //delete log file string realLogFileName = VirtualPathUtility.GetRealPathByVirtual("user:Logs\\UIWebBrowser_CefGlue.log"); try { if (File.Exists(realLogFileName)) { File.Delete(realLogFileName); } } catch { } try { CefRuntime.Load(); } catch (DllNotFoundException ex) { Log.Error("UIWebBrowser: InitializeCefRuntime: CefRuntime.Load: " + ex.Message); return; } catch (CefRuntimeException ex) { Log.Error("UIWebBrowser: InitializeCefRuntime: CefRuntime.Load: " + ex.Message); return; } catch (Exception ex) { Log.Error("UIWebBrowser: InitializeCefRuntime: CefRuntime.Load: " + ex.Message); return; } var mainArgs = new CefMainArgs(null); var cefApp = new SimpleApp(); var exitCode = CefRuntime.ExecuteProcess(mainArgs, cefApp, IntPtr.Zero); if (exitCode != -1) { Log.Error("UIWebBrowser: InitializeCefRuntime: CefRuntime.ExecuteProcess: Exit code: {0}", exitCode); return; } var cefSettings = new CefSettings { SingleProcess = true, WindowlessRenderingEnabled = true, MultiThreadedMessageLoop = true, LogSeverity = CefLogSeverity.Verbose, LogFile = realLogFileName, BrowserSubprocessPath = "", CachePath = "", }; ///// <summary> ///// Set to <c>true</c> to disable configuration of browser process features using ///// standard CEF and Chromium command-line arguments. Configuration can still ///// be specified using CEF data structures or via the ///// CefApp::OnBeforeCommandLineProcessing() method. ///// </summary> //public bool CommandLineArgsDisabled { get; set; } ///// <summary> ///// The fully qualified path for the resources directory. If this value is ///// empty the cef.pak and/or devtools_resources.pak files must be located in ///// the module directory on Windows/Linux or the app bundle Resources directory ///// on Mac OS X. Also configurable using the "resources-dir-path" command-line ///// switch. ///// </summary> //public string ResourcesDirPath { get; set; } try { CefRuntime.Initialize(mainArgs, cefSettings, cefApp, IntPtr.Zero); } catch (CefRuntimeException ex) { Log.Error("UIWebBrowser: InitializeCefRuntime: CefRuntime.Initialize: " + ex.Message); return; } isCefRuntimeInitialized = true; }
private void frmMain_Load(object sender, EventArgs e) { this.Text = $"{Application.ProductName} ({SimpleApp.GetResolution()})"; setTxtWatermark(txtX.Handle, "width"); setTxtWatermark(txtY.Handle, "height"); }