コード例 #1
0
        private GxdTemplateHost GetGxdTemplate(XElement ele)
        {
            if (ele == null)
            {
                return(null);
            }
            string name        = GetStringAttribute(ele, "name");
            string fullname    = GetStringAttribute(ele, "fullname");
            string tempContent = null;

            if (ele.Element("Layout") != null)
            {
                tempContent = ele.Element("Layout").ToString();
            }
            ILayoutTemplate temp = LayoutTemplate.CreateFrom(tempContent);

            if (temp != null)
            {
                GxdTemplateHost host = new GxdTemplateHost(temp);
                return(host);
            }
            return(null);
        }
コード例 #2
0
        private void TryApplyVars(ILayoutTemplate t, string drawFName)
        {
            string         fileName          = drawFName.Replace("_G", "");
            RasterIdentify rst               = new RasterIdentify(fileName);
            Dictionary <string, string> vars = new Dictionary <string, string>();

            //
            fileName = Path.GetFileName(fileName).ToUpper();
            if (fileName.Contains("EA"))
            {
                vars.Add("{Region}", "洞庭湖");
                _region = "EA";
            }
            else if (fileName.Contains("EB"))
            {
                vars.Add("{Region}", "鄱阳湖");
                _region = "EB";
            }
            if (!string.IsNullOrEmpty(rst.Satellite))
            {
                string sate = rst.Satellite.ToUpper();
                if (sate.Contains("FY3"))
                {
                    sate = sate.Replace("FY3", "FY-3");
                }
                vars.Add("{Satellite}", sate);
            }
            if (!string.IsNullOrEmpty(rst.Sensor))
            {
                vars.Add("{Sensor}", rst.Sensor);
            }
            if (rst.GenerateDateTime != DateTime.MinValue)
            {
                vars.Add("{OrbitDateTime}", rst.OrbitDateTime.AddHours(8).ToString("yyyy年MM月dd日 HH:mm") + " (北京时)");
            }
            t.ApplyVars(vars);
        }
コード例 #3
0
        protected override void ApplyAttributesOfLayoutTemplate(ILayoutTemplate template)
        {
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            string[] files  = GetStringArray("SelectedPrimaryFiles");
            ILayout  layout = template.Layout;
            double   minx;
            double   miny;
            double   maxx;
            double   maxy;

            using (IRasterDataProvider dataPrd = GeoDataDriver.Open(files[0], "") as IRasterDataProvider)
            {
                minx = dataPrd.CoordEnvelope.MinX - 1;   //扩大数据框范围
                maxx = dataPrd.CoordEnvelope.MaxX + 1;
                miny = dataPrd.CoordEnvelope.MinY - 1;
                maxy = dataPrd.CoordEnvelope.MaxY + 1;
            }
            _envelope = new Layout.GxdEnvelope(minx, maxx, miny, maxy);
            Dictionary <string, string> vars = new Dictionary <string, string>();

            vars.Add("{NAME}", imgname);
            template.ApplyVars(vars);
        }
コード例 #4
0
        public void Generate(string dataFileName, string templateName, int[] aoi, string extInfos, string outIdentify, params object[] options)
        {
            _doc   = null;
            _fname = null;
            ILayoutTemplate t = GetTemplateByName(dataFileName, templateName);

            if (t == null)
            {
                return;
            }
            if (IsFitToTemplateWidth)
            {
                using (IRasterDataProvider prd = GeoDataDriver.Open(dataFileName) as IRasterDataProvider)
                {
                    if (prd != null)
                    {
                        FitTemplateWidth(t.Layout, prd.Width, prd.Height);
                    }
                }
            }
            _fname = GetOutputGxdFileName(dataFileName, outIdentify, extInfos);
            _doc   = GetDocument(dataFileName, aoi, t, options != null && options.Length > 0 ? options[0] : null);
            TrySetAttributesOfElements(_doc);
        }
コード例 #5
0
ファイル: SubProductIMGFIR.cs プロジェクト: windygu/hispeed
        protected override void ApplyAttributesOfLayoutTemplate(ILayoutTemplate template)
        {
            _addFirInfo = false;
            _firFile    = null;
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (instanceIdentify == "FPGI" || instanceIdentify == "0SDI")
            {
                foreach (IElement item in template.Layout.Elements)
                {
                    if (item is MultlineTextElement)
                    {
                        MultlineTextElement txt = item as MultlineTextElement;
                        if (txt.Text.Contains("{ControlPoints}"))
                        {
                            _addFirInfo = true;
                            break;
                        }
                    }
                }
                if (_addFirInfo)
                {
                    string[] frilFileList = FindFRILFiles();
                    if (frilFileList == null || frilFileList.Length < 1)
                    {
                        _firFile = null;
                        return;
                    }
                    SetFireInfos(frilFileList[0]);
                    _firFile = frilFileList[0];
                    Dictionary <string, string> vars = new Dictionary <string, string>();
                    vars.Add("{ControlPoints}", _firInfos.ToString());
                    template.ApplyVars(vars);
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LayoutBlockStateView"/> class.
 /// </summary>
 /// <param name="controllerView">The controller view to which this object belongs.</param>
 /// <param name="blockState">The block state.</param>
 /// <param name="template">The frame template.</param>
 protected LayoutBlockStateView(LayoutControllerView controllerView, ILayoutBlockState blockState, ILayoutTemplate template)
     : base(controllerView, blockState, template)
 {
 }
コード例 #7
0
ファイル: ThemeGraphHelper.cs プロジェクト: windygu/hispeed
        private ILayoutTemplate GetTemplateByName(string templateName)
        {
            ILayoutTemplate t = LayoutTemplate.FindTemplate(templateName);

            return(t);
        }
コード例 #8
0
ファイル: ThemeGraphHelper.cs プロジェクト: windygu/hispeed
 public ThematicGraphHelper(ISmartSession session, string templateName)
 {
     _session      = session;
     _templateName = templateName;
     _template     = GetTemplateByName(templateName);
 }
コード例 #9
0
 private void ApplyLayoutTemplate(ILayoutViewer viewer, ref ILayoutTemplate temp)
 {
     _host = viewer.LayoutHost;
     _host.ApplyTemplate(temp);
 }
コード例 #10
0
        private void TryApplyVars(ILayoutTemplate temp, IRasterDrawing rs)
        {
            string         fileName                  = rs.FileName;
            RasterIdentify rst                       = new RasterIdentify(fileName);
            Dictionary <string, string> vars         = new Dictionary <string, string>();
            IRasterDataProvider         dataProvider = GeoDataDriver.Open(fileName) as IRasterDataProvider;

            if (!string.IsNullOrEmpty(rst.Satellite))
            {
                string sate = rst.Satellite.ToUpper();
                if (sate.Contains("FY3"))
                {
                    sate = sate.Replace("FY3", "FY-3");
                }
                vars.Add("{Satellite}", sate);
            }
            if (!string.IsNullOrEmpty(rst.Sensor))
            {
                vars.Add("{Sensor}", rst.Sensor);
            }
            if (rst.GenerateDateTime != DateTime.MinValue)
            {
                vars.Add("{OrbitDateTime}", rst.OrbitDateTime.AddHours(8).ToString("yyyy年MM月dd日 HH:mm") + " (北京时)");
            }
            if (dataProvider != null)
            {
                string resolutionStr = Math.Round(dataProvider.ResolutionX, 4).ToString();
                vars.Add("{resolution}", resolutionStr);
                if (dataProvider.SpatialRef == null)
                {
                    vars.Add("{projection}", "等经纬度");
                }
                else if (dataProvider.SpatialRef.GeographicsCoordSystem == null)
                {
                    vars.Add("{projection}", "");
                }
                else if (dataProvider.SpatialRef.ProjectionCoordSystem == null)
                {
                    vars.Add("{projection}", "等经纬度");
                }
                else
                {
                    string targatName  = string.Empty;
                    string projectName = dataProvider.SpatialRef.ProjectionCoordSystem.Name.Name;
                    GetProjectName(projectName, out targatName);
                    vars.Add("{projection}", targatName);
                }
                int[]         channels    = rs.SelectedBandNos;// dataProvider.GetDefaultBands();
                List <string> channelList = new List <string>();
                if (channels != null && channels.Count() > 0)
                {
                    for (int i = 0; i < channels.Length; i++)
                    {
                        channelList.Add(channels[i].ToString());
                        channelList.Add(",");
                    }
                    channelList.RemoveAt(channelList.Count - 1);
                }
                string channelStr = null;
                foreach (string item in channelList)
                {
                    channelStr += item;
                }
                vars.Add("{channel}", channelStr);
            }
            temp.ApplyVars(vars);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        private void TryApplyVars(ILayoutTemplate temp, IRasterDrawing rasterDrawing)
        {
            string       fileName = Path.Combine(Path.GetDirectoryName(rasterDrawing.FileName), rasterDrawing.FileName.Replace("_G.", "."));
            DataIdentify did;

            if (File.Exists(fileName))
            {
                using (IRasterDataProvider dataPrd = GeoDataDriver.Open(fileName) as IRasterDataProvider)
                {
                    did = dataPrd.DataIdentify;
                }
            }
            else
            {
                did = rasterDrawing.DataProviderCopy.DataIdentify;
            }
            Dictionary <string, string> vars = new Dictionary <string, string>();

            //
            fileName = Path.GetFileName(fileName).ToUpper();
            if (fileName.Contains("EA"))
            {
                vars.Add("{Region}", "洞庭湖");
                _region = "EA";
            }
            else if (fileName.Contains("EB"))
            {
                vars.Add("{Region}", "鄱阳湖");
                _region = "EB";
            }
            if (!string.IsNullOrEmpty(did.Satellite))
            {
                string sate = did.Satellite.ToUpper();
                if (sate.Contains("FY3"))
                {
                    sate = sate.Replace("FY3", "FY-3");
                }
                vars.Add("{Satellite}", sate);
            }
            if (!string.IsNullOrEmpty(did.Sensor))
            {
                vars.Add("{Sensor}", did.Sensor);
            }
            if (did.OrbitDateTime != DateTime.MinValue)
            {
                vars.Add("{OrbitDateTime}", did.OrbitDateTime.AddHours(8).ToString("yyyy年MM月dd日 HH:mm") + " (北京时)");
            }
            IRasterDataProvider dataProvider = rasterDrawing.DataProviderCopy;// GeoDataDriver.Open(fileName) as IRasterDataProvider;

            if (dataProvider != null)
            {
                string resolutionStr = Math.Round(dataProvider.ResolutionX, 4).ToString();
                vars.Add("{resolution}", resolutionStr);
                if (dataProvider.SpatialRef == null)
                {
                    vars["{resolution}"] += "度";
                    vars.Add("{projection}", "等经纬度");
                }
                else if (dataProvider.SpatialRef.GeographicsCoordSystem == null)
                {
                    vars.Add("{projection}", "");
                }
                else if (dataProvider.SpatialRef.ProjectionCoordSystem == null)
                {
                    vars["{resolution}"] += "度";
                    vars.Add("{projection}", "等经纬度");
                }
                else
                {
                    string targatName  = string.Empty;
                    string projectName = dataProvider.SpatialRef.ProjectionCoordSystem.Name.Name;
                    GetProjectName(projectName, out targatName);
                    vars.Add("{projection}", targatName);
                }
                int[]         channels    = rasterDrawing.SelectedBandNos;// dataProvider.GetDefaultBands();
                List <string> channelList = new List <string>();
                if (channels != null && channels.Count() > 0)
                {
                    for (int i = 0; i < channels.Length; i++)
                    {
                        channelList.Add(channels[i].ToString());
                        channelList.Add(",");
                    }
                    channelList.RemoveAt(channelList.Count - 1);
                }
                string channelStr = null;
                foreach (string item in channelList)
                {
                    channelStr += item;
                }
                vars.Add("{channel}", channelStr);
            }
            temp.ApplyVars(vars);
        }
コード例 #13
0
        public static void UpdateLegend(ProductColorTable[] colors, Action <int, string> percentProgress)
        {
            string path = System.AppDomain.CurrentDomain.BaseDirectory + "LayoutTemplate";

            if (!Directory.Exists(path))
            {
                return;
            }
            string[] files = Directory.GetFiles(path, "*.gxt", SearchOption.AllDirectories);
            if (files == null || files.Length == 0)
            {
                return;
            }
            for (int i = 0; i < files.Length; i++)
            {
                string          fname    = files[i];
                ILayoutTemplate template = LayoutTemplate.LoadTemplateFrom(fname);

                //LayoutTemplate.LoadTemplateFrom(fname);
                if (template == null)
                {
                    return;
                }
                if (percentProgress != null)
                {
                    percentProgress((int)((i + 1) * 100f / files.Length), "");
                }
                ILayout layout   = template.Layout;
                bool    haUpdate = false;
                for (int e = 0; e < layout.Elements.Count; e++)
                {
                    if (layout.Elements[e] is ILegendElement)
                    {
                        ILegendElement legendEle = layout.Elements[e] as ILegendElement;
                        string         colotName = legendEle.ColorTableName;
                        if (!string.IsNullOrWhiteSpace(colotName))
                        {
                            ProductColorTable colorTable = ProductColorTableFactory.GetColorTable(colotName);
                            if (colorTable != null)
                            {
                                List <LegendItem> items = new List <LegendItem>();
                                foreach (ProductColor pc in colorTable.ProductColors)
                                {
                                    if (!pc.DisplayLengend)
                                    {
                                        continue;
                                    }
                                    LegendItem item = new LegendItem(pc.LableText, pc.Color);
                                    items.Add(item);
                                }
                                legendEle.LegendItems = items.ToArray();
                                haUpdate = true;
                            }
                        }
                    }
                }
                if (haUpdate)
                {
                    template.SaveTo(fname);
                }
            }
        }
コード例 #14
0
 public GxdTemplateHost(ILayoutTemplate layoutTemplate)
 {
     _layoutTemplate = layoutTemplate;
 }
コード例 #15
0
        //应用变量
        private void TryApplyVars(IGxdDocument doc, string fileName)
        {
            ILayoutTemplate             temp     = doc.GxdTemplateHost.LayoutTemplate;
            RasterIdentify              identify = new RasterIdentify(fileName);
            Dictionary <string, string> vars     = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(identify.Satellite))
            {
                string sate = identify.Satellite.ToUpper();
                if (sate.Contains("FY3"))
                {
                    sate = sate.Replace("FY3", "FY-3");
                }
                else if (sate.Contains("FY2"))
                {
                    sate = sate.Replace("FY2", "FY-2");
                }
                vars.Add("{Satellite}", sate);
            }
            if (!string.IsNullOrEmpty(identify.Sensor))
            {
                vars.Add("{Sensor}", identify.Sensor);
            }
            if (!string.IsNullOrEmpty(identify.ProductName))
            {
                vars.Add("{Product}", identify.ProductName);
            }
            if (string.IsNullOrWhiteSpace(DateString))
            {
                if (identify.OrbitDateTime != DateTime.MinValue)
                {
                    identify.OrbitDateTime.AddHours(8);
                    vars.Add("{OrbitDateTime}", identify.OrbitDateTime.AddHours(8).ToString("yyyy年MM月dd日 HH:mm") + " (北京时)");
                }
                if (identify.MaxOrbitDate != DateTime.MaxValue && identify.MinOrbitDate != DateTime.MinValue)
                {
                    DateTime minTime = identify.MinOrbitDate.AddHours(8);
                    DateTime maxTime = identify.MaxOrbitDate.AddHours(8);
                    vars.Add("{MinOrbitDateTime~MaxOrbitDateTime}", minTime.ToString("yyyy年MM月dd日 HH:mm") + " ~ " + maxTime.ToString("yyyy年MM月dd日 HH:mm"));
                }
            }
            else
            {
                vars.Add("{OrbitDateTime}", DateString);
                vars.Add("{MinOrbitDateTime~MaxOrbitDateTime}", DateString);
            }
            if (!string.IsNullOrWhiteSpace(TimesCount))
            {
                vars.Add("{ValidDays}", "有效天数:" + TimesCount);
            }
            else
            {
                vars.Add("{ValidDays}", "");
            }

            if (!IsVector(fileName))
            {
                using (RasterDataProvider rdd = GeoDataDriver.Open(fileName) as RasterDataProvider)
                {
                    if (rdd != null)
                    {
                        string resolutionStr = Math.Round(rdd.ResolutionX, 4).ToString();
                        vars.Add("{resolution}", resolutionStr);
                        if (rdd.SpatialRef == null)
                        {
                            vars["{resolution}"] += "度";
                            vars.Add("{projection}", "等经纬度");
                        }
                        else if (rdd.SpatialRef.GeographicsCoordSystem == null)
                        {
                            vars.Add("{projection}", "");
                        }
                        else if (rdd.SpatialRef.ProjectionCoordSystem == null)
                        {
                            vars["{resolution}"] += "度";
                            vars.Add("{projection}", "等经纬度");
                        }
                        else
                        {
                            string targatName  = string.Empty;
                            string projectName = rdd.SpatialRef.ProjectionCoordSystem.Name.Name;
                            GetProjectName(projectName, out targatName);
                            vars.Add("{projection}", targatName);
                        }
                    }
                }
            }
            temp.ApplyVars(vars);
        }
コード例 #16
0
 public CoverageLayoutFrame()
 {
     ILayoutTemplate ParentTemplate = this.ParentTemplate;
     ILayoutFrame    ParentFrame    = this.ParentFrame;
 }