private void Export() { using (SaveFileDialog diag = new SaveFileDialog()) { diag.Title = "导出产品颜色表"; diag.Filter = "产品颜色表(*.pct)|*.pct|所有文件(*.*)|*.*"; ProductDic product = listBox1.SelectedItem as ProductDic; diag.FileName = Path.GetFileNameWithoutExtension(product.FileName); if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string filename = diag.FileName; ProductColorTableParser.WriteToXml(_selectedProductColorTables, filename); } } }
private void InitLoadColorTables(string selectedFilename) { ProductColorTableParser parser = new ProductColorTableParser(); string[] files = parser.LoadColorTables(); ProductDic[] pdcs = new ProductDic[files.Length]; for (int i = 0; i < files.Length; i++) { ProductDic pdc = new ProductDic(); pdc.FileName = files[i]; pdc.ProductIdentify = Path.GetFileNameWithoutExtension(files[i]); pdcs[i] = pdc; } TrySetProductDicName(pdcs); _productDics = pdcs; InitLoadProductDicList(selectedFilename); }
private void SaveColorTable() { try { if (!_hasChanged || _selectedProductDic == null || _selectedProductColorTables == null) { return; } ProductColorTableParser.WriteToXml(_selectedProductColorTables, _selectedProductDic.FileName); ProductColorTableFactory.ReLoadAllColorTables(); if (chkUpdateTheme.Checked) { LayoutTemplateHelper.UpdateLegend(_selectedProductColorTables, null); } _hasChanged = false; MsgBox.ShowInfo("更新完成"); } catch (Exception ex) { MsgBox.ShowInfo(@"更新完成:" + ex.Message); } }
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)); } }