📄 onlinehelp.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.IO;
using HardwareDistributor.Properties;
namespace HardwareDistributor.UI
{
public partial class OnlineHelp : Form
{
private string _fileName;
private bool _clicked = false;
private static string helpFolder = "Help";
public OnlineHelp(string fileName)
{
InitializeComponent();
// We are removing both the Control Box and the Minimize Box, so that we don't
// have to handle these in our code. This is not necessary in Windows Mobile Standard,
// but we are writing this code so that it works on all platforms without any changes
// or any recompiling.
this.ControlBox = false;
this.MinimizeBox = false;
//get the localized help path
_fileName = GetLocalizedHelpfile( fileName);
}
/// <summary>
/// Tries to find a localized help file. If it cannot, it simply uses the one in the default help folder
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
private static string GetLocalizedHelpfile(string fileName)
{
string defaultHelpFolder = null;
StringBuilder helpFilePath = new StringBuilder();
helpFilePath.Append(Business.GlobalCache.Instance.AppPath);
helpFilePath.Append(helpFolder);
//hold on to the default folder
defaultHelpFolder = helpFilePath.ToString();
//now tag on the localized path
helpFilePath.Append("\\");
helpFilePath.Append(CultureInfo.CurrentUICulture.Name);
helpFilePath.Append("\\");
helpFilePath.Append(fileName + "-" + CultureInfo.CurrentUICulture.Name + ".htm");
string localizedHelpFile = helpFilePath.ToString();
string defaultHelpFile = defaultHelpFolder + "\\" + fileName + ".htm";
//send localized filepath IF it exists
return (File.Exists(localizedHelpFile)) ? localizedHelpFile : defaultHelpFile;
}
/// <summary>
/// Dismiss the dialog (soft key is clicked)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItemDismiss_Click(object sender, EventArgs e)
{
if (!_clicked)
{
_clicked = true;
this.Close();
}
}
/// <summary>
/// Custom Handling for the back key
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnlineHelp_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Back))
{
// Back
// if the back key is hit, and the dialog is not already closing, close it now
if (!_clicked)
{
_clicked = true;
this.Close();
}
}
}
/// <summary>
/// Load the Online Help Dialog
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnlineHelp_Load(object sender, EventArgs e)
{
try
{
TextReader reader = new StreamReader(_fileName);
//text.Text = reader.ReadToEnd();
webBrowser.DocumentText = reader.ReadToEnd();
}
catch (Exception ex)
{
Business.Services.LogErrors(ex);
MessageBox.Show(Resources.HelpDisplayError, Resources.SystemError);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -