فهرست منبع

禁用右键功能

章政 7 سال پیش
والد
کامیت
2375483992
3فایلهای تغییر یافته به همراه36 افزوده شده و 2 حذف شده
  1. 4 2
      UAS_Web/Browser.cs
  2. 1 0
      UAS_Web/UAS_Web.csproj
  3. 31 0
      UAS_Web/tool/MenuHandler.cs

+ 4 - 2
UAS_Web/Browser.cs

@@ -3,6 +3,7 @@ using System;
 using System.Diagnostics;
 using System.Runtime.InteropServices;
 using System.Windows.Forms;
+using UAS_Web.tool;
 
 namespace UAS_Web
 {
@@ -20,12 +21,13 @@ namespace UAS_Web
         public Browser()
         {
             InitializeComponent();
-            Text = "英唐数码-供应商条码打印";
-            string path = "http://218.18.115.198:8889/ERP/jsps/vendbarcode/login.jsp";
+            Text = "思拓微-供应商条码打印";
+            string path = "http://stwecig.vicp.io:8099/ERP/jsps/vendbarcode/login.jsp";
             webBrowser = new ChromiumWebBrowser(path)
             {
                 Dock = DockStyle.Fill
             };
+            webBrowser.MenuHandler = new MenuHandler();
             Controls.Add(webBrowser);
             webBrowser.LoadError += WebBrowser_LoadError;
         }

+ 1 - 0
UAS_Web/UAS_Web.csproj

@@ -100,6 +100,7 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="tool\MenuHandler.cs" />
     <EmbeddedResource Include="Browser.resx">
       <DependentUpon>Browser.cs</DependentUpon>
     </EmbeddedResource>

+ 31 - 0
UAS_Web/tool/MenuHandler.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using CefSharp;
+
+namespace UAS_Web.tool
+{
+    class MenuHandler : IContextMenuHandler
+    {
+        public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
+        {
+            model.Clear();
+        }
+
+        public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
+        {
+            return false;
+        }
+
+        public void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame)
+        {
+            //throw new NotImplementedException();
+        }
+
+        public bool RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback)
+        {
+            return false;
+        }
+    }
+}