private void LoadCurProductColorTable(ProductDic product) { _selectedProductDic = product; _selectedProductColorTables = null; _selectedProductColorTable = null; if (product == null || string.IsNullOrWhiteSpace(product.FileName)) { ClearPcts(); return; } ProductColorTableParser parser = new ProductColorTableParser(); _selectedProductColorTables = ProductColorTableParser.Parse(product.FileName); if (_selectedProductColorTables == null) { ClearPcts(); } else { LoadColorTable(_selectedProductColorTables); } }
private void Import(string filename) { ProductColorTable[] colortables = ProductColorTableParser.Parse(filename); if (colortables == null) { MsgBox.ShowInfo("导入产品颜色表失败:解析出来的颜色表数据为空"); return; } bool isCopy = true; if (_productDics != null) { string name = Path.GetFileNameWithoutExtension(filename).ToLower(); for (int i = 0; i < _productDics.Length; i++) { if (name == _productDics[i].ProductIdentify.ToLower()) { if ((MessageBox.Show("已经存在名称为" + name + "的颜色表,是否替换?", "信息提示", MessageBoxButtons.YesNo) == DialogResult.Yes)) { isCopy = true; } else { isCopy = false; } break; } } } if (isCopy) { string selectedFilename = null; selectedFilename = ProductColorTableParser.Import(filename, true); ReloadColorTable(selectedFilename); } }
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)); } }