Commit 1dfe15568375a7b79ffc77a509d17c28bcaa6b10

Authored by sh
1 parent 308961a4

修改WebBrowser网页适配问题,修改官网标题问题

FRControl/App.config
... ... @@ -46,9 +46,6 @@
46 46 <setting name="closeImg" serializeAs="String">
47 47 <value>Resources/close.png</value>
48 48 </setting>
49   - <setting name="caseName" serializeAs="String">
50   - <value>官网</value>
51   - </setting>
52 49 <setting name="lawyerName" serializeAs="String">
53 50 <value>案件信息公开</value>
54 51 </setting>
... ... @@ -58,6 +55,9 @@
58 55 <setting name="personInterview" serializeAs="String">
59 56 <value>https://www.12309.gov.cn/front-cas/login?casLv=1&amp;service=https://www.12309.gov.cn/sppWeb/j_spring_cas_security_check</value>
60 57 </setting>
  58 + <setting name="caseName" serializeAs="String">
  59 + <value>门户网站</value>
  60 + </setting>
61 61 </FRControl.Properties.Settings>
62 62 </userSettings>
63 63 </configuration>
64 64 \ No newline at end of file
... ...
FRControl/FRControl.csproj
... ... @@ -49,6 +49,9 @@
49 49 <Reference Include="System.Xml" />
50 50 </ItemGroup>
51 51 <ItemGroup>
  52 + <Compile Include="ZoomBrowser.cs">
  53 + <SubType>Component</SubType>
  54 + </Compile>
52 55 <Compile Include="Home.cs">
53 56 <SubType>Form</SubType>
54 57 </Compile>
... ...
FRControl/Properties/Settings.Designer.cs
... ... @@ -172,18 +172,6 @@ namespace FRControl.Properties {
172 172  
173 173 [global::System.Configuration.UserScopedSettingAttribute()]
174 174 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
175   - [global::System.Configuration.DefaultSettingValueAttribute("官网")]
176   - public string caseName {
177   - get {
178   - return ((string)(this["caseName"]));
179   - }
180   - set {
181   - this["caseName"] = value;
182   - }
183   - }
184   -
185   - [global::System.Configuration.UserScopedSettingAttribute()]
186   - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
187 175 [global::System.Configuration.DefaultSettingValueAttribute("案件信息公开")]
188 176 public string lawyerName {
189 177 get {
... ... @@ -218,5 +206,17 @@ namespace FRControl.Properties {
218 206 this["personInterview"] = value;
219 207 }
220 208 }
  209 +
  210 + [global::System.Configuration.UserScopedSettingAttribute()]
  211 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  212 + [global::System.Configuration.DefaultSettingValueAttribute("门户网站")]
  213 + public string caseName {
  214 + get {
  215 + return ((string)(this["caseName"]));
  216 + }
  217 + set {
  218 + this["caseName"] = value;
  219 + }
  220 + }
221 221 }
222 222 }
... ...
FRControl/Properties/Settings.settings
... ... @@ -38,9 +38,6 @@
38 38 <Setting Name="closeImg" Type="System.String" Scope="User">
39 39 <Value Profile="(Default)">Resources/close.png</Value>
40 40 </Setting>
41   - <Setting Name="caseName" Type="System.String" Scope="User">
42   - <Value Profile="(Default)">官网</Value>
43   - </Setting>
44 41 <Setting Name="lawyerName" Type="System.String" Scope="User">
45 42 <Value Profile="(Default)">案件信息公开</Value>
46 43 </Setting>
... ... @@ -50,5 +47,8 @@
50 47 <Setting Name="personInterview" Type="System.String" Scope="User">
51 48 <Value Profile="(Default)">https://www.12309.gov.cn/front-cas/login?casLv=1&amp;service=https://www.12309.gov.cn/sppWeb/j_spring_cas_security_check</Value>
52 49 </Setting>
  50 + <Setting Name="caseName" Type="System.String" Scope="User">
  51 + <Value Profile="(Default)">门户网站</Value>
  52 + </Setting>
53 53 </Settings>
54 54 </SettingsFile>
55 55 \ No newline at end of file
... ...
FRControl/WebView.cs
... ... @@ -15,7 +15,6 @@ namespace FRControl
15 15 {
16 16 public WebView()
17 17 {
18   -
19 18 SetWebBrowserFeatures(11);
20 19 InitializeComponent();
21 20 Size WindowsScreenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
... ... @@ -73,16 +72,27 @@ namespace FRControl
73 72 //获取网页的最大size
74 73 Size szba = new Size(webBrowser1.Document.Body.ScrollRectangle.Width, webBrowser1.Document.Body.ScrollRectangle.Height);
75 74 Size sz = webBrowser1.Size;
  75 + //Console.WriteLine("szba:" + szba + ",sz:" + sz);
76 76 int xbili = (int)((float)sz.Width / (float)szba.Width * 100);//水平方向缩小比例
77 77 int ybili = (int)((float)sz.Height / (float)szba.Height * 100);//垂直方向缩小比例
78   - Console.WriteLine("xbili:" + xbili + ",ybili:" + ybili);
79   - webBrowser1.Document.Body.Style = "zoom:" + xbili.ToString() + "%";
80   - if (xbili < ybili)
81   - webBrowser1.Document.Body.Style = "zoom:" + xbili.ToString() + "%";
82   - else
83   - webBrowser1.Document.Body.Style = "zoom:" + ybili.ToString() + "%";
84   - webBrowser1.Invalidate();
85   - }
  78 + //Console.WriteLine("xbili:" + xbili + ",ybili:" + ybili);
  79 + //webBrowser1.Document.Body.Style = "width:1080px;";
  80 +
  81 + //Zoom(axIWebBrowser2, 150);
  82 +
  83 + // webBrowser1.Document.Body.Style = "zoom:" + xbili.ToString() + "%";
  84 + //if (xbili < ybili)
  85 + // webBrowser1.Document.Body.Style = "zoom:" + xbili.ToString() + "%";
  86 + //else
  87 + // webBrowser1.Document.Body.Style = "zoom:" + ybili.ToString() + "%";
  88 + //webBrowser1.Invalidate();
  89 +
  90 + FRControl.ZoomBrowser.IWebBrowser2 axIWebBrowser2 = (FRControl.ZoomBrowser.IWebBrowser2)this.webBrowser1.ActiveXInstance; //关键代码
  91 + axIWebBrowser2.ExecWB(FRControl.ZoomBrowser.OLECMDID.OLECMDID_OPTICAL_ZOOM,
  92 + FRControl.ZoomBrowser.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
  93 + xbili, IntPtr.Zero);
  94 + }
  95 +
86 96 private void Window_Error(object sender, HtmlElementErrorEventArgs e)
87 97 {
88 98 e.Handled = true;
... ...
FRControl/ZoomBrowser.cs 0 → 100644
  1 +using System;
  2 +using System.Windows.Forms;
  3 +using System.Runtime.InteropServices;
  4 +
  5 +namespace FRControl
  6 +{
  7 + public partial class ZoomBrowser : WebBrowser
  8 + {
  9 + #region enums
  10 + public enum OLECMDID
  11 + {
  12 + // ...
  13 + OLECMDID_OPTICAL_ZOOM = 63,
  14 + OLECMDID_OPTICAL_GETZOOMRANGE = 64,
  15 + // ...
  16 + }
  17 +
  18 + public enum OLECMDEXECOPT
  19 + {
  20 + // ...
  21 + OLECMDEXECOPT_DONTPROMPTUSER,
  22 + // ...
  23 + }
  24 +
  25 + public enum OLECMDF
  26 + {
  27 + // ...
  28 + OLECMDF_SUPPORTED = 1
  29 + }
  30 + #endregion
  31 +
  32 + #region IWebBrowser2
  33 + [ComImport, /*SuppressUnmanagedCodeSecurity,*/
  34 + TypeLibType(TypeLibTypeFlags.FOleAutomation |
  35 + TypeLibTypeFlags.FDual |
  36 + TypeLibTypeFlags.FHidden),
  37 + Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E")]
  38 + public interface IWebBrowser2
  39 + {
  40 + [DispId(100)] void GoBack();
  41 + [DispId(0x65)] void GoForward();
  42 + [DispId(0x66)] void GoHome();
  43 + [DispId(0x67)] void GoSearch();
  44 + [DispId(0x68)]
  45 + void Navigate([In] string Url,
  46 + [In] ref object flags,
  47 + [In] ref object targetFrameName,
  48 + [In] ref object postData,
  49 + [In] ref object headers);
  50 + [DispId(-550)] void Refresh();
  51 + [DispId(0x69)] void Refresh2([In] ref object level);
  52 + [DispId(0x6a)] void Stop();
  53 + [DispId(200)]
  54 + object Application
  55 + {
  56 + [return:
  57 + MarshalAs(UnmanagedType.IDispatch)]
  58 + get;
  59 + }
  60 + [DispId(0xc9)]
  61 + object Parent
  62 + {
  63 + [return:
  64 + MarshalAs(UnmanagedType.IDispatch)]
  65 + get;
  66 + }
  67 + [DispId(0xca)]
  68 + object Container
  69 + {
  70 + [return:
  71 + MarshalAs(UnmanagedType.IDispatch)]
  72 + get;
  73 + }
  74 + [DispId(0xcb)]
  75 + object Document
  76 + {
  77 + [return:
  78 + MarshalAs(UnmanagedType.IDispatch)]
  79 + get;
  80 + }
  81 + [DispId(0xcc)] bool TopLevelContainer { get; }
  82 + [DispId(0xcd)] string Type { get; }
  83 + [DispId(0xce)] int Left { get; set; }
  84 + [DispId(0xcf)] int Top { get; set; }
  85 + [DispId(0xd0)] int Width { get; set; }
  86 + [DispId(0xd1)] int Height { get; set; }
  87 + [DispId(210)] string LocationName { get; }
  88 + [DispId(0xd3)] string LocationURL { get; }
  89 + [DispId(0xd4)] bool Busy { get; }
  90 + [DispId(300)] void Quit();
  91 + [DispId(0x12d)] void ClientToWindow(out int pcx, out int pcy);
  92 + [DispId(0x12e)]
  93 + void PutProperty([In] string property,
  94 + [In] object vtValue);
  95 + [DispId(0x12f)] object GetProperty([In] string property);
  96 + [DispId(0)] string Name { get; }
  97 + [DispId(-515)] int HWND { get; }
  98 + [DispId(400)] string FullName { get; }
  99 + [DispId(0x191)] string Path { get; }
  100 + [DispId(0x192)] bool Visible { get; set; }
  101 + [DispId(0x193)] bool StatusBar { get; set; }
  102 + [DispId(0x194)] string StatusText { get; set; }
  103 + [DispId(0x195)] int ToolBar { get; set; }
  104 + [DispId(0x196)] bool MenuBar { get; set; }
  105 + [DispId(0x197)] bool FullScreen { get; set; }
  106 + [DispId(500)]
  107 + void Navigate2([In] ref object URL,
  108 + [In] ref object flags,
  109 + [In] ref object targetFrameName,
  110 + [In] ref object postData,
  111 + [In] ref object headers);
  112 + [DispId(0x1f5)] OLECMDF QueryStatusWB([In] OLECMDID cmdID);
  113 + [DispId(0x1f6)]
  114 + void ExecWB([In] OLECMDID cmdID,
  115 + [In] OLECMDEXECOPT cmdexecopt,
  116 + ref object pvaIn, IntPtr pvaOut);
  117 + [DispId(0x1f7)]
  118 + void ShowBrowserBar([In] ref object pvaClsid,
  119 + [In] ref object pvarShow,
  120 + [In] ref object pvarSize);
  121 + [DispId(-525)] WebBrowserReadyState ReadyState { get; }
  122 + [DispId(550)] bool Offline { get; set; }
  123 + [DispId(0x227)] bool Silent { get; set; }
  124 + [DispId(0x228)] bool RegisterAsBrowser { get; set; }
  125 + [DispId(0x229)] bool RegisterAsDropTarget { get; set; }
  126 + [DispId(0x22a)] bool TheaterMode { get; set; }
  127 + [DispId(0x22b)] bool AddressBar { get; set; }
  128 + [DispId(0x22c)] bool Resizable { get; set; }
  129 + }
  130 + #endregion
  131 +
  132 + private IWebBrowser2 axIWebBrowser2;
  133 +
  134 + public ZoomBrowser()
  135 + {
  136 + }
  137 +
  138 + protected override void AttachInterfaces(
  139 + object nativeActiveXObject)
  140 + {
  141 + base.AttachInterfaces(nativeActiveXObject);
  142 + this.axIWebBrowser2 = (IWebBrowser2)nativeActiveXObject;
  143 + }
  144 +
  145 + protected override void DetachInterfaces()
  146 + {
  147 + base.DetachInterfaces();
  148 + this.axIWebBrowser2 = null;
  149 + }
  150 +
  151 + public void Zoom(int factor)
  152 + {
  153 + object pvaIn = factor;
  154 + try
  155 + {
  156 + this.axIWebBrowser2.ExecWB(OLECMDID.OLECMDID_OPTICAL_ZOOM,
  157 + OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
  158 + ref pvaIn, IntPtr.Zero);
  159 + }
  160 + catch (Exception)
  161 + {
  162 + throw;
  163 + }
  164 + }
  165 + }
  166 +}
... ...