diff --git a/MWPFCore/MWPFCore.csproj b/MWPFCore/MWPFCore.csproj
deleted file mode 100644
index dafa742f7ef74885e13fdac4db2b5f8d95ea8f71..0000000000000000000000000000000000000000
--- a/MWPFCore/MWPFCore.csproj
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- Library
- net8.0-windows
- AnyCPU;x86;x64
- true
- enable
- true
- $(SolutionDir)Output\$(Platform)\
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/MWebBrowser.sln b/MWebBrowser.sln
index 26ce5e6f76e7d037e5f17aafa9c1f25915c5bd75..91681cf51a42efb79819ecb0d48fc088e5fb3ed9 100644
--- a/MWebBrowser.sln
+++ b/MWebBrowser.sln
@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MWebBrowser", "MWebBrowser\MWebBrowser.csproj", "{7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cys_Resource", "Cys_Resource\Cys_Resource.csproj", "{BFA86333-1D51-4611-B199-BB9059047012}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cys_CustomControls", "Cys_CustomControls\Cys_CustomControls.csproj", "{C280D126-6E40-4BB6-83A0-8047CB4F8DC4}"
@@ -17,11 +15,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cys_Model", "Cys_Model\Cys_
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cys_Services", "Cys_Services\Cys_Services.csproj", "{4D840FD3-3DB7-47B9-88FE-524F538223B7}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MWinFormsCore", "MWinFormsCore\MWinFormsCore.csproj", "{2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cys", "Cys", "{D01C5D35-0DBB-4B5C-994F-C4A132A627FD}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MWPFCore", "MWPFCore\MWPFCore.csproj", "{8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MWinFormsBrowser", "MWinFormsBrowser\MWinFormsBrowser.csproj", "{FF605711-EA53-4987-9BA9-4EA45BC90A1F}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cys", "Cys", "{D01C5D35-0DBB-4B5C-994F-C4A132A627FD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MWebBrowser", "MWebBrowser\MWebBrowser.csproj", "{488A48CC-5570-4733-BCD6-50D1CC9C4B6A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -33,18 +31,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Debug|x64.ActiveCfg = Debug|x86
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Debug|x64.Build.0 = Debug|x86
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Debug|x86.ActiveCfg = Debug|Any CPU
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Debug|x86.Build.0 = Debug|Any CPU
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Release|Any CPU.Build.0 = Release|Any CPU
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Release|x64.ActiveCfg = Release|Any CPU
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Release|x64.Build.0 = Release|Any CPU
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Release|x86.ActiveCfg = Release|x86
- {7FF6E8EE-4310-43AC-8C99-DBDCDC33B57B}.Release|x86.Build.0 = Release|x86
{BFA86333-1D51-4611-B199-BB9059047012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BFA86333-1D51-4611-B199-BB9059047012}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BFA86333-1D51-4611-B199-BB9059047012}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -117,30 +103,30 @@ Global
{4D840FD3-3DB7-47B9-88FE-524F538223B7}.Release|x64.Build.0 = Release|Any CPU
{4D840FD3-3DB7-47B9-88FE-524F538223B7}.Release|x86.ActiveCfg = Release|Any CPU
{4D840FD3-3DB7-47B9-88FE-524F538223B7}.Release|x86.Build.0 = Release|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Debug|x64.ActiveCfg = Debug|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Debug|x64.Build.0 = Debug|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Debug|x86.ActiveCfg = Debug|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Debug|x86.Build.0 = Debug|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Release|Any CPU.Build.0 = Release|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Release|x64.ActiveCfg = Release|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Release|x64.Build.0 = Release|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Release|x86.ActiveCfg = Release|Any CPU
- {2A71CEEA-C0BD-4DE7-93DB-0F4E971C6682}.Release|x86.Build.0 = Release|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Debug|x64.ActiveCfg = Debug|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Debug|x64.Build.0 = Debug|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Debug|x86.ActiveCfg = Debug|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Debug|x86.Build.0 = Debug|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Release|Any CPU.Build.0 = Release|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Release|x64.ActiveCfg = Release|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Release|x64.Build.0 = Release|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Release|x86.ActiveCfg = Release|Any CPU
- {8E54DF10-5C9D-44B3-A0E6-F30C2268CC24}.Release|x86.Build.0 = Release|Any CPU
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Debug|x64.ActiveCfg = Debug|x64
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Debug|x64.Build.0 = Debug|x64
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Debug|x86.ActiveCfg = Debug|x86
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Debug|x86.Build.0 = Debug|x86
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Release|x64.ActiveCfg = Release|x64
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Release|x64.Build.0 = Release|x64
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Release|x86.ActiveCfg = Release|x86
+ {FF605711-EA53-4987-9BA9-4EA45BC90A1F}.Release|x86.Build.0 = Release|x86
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Debug|x64.Build.0 = Debug|Any CPU
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Debug|x86.ActiveCfg = Debug|x86
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Debug|x86.Build.0 = Debug|x86
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Release|x64.ActiveCfg = Release|Any CPU
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Release|x64.Build.0 = Release|Any CPU
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Release|x86.ActiveCfg = Release|x86
+ {488A48CC-5570-4733-BCD6-50D1CC9C4B6A}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/MWebBrowser/App.xaml.cs b/MWebBrowser/App.xaml.cs
index 86725e24ef6445c65524656e4cc8cf536595d442..a6430df3a18528599e4562a70efa430a0dba8e8e 100644
--- a/MWebBrowser/App.xaml.cs
+++ b/MWebBrowser/App.xaml.cs
@@ -1,4 +1,4 @@
-using MWinFormsCore;
+using MWebBrowser;
using System.Windows;
namespace MWebBrowser
diff --git a/MWebBrowser/AssemblyInfo.cs b/MWebBrowser/AssemblyInfo.cs
index 01c8003fff741d0502de477c453b28e7a53feef7..8b5504ecfbb1bfbb008957f80ac70f8fcdab91dd 100644
--- a/MWebBrowser/AssemblyInfo.cs
+++ b/MWebBrowser/AssemblyInfo.cs
@@ -8,4 +8,3 @@ using System.Windows;
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
-[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
\ No newline at end of file
diff --git a/MWebBrowser/BrowserUserControl.xaml b/MWebBrowser/BrowserUserControl.xaml
new file mode 100644
index 0000000000000000000000000000000000000000..1884ee03a528a370b0f66d055a6ddc510c1b0163
--- /dev/null
+++ b/MWebBrowser/BrowserUserControl.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MWebBrowser/BrowserUserControl.xaml.cs b/MWebBrowser/BrowserUserControl.xaml.cs
new file mode 100644
index 0000000000000000000000000000000000000000..b7cf638218c0aa817c04bd0e4cf627c27017c75a
--- /dev/null
+++ b/MWebBrowser/BrowserUserControl.xaml.cs
@@ -0,0 +1,51 @@
+using CefSharp;
+using MWebBrowser.Code.CustomCef;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace MWebBrowser
+{
+ ///
+ /// Interaction logic for BrowserUserControl.xaml
+ ///
+ public partial class BrowserUserControl : UserControl
+ {
+ public CustomWebBrowser CefWebBrowser;
+ public BrowserUserControl()
+ {
+ InitializeComponent();
+ InitData();
+ }
+
+ private void InitData()
+ {
+ CefWebBrowser = new CustomWebBrowser();
+ webBrower.Children.Add(CefWebBrowser);
+ }
+
+ public void ShowDevToolsDocked()
+ {
+ if (devToolsGrid.Visibility == Visibility.Collapsed)
+ {
+ devToolsGrid.Visibility = Visibility.Visible;
+ }
+
+ CefWebBrowser.GetBrowserHost().ShowDevTools();
+
+
+ // 获取开发者工具的 WebView,wpf源码没提供,暂放弃
+ CefWebBrowser.ShowDevTools();
+ if (devToolsGrid.Children.Count == 0)
+ {
+ // 将开发者工具嵌入到指定的 Grid 中
+ }
+ }
+
+ public void CloseDevToolsDocked()
+ {
+ devToolsGrid.Children.Clear();
+ devToolsGrid.Visibility = Visibility.Collapsed; // 隐藏开发者工具
+ }
+ }
+
+}
diff --git a/MWebBrowser/Code/Configure/ConfigEntity.cs b/MWebBrowser/Code/Configure/ConfigEntity.cs
new file mode 100644
index 0000000000000000000000000000000000000000..57b36e5ae7f6466201816cfa4a8dcf0cf902e752
--- /dev/null
+++ b/MWebBrowser/Code/Configure/ConfigEntity.cs
@@ -0,0 +1,7 @@
+namespace MWebBrowser.Code.Configure
+{
+ public class ConfigEntity
+ {
+ public string DownLoadPath { get; set; }
+ }
+}
diff --git a/MWebBrowser/Code/Configure/ConfigHelper.cs b/MWebBrowser/Code/Configure/ConfigHelper.cs
new file mode 100644
index 0000000000000000000000000000000000000000..fcc66b5fef9c925753d795cb54e2d2309b6fdaa3
--- /dev/null
+++ b/MWebBrowser/Code/Configure/ConfigHelper.cs
@@ -0,0 +1,47 @@
+using System;
+using System.IO;
+
+namespace MWebBrowser.Code.Configure
+{
+ public static class ConfigHelper
+ {
+ public static ConfigEntity Config { get; private set; }
+
+ public static void LoadLocalConfig()
+ {
+ ConfigEntity config = null;
+ if (string.IsNullOrEmpty(AppDomain.CurrentDomain.BaseDirectory))
+ {
+ config = new ConfigEntity();
+ }
+ else
+ {
+ string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json");
+ if (File.Exists(path))
+ {
+ try
+ {
+ using StreamReader streamReader = new StreamReader(path, System.Text.Encoding.UTF8);
+ string json = streamReader.ReadToEnd();
+ config = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
+ }
+ catch
+ {
+ File.Delete(path);
+ }
+ }
+ config ??= new ConfigEntity();
+ }
+ Config = config;
+ CheckConfig();
+ }
+
+ private static void CheckConfig()
+ {
+ if (string.IsNullOrEmpty(Config.DownLoadPath) || Directory.Exists(Config.DownLoadPath))
+ {
+ Config.DownLoadPath = KnownFolderHelper.GetDownload();
+ }
+ }
+ }
+}
diff --git a/MWebBrowser/Code/Configure/KnownFolder.cs b/MWebBrowser/Code/Configure/KnownFolder.cs
new file mode 100644
index 0000000000000000000000000000000000000000..2aef037066ab19b81c1fb90e22f68987ba0b2564
--- /dev/null
+++ b/MWebBrowser/Code/Configure/KnownFolder.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace MWebBrowser.Code.Configure
+{
+ public static class KnownFolder
+ {
+ public static readonly Guid Downloads = new Guid("374DE290-123F-4565-9164-39C4925E467B");
+ }
+
+ public static class KnownFolderHelper
+ {
+ [DllImport("shell32.dll", CharSet = CharSet.Unicode)]
+ private static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid,
+ uint dwFlags, IntPtr hToken, out string pszPath);
+
+ public static string GetDownload()
+ {
+ SHGetKnownFolderPath(KnownFolder.Downloads, 0, IntPtr.Zero, out var downloads);
+ return downloads;
+ }
+ }
+}
diff --git a/MWPFCore/CustomCef/CustomDownloadHandler.cs b/MWebBrowser/Code/CustomCef/CustomDownloadHandler.cs
similarity index 95%
rename from MWPFCore/CustomCef/CustomDownloadHandler.cs
rename to MWebBrowser/Code/CustomCef/CustomDownloadHandler.cs
index 64c1288d82d5babe60e89a07e38f9ae3623c7451..60c3f76b96079057f97f1c682f4274774b1d23d5 100644
--- a/MWPFCore/CustomCef/CustomDownloadHandler.cs
+++ b/MWebBrowser/Code/CustomCef/CustomDownloadHandler.cs
@@ -1,8 +1,8 @@
using CefSharp;
-using Cys_Common.Code.Configure;
+using MWebBrowser.Code.Configure;
using System;
-namespace MWPFCore.Code.CustomCef
+namespace MWebBrowser.Code.CustomCef
{
public class CustomDownloadHandler : IDownloadHandler
{
diff --git a/MWPFCore/CustomCef/CustomLifeSpanHandler.cs b/MWebBrowser/Code/CustomCef/CustomLifeSpanHandler.cs
similarity index 96%
rename from MWPFCore/CustomCef/CustomLifeSpanHandler.cs
rename to MWebBrowser/Code/CustomCef/CustomLifeSpanHandler.cs
index 5379b6bab8ce9db390bd861b924a2a08b24f3ff1..ede8648074f67ba1461edaef73e3c6dab7fc115a 100644
--- a/MWPFCore/CustomCef/CustomLifeSpanHandler.cs
+++ b/MWebBrowser/Code/CustomCef/CustomLifeSpanHandler.cs
@@ -1,7 +1,7 @@
using CefSharp;
using System;
-namespace MWPFCore.Code.CustomCef
+namespace MWebBrowser.Code.CustomCef
{
public class CustomLifeSpanHandler : ILifeSpanHandler
{
diff --git a/MWPFCore/CustomCef/CustomRequestHandler.cs b/MWebBrowser/Code/CustomCef/CustomRequestHandler.cs
similarity index 95%
rename from MWPFCore/CustomCef/CustomRequestHandler.cs
rename to MWebBrowser/Code/CustomCef/CustomRequestHandler.cs
index b315fcd8bcf8d126aa5d6cf9028cb5b3ae3db049..c571aa0370476baa38268d2ed91456109afc2ad8 100644
--- a/MWPFCore/CustomCef/CustomRequestHandler.cs
+++ b/MWebBrowser/Code/CustomCef/CustomRequestHandler.cs
@@ -1,8 +1,8 @@
using CefSharp;
+using MWebBrowser.Code.Helpers;
using System.Security.Cryptography.X509Certificates;
-using System.Windows;
-namespace MWPFCore.Code.CustomCef
+namespace MWebBrowser.Code.CustomCef
{
public class CustomRequestHandler: IRequestHandler
{
@@ -20,8 +20,8 @@ namespace MWPFCore.Code.CustomCef
public bool OnOpenUrlFromTab(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl,
WindowOpenDisposition targetDisposition, bool userGesture)
{
-
- Application.Current.Dispatcher.Invoke(() =>
+
+ DispatcherHelper.UIDispatcher.Invoke(() =>
{
var s = chromiumWebBrowser.Address;
});
diff --git a/MWPFCore/CustomCef/CustomWebBrowser.cs b/MWebBrowser/Code/CustomCef/CustomWebBrowser.cs
similarity index 98%
rename from MWPFCore/CustomCef/CustomWebBrowser.cs
rename to MWebBrowser/Code/CustomCef/CustomWebBrowser.cs
index a8f08c5d85ffc5f38f478436950109697b9d2204..080105315298320fae05b52837cbf602203bda64 100644
--- a/MWPFCore/CustomCef/CustomWebBrowser.cs
+++ b/MWebBrowser/Code/CustomCef/CustomWebBrowser.cs
@@ -5,7 +5,7 @@ using Cys_CustomControls.Controls;
using System;
using System.Windows.Input;
-namespace MWPFCore.Code.CustomCef
+namespace MWebBrowser.Code.CustomCef
{
public class CustomWebBrowser: ChromiumWebBrowser
{
diff --git a/MWebBrowser/Code/Helpers/F11Helper.cs b/MWebBrowser/Code/Helpers/F11Helper.cs
index 02c5e7d95cfdfe55ae1110361bf0b1386f355422..12c2afc5b8d91c524808e18e9712240f4fcb8d18 100644
--- a/MWebBrowser/Code/Helpers/F11Helper.cs
+++ b/MWebBrowser/Code/Helpers/F11Helper.cs
@@ -1,49 +1,42 @@
-using MWebBrowser.View;
-using MWinFormsCore;
+using MWebBrowser.Code.CustomCef;
+using MWebBrowser.Code.Helpers;
+using MWebBrowser.View;
using System.Windows;
-using System.Windows.Forms.Integration;
+using System.Windows.Controls;
-namespace MWebBrowser.Code.Helpers
+namespace MWinFormsBrowser.Code.Helpers
{
public static class F11Helper
{
private static F11Window f11Window;
- private static Rect originalBounds;
-
- public static void F11(BrowserUserControl browserUserControl, WindowsFormsHost orgWebFormsHost)
+ public static void F11(Grid parent, CustomWebBrowser CefWebBrowser)
{
DispatcherHelper.UIDispatcher.Invoke(() =>
{
if (f11Window != null)
{
- ExitFullscreen(browserUserControl, orgWebFormsHost);
+ ExitFullscreen(CefWebBrowser);
+ parent.Children.Add(CefWebBrowser);
}
else
{
- EnterFullscreen(browserUserControl, orgWebFormsHost);
+ parent.Children.Remove(CefWebBrowser);
+ EnterFullscreen(CefWebBrowser);
}
});
}
- private static void EnterFullscreen(BrowserUserControl browserUserControl, WindowsFormsHost orgWebFormsHost)
+ private static void EnterFullscreen(CustomWebBrowser CefWebBrowser)
{
- originalBounds = new Rect(
- browserUserControl.CefWebBrowser.Margin.Left,
- browserUserControl.CefWebBrowser.Margin.Top,
- browserUserControl.CefWebBrowser.Width,
- browserUserControl.CefWebBrowser.Height
- );
f11Window = new F11Window();
- orgWebFormsHost.Child.Controls.Remove(browserUserControl);
- f11Window.WebFormsHost.Child = browserUserControl;
+ f11Window.Parent.Children.Add(CefWebBrowser);
f11Window.Show();
Application.Current.MainWindow.Hide();
}
- private static void ExitFullscreen(BrowserUserControl browserUserControl, WindowsFormsHost orgWebFormsHost)
+ private static void ExitFullscreen(CustomWebBrowser CefWebBrowser)
{
- f11Window.WebFormsHost.Child.Controls.Remove(browserUserControl);
- orgWebFormsHost.Child = browserUserControl;
+ f11Window.Parent.Children.Remove(CefWebBrowser);
Application.Current.MainWindow.Show();
f11Window.Close();
f11Window = null;
diff --git a/MWPFCore/InitCefSharp.cs b/MWebBrowser/InitCefSharp.cs
similarity index 98%
rename from MWPFCore/InitCefSharp.cs
rename to MWebBrowser/InitCefSharp.cs
index 9875f021fd6e2e6255d3c96ef001217f0797a7a9..7cb1d7e1b6a3174b33e2e663b97e1657bfbd6f62 100644
--- a/MWPFCore/InitCefSharp.cs
+++ b/MWebBrowser/InitCefSharp.cs
@@ -3,7 +3,7 @@ using CefSharp.Wpf;
using System;
using System.IO;
-namespace MWPFCore
+namespace MWebBrowser
{
public class InitCefSharp
{
diff --git a/MWebBrowser/MWebBrowser.csproj b/MWebBrowser/MWebBrowser.csproj
index 2910a616c65046fa7f2bfb41c340137757c53058..34ce41b7c8c5b45541a8eb5a6dfe3755ee6e642c 100644
--- a/MWebBrowser/MWebBrowser.csproj
+++ b/MWebBrowser/MWebBrowser.csproj
@@ -2,13 +2,12 @@
WinExe
- net8.0-windows
+ net8.0-windows
true
- true
- AnyCPU;x86;x64
+ AnyCPU
true
Icon.ico
- $(SolutionDir)Output\$(Platform)\
+ $(SolutionDir)Output\WPF\$(Platform)\
@@ -19,17 +18,16 @@
-
-
-
+
+
+
-
@@ -37,9 +35,6 @@
-
- PreserveNewest
-
Always
@@ -53,5 +48,19 @@
$(DefaultXamlRuntime)
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MWebBrowser/MainWindow.xaml.cs b/MWebBrowser/MainWindow.xaml.cs
index b1ee165e165fc9c6fa1224ca8cda7e417a3ea870..d26b3d86e3434155e52c0871241ca2fd99c340e7 100644
--- a/MWebBrowser/MainWindow.xaml.cs
+++ b/MWebBrowser/MainWindow.xaml.cs
@@ -1,8 +1,8 @@
-using Cys_Common.Code.Configure;
-using Cys_Common.Settings;
+using Cys_Common.Settings;
using Cys_CustomControls.Controls;
using Cys_DataRepository;
using Cys_Model.DataBase;
+using MWebBrowser.Code.Configure;
using MWebBrowser.Code.Helpers;
namespace MWebBrowser
@@ -19,17 +19,10 @@ namespace MWebBrowser
ConfigHelper.LoadLocalConfig();
InitGlobalInfo();
this.Closing += MainWindow_Closing;
- this.Loaded += MainWindow_Loaded;
- }
-
- private void MainWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
- {
- MLogger.Info("Main Window Show Success!");
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
-
SaveGlobalInfo();
}
@@ -38,14 +31,12 @@ namespace MWebBrowser
DbSeed.InitData();
GlobalInfo.DownloadSetting = DataRepositoryServer.Instance.DownloadData.GetDownloadSetting();
GlobalInfo.FavoritesSetting = DataRepositoryServer.Instance.FavoritesData.GetFavoritesSetting();
- GlobalInfo.SearchEngineSetting = DataRepositoryServer.Instance.SearchEngineData.GetSearchEngineSetting();
}
private void SaveGlobalInfo()
{
DataRepositoryServer.Instance.DownloadData.SaveDownloadSetting();
DataRepositoryServer.Instance.FavoritesData.SaveFavoritesSetting();
- DataRepositoryServer.Instance.SearchEngineData.SaveSearchEngineSetting();
}
}
}
diff --git a/MWebBrowser/View/Download/DownloadShowAllUc.xaml.cs b/MWebBrowser/View/Download/DownloadShowAllUc.xaml.cs
index 1ce084941238e40e8768818b6548e2806afed4a5..617398954d841ca3880410cf1a645496f24f542a 100644
--- a/MWebBrowser/View/Download/DownloadShowAllUc.xaml.cs
+++ b/MWebBrowser/View/Download/DownloadShowAllUc.xaml.cs
@@ -1,5 +1,5 @@
-using Cys_Common.Code.Configure;
-using Cys_Common.Settings;
+using Cys_Common.Settings;
+using MWebBrowser.Code.Configure;
using MWebBrowser.ViewModel;
using System;
using System.Diagnostics;
diff --git a/MWebBrowser/View/Download/DownloadToolUc.xaml.cs b/MWebBrowser/View/Download/DownloadToolUc.xaml.cs
index b3917fd562a7c4c1f644f7612795cddf2ca09dba..0af904906ff60062aac69f153ed51c9f0f3e6863 100644
--- a/MWebBrowser/View/Download/DownloadToolUc.xaml.cs
+++ b/MWebBrowser/View/Download/DownloadToolUc.xaml.cs
@@ -1,14 +1,11 @@
using CefSharp;
+using Cys_Common.Settings;
using MWebBrowser.ViewModel;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
-using Cys_Common.Settings;
-using MWebBrowser.Code.Helpers;
-using Org.BouncyCastle.Asn1.Ocsp;
-using Cys_Controls.Code;
namespace MWebBrowser.View
{
@@ -55,6 +52,7 @@ namespace MWebBrowser.View
this.Dispatcher.Invoke(new Action(() =>
{
+ //this.Visibility = Visibility.Visible;
DisplayTool();
var item = new DownloadToolItemUc { DataContext = viewModel };
ItemsParent.Children.Insert(0, item);
@@ -93,15 +91,11 @@ namespace MWebBrowser.View
private void DisplayTool()
{
- var uc = ControlHelper.FindVisualChild(Application.Current.MainWindow);
- uc.SetCurrentWebTabItemSize(true);
_displayToolStoryboard.Begin();
}
private void HideTool()
{
- var uc = ControlHelper.FindVisualChild(Application.Current.MainWindow);
- uc.SetCurrentWebTabItemSize(false);
_hideToolStoryboard.Begin();
}
diff --git a/MWebBrowser/View/F11Window.xaml.cs b/MWebBrowser/View/F11Window.xaml.cs
index 1aa6481dfef3f961364e7b7a843973a33aca9a1d..131eb8caf2bb5e34426b4c2e91ecfcdcc8eb1f33 100644
--- a/MWebBrowser/View/F11Window.xaml.cs
+++ b/MWebBrowser/View/F11Window.xaml.cs
@@ -1,5 +1,4 @@
using System.Windows;
-using System.Windows.Forms.Integration;
namespace MWebBrowser.View
{
@@ -8,17 +7,9 @@ namespace MWebBrowser.View
///
public partial class F11Window : Window
{
- public WindowsFormsHost WebFormsHost { get; }
public F11Window()
{
InitializeComponent();
- WebFormsHost = new WindowsFormsHost();
- InitData();
- }
-
- private void InitData()
- {
- Parent.Children.Add(WebFormsHost);
}
}
}
diff --git a/MWebBrowser/View/Favorites/FavoritesBarUc.xaml.cs b/MWebBrowser/View/Favorites/FavoritesBarUc.xaml.cs
index a6b8d153b8ff3006a85f243c94b2aa9c0b1825f4..ab28782efd15773e5687c12582fb39ce0afbd2ea 100644
--- a/MWebBrowser/View/Favorites/FavoritesBarUc.xaml.cs
+++ b/MWebBrowser/View/Favorites/FavoritesBarUc.xaml.cs
@@ -25,7 +25,7 @@ namespace MWebBrowser.View
///
private MFavoritesItem _currentRightItem;
public Func GetWebUrlEvent;
- public Action OpenUrlCurrentEvent;
+ public Action OpenNewTabEvent;
public FavoritesBarUc()
{
InitializeComponent();
@@ -132,7 +132,7 @@ namespace MWebBrowser.View
if (item == null || item.Type == 1) return;
if (!GlobalInfo.FavoritesSetting.FavoritesInfos.Exists(x => x.NodeId == item.NodeId)) return;
var treeNode = GlobalInfo.FavoritesSetting.FavoritesInfos.First(x => x.NodeId == item.NodeId);
- OpenUrlCurrentEvent?.Invoke(treeNode.Url);
+ OpenNewTabEvent?.Invoke(treeNode.Url);
}
///
diff --git a/MWebBrowser/View/Favorites/FavoritesMenuUc.xaml.cs b/MWebBrowser/View/Favorites/FavoritesMenuUc.xaml.cs
index d1a78814a63b850c9c2eca2dda6500ef9e43387f..522c26b34816872bbef50043d3750dd5f0d19550 100644
--- a/MWebBrowser/View/Favorites/FavoritesMenuUc.xaml.cs
+++ b/MWebBrowser/View/Favorites/FavoritesMenuUc.xaml.cs
@@ -1,4 +1,5 @@
-using Cys_Common.Settings;
+using Cys_Common;
+using Cys_Common.Settings;
using Cys_Controls.Code;
using Cys_CustomControls.Controls;
using Cys_Model;
@@ -20,7 +21,7 @@ namespace MWebBrowser.View
public partial class FavoritesMenuUc : UserControl
{
public Func GetWebUrlEvent;
- public Action OpenUrlCurrentEvent;
+ public Action OpenNewTabEvent;
public Action RefreshFavoritesBarEvent;
///
@@ -284,7 +285,7 @@ namespace MWebBrowser.View
if (item.IsEdit) return;
if (!GlobalInfo.FavoritesSetting.FavoritesInfos.Exists(x => x.NodeId == item.NodeId)) return;
var treeNode = GlobalInfo.FavoritesSetting.FavoritesInfos.First(x => x.NodeId == item.NodeId);
- OpenUrlCurrentEvent?.Invoke(treeNode.Url);
+ OpenNewTabEvent?.Invoke(treeNode.Url);
}
private void ReName_OnClick(object sender, RoutedEventArgs e)
diff --git a/MWebBrowser/View/History/HistoryItemUc.xaml.cs b/MWebBrowser/View/History/HistoryItemUc.xaml.cs
index 137b77c60316cc178c4b9ce237bb1d08e42a12b1..c4b1116c9f5dfd45143577365860f15bc4087152 100644
--- a/MWebBrowser/View/History/HistoryItemUc.xaml.cs
+++ b/MWebBrowser/View/History/HistoryItemUc.xaml.cs
@@ -40,13 +40,13 @@ namespace MWebBrowser.View.History
{
if (!(this.DataContext is HistoryItemViewModel viewModel)) return;
try
- {
- ControlHelper.FindVisualChild(Application.Current.MainWindow).FavoritesPop.IsOpen = false;
- ControlHelper.FindVisualChild(Application.Current.MainWindow).OpenUrl(viewModel.Url);
+ {
+ var uc = ControlHelper.FindVisualChild(Application.Current.MainWindow);
+ uc.TabItemAdd(viewModel.Url);
}
catch (Exception ex)
{
- MLogger.Info($"history mouse left button down exception:{ex}");
+
}
}
diff --git a/MWebBrowser/View/Setting/SettingUc.xaml b/MWebBrowser/View/Setting/SettingUc.xaml
index da46d042fa819ece197ae8a7eb93c2945ddac3d9..0d189f8434c967c1fffec44bc9e90ec0f2d386b5 100644
--- a/MWebBrowser/View/Setting/SettingUc.xaml
+++ b/MWebBrowser/View/Setting/SettingUc.xaml
@@ -4,17 +4,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Cys_CustomControls.Controls;assembly=Cys_CustomControls"
- xmlns:local="clr-namespace:Cys_CustomControls.Code;assembly=Cys_CustomControls"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="1000"
Foreground="{DynamicResource WebBrowserBrushes.DefaultForeground}"
Background="{DynamicResource WebBrowserBrushes.DefaultBackground}">
-
-
-
@@ -26,22 +19,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -50,7 +42,7 @@
-
+
diff --git a/MWebBrowser/View/Setting/SettingUc.xaml.cs b/MWebBrowser/View/Setting/SettingUc.xaml.cs
index cec5eeccbe8c47f65a83a61301673342978553f3..7155ed8aaada8e78bdc89278093df51ebef127a2 100644
--- a/MWebBrowser/View/Setting/SettingUc.xaml.cs
+++ b/MWebBrowser/View/Setting/SettingUc.xaml.cs
@@ -1,6 +1,4 @@
-using MWebBrowser.ViewModel;
-using MWebBrowser.ViewModel.Setting;
-using System.Windows.Controls;
+using System.Windows.Controls;
namespace MWebBrowser.View
{
@@ -9,12 +7,9 @@ namespace MWebBrowser.View
///
public partial class SettingUc : UserControl
{
- private readonly SettingViewModel settingViewModel;
public SettingUc()
{
InitializeComponent();
- settingViewModel = new SettingViewModel();
- this.DataContext = settingViewModel;
}
}
}
diff --git a/MWebBrowser/View/WebMenuUc.xaml.cs b/MWebBrowser/View/WebMenuUc.xaml.cs
index 84d294d623886bcaa1a0fae6ad67172f72486b35..96112c2b9adb151a62aa159939b6fabf281a6251 100644
--- a/MWebBrowser/View/WebMenuUc.xaml.cs
+++ b/MWebBrowser/View/WebMenuUc.xaml.cs
@@ -3,7 +3,6 @@ using System.Windows;
using System.Windows.Controls;
using Cys_Controls.Code;
using Cys_CustomControls.Controls;
-using MWebBrowser.Code.Helpers;
namespace MWebBrowser.View
{
@@ -48,10 +47,7 @@ namespace MWebBrowser.View
public void ZoomCallBack(string zoomRatio)
{
- DispatcherHelper.UIDispatcher.Invoke(() =>
- {
- ZoomMenuItem.ZoomRatio = zoomRatio;
- });
+ ZoomMenuItem.ZoomRatio = zoomRatio;
}
}
}
diff --git a/MWebBrowser/View/WebTabControlUc.xaml.cs b/MWebBrowser/View/WebTabControlUc.xaml.cs
index c343156ce0b78b79a516f8e974609b2c54e781de..b4e76523c27a957258245774a2ab856984c32c94 100644
--- a/MWebBrowser/View/WebTabControlUc.xaml.cs
+++ b/MWebBrowser/View/WebTabControlUc.xaml.cs
@@ -1,14 +1,15 @@
using CefSharp;
+using CefSharp.DevTools.WebAudio;
using Cys_Controls.Code;
using Cys_CustomControls.Controls;
using Cys_Model.Tables;
using Cys_Resource.Code;
using Cys_Services;
using MWebBrowser.Code;
-using MWebBrowser.Code.CefWebOperate;
using MWebBrowser.Code.Helpers;
using MWebBrowser.ViewModel;
using System;
+using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@@ -22,42 +23,47 @@ namespace MWebBrowser.View
///
public partial class WebTabControlUc : UserControl
{
- private readonly WebTabControlViewModel viewModel;
- private WebTabItemUc currentWebTabItem;
- private HistoryServices historyServices;
- private CefWebZoom cefWebZoom;
- private CefWebSearch cefWebSearch;
+ private readonly WebTabControlViewModel _viewModel;
+ private WebTabItemUc _currentWebTabItem;
+ private readonly System.Timers.Timer _zoomToolTimer = new System.Timers.Timer(1000);
+ private int _zoomWaitingCount = -1;
+
+ private HistoryServices _historyServices;
public WebTabControlUc()
{
InitializeComponent();
InitWebTabControl();
- historyServices = new HistoryServices();
- viewModel = new WebTabControlViewModel();
- this.DataContext = viewModel;
+ _historyServices = new HistoryServices();
+ _viewModel = new WebTabControlViewModel();
+ this.DataContext = _viewModel;
this.Loaded += MWebBrowserUc_Loaded;
WebTabControl.SelectionChanged += WebTabControl_SelectionChanged;
- FavoritesMenu.GetWebUrlEvent += () => viewModel;
- FavoritesMenu.OpenUrlCurrentEvent += OpenUrlByCurrentTab;
+ FavoritesMenu.GetWebUrlEvent += () => _viewModel;
+ FavoritesMenu.OpenNewTabEvent += TabItemAdd;
FavoritesMenu.RefreshFavoritesBarEvent += FavoritesBar.RefreshFavoritesBar;
- FavoritesBar.GetWebUrlEvent += () => viewModel;
- FavoritesBar.OpenUrlCurrentEvent += OpenUrlByCurrentTab;
+ FavoritesBar.GetWebUrlEvent += () => _viewModel;
+ FavoritesBar.OpenNewTabEvent += TabItemAdd;
}
- public void SetCurrentWebTabItemSize(bool setHeight)
- {
- currentWebTabItem.RowBottom.Height = new GridLength(setHeight ? 40 : 0);
- }
private void MWebBrowserUc_Loaded(object sender, RoutedEventArgs e)
{
if (this.IsInDesignMode())
return;
InitCommand();
InitData();
- OpenUrl("https://www.cnblogs.com/mchao/collections/12168");
+ InitSearchCommand();
+ InitWebMenu();
+ TabItemAdd("https://www.cnblogs.com/mchao/collections/12168");
}
#region InitData
+ private void InitWebMenu()
+ {
+ WebMenu.ZoomInEvent += ZoomIn;
+ WebMenu.ZoomOutEvent += ZoomOut;
+ WebMenu.ExecuteMenuEvent += ExecuteMenuFunction;
+ }
private void InitWebTabControl()
{
WebTabControl.CloseTabEvent += () =>
@@ -75,16 +81,14 @@ namespace MWebBrowser.View
{
WebTabControl.PartHeaderParentGrid.MouseLeftButtonDown += mw.HeaderClickOrDragMove;
}
- cefWebZoom = new CefWebZoom(WebMenu, viewModel, SearchText);
- cefWebSearch = new CefWebSearch(viewModel);
+
DownloadTool.ShowDownloadTabEvent += ShowDownloadTab;
- WebMenu.ExecuteMenuEvent += ExecuteMenuFunction;
}
private void InitCommand()
{
- WebTabControl.TabItemAddCommand = new BaseCommand