-
Notifications
You must be signed in to change notification settings - Fork 7
C# CefSharp.WinForms.Web.Browser__Plugins.Plugins.list | Profile\(UserPrefs.json) | (C#) Add to (plugins.plugins_list)
Mohammed Osama Mohamed Sayed Ahmed edited this page Jul 7, 2019
·
3 revisions
C# CefSharp WinForms Web Browser__Plugins.Plugins.list | Profile\UserPrefs.json | (C#) Add to plugins.plugins_list
C:\Users\ <User> \.AppPathProfileUserDataCefSharp\UserPrefs.json
{"plugins":{"plugins_list":[
{"Description":"VLC Player Web Plugin","Name":"VLC Web Plugin","Path":"C:\\Program Files (x86)\\VideoLAN\\VLC\\npvlc.dll","Version":"3.0.3"},
{"Description":"Widevine Content Decryption Module","Name":"WidevineCdm","Path":".\\WidevineCdm\\widevinecdm.dll","Version":"4.10.1303.2"},
{"Description":"Widevine Content Decryption Module - widevinecdmadapter.dll","Name":"WidevineCdm Web Adapter","Path":".\\WidevineCdm\\widevinecdmadapter.dll","Version":"1.4.9.1088"}
]},
New.Get.14.Create.Browser.User.Example.Auto.CefSharp.Web.Browser.Version.73.1.130_73.0.3683.75__Other-2019-07-07__Default.sln.zip
#region
string error;
Cef.UIThreadTaskFactory.StartNew(delegate
{
ChromiumWebBrowser.RequestContext.SetPreference("plugins.plugins_list", new List<object> {
new WebPluginInfo(name: "VLC Web Plugin", description: "VLC Player Web Plugin", path: @"C:\Program Files (x86)\VideoLAN\VLC\npvlc.dll", version: "3.0.3"),
new WebPluginInfo(name: "WidevineCdm", description: "Widevine Content Decryption Module", path: @".\WidevineCdm\widevinecdm.dll", version: "4.10.1303.2"),
new WebPluginInfo(name: "WidevineCdm Web Adapter", description: "Widevine Content Decryption Module - widevinecdmadapter.dll", path: @".\WidevineCdm\widevinecdmadapter.dll", version: "1.4.9.1088")
}, out error); // List (".....",".........") }, out error);
});
#endregion
public CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
var headers = request.Headers;
headers["Custom-Header"] = "My Custom Header";
request.Headers = headers;
return CefReturnValue.Continue;
}
Anyone got an answer for my question above re loading a page into the control when the WPF TabItem it is on it doesn't have focus?
@nzmike99 The default WPF TabControl
isn't really suitable for hosting a browser, see
When I add the ChromiumWebBrowserWithScreenshotSupport.cs file to the CefSharp.Wpf.Example project it needs the "using GalaSoft.MvvmLight.Command; " dependency which destroys the project with errors
@jeremiahjordani_twitter You could use any Delegate/RelayCommand implementation you like. Pretty common for WPF apps to have one.
If you don't have one then just change the access modifier for the paramaterless TakeScreenshot so it's usable in your instance. The command is entirely optional.
private void /*Btn*/Sceenshot_Click(object sender, RoutedEventArgs e)
{
/*
//CefSharp - Quick and Dirty Screenshot with no class dependency
MessageBox.Show("Take screenshot");
double dWidth = (webCefSharpChromiumWebBrowser.ActualWidth);
double dHeight = (webCefSharpChromiumWebBrowser.ActualHeight);
int actualWidth = 0;
int actualHeight = 0;
actualWidth = Convert.ToInt32(dWidth);
actualHeight = Convert.ToInt32(dHeight);
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(actualWidth, actualHeight, 90, 90, PixelFormats.Pbgra32);
renderTargetBitmap.Render(webCefSharpChromiumWebBrowser);
PngBitmapEncoder pngImage = new PngBitmapEncoder();
pngImage.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
using (Stream fileStream = File.Create(@"C:\SaveFolderName\apollo.png")) //uses System.IO for fileStream
{
pngImage.Save(fileStream);
}
*/
}
[C#
] TakeScreenshot [WPF
]
/*Here is an example that reuses the image that's already rendered to the screen.*/
var template = Browser.Template;
var image = (System.Windows.Controls.Image)template.FindName("PART_image", Browser);
var pngImage = new PngBitmapEncoder();
pngImage.Frames.Add(BitmapFrame.Create((System.Windows.Media.Imaging.BitmapSource)image.Source));
var screenshotPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "CefSharp screenshot" + DateTime.Now.Ticks + ".png");
using (var fileStream = File.Create(screenshotPath))
{
pngImage.Save(fileStream);
}