1 #region 矢量渲染方案模块 2 /// 3 ///保存矢量渲染方案 4 /// 5 /// 6 /// 7 private void btn_SaveVecRender_Click(object sender, EventArgs e) 8 { 9 //1、获取保存方案数据 10 ILayer layer = mapControlMain.ActiveView.FocusMap.GetLayer(0); 11 if (layer.LayerType != LayerType.LayerTypeFeatureLayer) return; 12 IFeatureLayer featureLayer = layer as IFeatureLayer; 13 //2、设置保存路径 14 SaveFileDialog saveDialog = new SaveFileDialog(); 15 saveDialog.Title = "保存显示方案"; 16 saveDialog.Filter = "Xml文件(*.xml)|*.xml"; 17 if (saveDialog.ShowDialog() != DialogResult.OK) return; 18 //3、执行保存方案 19 RenderFactory.ExportToFile(featureLayer.Render, saveDialog.FileName); 20 } 21 22 /// 23 /// 打开矢量数据渲染方案 24 /// 25 /// 26 /// 27 private void tbn_OpenVecRender_Click(object sender, EventArgs e) 28 { 29 //1、获取保存方案数据 30 ILayer layer = mapControlMain.ActiveView.FocusMap.GetLayer(0); 31 if (layer.LayerType != LayerType.LayerTypeFeatureLayer) return; 32 IFeatureLayer featureLayer = layer as IFeatureLayer; 33 //2、选择渲染的方案 34 OpenFileDialog openDialog = new OpenFileDialog(); 35 openDialog.Title = "打开渲染方案"; 36 openDialog.Filter = "渲染方案(*.xml)|*.xml"; 37 if (openDialog.ShowDialog() != DialogResult.OK) return; 38 //3、执行渲染并刷新 39 featureLayer.Render = RenderFactory.ImportFromFile1(openDialog.FileName); 40 mapControlMain.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll); 41 } 42 #endregion 43 44 #region 栅格渲染方案模块 45 /// 46 /// 保存栅格渲染方案 47 /// 48 /// 49 /// 50 private void btn_SaveRasterRender_Click(object sender, EventArgs e) 51 { 52 //1、获取保存方案数据 53 ILayer layer = mapControlMain.ActiveView.FocusMap.GetLayer(0); 54 if (layer.LayerType != LayerType.LayerTypeRasterLayer) return; 55 IRasterLayer rasterLayer = layer as IRasterLayer; 56 //2、设置保存路径 57 SaveFileDialog saveDialog = new SaveFileDialog(); 58 saveDialog.Title = "保存显示方案"; 59 saveDialog.Filter = "Xml文件(*.xml)|*.xml"; 60 if (saveDialog.ShowDialog() != DialogResult.OK) return; 61 //3、执行保存方案 62 RenderFactory.ExportToFile(rasterLayer.Render, saveDialog.FileName); 63 } 64 65 /// 66 /// 打开栅格渲染方案 67 /// 68 /// 69 /// 70 private void btn_OpenRasterRender_Click(object sender, EventArgs e) 71 { 72 //1、获取保存方案数据 73 ILayer layer = mapControlMain.ActiveView.FocusMap.GetLayer(0); 74 if (layer.LayerType != LayerType.LayerTypeRasterLayer) return; 75 IRasterLayer rasterLayer = layer as IRasterLayer; 76 //2、选择渲染的方案 77 OpenFileDialog openDialog = new OpenFileDialog(); 78 openDialog.Title = "打开渲染方案"; 79 openDialog.Filter = "渲染方案(*.xml)|*.xml"; 80 if (openDialog.ShowDialog() != DialogResult.OK) return; 81 //3、执行渲染并刷新 82 rasterLayer.Render = RenderFactory.ImportFromFile(openDialog.FileName); 83 mapControlMain.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll); 84 } 85 86 /// 87 /// 栅格渲染控制案例 88 /// 89 /// 90 /// 91 private void btn_RasterRenderControl_Click(object sender, EventArgs e) 92 { 93 ILayer layer = mapControlMain.ActiveView.FocusMap.GetLayer(0); 94 if (layer.LayerType != LayerType.LayerTypeRasterLayer) return; 95 IRasterLayer rasterLayer = layer as IRasterLayer; 96 FormDynamicRender FrmDialog = new FormDynamicRender(rasterLayer, mapControlMain.ActiveView); 97 FrmDialog.Owner = this; 98 FrmDialog.Show(); 99 }100 #endregion