private void AnalyzeLayer() { this.LayerscheckedListBox.Items.Clear(); this.ColorscheckedListBox.Items.Clear(); if (!string.IsNullOrEmpty(this.CADtextBox.Text)) { IFeatureClass featureClass = CADManager.GetFeatureClass(this.CADtextBox.Text); if (featureClass == null) { MessageBox.Show(string.Format("无法打开文件{0}", System.IO.Path.GetFileName(this.CADtextBox.Text))); return; } _featureClass = featureClass; var layers = _featureClass.GetUniqueValue(LayerName); foreach (var item in layers) { this.LayerscheckedListBox.Items.Add(item, true); } var colors = _featureClass.GetUniqueValue(ColorName); foreach (var item in colors) { this.ColorscheckedListBox.Items.Add(item, true); } } }
/// <summary> /// 初始化 /// </summary> /// <returns></returns> private bool Init() { if (CADFiles == null || CADFiles.Count == 0) { _error += "CAD文件列表为空;"; return(false); } if (System.IO.File.Exists(PolylineFile)) { System.IO.File.Delete(PolylineFile); } var first = CADFiles[0]; var featureClass = CADManager.GetFeatureClass(first); if (featureClass == null) { _error += string.Format("读取到的文件:{0} 无法读取信息;", System.IO.Path.GetFileNameWithoutExtension(first)); return(false); } ISpatialReference spatialReference = SpatialReferenceManager.GetSpatialReference(featureClass); _polylineFeatureClass = FeatureClassManager.CreateFeatrueClass(PolylineFile, spatialReference, esriGeometryType.esriGeometryPolyline); if (_polylineFeatureClass == null) { _error += string.Format("创建shapefile文件:{0} 失败!", PolylineFile); return(false); } _errorList = new List <string>(); return(true); }
public bool Init() { if (!System.IO.File.Exists(CADFile)) { _error += string.Format("文件:{0}不存在", CADFile); return(false); } _featureClass = CADManager.GetFeatureClass(CADFile); if (_featureClass == null) { _error += string.Format("无法读取文件:{0}", CADFile); return(false); } _index = PolylineFeatureClass.Fields.FindField(TCMC); return(true); }
private void AnalyzeColorbutton_Click(object sender, EventArgs e) { this.AnalyzeColorbutton.Text = "正在分析..."; this.AnalyzeColorbutton.Enabled = false; this.ColorscheckedListBox.Items.Clear(); var files = CheckedListBoxManager.GetChecked(this.FilescheckedListBox); if (files.Count == 0) { MessageBox.Show("当前未选择文件"); this.AnalyzeColorbutton.Text = "分析颜色"; this.AnalyzeColorbutton.Enabled = true; return; } var allColors = new List <string>(); foreach (var fileName in files) { var fullName = System.IO.Path.Combine(this.FlodertextBox.Text, fileName); if (System.IO.File.Exists(fullName)) { var featureClass = CADManager.GetFeatureClass(fullName); if (featureClass != null) { var colors = featureClass.GetUniqueValue(ColorName); foreach (var item in colors) { if (!allColors.Contains(item)) { allColors.Add(item); } } } } } foreach (var item in allColors) { this.ColorscheckedListBox.Items.Add(item, true); } this.AnalyzeColorbutton.Text = "分析颜色"; this.AnalyzeColorbutton.Enabled = true; }