GIS二次开发—专题图主窗体代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
namespace MapLayout.PageLayout
{
public class PageLayout
{
#region 打印输出
///
/// pageLayout输出图片
///
///
public static bool ExportMapToImage(AxPageLayoutControl axPageLayoutControl1)
{
try
{
SaveFileDialog pSaveDialog = new SaveFileDialog();
pSaveDialog.FileName = "";
pSaveDialog.Filter = "JPG图片(*.JPG)|*.jpg|tif图片(*.tif)|*.tif|PDF文档(*.PDF)|*.pdf";
if (pSaveDialog.ShowDialog() == DialogResult.OK)
{
double iScreenDispalyResolution =
axPageLayoutControl1.ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
IExporter pExporter = null;
if (pSaveDialog.FilterIndex == 0)
{
pExporter = new JpegExporterClass();
}
else if (pSaveDialog.FilterIndex == 1)
{
pExporter = new TiffExporterClass();
}
else if (pSaveDialog.FilterIndex == 2)
{
pExporter = new PDFExporterClass();
}
pExporter.ExportFileName = pSaveDialog.FileName;
pExporter.Resolution = (short)iScreenDispalyResolution;
tagRECT deviceRect =
axPageLayoutControl1.ActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame();
IEnvelope pDeviceEnvelope = new EnvelopeClass();
pDeviceEnvelope.PutCoords(deviceRect.left, deviceRect.bottom,
deviceRect.right, deviceRect.top);
pExporter.PixelBounds = pDeviceEnvelope;
ITrackCancel pCancle = new CancelTrackerClass();
axPageLayoutControl1.ActiveView.Output(pExporter.StartExporting(),
pExporter.Resolution, ref deviceRect, axPageLayoutControl1.ActiveView.Extent, pCancle);
Application.DoEvents();
pExporter.FinishExporting();
return true;
}
else
{
return false;
}
}
catch (Exception Err)
{
MessageBox.Show(Err.Message, "输出图片", MessageBoxButtons.OK,
rmation);
return false;
}
}
///
/// 打印PageLayout
///
/// PageLayout对象
public static void PrintPageLayout(AxPageLayoutControl pPageLayout)
{
try
{
if (pPageLayout.Printer != null)
{
IPrinter pPrinter = pPageLayout.Printer;
if (pPrinter.Paper.Orientation != pPageLayout.Page.Orientation)
{
pPrinter.Paper.Orientation = pPageLayout.Page.Orientation;
}
pPageLayout.PrintPageLayout(1, 0, 0);
}
}
catch (Exception Err)
{
MessageBox.Show(Err.Message, "打印", MessageBoxButtons.OK,