??軟件的幫助文檔可借助第三方軟件如PDF Reader、Adobe PDF等顯示,但客戶機(jī)上需安裝此類軟件。WPF開發(fā)的軟件可借助第三方庫 MoonPdf將PDF文檔加載顯示到軟件窗口中(Dll下載地址,GitHub源碼地址)。
成都創(chuàng)新互聯(lián)公司是一家專注于做網(wǎng)站、網(wǎng)站建設(shè)與策劃設(shè)計,城西網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:城西等地區(qū)。城西做網(wǎng)站價格咨詢: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;
}
}
調(diào)用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( "打開幫助文檔失敗,請重試!" );
}
}
}