private IGxdDocument CreateDocument(ILayoutTemplate template, object p) { IGxdDocument doc = new GxdDocument(new GxdTemplateHost(template)); IGxdDataFrame gxdDf = doc.DataFrames.Count > 0 ? doc.DataFrames[0] : null; return(doc); }
private void button21_Click(object sender, EventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Filter = "Smart Layout Document(*.gxd)|*.gxd"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IGxdDocument doc = GxdDocument.LoadFrom(dlg.FileName); _host.ApplyGxdDocument(doc); _host.Render(); } } }
private IGxdDocument GetDocument(string dataFileName, int[] aoi, ILayoutTemplate t, object options) { IGxdDocument doc = new GxdDocument(new GxdTemplateHost(t)); IGxdDataFrame gxdDf = doc.DataFrames.Count > 0 ? doc.DataFrames[0] : null; if (gxdDf != null) { IGxdRasterItem rst = new GxdRasterItem(dataFileName, options);//这里传具体的色标定义标识 gxdDf.GxdRasterItems.Add(rst); // TryGeneratreAOISecondaryFile(aoi, rst); // TryApplyVars(doc, dataFileName); } return(doc); }
private IGxdDocument GetDocument(ISmartSession session, string rasterFname, string outputFileName, ILayoutTemplate temp, string wndName, params object[] arguments) { IGxdDocument doc = new GxdDocument(new GxdTemplateHost(temp)); IGxdDataFrame gxdDf = doc.DataFrames.Count > 0 ? doc.DataFrames[0] : null; if (string.IsNullOrEmpty(outputFileName)) { return(null); } if (gxdDf != null) { IGxdRasterItem rst = new GxdRasterItem(outputFileName, null);//这里传具体的色标定义标识 gxdDf.GxdRasterItems.Add(rst); } return(doc); }
public override bool Open(string fname, out bool memoryIsNotEnough) { memoryIsNotEnough = false; string text = OpenFileFactory.GetTextByFileName(fname); ILayoutViewer viewer = new LayoutViewer(text); (viewer as LayoutViewer).Tag = fname; (viewer as LayoutViewer).SetSession(_session); _session.SmartWindowManager.DisplayWindow(viewer); if (viewer != null) { string extName = Path.GetExtension(fname).ToUpper(); switch (extName) { case ".GXT": ILayoutTemplate template = LayoutTemplate.LoadTemplateFrom(fname); if (template != null) { viewer.LayoutHost.ApplyTemplate(template); viewer.LayoutHost.ToSuitedSize(); AnsynRefreshData(viewer); _session.UIFrameworkHelper.ActiveTab("专题制图"); } break; case ".GXD": IGxdDocument doc = GxdDocument.LoadFrom(fname); if (doc != null) { viewer.LayoutHost.ApplyGxdDocument(doc); viewer.LayoutHost.ToSuitedSize(); AnsynRefreshData(viewer); //_session.UIFrameworkHelper.ActiveTab("专题制图"); } break; } } return(true); }
public void ExportImageOfGxdFiles() { if (!AutoGeneratorSettings.CurrentSettings.IsOutputPng) { return; } if (AutoGeneratorSettings.CurrentSettings.GxdFileNames == null || AutoGeneratorSettings.CurrentSettings.GxdFileNames.Count == 0) { return; } bool isNeedCopy = !string.IsNullOrEmpty(AutoGeneratorSettings.CurrentSettings.FolderOfCopyTo); if (isNeedCopy) { AutoGeneratorSettings.CurrentSettings.GeneratedFileNames.Clear(); } IContextMessage msg = Session.SmartWindowManager.SmartToolWindowFactory.GetSmartToolWindow(9006) as IContextMessage; if (msg != null) { msg.PrintMessage("开始导出专题图图片......"); } foreach (string fname in GxdFileNames) { IGxdDocument doc = GxdDocument.LoadFrom(fname); if (doc == null) { if (msg != null) { msg.PrintMessage("专题图\"" + fname + "\"打开失败。"); } return; } using (LayoutViewer viewer = new LayoutViewer()) { viewer.LayoutHost.ApplyGxdDocument(doc); using (Bitmap bm = viewer.LayoutHost.ExportToBitmap(System.Drawing.Imaging.PixelFormat.Format32bppArgb)) { if (bm == null) { if (msg != null) { msg.PrintMessage("专题图\"" + fname + "\"导出图片失败。"); } return; } string fileName = Path.Combine(Path.GetDirectoryName(fname), Path.GetFileNameWithoutExtension(fname) + ".png"); bm.Save(fileName, ImageFormat.Png); if (isNeedCopy) { AutoGeneratorSettings.CurrentSettings.GeneratedFileNames.Add(fileName); } } } if (msg != null) { msg.PrintMessage("已导出专题图\"" + fname + "\"。"); } } // if (msg != null) { msg.PrintMessage("导出专题图图片结束。"); } // CopyFileToCopyFolder(); }