大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
软件的帮助文档可借助第三方软件如PDF Reader、Adobe PDF等显示,但客户机上需安装此类软件。WPF开发的软件可借助第三方库 MoonPdf将PDF文档加载显示到软件窗口中(Dll下载地址,GitHub源码地址)。
成都创新互联公司是一家专注于做网站、网站建设与策划设计,城西网站建设哪家好?成都创新互联公司做网站,专注于网站建设10多年,网设计领域的专业建站公司;建站业务涵盖:城西等地区。城西做网站价格咨询:028-86922220
PDFViewer.xaml
PDFViewer.cs
using MoonPdfLib; //记得引用此命名空间
public partial class PdfViewer : UserControl
{
private bool m_bLoaded = false;
public PdfViewer()
{
InitializeComponent();
}
public bool LoadPdfDoc( string strPdfPath )
{
try
{
this.pdfViewer.OpenFile( strPdfPath );
this.pdfViewer.Zoom( 1.0 );
m_bLoaded = true;
}
catch
{
m_bLoaded = false;
}
return m_bLoaded;
}
private void ZoomToOrigin_Click( object sender, RoutedEventArgs e )
{
if ( !m_bLoaded )
return;
this.pdfViewer.Zoom( 1.0 );
}
private void SinglePage_Click( object sender, RoutedEventArgs e )
{
if ( !m_bLoaded )
return;
this.pdfViewer.ViewType = ViewType.SinglePage;
}
private void DoublePage_Click( object sender, RoutedEventArgs e )
{
if ( !m_bLoaded )
return;
this.pdfViewer.ViewType = ViewType.Facing;
}
}
调用PdfViewer,及HelpWin窗口类:HelpWin.xaml
HelpWin.cs
public partial class HelpWin : Window
{
private string m_strPdfPath = AppDomain.CurrentDomain.BaseDirectory + "help.pdf";
public HelpWin()
{
InitializeComponent();
}
private void ImgClose_MouseDown( object sender, MouseButtonEventArgs e )
{
this.Close();
}
private void PDFView_Loaded( object sender, RoutedEventArgs e )
{
if ( !this.PDFView.LoadPdfDoc( m_strPdfPath ) )
{
MessageBox.Show( "打开帮助文档失败,请重试!" );
}
}
}