也許,我有一個解決這個平移問題。它確實需要IE10(桌面),但我記得閱讀過評論(被刪除了嗎?)這個項目的目標平臺是Windows 7,所以希望你有自由在那裏部署IE10。我用我的舊華碩Eee PC T91MT(Windows 7 SP1 w/Platform Update和IE10)進行了測試,即使在那塊硬件上也感覺很不錯。
抓住工作VS2012項目WinForms或WPF。
的主要點是:
代碼(C#):
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Navigation;
namespace WpfWbApp
{
//
// By Noseratio [http://stackoverflow.com/users/1768303/noseratio]
//
// Question: http://stackoverflow.com/questions/17170011/c-sharp-webbrowser-panningmode
//
public partial class MainWindow : Window
{
public MainWindow()
{
SetBrowserCompatibilityMode();
InitializeComponent();
this.Loaded += MainWindow_Loaded;
this.WB.LoadCompleted += WB_LoadCompleted;
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
this.WB.Navigate(new Uri(new Uri(Assembly.GetExecutingAssembly().CodeBase), "content/test.htm").AbsoluteUri);
}
void WB_LoadCompleted(object sender, NavigationEventArgs e)
{
this.WB.Focus();
this.WB.InvokeScript("focus");
}
private void SetBrowserCompatibilityMode()
{
// http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx
// FeatureControl settings are per-process
var fileName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);
if (String.Compare(fileName, "devenv.exe", true) == 0) // make sure we're not running inside Visual Studio
return;
using (var key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION",
RegistryKeyPermissionCheck.ReadWriteSubTree))
{
// Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
UInt32 mode = 10000; // 10000;
key.SetValue(fileName, mode, RegistryValueKind.DWord);
}
using (var key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BLOCK_LMZ_SCRIPT",
RegistryKeyPermissionCheck.ReadWriteSubTree))
{
// enable <scripts> in local machine zone
UInt32 mode = 0;
key.SetValue(fileName, mode, RegistryValueKind.DWord);
}
using (var key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE",
RegistryKeyPermissionCheck.ReadWriteSubTree))
{
// disable Legacy Input Model
UInt32 mode = 0;
key.SetValue(fileName, mode, RegistryValueKind.DWord);
}
}
}
}
XAML:
<Window x:Class="WpfWbApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Touch and pan the picture" Width="1024" Height="800">
<WebBrowser Name="WB"></WebBrowser>
</Window>
HTML:
<!doctype html>
<html>
<head>
<style>
body { -ms-content-zooming:none; -ms-scroll-rails: none; }
</style>
</head>
<body style="overflow: auto">
<img src="panorama.jpg">
</body>
</html>
我不能IE9測試它,因爲我沒有與IE9的觸摸屏機器,但我敢肯定它不會工作。顯然,新的Pointer Events Touch API是爲Windows 7(與Platform Update)specifically for IE10引入的。
讓我們知道它是如何爲你工作的。祝你好運!
[編輯] 更新了鏈接到a WinForms project。
如果你知道頁面的html,你能不能添加樣式到圖像?像默認的widhth = 200px或什麼的? – confusedMind
因爲用戶需要查看詳細信息。他們只需要能夠向右滾動而不需要先滾動。 – teynon
當圖像水平延伸到瀏覽器窗口之外時,這更是一個問題,但不足以垂直拉伸頁面。在這種情況下,無法在Windows Mobile設備上向右滾動。 – teynon