Пример #1
0
        public override void OnClick()
        {
            frmClipOutSet frmClipOutSet = new frmClipOutSet();

            if (frmClipOutSet.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                List <IFeatureClass> list = new List <IFeatureClass>();
                for (int i = 0; i < this._context.FocusMap.LayerCount; i++)
                {
                    ILayer layer = this._context.FocusMap.get_Layer(i);
                    if (layer.Visible)
                    {
                        if (layer is IFeatureLayer)
                        {
                            list.Add((layer as IFeatureLayer).FeatureClass);
                        }
                        else if (layer is IGroupLayer)
                        {
                            this.method_0(layer as IGroupLayer, list);
                        }
                    }
                }
                if (frmClipOutSet.Type == 0)
                {
                    SDEToShapefile sde1 = new SDEToShapefile
                    {
                        ClipGeometry = this._context.FocusMap.ClipGeometry,
                        IsClip       = true
                    };
                    sde1.AddFeatureClasses(list);
                    sde1.Convert(frmClipOutSet.OutWorspace);
                    ComReleaser.ReleaseCOMObject(frmClipOutSet.OutWorspace);
                }
                else if (frmClipOutSet.Type == 1)
                {
                    new ExportToMiTab
                    {
                        InputFeatureClasses = list,
                        OutPath             = frmClipOutSet.OutPath,
                        ClipGeometry        = this._context.FocusMap.ClipGeometry,
                        IsClip = true
                    }.Export();
                }
                else if (frmClipOutSet.Type == 2)
                {
                    VCTWrite vCTWrite = new VCTWrite();
                    for (int i = 0; i < list.Count; i++)
                    {
                        vCTWrite.AddDataset(list[i] as IDataset);
                    }
                    vCTWrite.ClipGeometry = this._context.FocusMap.ClipGeometry;
                    vCTWrite.IsClip       = true;
                    vCTWrite.Write(frmClipOutSet.OutPath);
                }
            }
        }
Пример #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         IDictionary <int, IGeometry> boundGeometrys = this.ucExtentSetting1.BoundGeometrys;
         if (boundGeometrys == null || boundGeometrys.Count <= 0)
         {
             MessageBox.Show(@"请选择输出数据的范围!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         if (_layerCheckBoxs == null || !_layerCheckBoxs.Any(c => c.Checked))
         {
             MessageBox.Show(@"请选择要裁剪的图层!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         if (string.IsNullOrWhiteSpace(this.ucExportPath1.Path))
         {
             MessageBox.Show(@"请选择要输出数据的存放位置!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         List <IFeatureClass> list = new List <IFeatureClass>();
         foreach (CheckBox checkBox in _layerCheckBoxs)
         {
             if (checkBox.Checked)
             {
                 list.Add(checkBox.Tag as IFeatureClass);
             }
         }
         SDEToShapefile sde = new SDEToShapefile();
         sde.AddFeatureClasses(list);
         sde.ClipGeometry = boundGeometrys[0];
         sde.IsClip       = true;
         sde.Convert(this.ucExportPath1.Workspace);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Пример #3
0
        public override void OnDblClick()
        {
            if (this.idisplayFeedback_0 == null)
            {
                return;
            }
            this.ipolygon_0         = (this.idisplayFeedback_0 as INewPolygonFeedback).Stop();
            this.idisplayFeedback_0 = null;
            if ((this.ipolygon_0 as IArea).Area == 0.0)
            {
                this.ipolygon_0 = null;
                return;
            }

            (this._context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
            if ((this.ipolygon_0 as ITopologicalOperator).IsSimple)
            {
                this.ipolygon_0.SpatialReference = this._context.FocusMap.SpatialReference;
                frmClipOutSet frmClipOutSet = new frmClipOutSet();
                if (frmClipOutSet.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    List <IFeatureClass> list = new List <IFeatureClass>();
                    for (int i = 0; i < this._context.FocusMap.LayerCount; i++)
                    {
                        ILayer layer = this._context.FocusMap.get_Layer(i);
                        if (layer.Visible)
                        {
                            if (layer is IFeatureLayer)
                            {
                                list.Add((layer as IFeatureLayer).FeatureClass);
                            }
                            else if (layer is IGroupLayer)
                            {
                                this.method_1(layer as IGroupLayer, list);
                            }
                        }
                    }
                    if (frmClipOutSet.Type == 0)
                    {
                        SDEToShapefile sde1 = new SDEToShapefile();
                        sde1.AddFeatureClasses(list);
                        sde1.ClipGeometry = this.ipolygon_0;
                        sde1.IsClip       = true;
                        sde1.Convert(frmClipOutSet.OutWorspace);
                        ComReleaser.ReleaseCOMObject(frmClipOutSet.OutWorspace);
                    }
                    else if (frmClipOutSet.Type == 1)
                    {
                        new ExportToMiTab
                        {
                            InputFeatureClasses = list,
                            OutPath             = frmClipOutSet.OutPath,
                            ClipGeometry        = this.ipolygon_0,
                            IsClip = true
                        }.Export();
                    }
                    else if (frmClipOutSet.Type == 2)
                    {
                        VCTWrite vCTWrite = new VCTWrite();
                        for (int i = 0; i < list.Count; i++)
                        {
                            vCTWrite.AddDataset(list[i] as IDataset);
                        }
                        vCTWrite.ClipGeometry = this.ipolygon_0;
                        vCTWrite.IsClip       = true;
                        vCTWrite.Write(frmClipOutSet.OutPath);
                    }
                }
            }
            this.ipolygon_0 = null;
            (this._context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
        }