IPictureElement的使用方法
string bmpPath = "";
private void axPageLayoutControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e)
{
IPageLayout pPageLayout=axPageLayoutControl1.PageLayout;
IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer;
IActiveView pActiveView = pPageLayout as IActiveView;
IPictureElement pBmpPicEle = new BmpPictureElementClass();
if (bmpPath != "")
{
pBmpPicEle.ImportPictureFromFile(bmpPath);
pBmpPicEle.MaintainAspectRatio = true;
IEnvelope pEnv;
pEnv = axPageLayoutControl1.TrackRectangle();
IElement pEle;
pEle = pBmpPicEle as IElement;
pEle.Geometry = pEnv;
pGraphicsContainer.AddElement(pEle, 0);
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.AddExtension = true;
dlg.CheckFileExists = true;
dlg.CheckPathExists = true;
dlg.Multiselect = false;
dlg.RestoreDirectory = true;
dlg.ShowReadOnly = true;
dlg.Filter = "bmp (*.bmp)|*.bmp";
dlg.Title = "打开BMP文件";
dlg.InitialDirectory = "D:\\";
if(dlg.ShowDialog() ==DialogResult.OK)
{
bmpPath = dlg.FileName;
}