private void btnApply_Click(object sender, EventArgs e) { if (_rangeList == null || _rangeList.Count == 0) { MessageBox.Show("请设置密度分割范围!", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (_rangeList != null) { if (UpdateDensSliceEvent != null) { _mapColor = DensitySolution.GetColorMapTable(_rangeList.ToArray()); UpdateDensSliceEvent(_selectBand, _mapColor); } } }
private void tsmiSaveFile_Click(object sender, EventArgs e) { if (_rangeList == null || _rangeList.Count == 0) { MessageBox.Show("请先设置密度分割范围,然后保存方案!", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string filename = null; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "XML文件|*.xml|所有文件|*.*"; saveFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + @"\\SesitySliceForm\"; if (!Directory.Exists(saveFileDialog.InitialDirectory)) { Directory.CreateDirectory(saveFileDialog.InitialDirectory); } saveFileDialog.FileName = CreateFileName(); if (saveFileDialog.ShowDialog() == DialogResult.OK) { filename = saveFileDialog.FileName; } else { return; } DensityDef densityDef = new DensityDef(); densityDef.MaxValue = _maxValue; densityDef.MinValue = _minValue; densityDef.Interval = _interval; densityDef.RangeCount = _rangeList.Count; densityDef.ApplayInterval = ckInterval.Checked; List <DensityRange> ranges = new List <DensityRange>(); for (int i = 0; i < _rangeList.Count; i++) { DensityRange tempRange = new DensityRange(); tempRange.minValue = _rangeList[i].minValue; tempRange.maxValue = _rangeList[i].maxValue; tempRange.RGB_r = _rangeList[i].RGB_r; tempRange.RGB_g = _rangeList[i].RGB_g; tempRange.RGB_b = _rangeList[i].RGB_b; ranges.Add(tempRange); } densityDef.Ranges = ranges.ToArray(); DensitySolution.Save(filename, densityDef); }
private void tsmiOpenFile_Click(object sender, EventArgs e) { lstDensityRange.Items.Clear(); if (_rangeList != null) { _rangeList.Clear(); } else { _rangeList = new List <DensityRange>(); } string filename = null; if (e != null) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "密度分割方案(*.xml)|*.xml"; if (dlg.ShowDialog() == DialogResult.OK) { filename = dlg.FileName; } else { return; } } else { filename = _densityXML; } DensityDef densityDef = DensitySolution.Read(filename); if (densityDef == null) { return; } txtMax.Text = densityDef.MaxValue.ToString(); txtMin.Text = densityDef.MinValue.ToString(); _isOpenXML = true; txtInterval.Text = densityDef.Interval.ToString(); _isOpenXML = false; ckInterval.Checked = Convert.ToBoolean(densityDef.ApplayInterval.ToString()); int length = densityDef.Ranges == null || densityDef.Ranges.Length == 0 ? 0 : densityDef.Ranges.Length; DensityRange temprange; for (int i = 0; i < length; i++) { if (e != null) { temprange.minValue = densityDef.Ranges[i].minValue; temprange.maxValue = densityDef.Ranges[i].maxValue; } else { temprange.minValue = i == 0 ? _min_value : (_lwMinValue == 0 ? _min_value : _lwMinValue) + _lwInterval * (i - 1); temprange.maxValue = i + 1 == length ? _max_value : (_lwMinValue == 0 ? _min_value : _lwMinValue) + _lwInterval * i; } temprange.RGB_r = densityDef.Ranges[i].RGB_r; temprange.RGB_g = densityDef.Ranges[i].RGB_g; temprange.RGB_b = densityDef.Ranges[i].RGB_b; _rangeList.Add(temprange); } for (int i = 0; i < _rangeList.Count; i++) { lstDensityRange.Items.Add(_rangeList[i].ToString()); } }