private void btnSinglePlot_Click(object sender, EventArgs e) { MgdMap map = (MgdMap)_viewer.GetMap(); MgMapViewerProvider provider = _viewer.GetProvider(); MgdMappingService mappingSvc = (MgdMappingService)provider.CreateService(MgServiceType.MappingService); MgResourceIdentifier layoutId = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout"); using (SaveFileDialog save = new SaveFileDialog()) { save.Filter = "DWF Files (*.dwf)|*.dwf"; if (save.ShowDialog() == DialogResult.OK) { MgdDwfVersion dwfVer = new MgdDwfVersion("6.01", "1.2"); MgdLayout layout = new MgdLayout(layoutId, "City of Sheboygan", MgdPageUnitsType.Inches); MgdPlotSpecification plotSpec = new MgdPlotSpecification(8.5f, 11.0f, MgdPageUnitsType.Inches, 0.5f, 0.5f, 0.5f, 0.5f); MgByteReader result = mappingSvc.GeneratePlot(map, plotSpec, layout, dwfVer); MgByteSink sink = new MgByteSink(result); sink.ToFile(save.FileName); MessageBox.Show("Saved to " + save.FileName); } } }
private void plotToDwfComponent_Invoked(object sender, EventArgs e) { var diag = new ResourceIdDialog(); if (diag.ShowDialog() == DialogResult.OK) { var layoutId = diag.ResourceID; using (var save = new SaveFileDialog()) { save.Filter = "DWF Files (*.dwf)|*.dwf"; if (save.ShowDialog() == DialogResult.OK) { var mappingSvc = (MgdMappingService)mapViewer.GetProvider().CreateService(MgServiceType.MappingService); var map = (MgdMap)mapViewer.GetMap(); var dwfVer = new MgdDwfVersion("6.01", "1.2"); var layout = new MgdLayout(layoutId, "TestPlot", MgdPageUnitsType.Inches); var plotSpec = new MgdPlotSpecification(8.5f, 11.0f, MgdPageUnitsType.Inches, 0.5f, 0.5f, 0.5f, 0.5f); var result = mappingSvc.GeneratePlot(map, plotSpec, layout, dwfVer); var sink = new MgByteSink(result); sink.ToFile(save.FileName); MessageBox.Show("Saved to " + save.FileName); } } } }
public override void Invoke() { var diag = new ResourceIdDialog(); if (diag.ShowDialog() == DialogResult.OK) { var layoutId = diag.ResourceID; using (var save = new SaveFileDialog()) { save.Filter = "DWF Files (*.dwf)|*.dwf"; if (save.ShowDialog() == DialogResult.OK) { var mappingSvc = (MgdMappingService)this.Viewer.GetProvider().CreateService(MgServiceType.MappingService); var map = (MgdMap)this.Viewer.GetMap(); var dwfVer = new MgdDwfVersion("6.01", "1.2"); var layout = new MgdLayout(layoutId, "TestPlot", MgdPageUnitsType.Inches); var plotSpec = new MgdPlotSpecification(8.5f, 11.0f, MgdPageUnitsType.Inches, 0.5f, 0.5f, 0.5f, 0.5f); var result = mappingSvc.GeneratePlot(map, plotSpec, layout, dwfVer); var sink = new MgByteSink(result); sink.ToFile(save.FileName); MessageBox.Show("Saved to " + save.FileName); } } } }
private void btnMultiPlot_Click(object sender, EventArgs e) { MgdMap map = (MgdMap)_viewer.GetMap(); MgMapViewerProvider provider = _viewer.GetProvider(); MgdMappingService mappingSvc = (MgdMappingService)provider.CreateService(MgServiceType.MappingService); MgResourceIdentifier layoutId = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout"); using (SaveFileDialog save = new SaveFileDialog()) { save.Filter = "DWF Files (*.dwf)|*.dwf"; if (save.ShowDialog() == DialogResult.OK) { MgdDwfVersion dwfVer = new MgdDwfVersion("6.01", "1.2"); MgdLayout layout = new MgdLayout(layoutId, "City of Sheboygan", MgdPageUnitsType.Inches); MgdPlotSpecification plotSpec = new MgdPlotSpecification(8.5f, 11.0f, MgdPageUnitsType.Inches, 0.5f, 0.5f, 0.5f, 0.5f); MgdMapPlotCollection plotCollection = new MgdMapPlotCollection(); MgdMapPlot plot1 = new MgdMapPlot(map, plotSpec, layout); plot1.SetCenterAndScale(map.GetViewCenter().GetCoordinate(), map.GetViewScale() * 2); plotCollection.Add(plot1); // Create a second map for the second sheet in the DWF. This second sheet uses the print layout // to display a page title and legend. MgdMap map2 = new MgdMap(map.GetMapDefinition(), "Sheet 2"); MgdMapPlot plot2 = new MgdMapPlot(map2, plotSpec, layout); plot2.SetCenterAndScale(map.GetViewCenter().GetCoordinate(), map.GetViewScale()); plotCollection.Add(plot2); MgByteReader result = mappingSvc.GenerateMultiPlot(plotCollection, dwfVer); MgByteSink sink = new MgByteSink(result); sink.ToFile(save.FileName); MessageBox.Show("Saved to " + save.FileName); } } }