Ejemplo n.º 1
0
        /// <summary>Ends TrackCancel progress meter</summary>
        public void EndProgress()
        {
            if (StepProgressor == null)
            {
                return;
            }

            StepProgressor.Hide();
        }
Ejemplo n.º 2
0
        public override bool Work()
        {
            base.Work();
            if (!Init())
            {
                ProgressDialog.HideDialog();
                return(false);
            }
            foreach (var item in _files)
            {
                Count++;
                StepProgressor.Message = string.Format("正在分析{0},进度{1}/{2}", System.IO.Path.GetFileNameWithoutExtension(item), Count, _files.Count);
                CanContinue            = TrackCancel.Continue();
                if (!CanContinue)
                {
                    break;
                }


                try
                {
                    var tables = GetTableNames(item);
                    if (tables.Count > 0)
                    {
                        foreach (var tableName in tables)
                        {
                            var fields    = GainField(item, tableName);
                            var fieldList = new List <string>();
                            foreach (var a in _fields)
                            {
                                if (fields.Contains(a))
                                {
                                    fieldList.Add(a);
                                }
                            }
                            var temp = Prgram(item, tableName, fieldList.ToArray());
                            if (temp.Count > 0)
                            {
                                Save(temp, tableName, _saveFilePath);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Copy(item, _folder);
                }

                StepProgressor.Step();
            }
            ProgressDialog.HideDialog();
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>Start TrackCancel progress bar</summary>
        public void StartProgress(int maxRange)
        {
            if (StepProgressor == null)
            {
                return;
            }

            StepProgressor.MinRange  = 0;
            StepProgressor.MaxRange  = maxRange;
            StepProgressor.Position  = 0;
            StepProgressor.StepValue = 1;
            StepProgressor.Show();

            _stepCancelCheckThreshold = Math.Max(1, maxRange / 100);
        }
        public override bool Work()
        {
            base.Work();
            if (!Init())
            {
                ProgressDialog.HideDialog();
                Error = string.Format("初始化错误:{0}", Error);
                return(false);
            }
            var list = new List <int>();
            var shps = new List <string>();

            for (var i = 0; i < Layers.Count; i++)
            {
                StepProgressor.Message = string.Format("正在对图层:{0}进行分析", Layers[i]);
                CanContinue            = TrackCancel.Continue();
                if (!CanContinue)
                {
                    break;
                }
                try
                {
                    // ConstructPolygon(System.IO.Path.GetDirectoryName(CADFilePath), System.IO.Path.GetFileNameWithoutExtension(CADFilePath), i, LayerField, Layers[i]);
                    var result          = SelectPolyline(System.IO.Path.GetDirectoryName(CADFilePath), System.IO.Path.GetFileNameWithoutExtension(CADFilePath), i, LayerField, Layers[i]);
                    var polygonfilepath = string.Format("{0}\\{1}_1.shp", System.IO.Path.GetDirectoryName(result), System.IO.Path.GetFileNameWithoutExtension(result));
                    if (TranslatePolylineToPolygon(result, polygonfilepath, Layers[i]))
                    {
                        shps.Add(polygonfilepath);
                    }
                    list.Add(i);
                } catch (Exception ex)
                {
                }
                StepProgressor.Step();
            }
            if (shps.Count > 0)
            {
                Merge(shps, SaveFilePath);
            }

            // ContractPolygon(shps, SaveFilePath);
            // Merge(System.IO.Path.GetDirectoryName(CADFilePath), list, System.IO.Path.GetFileNameWithoutExtension(CADFilePath));
            ProgressDialog.HideDialog();
            return(true);
        }
Ejemplo n.º 5
0
        public override bool Work()
        {
            base.Work();
            if (!Init())
            {
                //System.Runtime.InteropServices.Marshal.ReleaseComObject(InsertFeatureCursor);
                ProgressDialog.HideDialog();
                return(false);
            }
            foreach (var file in Files)
            {
                Count++;
                var tcmc = System.IO.Path.GetFileNameWithoutExtension(file);
                StepProgressor.Message = string.Format("正在分析{0},进度{1}/{2}", tcmc, Count, MaxValue);
                CanContinue            = TrackCancel.Continue();
                if (!CanContinue)
                {
                    break;
                }
                var inputfeatureClass = file.GetShpFeatureClass();
                if (inputfeatureClass != null)
                {
                    if (FeatureClass == null)
                    {
                        IGeoDataset geodataset = inputfeatureClass as IGeoDataset;
                        FeatureClass = FeatureClassManager.CreateFeatrueClass(this.SavaFilePath, geodataset.SpatialReference, inputfeatureClass.ShapeType);
                    }
                    if (FeatureClass != null)
                    {
                        CheckField(FeatureClass, inputfeatureClass);
                        var            insertfeaturecursor = FeatureClass.Insert(true);
                        IFeatureBuffer featureBuffer       = null;
                        IFeatureCursor featureCursor       = inputfeatureClass.Search(null, false);
                        IFeature       feature             = featureCursor.NextFeature();
                        while (feature != null)
                        {
                            #region

                            featureBuffer = FeatureClass.CreateFeatureBuffer();
                            var copy = feature.ShapeCopy;
                            var aw   = copy as IZAware;
                            if (aw.ZAware == true)
                            {
                                aw.ZAware = false;
                            }
                            featureBuffer.Shape = copy;
                            foreach (var field in Fields)
                            {
                                if (field.Name == "TCMC")
                                {
                                    featureBuffer.set_Value(field.Index, tcmc);
                                    continue;
                                }
                                var a = feature.Fields.FindField(field.Name);
                                if (a != -1)
                                {
                                    featureBuffer.set_Value(field.Index, feature.get_Value(a));
                                }
                            }
                            try
                            {
                                object featureOID = insertfeaturecursor.InsertFeature(featureBuffer);
                                insertfeaturecursor.Flush();
                            }
                            catch (Exception ex)
                            {
                                Error += string.Format("在读取{0}时,合并错误,错误信息:{1};", tcmc, ex.Message);
                                break;
                            }
                            #endregion
                            feature = featureCursor.NextFeature();
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(insertfeaturecursor);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
                    }
                }
                else
                {
                    Error += string.Format("无法打开文件:{0};", tcmc);
                }
                StepProgressor.Step();
            }
            // System.Runtime.InteropServices.Marshal.ReleaseComObject(InsertFeatureCursor);
            ProgressDialog.HideDialog();
            return(true);
        }
        public override bool Work()
        {
            base.Work();
            if (!Init())
            {
                ProgressDialog.HideDialog();
                return(false);
            }
            ParallelLoopResult result = Parallel.ForEach <string>(Files, s => { Analyze(s); });


            //foreach(var file in Files)
            //{
            //    Count++;
            //    StepProgressor.Message = string.Format("正在分析{0},进度{1}/{2}", file, Count,MaxValue);
            //    CanContinue = TrackCancel.Continue();
            //    if (!CanContinue)
            //    {
            //        break;
            //    }
            //    Application.DoEvents();
            //    Analyze(file);
            //    StepProgressor.Step();
            //}

            foreach (var file in Files)
            {
                Count++;
                StepProgressor.Message = string.Format("正在分析{0},进度{1}/{2}", file, Count, MaxValue);
                CanContinue            = TrackCancel.Continue();
                if (!CanContinue)
                {
                    break;
                }
                Application.DoEvents();
                Judge(file);
                StepProgressor.Step();
            }
            StepProgressor.Message = string.Format("正在保存中");
            if (PointFiles.Count > 0)
            {
                var savePoint = string.Format("{0}\\{1}_点.shp", System.IO.Path.GetDirectoryName(this.SaveFilePath), System.IO.Path.GetFileNameWithoutExtension(this.SaveFilePath));
                StepProgressor.Message = string.Format("正在生成文件{0}", savePoint);
                Merge(string.Join(";", PointFiles.ToArray()), savePoint);
            }
            if (PolylineFiles.Count > 0)
            {
                var savePolyline = string.Format("{0}\\{1}_线.shp", System.IO.Path.GetDirectoryName(this.SaveFilePath), System.IO.Path.GetFileNameWithoutExtension(this.SaveFilePath));
                StepProgressor.Message = string.Format("正在生成文件{0}", savePolyline);
                Merge(string.Join(";", PolylineFiles.ToArray()), savePolyline);
            }

            if (PolygonFiles.Count > 0)
            {
                var savePolygon = string.Format("{0}\\{1}_点.shp", System.IO.Path.GetDirectoryName(this.SaveFilePath), System.IO.Path.GetFileNameWithoutExtension(this.SaveFilePath));
                StepProgressor.Message = string.Format("正在生成文件{0}", savePolygon);
                Merge(string.Join(";", PolygonFiles.ToArray()), savePolygon);
            }
            ProgressDialog.HideDialog();
            return(true);
        }