Skip to content

Commit

Permalink
Merge pull request #6 from rocksdanister/dev
Browse files Browse the repository at this point in the history
v4.1
  • Loading branch information
rocksdanister authored Mar 24, 2020
2 parents c259dc6 + 366a082 commit 3dc0732
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
35 changes: 35 additions & 0 deletions src/cefsharptest/Cef/CefMenuHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CefSharp;

namespace cefsharptest
{
/// <summary>
/// Cef right click contextmenu disable.
/// </summary>
class CefMenuHandler : IContextMenuHandler
{
public void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
{
model.Clear();
}

public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
{
return false;
}

public void OnContextMenuDismissed(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame)
{

}

public bool RunContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback)
{
return false;
}
}
}
34 changes: 34 additions & 0 deletions src/cefsharptest/Cef/CefPopUpHandle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CefSharp;

namespace cefsharptest
{
class CefPopUpHandle : ILifeSpanHandler
{
public bool DoClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
return false;
}

public void OnAfterCreated(IWebBrowser chromiumWebBrowser, IBrowser browser)
{

}

public void OnBeforeClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
{

}

public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
{
browser.MainFrame.LoadUrl(targetUrl);
newBrowser = null;
return true;
}
}
}
6 changes: 5 additions & 1 deletion src/cefsharptest/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ public void InitializeChromium()
}

}
//cef right click contextmenu disable.
chromeBrowser.MenuHandler = new CefMenuHandler();
//disable links starting in new cef window.
chromeBrowser.LifeSpanHandler = new CefPopUpHandle();

this.Controls.Add(chromeBrowser);
//chromeBrowser.Anchor = AnchorStyles.Top;
Expand Down Expand Up @@ -444,7 +448,7 @@ private string ShadertoyURLtoEmbedLink(string shadertoylink)

string text = @"<!DOCTYPE html><html lang=""en"" dir=""ltr""> <head> <meta charset=""utf - 8"">
<title>Digital Brain</title> <style media=""screen""> iframe { position: fixed; width: 100%; height: 100%; top: 0; right: 0; bottom: 0;
left: 0; z-index; -1; pointer-events: none; } </style> </head> <body> <iframe width=""640"" height=""360"" frameborder=""0""
left: 0; z-index; -1; } </style> </head> <body> <iframe width=""640"" height=""360"" frameborder=""0""
src=" + shadertoylink + @"?gui=false&t=10&paused=false&muted=true""></iframe> </body></html>";
// WriteAllText creates a file, writes the specified string to the file,
// and then closes the file. You do NOT need to call Flush() or Close().
Expand Down
2 changes: 1 addition & 1 deletion src/cefsharptest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyVersion("4.1.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 2 additions & 0 deletions src/cefsharptest/cefsharptest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cef\CefMenuHandler.cs" />
<Compile Include="Cef\CefPopUpHandle.cs" />
<Compile Include="LivelyLib\DataClass.cs" />
<Compile Include="Cef\DownloadHandler.cs" />
<Compile Include="Form1.cs">
Expand Down

0 comments on commit 3dc0732

Please sign in to comment.