private void CreateLegendItems(string[] shpFiles) { _colorTable = ProductColorTableFactory.GetColorTable(_subProductDef.ProductDef.Identify, "EDGE");//ICE,EDGE _legendItems.Clear(); int index = 0; foreach (string file in shpFiles) { index++; RasterIdentify identify = new RasterIdentify(file); DateTime dt = identify.OrbitDateTime; ProductColor pcolor = _colorTable.GetColor(index); if (pcolor == null) { _legendItems.Add(dt.AddHours(8).ToString(), Color.FromArgb(255, 166, 208, 255)); } else { _legendItems.Add(dt.AddHours(8).ToString(), pcolor.Color); } } }
public object GetStretcher(string fname, enumDataType inDataType, string colorTableName, out ColorMapTable <int> colorMapTable) { colorMapTable = null; ProductColorTable pct = null; if (colorTableName == null) { string[] parts = Path.GetFileName(fname).Split('_'); //by chennan 20120819 单通道ldf产品付色 //if (parts.Length < 3 && !fname.ToUpper().EndsWith(".DAT")) if (parts.Length < 3) { return(null); } string productIdentify = parts[0]; string subProductIdentify = parts[1]; pct = ProductColorTableFactory.GetColorTable(productIdentify, subProductIdentify); } else { pct = ProductColorTableFactory.GetColorTable(colorTableName); } if (pct == null) { return(null); } //enumDataType dataType = enumDataType.Atypism; if (inDataType == enumDataType.Atypism) { using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider) { inDataType = prd.DataType; } } return(GetStretcher(inDataType, pct, out colorMapTable)); }
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); } } }
private void button22_Click(object sender, EventArgs e) { ProductColorTable ct = ProductColorTableFactory.GetColorTable("FOG", "DBLV"); object[] sts = ProductColorTableFactory.GetStretcher <UInt16>(ct); }
private IExtractResult IMGAlgorithm() { string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string; if (string.IsNullOrWhiteSpace(instanceIdentify)) { return(null); } SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify); if (instance == null) { return(ThemeGraphyResult(null)); } if (instanceIdentify == "0MSI") { return(ThemeGraphyMCSIDBLV(instance)); } else if (instanceIdentify == "FLSI") { string[] files = GetStringArray("SelectedPrimaryFiles"); if (files == null || files.Length == 0) { TrySetSelectedPrimaryFiles(ref files); } if (files == null || files.Length == 0) { return(null); } string colorTableFile = ProductColorTableParser.LoadProColorTable("FLD"); ProductColorTable[] colorTabels = ProductColorTableParser.Parse(colorTableFile); ProductColorTable[] colorTabelsBack = ProductColorTableParser.Parse(colorTableFile); foreach (ProductColorTable pct in colorTabels) { if (pct.ColorTableName != "FLD" + instanceIdentify) { continue; } List <int> colorNums = new List <int>(); using (IRasterDataProvider rdp = GeoDataDriver.Open(files[0]) as IRasterDataProvider) { LastDaysSetValue outLastDays = (rdp as MemoryRasterDataProvider).GetExtHeader <LastDaysSetValue>(); for (int i = 0; i < outLastDays.LastDaysColor.Length; i++) { if (outLastDays.LastDaysColor[i] == 0) { break; } colorNums.Add(outLastDays.LastDaysColor[i]); } } if (colorNums.Count == 0) { break; } List <ProductColor> pcList = new List <ProductColor>(); pcList.Add(pct.ProductColors[0]); pct.ProductColors[1].MaxValue = colorNums[0] + 1; pct.ProductColors[1].LableText = " " + (pct.ProductColors[1].MaxValue - 1).ToString(); pcList.Add(pct.ProductColors[1]); for (int i = 2; i < colorNums.Count + 1; i++) { pct.ProductColors[i].MinValue = colorNums[i - 2] + 1; pct.ProductColors[i].MaxValue = colorNums[i - 1] + 1; pct.ProductColors[i].LableText = " " + (pct.ProductColors[i].MaxValue - 1).ToString(); pcList.Add(pct.ProductColors[i]); } //ProductColor newpc = new ProductColor(); //newpc.Color = pct.ProductColors[pct.ProductColors.Length - 3].Color; //newpc.DisplayLengend = pct.ProductColors[pct.ProductColors.Length - 3].DisplayLengend; //newpc.LableText = ">" + colorNums[colorNums.Count - 1] + "天"; //newpc.MaxValue = pct.ProductColors[pct.ProductColors.Length - 3].MaxValue; //newpc.MinValue = colorNums[colorNums.Count - 1] + 1; //pcList.Add(newpc); pcList.Add(pct.ProductColors[pct.ProductColors.Length - 2]); pcList.Add(pct.ProductColors[pct.ProductColors.Length - 1]); pct.ProductColors = pcList.ToArray(); ProductColorTableParser.WriteToXml(colorTabels, colorTableFile); ProductColorTableFactory.ReLoadAllColorTables(); LayoutTemplateHelper.UpdateLegend(colorTabels, null); ProductColorTableParser.WriteToXml(colorTabelsBack, colorTableFile); } return(ThemeGraphyResult(null)); } else { return(ThemeGraphyResult(null)); } }