Commit d35206659dab4ae18ed0ba5517d50f64a9565228
1 parent
b2d359e4
修改律师阅卷的访问URL、修改WebView.cs 中标题和URL不匹配问题,添加设置IE内核的方法
Showing
4 changed files
with
119 additions
and
13 deletions
FRControl/App.config
| @@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
| 29 | <value>Resources/person.png</value> | 29 | <value>Resources/person.png</value> |
| 30 | </setting> | 30 | </setting> |
| 31 | <setting name="personInterview" serializeAs="String"> | 31 | <setting name="personInterview" serializeAs="String"> |
| 32 | - <value>http://xz.wh.hbjc.gov.cn/</value> | 32 | + <value>https://www.12309.gov.cn/front-cas/login</value> |
| 33 | </setting> | 33 | </setting> |
| 34 | <setting name="caseImg" serializeAs="String"> | 34 | <setting name="caseImg" serializeAs="String"> |
| 35 | <value>Resources/caseInfo.png</value> | 35 | <value>Resources/caseInfo.png</value> |
FRControl/Home.cs
| @@ -45,7 +45,7 @@ namespace FRControl | @@ -45,7 +45,7 @@ namespace FRControl | ||
| 45 | // | 45 | // |
| 46 | WebView webView = new WebView(); | 46 | WebView webView = new WebView(); |
| 47 | title = Properties.Settings.Default.caseName; | 47 | title = Properties.Settings.Default.caseName; |
| 48 | - url = Properties.Settings.Default.caseInformation; | 48 | + url = Properties.Settings.Default.lawyerInterview; |
| 49 | //webView.param = Properties.Settings.Default.caseInformation; | 49 | //webView.param = Properties.Settings.Default.caseInformation; |
| 50 | webView.Show(); | 50 | webView.Show(); |
| 51 | } | 51 | } |
| @@ -56,7 +56,7 @@ namespace FRControl | @@ -56,7 +56,7 @@ namespace FRControl | ||
| 56 | //System.Diagnostics.Process.Start(Properties.Settings.Default.lawyerInterview); | 56 | //System.Diagnostics.Process.Start(Properties.Settings.Default.lawyerInterview); |
| 57 | WebView webView = new WebView(); | 57 | WebView webView = new WebView(); |
| 58 | title = Properties.Settings.Default.lawyerName; | 58 | title = Properties.Settings.Default.lawyerName; |
| 59 | - url = Properties.Settings.Default.lawyerInterview; | 59 | + url = Properties.Settings.Default.caseInformation; |
| 60 | //webView.param = Properties.Settings.Default.caseInformation; | 60 | //webView.param = Properties.Settings.Default.caseInformation; |
| 61 | webView.Show(); | 61 | webView.Show(); |
| 62 | } | 62 | } |
FRControl/WebView.Designer.cs
| @@ -48,7 +48,7 @@ | @@ -48,7 +48,7 @@ | ||
| 48 | this.webBrowser1.ScriptErrorsSuppressed = true; | 48 | this.webBrowser1.ScriptErrorsSuppressed = true; |
| 49 | this.webBrowser1.Size = new System.Drawing.Size(608, 1053); | 49 | this.webBrowser1.Size = new System.Drawing.Size(608, 1053); |
| 50 | this.webBrowser1.TabIndex = 0; | 50 | this.webBrowser1.TabIndex = 0; |
| 51 | - this.webBrowser1.Url = new System.Uri("http://www.baidu.com", System.UriKind.Absolute); | 51 | + this.webBrowser1.Url = new System.Uri("http://xz.wh.hbjc.gov.cn/", System.UriKind.Absolute); |
| 52 | this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted_1); | 52 | this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted_1); |
| 53 | // | 53 | // |
| 54 | // BodyPanel | 54 | // BodyPanel |
FRControl/WebView.cs
| 1 | -using System; | 1 | +using Microsoft.Win32; |
| 2 | +using System; | ||
| 2 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
| 3 | using System.ComponentModel; | 4 | using System.ComponentModel; |
| 4 | using System.Data; | 5 | using System.Data; |
| @@ -14,11 +15,13 @@ namespace FRControl | @@ -14,11 +15,13 @@ namespace FRControl | ||
| 14 | { | 15 | { |
| 15 | public WebView() | 16 | public WebView() |
| 16 | { | 17 | { |
| 17 | - | 18 | + |
| 19 | + SetWebBrowserFeatures(11); | ||
| 18 | InitializeComponent(); | 20 | InitializeComponent(); |
| 19 | Size WindowsScreenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); | 21 | Size WindowsScreenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); |
| 20 | - Console.WriteLine(WindowsScreenSize); | ||
| 21 | int width = Screen.PrimaryScreen.Bounds.Width; | 22 | int width = Screen.PrimaryScreen.Bounds.Width; |
| 23 | + //Console.WriteLine("WindowsScreenSize:" + WindowsScreenSize+ ",width:"+ width); | ||
| 24 | + | ||
| 22 | if (width == 1080) | 25 | if (width == 1080) |
| 23 | { | 26 | { |
| 24 | this.Size = new Size(1080, 1920); | 27 | this.Size = new Size(1080, 1920); |
| @@ -43,6 +46,7 @@ namespace FRControl | @@ -43,6 +46,7 @@ namespace FRControl | ||
| 43 | this.webBrowser1.ScrollBarsEnabled = false; | 46 | this.webBrowser1.ScrollBarsEnabled = false; |
| 44 | 47 | ||
| 45 | } | 48 | } |
| 49 | + | ||
| 46 | private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e) | 50 | private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e) |
| 47 | { | 51 | { |
| 48 | //System.IO.StreamReader sr = new System.IO.StreamReader(webBrowser1.DocumentStream, Encoding.GetEncoding("gb2312")); | 52 | //System.IO.StreamReader sr = new System.IO.StreamReader(webBrowser1.DocumentStream, Encoding.GetEncoding("gb2312")); |
| @@ -53,6 +57,11 @@ namespace FRControl | @@ -53,6 +57,11 @@ namespace FRControl | ||
| 53 | //int end = html.IndexOf("</div>", start) + 8; | 57 | //int end = html.IndexOf("</div>", start) + 8; |
| 54 | //string tbhtm = html.Substring(start, end - start); | 58 | //string tbhtm = html.Substring(start, end - start); |
| 55 | 59 | ||
| 60 | + if (webBrowser1.ReadyState != WebBrowserReadyState.Complete) | ||
| 61 | + return; | ||
| 62 | + //if (e.Url.ToString() != webBrowser1.Url.ToString()) | ||
| 63 | + // return; | ||
| 64 | + | ||
| 56 | //webBrowser1.DocumentText = tbhtm;//设置为table的html代码 | 65 | //webBrowser1.DocumentText = tbhtm;//设置为table的html代码 |
| 57 | //将所有的链接的目标,指向本窗体 | 66 | //将所有的链接的目标,指向本窗体 |
| 58 | foreach (HtmlElement htmlElement in webBrowser1.Document.Links) | 67 | foreach (HtmlElement htmlElement in webBrowser1.Document.Links) |
| @@ -65,10 +74,12 @@ namespace FRControl | @@ -65,10 +74,12 @@ namespace FRControl | ||
| 65 | Size sz = webBrowser1.Size; | 74 | Size sz = webBrowser1.Size; |
| 66 | int xbili = (int)((float)sz.Width / (float)szba.Width * 100);//水平方向缩小比例 | 75 | int xbili = (int)((float)sz.Width / (float)szba.Width * 100);//水平方向缩小比例 |
| 67 | int ybili = (int)((float)sz.Height / (float)szba.Height * 100);//垂直方向缩小比例 | 76 | int ybili = (int)((float)sz.Height / (float)szba.Height * 100);//垂直方向缩小比例 |
| 68 | - if (xbili < ybili) | ||
| 69 | - webBrowser1.Document.Body.Style = "zoom:" + xbili.ToString() + "%"; | ||
| 70 | - else | ||
| 71 | - webBrowser1.Document.Body.Style = "zoom:" + ybili.ToString() + "%"; | 77 | + Console.WriteLine("xbili:" + xbili + ",ybili:" + ybili); |
| 78 | + webBrowser1.Document.Body.Style = "zoom:" + xbili.ToString() + "%"; | ||
| 79 | + //if (xbili < ybili) | ||
| 80 | + // webBrowser1.Document.Body.Style = "zoom:" + xbili.ToString() + "%"; | ||
| 81 | + //else | ||
| 82 | + // webBrowser1.Document.Body.Style = "zoom:" + ybili.ToString() + "%"; | ||
| 72 | webBrowser1.Invalidate(); | 83 | webBrowser1.Invalidate(); |
| 73 | } | 84 | } |
| 74 | private void Window_Error(object sender, HtmlElementErrorEventArgs e) | 85 | private void Window_Error(object sender, HtmlElementErrorEventArgs e) |
| @@ -85,15 +96,110 @@ namespace FRControl | @@ -85,15 +96,110 @@ namespace FRControl | ||
| 85 | } | 96 | } |
| 86 | private void ReturnBtn_Click(object sender, EventArgs e) | 97 | private void ReturnBtn_Click(object sender, EventArgs e) |
| 87 | { | 98 | { |
| 99 | + this.webBrowser1.Dispose(); | ||
| 88 | this.Close(); | 100 | this.Close(); |
| 89 | } | 101 | } |
| 90 | - private void webBrowser1_DocumentCompleted_2(object sender, WebBrowserDocumentCompletedEventArgs e) | 102 | + //private void webBrowser1_DocumentCompleted_2(object sender, WebBrowserDocumentCompletedEventArgs e) |
| 103 | + //{ | ||
| 104 | + | ||
| 105 | + //} | ||
| 106 | + private void TitleLab_Click(object sender, EventArgs e) | ||
| 91 | { | 107 | { |
| 92 | 108 | ||
| 93 | } | 109 | } |
| 94 | - private void TitleLab_Click(object sender, EventArgs e) | 110 | + |
| 111 | + /// <summary> | ||
| 112 | + /// 修改注册表信息来兼容当前程序 | ||
| 113 | + /// | ||
| 114 | + /// </summary> | ||
| 115 | + static void SetWebBrowserFeatures(int ieVersion) | ||
| 95 | { | 116 | { |
| 117 | + // don't change the registry if running in-proc inside Visual Studio | ||
| 118 | + if (LicenseManager.UsageMode != LicenseUsageMode.Runtime) | ||
| 119 | + return; | ||
| 120 | + //获取程序及名称 | ||
| 121 | + var appName = System.IO.Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); | ||
| 122 | + //得到浏览器的模式的值 | ||
| 123 | + UInt32 ieMode = GeoEmulationModee(ieVersion); | ||
| 124 | + var featureControlRegKey = @"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\"; | ||
| 125 | + //设置浏览器对应用程序(appName)以什么模式(ieMode)运行 | ||
| 126 | + Registry.SetValue(featureControlRegKey + "FEATURE_BROWSER_EMULATION", | ||
| 127 | + appName, ieMode, RegistryValueKind.DWord); | ||
| 128 | + // enable the features which are "On" for the full Internet Explorer browser | ||
| 129 | + //不晓得设置有什么用 | ||
| 130 | + Registry.SetValue(featureControlRegKey + "FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", | ||
| 131 | + appName, 1, RegistryValueKind.DWord); | ||
| 132 | + | ||
| 133 | + | ||
| 134 | + //Registry.SetValue(featureControlRegKey + "FEATURE_AJAX_CONNECTIONEVENTS", | ||
| 135 | + // appName, 1, RegistryValueKind.DWord); | ||
| 136 | + | ||
| 137 | + | ||
| 138 | + //Registry.SetValue(featureControlRegKey + "FEATURE_GPU_RENDERING", | ||
| 139 | + // appName, 1, RegistryValueKind.DWord); | ||
| 96 | 140 | ||
| 141 | + | ||
| 142 | + //Registry.SetValue(featureControlRegKey + "FEATURE_WEBOC_DOCUMENT_ZOOM", | ||
| 143 | + // appName, 1, RegistryValueKind.DWord); | ||
| 144 | + | ||
| 145 | + | ||
| 146 | + //Registry.SetValue(featureControlRegKey + "FEATURE_NINPUT_LEGACYMODE", | ||
| 147 | + // appName, 0, RegistryValueKind.DWord); | ||
| 148 | + } | ||
| 149 | + /// <summary> | ||
| 150 | + /// 获取浏览器的版本 | ||
| 151 | + /// </summary> | ||
| 152 | + /// <returns></returns> | ||
| 153 | + static int GetBrowserVersion() | ||
| 154 | + { | ||
| 155 | + int browserVersion = 0; | ||
| 156 | + using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer", | ||
| 157 | + RegistryKeyPermissionCheck.ReadSubTree, | ||
| 158 | + System.Security.AccessControl.RegistryRights.QueryValues)) | ||
| 159 | + { | ||
| 160 | + var version = ieKey.GetValue("svcVersion"); | ||
| 161 | + if (null == version) | ||
| 162 | + { | ||
| 163 | + version = ieKey.GetValue("Version"); | ||
| 164 | + if (null == version) | ||
| 165 | + throw new ApplicationException("Microsoft Internet Explorer is required!"); | ||
| 166 | + } | ||
| 167 | + int.TryParse(version.ToString().Split('.')[0], out browserVersion); | ||
| 168 | + } | ||
| 169 | + //如果小于7 | ||
| 170 | + if (browserVersion < 7) | ||
| 171 | + { | ||
| 172 | + throw new ApplicationException("不支持的浏览器版本!"); | ||
| 173 | + } | ||
| 174 | + return browserVersion; | ||
| 175 | + } | ||
| 176 | + /// <summary> | ||
| 177 | + /// 通过版本得到浏览器模式的值 | ||
| 178 | + /// </summary> | ||
| 179 | + /// <param name="browserVersion"></param> | ||
| 180 | + /// <returns></returns> | ||
| 181 | + static UInt32 GeoEmulationModee(int browserVersion) | ||
| 182 | + { | ||
| 183 | + UInt32 mode = 11000; // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode. | ||
| 184 | + switch (browserVersion) | ||
| 185 | + { | ||
| 186 | + case 7: | ||
| 187 | + mode = 7000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. | ||
| 188 | + break; | ||
| 189 | + case 8: | ||
| 190 | + mode = 8000; // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. | ||
| 191 | + break; | ||
| 192 | + case 9: | ||
| 193 | + mode = 9000; // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. | ||
| 194 | + break; | ||
| 195 | + case 10: | ||
| 196 | + mode = 10000; // Internet Explorer 10. | ||
| 197 | + break; | ||
| 198 | + case 11: | ||
| 199 | + mode = 11000; // Internet Explorer 11 | ||
| 200 | + break; | ||
| 201 | + } | ||
| 202 | + return mode; | ||
| 97 | } | 203 | } |
| 98 | } | 204 | } |
| 99 | } | 205 | } |