public GxdDocument(IGxdTemplateHost templateHost) { InitReplace(); _templateHost = templateHost; if (_templateHost != null) { if (_templateHost.LayoutTemplate != null && _templateHost.LayoutTemplate.Layout != null) { IElement[] eles = _templateHost.LayoutTemplate.Layout.QueryElements((e) => { return(e is IDataFrame); }); if (eles == null || eles.Length == 0) { return; } foreach (IDataFrame df in eles) { GxdDataFrame gxddf = new GxdDataFrame( df.Name, GxdEnvelopeGetter(df), GetDfVectorHostFromXml(df), df.SpatialRef, df.GetGridXml(), GetDocumentableLayersXml(df) ); _dataFrames.Add(gxddf); } } } }
public static IGxdDocument GenerateFrom(ILayoutHost host) { if (host == null || host.LayoutRuntime == null || host.LayoutRuntime.Layout == null) { return(null); } // ILayoutTemplate template = new LayoutTemplate(host.LayoutRuntime.Layout); GxdTemplateHost gxdTemplate = new GxdTemplateHost(template); // IGxdDocument gxdoc = new GxdDocument(gxdTemplate); // IElement[] dfs = host.LayoutRuntime.QueryElements((ele) => { return(ele is IDataFrame); }, false); if (dfs != null) { gxdoc.DataFrames.Clear(); foreach (IDataFrame df in dfs) { GxdDataFrame gxdDf = new GxdDataFrame(df.Name, GetDfEnvelope(df), GetDfVectorHost(df), df.SpatialRef, df.GetGridXml(), df.GetDocumentableLayersHostXml()); if (GxDataFrameRasterItemsSetter != null) { GxDataFrameRasterItemsSetter(df, gxdDf); } gxdoc.DataFrames.Add(gxdDf); } } return(gxdoc); }
private IGxdDataFrame GetGxdDataFrame(XElement ele) { string name = GetStringAttribute(ele, "name"); double minx = GetDoubleAttribute(ele, "minx"); double maxx = GetDoubleAttribute(ele, "maxx"); double miny = GetDoubleAttribute(ele, "miny"); double maxy = GetDoubleAttribute(ele, "maxy"); GxdEnvelope evp = null; if (!(double.IsNaN(minx) || double.IsNaN(maxx) || double.IsNaN(miny) || double.IsNaN(maxy))) { evp = new GxdEnvelope(minx, maxx, miny, maxy); } List <IGxdRasterItem> gxItems = null; if (ele.Element("GxdRasterItems") != null) { var eles = ele.Element("GxdRasterItems").Elements("GxdRasterItem"); if (eles != null) { gxItems = new List <IGxdRasterItem>(); foreach (XElement e in eles) { IGxdRasterItem item = GetRasterItem(e); if (item != null) { gxItems.Add(item); } } } } string spatialRef = null; XElement prjEle = ele.Element("SpatialRef"); if (prjEle != null) { spatialRef = prjEle.Value; } IGxdVectorHost vhost = GetGxdVectorHost(ele.Element("GxdVectorHost")); IGxdDataFrame df = new GxdDataFrame(name, evp, vhost, spatialRef, ele.Element("GeoGrid"), ele.Element("DocumentableLayersHost")); if (gxItems != null) { df.GxdRasterItems.AddRange(gxItems.ToArray()); } return(df); }