public void DisplayAvi(ISmartSession session, string wndName, string[] fnames, string templateName, string subIdentify, out string outputFname) { string satellite = null; string sensor = null; outputFname = GetOutputGxdFileName(fnames, subIdentify, out satellite, out sensor); bool isOk = false; FileIsSupportable(fnames); ILayoutTemplate temp = GetTemplateByArg(templateName); if (temp == null) { return; } ILayoutViewer viewer = new LayoutViewer(wndName); ApplyLayoutTemplate(viewer, ref temp); //在这里应用模板,初始化数据框的dataProvider TryApplyVars(temp, subIdentify, satellite, sensor); if (viewer.LayoutHost == null) { return; } ICanvas canvas = GetCanvasByTemplate(temp); if (canvas == null) { return; } Size dataSize = Size.Empty; GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewPrjEvp = null; GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp = null; float resolution = 0; int maxSize = GetBorderSizeByTemplate(viewer.LayoutHost.LayoutRuntime, temp); IAVILayer aviLyr = AVILayerBuilder.CreatAVILayer(fnames, canvas, maxSize, out dataSize, out viewPrjEvp, out viewGeoEvp, out resolution); if (aviLyr == null) { return; } aviLyr.OnTicked += new EventHandler(RefreshDataFrame); if (_isCustom) { TryApplyCustom(canvas, dataSize, subIdentify, viewPrjEvp, viewGeoEvp, resolution); } isOk = TryAddAviLayerToCanvas(canvas, aviLyr, viewPrjEvp); if (isOk) { session.SmartWindowManager.DisplayWindow(viewer); _host.ToSuitedSize(_host.LayoutRuntime.Layout); TryExportToGIF(session, subIdentify, outputFname); } }
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(); }