嵌入文本排版html

This commit is contained in:
老九 2021-10-30 10:56:05 +08:00
parent ea4277c93d
commit 712f8ca4f9
6 changed files with 132 additions and 20 deletions

View File

@ -1,4 +1,5 @@
using System.Diagnostics;
using Microsoft.Win32;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows;
@ -22,7 +23,8 @@ namespace FastGithub.UI
return;
}
this.fastGithub = StartFastGithub();
this.fastGithub = StartFastGithub();
SetWebBrowserVersion();
base.OnStartup(e);
}
@ -51,6 +53,13 @@ namespace FastGithub.UI
CreateNoWindow = true
};
return Process.Start(startInfo);
}
}
private static void SetWebBrowserVersion()
{
var emulation = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
var key = $"{Process.GetCurrentProcess().ProcessName}.exe";
emulation.SetValue(key, 9000, RegistryValueKind.DWord);
}
}
}

View File

@ -126,7 +126,10 @@
<Resource Include="app.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\reward.png" />
<Resource Include="Resource\reward.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\cert.html" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -145,20 +145,20 @@
<Grid Background="#00ffffff">
<TabControl Style="{StaticResource TabControlWithUnderLineStyle}" Foreground="Black" Background="Transparent" BorderBrush="Transparent" BorderThickness="0">
<TabItem Style="{StaticResource TabItemExWithUnderLineStyle}" Header="流量监控" Height="40" Width="100" Margin="5 0" FontSize="18">
<Grid Margin="16">
<local:FlowChart x:Name="flowChart" />
<Grid Background="#f7f7f7">
<local:FlowChart Margin="16" />
</Grid>
</TabItem>
<TabItem Style="{StaticResource TabItemExWithUnderLineStyle}" Header="证书验证" Height="40" Width="100" Margin="5 0" FontSize="18">
<Grid Margin="16">
<Grid Background="#f7f7f7">
<WebBrowser Name="webCert" />
</Grid>
</TabItem>
<TabItem Style="{StaticResource TabItemExWithUnderLineStyle}" Header="一支华子" Height="40" Width="100" Margin="5 0" FontSize="18">
<Grid Margin="16" >
<Image Source="Images/reward.png" />
<Grid Background="#f7f7f7">
<Image Source="Resource/reward.png" Margin="16" />
</Grid>
</TabItem>
</TabControl>

View File

@ -1,10 +1,8 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Interop;
namespace FastGithub.UI
@ -14,7 +12,7 @@ namespace FastGithub.UI
/// </summary>
public partial class MainWindow : Window
{
private NotifyIcon notifyIcon;
private System.Windows.Forms.NotifyIcon notifyIcon;
private const string FAST_GITHUB = "FastGithub";
private const string PROJECT_URI = "https://github.com/dotnetcore/FastGithub";
@ -22,23 +20,23 @@ namespace FastGithub.UI
{
InitializeComponent();
var about = new MenuItem("关于(&A)");
var about = new System.Windows.Forms.MenuItem("关于(&A)");
about.Click += (s, e) => Process.Start(PROJECT_URI);
var exit = new MenuItem("退出(&C)");
var exit = new System.Windows.Forms.MenuItem("退出(&C)");
exit.Click += (s, e) => this.Close();
this.notifyIcon = new NotifyIcon
this.notifyIcon = new System.Windows.Forms.NotifyIcon
{
Visible = true,
Text = FAST_GITHUB,
ContextMenu = new ContextMenu(new[] { about, exit }),
ContextMenu = new System.Windows.Forms.ContextMenu(new[] { about, exit }),
Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath)
};
this.notifyIcon.MouseClick += (s, e) =>
{
if (e.Button == MouseButtons.Left)
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
this.Show();
this.Activate();
@ -51,7 +49,22 @@ namespace FastGithub.UI
{
var version = FileVersionInfo.GetVersionInfo(fileName);
this.Title = $"{FAST_GITHUB} v{version.ProductVersion}";
}
}
this.webCert.AddHandler(KeyDownEvent, new RoutedEventHandler(WebBrowser_KeyDown), true);
var resource = Application.GetResourceStream(new Uri("Resource/cert.html", UriKind.Relative));
this.webCert.NavigateToStream(resource.Stream);
}
private void WebBrowser_KeyDown(object sender, RoutedEventArgs e)
{
var @event = (KeyEventArgs)e;
if (@event.Key == Key.F5)
{
var resource = Application.GetResourceStream(new Uri("Resource/cert.html", UriKind.Relative));
this.webCert.NavigateToStream(resource.Stream);
}
}
protected override void OnSourceInitialized(EventArgs e)

View File

@ -0,0 +1,87 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" crossorigin="anonymous">
<title>证书验证</title>
<style type="text/css">
body {
overflow-x: hidden;
background-color: #f7f7f7;
}
blockquote {
border-left: 5px solid #c5c5c5;
background-color: #f1f1f1;
}
.badge {
background-color: #999;
}
code {
cursor: pointer;
}
</style>
</head>
<body onContextMenu="return false;">
<div class="container">
<div>
<h3>Firefox</h3>
<blockquote>
<h4>建立安全连接失败</h4>
<p><small>连接到 github.com 时发生错误。对等端的证书有一个无效的签名。</small> </p>
<p><small> 错误代码SEC_ERROR_BAD_SIGNATURE</small> </p>
</blockquote>
<h4>解决办法</h4>
<p>
<span class="badge">1</span>
<span>地址栏输入:</span><code>about:config</code>
</p>
<p>
<span class="badge">2</span>
<span>输入首选项名称:</span><code>security.enterprise_roots.enabled</code>
</p>
<p>
<span class="badge">3</span>
<span>修改值为:</span><code>true</code>
</p>
</div>
<hr />
<div>
<h3>git.exe</h3>
<blockquote>
<h4>clone、pull或push等异常 </h4>
<p><small>fatal: unable to access 'https://github.com/xxx.git/'</small> </p>
<p><small>SSL certificate problem: unable to get local issuer certificate</small> </p>
</blockquote>
<h4>解决办法</h4>
<p>
<span class="badge">1</span>
<span>管理员身份运行:</span><code>cmd</code>
</p>
<p>
<span class="badge">2</span>
<span>在cmd输入</span><code>git config --global http.sslverify false</code>
</p>
</div>
</div>
<script type="text/javascript">
var codes = document.getElementsByTagName('code');
for (var i = 0; i < codes.length; i++) {
var code = codes[i];
code.setAttribute('title', '点击复制');
code.addEventListener("click", function () {
window.clipboardData.setData("Text", this.outerText);
});
}
</script>
</body>
</html>

View File

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 152 KiB