2015-06-15 16:33:22 +08:00
// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
2014-10-07 09:03:00 +08:00
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
2018-08-12 15:09:27 +08:00
using CefSharp.WinForms ;
2014-10-07 09:03:00 +08:00
using System ;
2017-03-22 13:04:33 +08:00
using System.IO ;
2014-10-07 09:03:00 +08:00
using System.Windows.Forms ;
namespace CefSharp.MinimalExample.WinForms
{
2021-12-08 07:52:48 +08:00
public static class Program
2014-10-07 09:03:00 +08:00
{
[STAThread]
2020-02-10 10:20:12 +08:00
public static int Main ( string [ ] args )
2014-10-07 09:03:00 +08:00
{
2021-02-08 14:53:54 +08:00
#if ANYCPU
2021-06-22 10:12:03 +08:00
CefRuntime . SubscribeAnyCpuAssemblyResolver ( ) ;
2021-02-08 14:53:54 +08:00
#endif
2022-06-20 09:03:18 +08:00
// Programmatically enable DPI Aweness
// Can also be done via app.manifest or app.config
// https://github.com/cefsharp/CefSharp/wiki/General-Usage#high-dpi-displayssupport
// If set via app.manifest this call will have no effect.
2016-09-20 09:58:37 +08:00
Cef . EnableHighDPISupport ( ) ;
2017-03-22 13:04:33 +08:00
var settings = new CefSettings ( )
{
//By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
CachePath = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , "CefSharp\\Cache" )
} ;
2018-07-13 08:48:52 +08:00
//Example of setting a command line argument
//Enables WebRTC
2020-09-09 15:51:12 +08:00
// - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access
// - CEF Doesn't currently support displaying a UI for media access permissions
//
//NOTE: WebRTC Device Id's aren't persisted as they are in Chrome see https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart
2020-05-23 10:11:28 +08:00
settings . CefCommandLineArgs . Add ( "enable-media-stream" ) ;
2020-09-09 15:51:12 +08:00
//https://peter.sh/experiments/chromium-command-line-switches/#use-fake-ui-for-media-stream
settings . CefCommandLineArgs . Add ( "use-fake-ui-for-media-stream" ) ;
//For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180)
settings . CefCommandLineArgs . Add ( "enable-usermedia-screen-capturing" ) ;
2015-11-05 07:13:24 +08:00
//Perform dependency check to make sure all relevant resources are in our output directory.
2021-04-07 13:52:14 +08:00
Cef . Initialize ( settings , performDependencyCheck : true , browserProcessHandler : null ) ;
2014-10-07 09:03:00 +08:00
var browser = new BrowserForm ( ) ;
Application . Run ( browser ) ;
2020-02-10 10:20:12 +08:00
return 0 ;
2014-10-07 09:03:00 +08:00
}
}
}