当前位置: 首页>>代码示例>>C#>>正文


C# CancelTrackerClass类代码示例

本文整理汇总了C#中CancelTrackerClass的典型用法代码示例。如果您正苦于以下问题:C# CancelTrackerClass类的具体用法?C# CancelTrackerClass怎么用?C# CancelTrackerClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CancelTrackerClass类属于命名空间,在下文中一共展示了CancelTrackerClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            try
            {
                IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

                if (TrackCancel == null)
                {
                    TrackCancel = new CancelTrackerClass();
                }

                IGPParameter inputFeatureClassParameter = paramvalues.get_Element(in_osmFeaturesNumber) as IGPParameter;
                IGPValue inputFeatureGPValue = gpUtilities3.UnpackGPValue(inputFeatureClassParameter) as IGPValue;

                IFeatureClass osmFeatureClass = null;
                IQueryFilter queryFilter = null;

                gpUtilities3.DecodeFeatureLayer((IGPValue)inputFeatureGPValue, out osmFeatureClass, out queryFilter);

                ((ITable)osmFeatureClass).ApplyOSMClassExtension();
            }
            catch (Exception ex)
            {
                message.AddError(120050, ex.Message);
            }
        }
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:26,代码来源:OSMGPAddExtension.cs

示例2: ExportBookmarksToFiles

        /// <summary>Exports all bookmarks to PDF files.</summary>
        /// <param name="directory">The directory that the exported files will be written to.</param>
        /// <param name="dpi">The resolution of the output files.</param>
        /// <param name="exportFormat">The format of the exported files.</param>
        public void ExportBookmarksToFiles(string directory, long dpi, ExportFormat exportFormat)
        {
            if (!Directory.Exists(directory))
            {
                throw new DirectoryNotFoundException("Directory not found: " + directory);
            }
            IMouseCursor mc = new MouseCursorClass();
            const int hourglass = 2;
            mc.SetCursor(hourglass);

            IMxDocument mxDoc = _app.Document as IMxDocument;
            IMapBookmarks bookmarks = (IMapBookmarks)mxDoc.FocusMap;

            IEnumSpatialBookmark enumBM = bookmarks.Bookmarks;
            enumBM.Reset();
            ISpatialBookmark sbm = enumBM.Next();

            ProgressDialogFactoryClass dialogFactory = new ProgressDialogFactoryClass();
            var cancelTracker = new CancelTrackerClass();
            IStepProgressor stepProgressor = dialogFactory.Create(cancelTracker, _app.hWnd);
            IProgressDialog2 progDialog = stepProgressor as IProgressDialog2;
            progDialog.CancelEnabled = true;

            progDialog.ShowDialog();
            stepProgressor.Hide();
            stepProgressor.Message = "Exporting...";

            // Create a formatting string with the proper extension.  (E.g., "{0}.pdf" for PDF files".)
            string fnFmt = string.Format("{{0}}.{0}", Enum.GetName(typeof(ExportFormat), exportFormat));
            try
            {
                while (sbm != null)
                {
                    sbm.ZoomTo(mxDoc.FocusMap);
                    string filename = System.IO.Path.Combine(directory, string.Format(fnFmt, sbm.Name));
                    ExportPageLayoutToFile(mxDoc.PageLayout, filename, dpi, exportFormat);
                    sbm = enumBM.Next();
                }
            }
            finally
            {
                if (progDialog != null)
                {
                    progDialog.HideDialog();
                    ComReleaser.ReleaseCOMObject(progDialog);
                }
            }
        }
开发者ID:WSDOT-GIS,项目名称:ArcMapBookmarkExporter,代码行数:52,代码来源:Exporter.cs

示例3: UpdatePointXYFromGeometry

        private bool UpdatePointXYFromGeometry(ITable PointTable, IQueryFilter QueryFilter, bool Unversioned, double UpdateIfMoreThanTolerance, out int ChangedPointCount)
        {
            IProgressDialogFactory pProgressorDialogFact = new ProgressDialogFactoryClass();
              ITrackCancel pTrackCancel = new CancelTrackerClass();
              IStepProgressor pStepProgressor = pProgressorDialogFact.Create(pTrackCancel, ArcMap.Application.hWnd);
              IProgressDialog2 pProgressorDialog = (IProgressDialog2)pStepProgressor;
              try
              {
            pStepProgressor.MinRange = 0;
            pStepProgressor.MaxRange = PointTable.RowCount(null);
            pStepProgressor.StepValue = 1;
            pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
            bool bCont = true;

            IRow pPointFeat = null;
            ICursor pPtCurs = null;
            ChangedPointCount = 0;
            if (Unversioned)
            {
              ITableWrite pTableWr = (ITableWrite)PointTable;//used for unversioned table
              pPtCurs = pTableWr.UpdateRows(QueryFilter, false);
            }
            else
              pPtCurs = PointTable.Update(QueryFilter, false);

            pPointFeat = pPtCurs.NextRow();

            int iPointIdx_X = pPtCurs.Fields.FindField("X");
            int iPointIdx_Y = pPtCurs.Fields.FindField("Y");

            pProgressorDialog.ShowDialog();
            pStepProgressor.Message = "Updating point data...";

            while (pPointFeat != null)
            {//loop through all of the fabric points, and if any of the point id values are in the deleted set,
              //then remove the control name from the point's NAME field

              bCont = pTrackCancel.Continue();
              if (!bCont)
            break;

              IFeature pFeat = (IFeature)pPointFeat;
              IPoint pPtSource = (IPoint)pFeat.ShapeCopy;

              if (pPtSource == null)
              {
            Marshal.ReleaseComObject(pPointFeat); //garbage collection
            pPointFeat = pPtCurs.NextRow();
            continue;
              }

              if (pPtSource.IsEmpty)
              {
            Marshal.ReleaseComObject(pPointFeat); //garbage collection
            pPointFeat = pPtCurs.NextRow();
            continue;
              }
              IPoint pPtTarget = new ESRI.ArcGIS.Geometry.PointClass();
              pPtTarget.X = Convert.ToDouble(pPointFeat.get_Value(iPointIdx_X));
              pPtTarget.Y = Convert.ToDouble(pPointFeat.get_Value(iPointIdx_Y));

              ILine pLine = new ESRI.ArcGIS.Geometry.LineClass();
              pLine.PutCoords(pPtSource, pPtTarget);

              if (pLine.Length > UpdateIfMoreThanTolerance)
              {
            pPointFeat.set_Value(iPointIdx_X, pPtSource.X);
            pPointFeat.set_Value(iPointIdx_Y, pPtSource.Y);

            //if (Unversioned)
              pPtCurs.UpdateRow(pPointFeat);
            //else
            //  pPointFeat.Store();
            ChangedPointCount++;
            string sCnt = ChangedPointCount.ToString() + " of " + pStepProgressor.MaxRange.ToString();
            pStepProgressor.Message = "Updating point data..." + sCnt;
              }

              Marshal.ReleaseComObject(pPointFeat); //garbage collection
              pPointFeat = pPtCurs.NextRow();

              if (pStepProgressor.Position < pStepProgressor.MaxRange)
            pStepProgressor.Step();

            }
            Marshal.ReleaseComObject(pPtCurs); //garbage collection
            return bCont;

              }
              catch (COMException ex)
              {
            MessageBox.Show("Problem updating point XY from shape: " + Convert.ToString(ex.ErrorCode));
            ChangedPointCount = 0;
            return false;
              }
              finally
              {
            pStepProgressor = null;
            if (!(pProgressorDialog == null))
              pProgressorDialog.HideDialog();
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:101,代码来源:CoordinateInverse.cs

示例4: CreateJumps

        public static void CreateJumps(IApplication app, JumpTypes jumpType, double jumpDistance)
        {
            IProgressDialog2 progressDialog = default(IProgressDialog2);

            IProgressDialogFactory progressDialogFactory = null;
            ITrackCancel trackCancel = null;
            IStepProgressor stepProgressor = null;
            ICursor lineCursor = null;
            IEditor editor = null;
            IFeature lineFeature = null;

            IMxDocument mxdoc = null;
            IMap map = null;

            UID geoFeatureLayerID = null;
            IEnumLayer enumLayer = null;

            IEditLayers eLayers = null;

            List<IFeatureLayer> lineLayers = null;
            ILayer layer = null;
            IFeatureLayer fLayer = null;
            IFeatureSelection fSel = null;
            try
            {

                //Get editor
                editor = Globals.getEditor(app);
                if (editor.EditState != esriEditState.esriStateEditing)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("MustBEditg"), A4LGSharedFunctions.Localizer.GetString("GeometryToolsLbl_6"));
                    return;
                }

                //ProgressBar
                progressDialogFactory = new ProgressDialogFactoryClass();

                // Create a CancelTracker

                trackCancel = new CancelTrackerClass();

                // Set the properties of the Step Progressor
                Int32 int32_hWnd = editor.Parent.hWnd;
                stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd);
                stepProgressor.MinRange = 0;
                // stepProgressor.MaxRange = itotal
                stepProgressor.StepValue = 1;
                stepProgressor.Message = "";
                stepProgressor.Hide();

                // Create the ProgressDialog. This automatically displays the dialog
                progressDialog = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast

                // Set the properties of the ProgressDialog
                progressDialog.CancelEnabled = false;
                progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("GeometryToolsProc_12") +"...";
                progressDialog.Title = A4LGSharedFunctions.Localizer.GetString("GeometryToolsProc_12");
                progressDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressGlobe;

                mxdoc = (IMxDocument)app.Document;
                map = editor.Map;

                //Get enumeration of feature layers
                geoFeatureLayerID = new UIDClass();
                geoFeatureLayerID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
                enumLayer = map.get_Layers(((ESRI.ArcGIS.esriSystem.UID)geoFeatureLayerID), true);

                //Get enumeration of editable layers
                eLayers = (IEditLayers)editor;

                // Create list of visible line layers with selected feature(s)
                lineLayers = new List<IFeatureLayer>();
                enumLayer.Reset();
                layer = enumLayer.Next();
                while (layer != null)
                {
                    fLayer = (IFeatureLayer)layer;
                    stepProgressor.Message = A4LGSharedFunctions.Localizer.GetString("GeometryToolsMess_2") + fLayer.Name;
                    if (fLayer.Valid && (fLayer.FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                       && (fLayer.Visible))
                    {
                        if (eLayers.IsEditable(fLayer))
                        {

                            fSel = fLayer as IFeatureSelection;
                            if (fSel.SelectionSet.Count > 0)
                            {
                                stepProgressor.Message = A4LGSharedFunctions.Localizer.GetString("GeometryToolsMess_3") + fLayer.Name;
                                lineLayers.Add(fLayer);
                            }
                        }
                    }
                    layer = enumLayer.Next();
                }
                if (lineLayers.Count == 0)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeometryToolsError_7"));
                    return;

                }
//.........这里部分代码省略.........
开发者ID:jrinks,项目名称:local-government-desktop-addins,代码行数:101,代码来源:GeometryTools.cs

示例5: Execute

        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            try
            {
                IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

                if (TrackCancel == null)
                {
                    TrackCancel = new CancelTrackerClass();
                }

                IGPValue inputLayersGPValue = gpUtilities3.UnpackGPValue(paramvalues.get_Element(in_LayersNumber));
                IGPMultiValue inputLayersMultiValue = gpUtilities3.UnpackGPValue(inputLayersGPValue) as IGPMultiValue;

                IGPParameter outputGroupLayerParameter = paramvalues.get_Element(out_groupLayerNumber) as IGPParameter;
                IGPValue outputGPGroupLayer = gpUtilities3.UnpackGPValue(outputGroupLayerParameter);
                IGPCompositeLayer outputCompositeLayer = outputGPGroupLayer as IGPCompositeLayer;

                if (outputCompositeLayer == null)
                {
                    message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), outputGroupLayerParameter.Name));
                    return;
                }

                IGroupLayer groupLayer = null;

                // find the last position of the "\" string
                // in case we find such a thing, i.e. position is >= -1 then let's assume that we are dealing with a layer file on disk
                // otherwise let's create a new group layer instance
                string outputGPLayerNameAsString = outputGPGroupLayer.GetAsText();
                int separatorPosition = outputGPLayerNameAsString.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
                string layerName = String.Empty;

                if (separatorPosition > -1)
                {
                    layerName = outputGPGroupLayer.GetAsText().Substring(separatorPosition + 1);
                }
                else
                {
                    layerName = outputGPGroupLayer.GetAsText();
                }

                ILayer foundLayer = null;
                IGPLayer existingGPLayer = gpUtilities3.FindMapLayer2(layerName, out foundLayer);

                if (foundLayer != null)
                {
                    gpUtilities3.RemoveFromMapEx((IGPValue)existingGPLayer);
                    gpUtilities3.RemoveInternalLayerEx(foundLayer);
                }

                groupLayer = new GroupLayer();
                ((ILayer)groupLayer).Name = layerName;

                for (int layerIndex = 0; layerIndex < inputLayersMultiValue.Count; layerIndex++)
                {
                    IGPValue gpLayerToAdd = inputLayersMultiValue.get_Value(layerIndex) as IGPValue;

                    ILayer sourceLayer = gpUtilities3.DecodeLayer(gpLayerToAdd);

                    groupLayer.Add(sourceLayer);
                }

                outputGPGroupLayer = gpUtilities3.MakeGPValueFromObject(groupLayer);

                if (separatorPosition > -1)
                {
                    try
                    {
                        // in the case that we are dealing with a layer file on disk
                        // let's persist the group layer information into the file
                        ILayerFile pointLayerFile = new LayerFileClass();

                        if (System.IO.Path.GetExtension(outputGPLayerNameAsString).ToUpper().Equals(".LYR"))
                        {
                            if (pointLayerFile.get_IsPresent(outputGPLayerNameAsString))
                            {
                                try
                                {
                                    gpUtilities3.Delete(outputGPGroupLayer);
                                }
                                catch (Exception ex)
                                {
                                    message.AddError(120001, ex.Message);
                                    return;
                                }
                            }

                            pointLayerFile.New(outputGPLayerNameAsString);

                            pointLayerFile.ReplaceContents(groupLayer);

                            pointLayerFile.Save();

                        }

                         outputGPGroupLayer = gpUtilities3.MakeGPValueFromObject(pointLayerFile.Layer);
                    }
                    catch (Exception ex)
                    {
//.........这里部分代码省略.........
开发者ID:weepingdog,项目名称:arcgis-osm-editor,代码行数:101,代码来源:GPCombineLayers.cs

示例6: Execute

        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();
            OSMToolHelper osmToolHelper = new OSMToolHelper();

            if (TrackCancel == null)
            {
                TrackCancel = new CancelTrackerClass();
            }

            IGPEnvironment configKeyword = OSMToolHelper.getEnvironment(envMgr, "configKeyword");
            IGPString gpString = configKeyword.Value as IGPString;

            string storageKeyword = String.Empty;

            if (gpString != null)
            {
                storageKeyword = gpString.Value;
            }

            IGPParameter osmFileParameter = paramvalues.get_Element(0) as IGPParameter;
            IGPValue osmFileLocationString = gpUtilities3.UnpackGPValue(osmFileParameter) as IGPValue;

            IGPParameter loadSuperRelationParameter = paramvalues.get_Element(1) as IGPParameter;
            IGPBoolean loadSuperRelationGPValue = gpUtilities3.UnpackGPValue(loadSuperRelationParameter) as IGPBoolean;

            IGPParameter osmSourceLineFeatureClassParameter = paramvalues.get_Element(2) as IGPParameter;
            IGPValue osmSourceLineFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmSourceLineFeatureClassParameter) as IGPValue;

            IGPParameter osmSourcePolygonFeatureClassParameter = paramvalues.get_Element(3) as IGPParameter;
            IGPValue osmSourcePolygonFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmSourcePolygonFeatureClassParameter) as IGPValue;

            IGPParameter osmTargetLineFeatureClassParameter = paramvalues.get_Element(6) as IGPParameter;
            IGPValue osmTargetLineFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmTargetLineFeatureClassParameter) as IGPValue;

            IName workspaceName = gpUtilities3.CreateParentFromCatalogPath(osmTargetLineFeatureClassGPValue.GetAsText());
            IWorkspace2 lineFeatureWorkspace = workspaceName.Open() as IWorkspace2;

            string[] lineFCNameElements = osmTargetLineFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);

            IFeatureClass osmLineFeatureClass = null;

            IGPParameter tagLineCollectionParameter = paramvalues.get_Element(4) as IGPParameter;
            IGPMultiValue tagLineCollectionGPValue = gpUtilities3.UnpackGPValue(tagLineCollectionParameter) as IGPMultiValue;

            List<String> lineTagstoExtract = null;

            if (tagLineCollectionGPValue.Count > 0)
            {
                lineTagstoExtract = new List<string>();

                for (int valueIndex = 0; valueIndex < tagLineCollectionGPValue.Count; valueIndex++)
                {
                    string nameOfTag = tagLineCollectionGPValue.get_Value(valueIndex).GetAsText();

                    lineTagstoExtract.Add(nameOfTag);
                }
            }
            else
            {
                lineTagstoExtract = OSMToolHelper.OSMSmallFeatureClassFields();
            }

            // lines
            try
            {
                osmLineFeatureClass = osmToolHelper.CreateSmallLineFeatureClass(lineFeatureWorkspace,
                    lineFCNameElements[lineFCNameElements.Length - 1], storageKeyword, "", "", lineTagstoExtract);
            }
            catch (Exception ex)
            {
                message.AddError(120035, String.Format(resourceManager.GetString("GPTools_OSMGPDownload_nullpointfeatureclass"), ex.Message));
                return;
            }

            if (osmLineFeatureClass == null)
            {
                return;
            }

            IGPParameter osmTargetPolygonFeatureClassParameter = paramvalues.get_Element(7) as IGPParameter;
            IGPValue osmTargetPolygonFeatureClassGPValue = gpUtilities3.UnpackGPValue(osmTargetPolygonFeatureClassParameter) as IGPValue;

            workspaceName = gpUtilities3.CreateParentFromCatalogPath(osmTargetPolygonFeatureClassGPValue.GetAsText());
            IWorkspace2 polygonFeatureWorkspace = workspaceName.Open() as IWorkspace2;

            string[] polygonFCNameElements = osmTargetPolygonFeatureClassGPValue.GetAsText().Split(System.IO.Path.DirectorySeparatorChar);

            IFeatureClass osmPolygonFeatureClass = null;

            IGPParameter tagPolygonCollectionParameter = paramvalues.get_Element(5) as IGPParameter;
            IGPMultiValue tagPolygonCollectionGPValue = gpUtilities3.UnpackGPValue(tagPolygonCollectionParameter) as IGPMultiValue;

            List<String> polygonTagstoExtract = null;

            if (tagPolygonCollectionGPValue.Count > 0)
            {
                polygonTagstoExtract = new List<string>();

                for (int valueIndex = 0; valueIndex < tagPolygonCollectionGPValue.Count; valueIndex++)
//.........这里部分代码省略.........
开发者ID:weepingdog,项目名称:arcgis-osm-editor,代码行数:101,代码来源:OSMGPRelationLoader.cs

示例7: CheckConnections

        public static void CheckConnections(IApplication app, bool CheckVisibleOnly)
        {
            IProgressDialog2 progressDialog = default(IProgressDialog2);
            IGeometricNetwork geometricNetwork = null;
            ISelectionEvents selEvents = null;
            IMxDocument mxDoc = null;
            IActiveView activeView = null;
            IMap map = null;
            List<IGeometricNetwork> gnList = null;
            IMouseCursor appCursor = null;
            IEnumFeatureClass enumClass = null;
            IFeatureClass featureClass = null;
            IFeatureLayer featureLayer = null;
            IProgressDialogFactory progressDialogFactory = null;
            ITrackCancel trackCancel = null;
            IStepProgressor stepProgressor = null;
            IFeatureSelection fSel = null;
            IEnumFeature enumFeatures = null;
            IEditor editor = null;

            try
            {
                editor = Globals.getEditor(ref app);
                if (editor == null)
                    return;

                if (editor.EditState == esriEditState.esriStateNotEditing)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("MustBEditg"), A4LGSharedFunctions.Localizer.GetString("GeoNetToolsLbl_2"));
                    return;
                }
                mxDoc = (IMxDocument)app.Document;
                activeView = (IActiveView)mxDoc.FocusMap;
                map = activeView.FocusMap;
                int countDeleted = 0;

                if (activeView == null) return;
                if (map.LayerCount == 0) return;
                long total = Globals.GetTotalVisibleNetworkFeatures(map);
                if (total > 1000)
                {
                    if (MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsAsk_11a") + total + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsAsk_11b"), A4LGSharedFunctions.Localizer.GetString("Proceed"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }

                }
                string resultMessage = "";
                string resultMessage2 = "";

                //Get visible networks
                gnList = Globals.GetGeometricNetworksCheckedVisible(ref map);

                if (gnList.Count == 0)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_11a"), A4LGSharedFunctions.Localizer.GetString("GeoNetToolsLbl_2"));
                    return;
                }

                //Change mouse cursor to wait - automatically changes back (ArcGIS Desktop only)
                appCursor = new MouseCursorClass();
                appCursor.SetCursor(2);

                //This step is required to avoid accidently deleting features
                if (map.SelectionCount > 0)
                {
                    activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    map.ClearSelection();
                }

                int itotal = Convert.ToInt32(total);

                //ProgressBar
                progressDialogFactory = new ProgressDialogFactoryClass();

                // Create a CancelTracker

                trackCancel = new CancelTrackerClass();

                // Set the properties of the Step Progressor
                Int32 int32_hWnd = editor.Parent.hWnd;
                stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd);
                stepProgressor.MinRange = 0;
                // stepProgressor.MaxRange = itotal
                stepProgressor.StepValue = 1;
                stepProgressor.Message = "";
                stepProgressor.Hide();

                // Create the ProgressDialog. This automatically displays the dialog
                progressDialog = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast

                // Set the properties of the ProgressDialog
                progressDialog.CancelEnabled = false;
                progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsDesc_11");
                progressDialog.Title = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsTitle_11");
                progressDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressGlobe;

                for (int i = 0; i < gnList.Count; i++)
                {
                    geometricNetwork = gnList[i] as IGeometricNetwork;
//.........这里部分代码省略.........
开发者ID:rlwarford,项目名称:local-government-desktop-addins,代码行数:101,代码来源:GeoNetTools.cs

示例8: ProfileCreateGraph


//.........这里部分代码省略.........
                pScatterSeriesProps.LabelField = "LABEL";

                if (ProfileGraph[CurrentDetail].PointAlong_ShowLabels.ToUpper() == "TRUE" && ProfileGraph[CurrentDetail].PointAlong_Labels.Length > 0)
                {

                    pScatterSeriesProps.Marks = true;
                }

                pScatterSeriesProps.InLegend = true; // show legend   ' false = don't show legend
                pScatterSeriesProps.Name = ProfileGraph[CurrentDetail].PointAlong_LayerName;//"Points Along";
                //pSeriesProps.LabelField = "OBJECTID"
                pScatterSeriesProps.ValueFormat = " ";

                pScatterSeriesProps.SetField(0, strXDataFldName);// timefldName
                pScatterSeriesProps.SetField(1, strYDataFldName);

                pColor = Globals.GetColor(255, 0, 0);// green

                pScatterSeriesProps.CustomColor = pColor.RGB;  // pSymbol.Color.RGB

                // don't have any symbols on the line, just solid
                //IPointSeriesProperties pScatterSeriesProps2;
                pScatterSeriesProps2 = (IPointSeriesProperties)pScatterSeriesProps;// 'QI

                pScatterSeriesProps2.SymbolProperties.Style = esriDataGraphTSymbolType.esriDataGraphTSymbolStar;
                pScatterSeriesProps2.SymbolProperties.Visible = true;

                pScatterSeriesProps2.SymbolProperties.Color = pColor.RGB;
                pScatterSeriesProps2.SymbolProperties.BorderProperties.Color = pColor.RGB;
                pScatterSeriesProps2.SymbolProperties.BorderProperties.Style = esriDataGraphTPenType.esriDataGraphTPenSolid;

                pDataGraphBase.UseSelectedSet = false;

                pCancelTracker = new CancelTrackerClass();
                pDataGraphT.Update(pCancelTracker);

                // create data graph window

                pDataGraphWin = new DataGraphWindowClass();
                pDataGraphWin.DataGraphBase = pDataGraphBase;
                pDataGraphWin.Application = app;
                // size and position the window
                pDataGraphWin.PutPosition(0, 0, 900, 250);

                // add the graph to the project

                pDataGraphs = (IDataGraphCollection)pMxDoc; //QI
                pDataGraphs.AddDataGraph(pDataGraphBase);
                //IDataGraphT ptmp = (IDataGraphT)pDataGraphs.DataGraph[1];

                //string fld = ptmp.SeriesProperties[5].GetField(0);
                //fld = ptmp.SeriesProperties[5].GetField(1);
                //fld = ptmp.SeriesProperties[5].GetField(2);
                //fld = ptmp.SeriesProperties[5].LabelField;
                //fld = ptmp.SeriesProperties[5].Marks.ToString();
                //   fld = ptmp.SeriesProperties[5].HorizontalAxis;

                pDataGraphT.AxisProperties[0].AutomaticMaximum = true;
                pDataGraphT.AxisProperties[0].AutomaticMinimum = true;
                // pDataGraphT.AxisProperties[0].Minimum = minChartVal - 5;
                //pDataGraphT.AxisProperties[0].Maximum = maxChartVal + 5;
                pDataGraphT.AxisProperties[0].InitDefaults();

                // show the graph
                pDataGraphWin.Show(true);
开发者ID:rlwarford,项目名称:local-government-desktop-addins,代码行数:66,代码来源:GeoNetTools.cs

示例9: TraceIsolationSummary

        public static void TraceIsolationSummary(IApplication app, string sourceFLName, string valveFLName, string operableFieldNameValve, string operableFieldNameSource,
                                double snapTol, bool processEvent, string[] opValues, string addSQL, bool traceIndeterminate, bool ZeroSourceCont,
                                    string mainsFLName, string meterFLName, string metersCritFieldName, string metersCritValue,
                                string traceSum_LayerName, string traceSum_FacilityIDField, string traceSum_DateFieldName, string traceSum_ValveCountFieldName,
                                    string traceSum_MeterCountFieldName, string traceSum_CritMeterCountFieldName, string traceSum_CommentsFieldName)
        {
            IFeatureLayer mainsFL = null;

            IFeatureLayer resultsLayer = null;
            IFeatureClass mainFC = null;
            INetworkClass mainsNetwork = null;
            IFeatureClass resultsFC = null;
            IFeatureSelection mainsFS = null;
            IFeature pMainsFeat = null;
            IProgressDialogFactory pProDFact = null;
            IStepProgressor pStepPro = null;
            IProgressDialog2 pProDlg = null;
            ITrackCancel pTrkCan = null;
            IWorkspaceEdit pWSEdit = null;
            IFeatureCursor pFC = null;
            IFeatureCursor pInsCur = null;
            // IFeatureClassLoad featureClassLoad = null;
            // ISchemaLock schemaLock = null;
            IFeatureBuffer pSumFeatBuf = null;
            IEnumIDs pSelectIDs = null;

            ICurve pCurve = null;
            IPoint pPnt = null;
            IDataset pDS = null;

            int facilityIDFieldPosition;

            int resultsFacilityIDFieldPosition;
            //int resultsSourceIDFieldPosition;
            int resultsDateFieldPosition;
            int resultsValveCountFieldPosition;
            int resultsMeterCountFieldPosition;
            int resultsCritMeterCountFieldPosition;
            int resultsCommentsFieldPosition;

            try
            {

                bool FCorLayerMains = true;
                mainsFL = (IFeatureLayer)Globals.FindLayer(((IMxDocument)app.Document).FocusMap, mainsFLName, ref FCorLayerMains);
                if (mainsFL == null)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsMess_15d") + mainsFLName + " feature class was not found.\r\n Check the TraceIsolationSummary_Main_FeatureLayer tag in the config");
                    return;
                }
                mainFC = mainsFL.FeatureClass;

                //Determine field position for facility id
                facilityIDFieldPosition = mainFC.Fields.FindField("FACILITYID");
                if (facilityIDFieldPosition == -1)
                    facilityIDFieldPosition = mainFC.Fields.FindField("FACID");
                if (facilityIDFieldPosition == -1)
                    facilityIDFieldPosition = mainFC.Fields.FindField("ASSETID");
                if (facilityIDFieldPosition == -1)
                    facilityIDFieldPosition = mainFC.Fields.FindField(mainFC.OIDFieldName);
                if (facilityIDFieldPosition == -1)
                    return;

                mainsNetwork = mainFC as INetworkClass;
                if ((mainsNetwork == null) || (mainsNetwork.GeometricNetwork == null))
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsMess_15d") + mainsFLName + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_18a"));
                    return;
                }

                mainsFS = (IFeatureSelection)mainsFL;
                int FeatureCount = 0;
                if (mainsFS.SelectionSet.Count == 0)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("No") + mainsFL.Name + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_18b"),
                        A4LGSharedFunctions.Localizer.GetString("GeoNetToolsLbl_18a"), MessageBoxButtons.OK);

                    return;

                }
                FeatureCount = mainsFS.SelectionSet.Count;

                bool boolCont = true;
                // Create a CancelTracker
                pTrkCan = new CancelTrackerClass();
                // Create the ProgressDialog. This automatically displays the dialog
                pProDFact = new ProgressDialogFactoryClass();
                pProDlg = (IProgressDialog2)pProDFact.Create(pTrkCan, 0);

                // Set the properties of the ProgressDialog
                pProDlg.CancelEnabled = true;
                pProDlg.Description = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsDesc_18a");
                pProDlg.Title = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsTitle_18a");
                pProDlg.Animation = esriProgressAnimationTypes.esriProgressGlobe;

                // Set the properties of the Step Progressor
                pStepPro = (IStepProgressor)pProDlg;

                pStepPro.MinRange = 1;
                pStepPro.MaxRange = FeatureCount - 1;
//.........这里部分代码省略.........
开发者ID:rlwarford,项目名称:local-government-desktop-addins,代码行数:101,代码来源:GeoNetTools.cs

示例10: Execute

        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            try
            {
                IGPUtilities3 execute_Utilities = new GPUtilitiesClass();

                if (TrackCancel == null)
                {
                    TrackCancel = new CancelTrackerClass();
                }

                IGPParameter inputOSMParameter = paramvalues.get_Element(in_osmFeatureClass) as IGPParameter;
                IGPValue inputOSMGPValue = execute_Utilities.UnpackGPValue(inputOSMParameter);

                IGPParameter tagCollectionParameter = paramvalues.get_Element(in_attributeSelector) as IGPParameter;
                IGPMultiValue tagCollectionGPValue = execute_Utilities.UnpackGPValue(tagCollectionParameter) as IGPMultiValue;

                if (tagCollectionGPValue == null)
                {
                    message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), tagCollectionParameter.Name));
                    return;
                }

                bool useUpdateCursor = false;

                IFeatureClass osmFeatureClass = null;
                ITable osmInputTable = null;
                IQueryFilter osmQueryFilter = null;

                try
                {
                    execute_Utilities.DecodeFeatureLayer(inputOSMGPValue, out osmFeatureClass, out osmQueryFilter);
                    if (osmFeatureClass != null)
                    {
                        if (osmFeatureClass.Extension is IOSMClassExtension)
                        {
                            useUpdateCursor = false;
                        }
                        else
                        {
                            useUpdateCursor = true;
                        }
                    }

                    osmInputTable = osmFeatureClass as ITable;
                }
                catch { }

                try
                {
                    if (osmInputTable == null)
                    {
                        execute_Utilities.DecodeTableView(inputOSMGPValue, out osmInputTable, out osmQueryFilter);
                    }
                }
                catch { }

                if (osmInputTable == null)
                {
                    string errorMessage = String.Format(resourceManager.GetString("GPTools_OSMGPAttributeSelecto_unableopentable"), inputOSMGPValue.GetAsText());
                    message.AddError(120053, errorMessage);
                    return;
                }

                // find the field that holds tag binary/xml field
                int osmTagCollectionFieldIndex = osmInputTable.FindField("osmTags");

                // if the Field doesn't exist - wasn't found (index = -1) get out
                if (osmTagCollectionFieldIndex == -1)
                {
                    message.AddError(120005, resourceManager.GetString("GPTools_OSMGPAttributeSelector_notagfieldfound"));
                    return;
                }

                // check if the tag collection includes the keyword "ALL", if does then we'll need to extract all tags
                bool extractAll = false;
                for (int valueIndex = 0; valueIndex < tagCollectionGPValue.Count; valueIndex++)
                {
                    if (tagCollectionGPValue.get_Value(valueIndex).GetAsText().Equals("ALL"))
                    {
                        extractAll = true;
                        break;
                    }
                }
                //if (extractAll)
                //{
                //    if (osmTagKeyCodedValues == null)
                //        extractAllTags(ref osmTagKeyCodedValues, osmInputTable, osmQueryFilter, osmTagCollectionFieldIndex, false);

                //    if (osmTagKeyCodedValues == null)
                //    {
                //        message.AddAbort(resourceManager.GetString("GPTools_OSMGPAttributeSelector_Unable2RetrieveTags"));
                //        return;
                //    }

                //    // empty the existing gp multivalue object
                //    tagCollectionGPValue = new GPMultiValueClass();

                //    // fill the coded domain in gp multivalue object
                //    for (int valueIndex = 0; valueIndex < osmTagKeyCodedValues.CodeCount; valueIndex++)
//.........这里部分代码省略.........
开发者ID:hallahan,项目名称:arcgis-osm-editor,代码行数:101,代码来源:OSMGPAttributeSelector.cs

示例11: OnClick


//.........这里部分代码省略.........
            if (!FabricUTILS.SetupEditEnvironment(pWS, pCadFabric, pEd, out bIsFileBasedGDB,
              out bIsUnVersioned, out bUseNonVersionedDelete))
              return;

            //loop through each control layer and
            //Get the selection of control
             int iCnt=0;
             int iTotalSelectionCount = 0;
             for (; iCnt < CFControlLayers.Count; iCnt++)
             {
               pFL = (IFeatureLayer)CFControlLayers.get_Element(iCnt);
               IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
               ISelectionSet2 pSelSet = (ISelectionSet2)pFeatSel.SelectionSet;
               iTotalSelectionCount += pSelSet.Count;
             }

             if (iTotalSelectionCount == 0)
             {
               MessageBox.Show("Please select some fabric control points and try again.", "No Selection",
             MessageBoxButtons.OK, MessageBoxIcon.Information);
               if (bUseNonVersionedDelete)
               {
             pCadEd.CadastralFabricLayer = null;
             CFControlLayers = null;
               }
               return;
             }

             bShowProgressor = (iTotalSelectionCount > 10);

             if (bShowProgressor)
             {
               pProgressorDialogFact = new ProgressDialogFactoryClass();
               pTrackCancel = new CancelTrackerClass();
               pStepProgressor = pProgressorDialogFact.Create(pTrackCancel, ArcMap.Application.hWnd);
               pProgressorDialog = (IProgressDialog2)pStepProgressor;
               pStepProgressor.MinRange = 1;
               pStepProgressor.MaxRange = iTotalSelectionCount * 2; //(runs through selection twice)
               pStepProgressor.StepValue = 1;
               pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
             }

            //loop through each control layer and
            //delete from its selection
            m_pQF = new QueryFilterClass();
            iCnt=0;
            for (; iCnt < CFControlLayers.Count; iCnt++)
            {
              pFL = (IFeatureLayer)CFControlLayers.get_Element(iCnt);
              IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
              ISelectionSet2 pSelSet = (ISelectionSet2)pFeatSel.SelectionSet;

              ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
              string sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
              string sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

              if (bShowProgressor)
              {
            pProgressorDialog.ShowDialog();
            pStepProgressor.Message = "Collecting Control point data...";
              }

              //Add the OIDs of all the selected control points into a new feature IDSet
              string[] sOIDListPoints = { "(" };
              int tokenLimit = 995;
              //int tokenLimit = 5; //temp for testing
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:67,代码来源:clsDeleteSelectedControl.cs

示例12: batchLoadBarriers

        public static void batchLoadBarriers(IApplication app)
        {
            bool fndAsLayer = false;
            List<string> strFiles = new List<string>();

            IEnumLayer pLays = null;
            IProgressDialogFactory pProDFact = null;
            IStepProgressor pStepPro = null;
            IProgressDialog2 pProDlg = null;
            ITrackCancel pTrkCan = null;
            IFeatureLayer pFl = null;
            IFeatureCursor featureCursor = null;

            IFeature feature = null;
            IFeatureLayerDefinition2 pFLD = null;
            IQueryFilter pQF = null;
            ILayer pLay = null;
            bool boolCont = true;
            int featCount = 0;
            try
            {
                double seTol = ConfigUtil.GetConfigValue("Trace_Click_Point_Tolerence", 5.0);
                pLays = Globals.GetLayers(app, "VECTOR");
                if (pLays != null)
                {
                    pLay = pLays.Next();

                    while (pLay != null)
                    {
                        if (pLay is IFeatureLayer)
                        {
                            if (((IFeatureLayer)pLay).FeatureClass != null)
                            {
                                if (((IFeatureLayer)pLay).FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                                {
                                    strFiles.Add(pLay.Name);

                                }
                            }

                        }
                        pLay = pLays.Next();
                    }
                    //MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsLbl_1") + "\n" + ex.Message, ex.Source);
                    string strRetVal = Globals.showOptionsForm(strFiles, A4LGSharedFunctions.Localizer.GetString("GeoNetToolsBatchBarrier"), ComboBoxStyle.DropDownList);
                    if (strRetVal != null && strRetVal != "||Cancelled||")
                    {
                        pFl = (IFeatureLayer)Globals.FindLayer(app, strRetVal, ref fndAsLayer);
                        if (pFl == null)
                        {

                            MessageBox.Show(strRetVal + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                            return;
                        }
                        if (pFl.FeatureClass == null)
                        {
                            MessageBox.Show(strRetVal + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_18d"));
                            return;
                        }
                        pFLD = (IFeatureLayerDefinition2)pFl;

                        // Create a CancelTracker
                        pTrkCan = new CancelTrackerClass();
                        // Create the ProgressDialog. This automatically displays the dialog
                        pProDFact = new ProgressDialogFactoryClass();
                        pProDlg = (IProgressDialog2)pProDFact.Create(pTrkCan, 0);

                        // Set the properties of the ProgressDialog
                        pProDlg.CancelEnabled = true;

                        pProDlg.Animation = esriProgressAnimationTypes.esriProgressGlobe;

                        // Set the properties of the Step Progressor
                        pStepPro = (IStepProgressor)pProDlg;

                        pStepPro.MinRange = 0;
                        pQF = new QueryFilterClass();
                        if (pFLD.DefinitionExpression.Trim() == "")
                        {

                            featCount = pFl.FeatureClass.FeatureCount(null);
                        }
                        else
                        {
                            pQF.WhereClause = pFLD.DefinitionExpression;
                            featCount = pFl.FeatureClass.FeatureCount(pQF);
                        }
                        if (featCount == 0) { return; }

                        pStepPro.MaxRange = featCount;
                        pStepPro.StepValue = 1;
                        pStepPro.Position = 0;
                        pStepPro.Message = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsProc_6");

                        featureCursor = pFl.Search(null, false);
                        feature = featureCursor.NextFeature();
                        while (feature != null)
                        {
                            if (!boolCont)
                            {
//.........这里部分代码省略.........
开发者ID:rkBiswal,项目名称:local-government-desktop-addins,代码行数:101,代码来源:GeoNetTools.cs

示例13: Execute

        /**
         * Executes each of the DataQualityTests in order and collects their results
         */
        public int Execute()
        {
            // Establish the place to store the errors
            try
            {
                tm.TransactionManager theTM = this.Extension.TransactionManager;
                string theFCName = this.Extension.get_SystemValue("tm.template.dataerrors.table");

                if (theTM.Current() == null)
                {
                    // This isn't tied to any transaction, so prompt the user to save a pgdb
                    SaveFileDialog theSaveDialog = new SaveFileDialog();

                    theSaveDialog.Filter = "Personal Geodatabase files (*.mdb)|*.mdb";
                    theSaveDialog.FilterIndex = 1;
                    theSaveDialog.RestoreDirectory = true;
                    theSaveDialog.Title = "Save Test Results";

                    if(theSaveDialog.ShowDialog() == DialogResult.OK)
                    {
                        string theTemplate = this.Extension.get_SystemValue("tm.template.tant.pgdb");
                        this._errors = new QAErrorStorage(theTemplate, theSaveDialog.FileName, theFCName);
                    }
                    else
                        return -2;
                }
                else
                {
                    if (this._errors == null || this._errors.StorageWorkspace != theTM.Current().PGDBConnection)
                    {
                        this._errors = new QAErrorStorage(theTM.Current().PGDBConnection, theFCName);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error raised when establishing place to save errors:" + Environment.NewLine
                    + ex.Message,
                    "Error Storage Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                util.Logger.Write("Error raised when establishing place to save errors:" + Environment.NewLine
                    + ex.Message + Environment.NewLine + ex.StackTrace);
                return -1;
            }

            bool bShowErrorManager = false;
            ArrayList theNewErrors = new ArrayList();

            // Initialize log file
            string logDirectory = this.Extension.get_SystemValue(util.Logger.LOG_DIRECTORY_KEY)
                + Path.DirectorySeparatorChar;
            String logFileName = logDirectory + "isdut_qa_" + DateTime.Now.ToString("s").Replace(":", "-") + ".log";

            // Will put up a progress dialog, with a proper CancelTracker
            IProgressDialog2 thePDialog = null;

            try
            {
                ITrackCancel theCancelTracker = new CancelTrackerClass();
                IProgressDialogFactory theFactory = new ProgressDialogFactoryClass();
                thePDialog = (IProgressDialog2)theFactory.Create(theCancelTracker, this._app.hWnd);
                thePDialog.CancelEnabled = true;
                thePDialog.Description = "";
                thePDialog.Title = "Running QA Tests";
                thePDialog.Animation = esriProgressAnimationTypes.esriProgressGlobe;

                IStepProgressor theStepProgressor = (IStepProgressor)thePDialog;
                theStepProgressor.MinRange = 0;
                theStepProgressor.MaxRange = this.TestCount + 2;
                theStepProgressor.StepValue = 1;

                bool bContinue = true;
                bool bProblemWithTest = false;

                for (int i = 0; i < this.TestCount; i++)
                {
                    QATest theQATest = this._tests.get_Test(i);

                    theStepProgressor.Message = theQATest.Name;

                    if (theQATest != null && theQATest.IsActive)
                    {
                        IDataQualityTest theTest = theQATest.Test;
                        if (theTest != null)
                        {
                            int errCount = theTest.Execute(logFileName);

                            bContinue = theCancelTracker.Continue();
                            if (bContinue == false)
                                break;

                            if (errCount < 0)
                            {
                                bProblemWithTest = true;
                            }

                            if (theTest.ErrorCount > 0)
//.........这里部分代码省略.........
开发者ID:EAWCS1,项目名称:SUITT,代码行数:101,代码来源:QAManager.cs

示例14: Execute

        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            try
            {
                IGPUtilities3 execute_Utilities = new GPUtilitiesClass();

                if (TrackCancel == null)
                {
                    TrackCancel = new CancelTrackerClass();
                }

                IGPParameter inputFeatureDatasetParameter = paramvalues.get_Element(in_featureDatasetParameterNumber) as IGPParameter;
                IGPValue inputFeatureDatasetGPValue = execute_Utilities.UnpackGPValue(inputFeatureDatasetParameter);
                IGPValue outputOSMFileGPValue = execute_Utilities.UnpackGPValue(paramvalues.get_Element(out_osmFileLocationParameterNumber));

                // get the name of the feature dataset
                int fdDemlimiterPosition = inputFeatureDatasetGPValue.GetAsText().LastIndexOf("\\");

                string nameOfFeatureDataset = inputFeatureDatasetGPValue.GetAsText().Substring(fdDemlimiterPosition + 1);


                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;

                System.Xml.XmlWriter xmlWriter = null;

                try
                {
                    xmlWriter = XmlWriter.Create(outputOSMFileGPValue.GetAsText(), settings);
                }
                catch (Exception ex)
                {
                    message.AddError(120021, ex.Message);
                    return;
                }

                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("osm"); // start the osm root node
                xmlWriter.WriteAttributeString("version", "0.6"); // add the version attribute
                xmlWriter.WriteAttributeString("generator", "ArcGIS Editor for OpenStreetMap"); // add the generator attribute

                // write all the nodes
                // use a feature search cursor to loop through all the known points and write them out as osm node

                IFeatureClassContainer osmFeatureClasses = execute_Utilities.OpenDataset(inputFeatureDatasetGPValue) as IFeatureClassContainer;

                if (osmFeatureClasses == null)
                {
                    message.AddError(120022, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), inputFeatureDatasetParameter.Name));
                    return;
                }

                IFeatureClass osmPointFeatureClass = osmFeatureClasses.get_ClassByName(nameOfFeatureDataset + "_osm_pt");

                if (osmPointFeatureClass == null)
                {
                    message.AddError(120023, string.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_no_pointfeatureclass"), nameOfFeatureDataset + "_osm_pt"));
                    return;
                }

                // check the extension of the point feature class to determine its version
                int internalOSMExtensionVersion = osmPointFeatureClass.OSMExtensionVersion();

                IFeatureCursor searchCursor = null;

                System.Xml.Serialization.XmlSerializerNamespaces xmlnsEmpty = new System.Xml.Serialization.XmlSerializerNamespaces();
                xmlnsEmpty.Add("", "");

                message.AddMessage(resourceManager.GetString("GPTools_OSMGPExport2OSM_exporting_pts_msg"));
                int pointCounter = 0;

                string nodesExportedMessage = String.Empty;

                // collect the indices for the point feature class once
                int pointOSMIDFieldIndex = osmPointFeatureClass.Fields.FindField("OSMID");
                int pointChangesetFieldIndex = osmPointFeatureClass.Fields.FindField("osmchangeset");
                int pointVersionFieldIndex = osmPointFeatureClass.Fields.FindField("osmversion");
                int pointUIDFieldIndex = osmPointFeatureClass.Fields.FindField("osmuid");
                int pointUserFieldIndex = osmPointFeatureClass.Fields.FindField("osmuser");
                int pointTimeStampFieldIndex = osmPointFeatureClass.Fields.FindField("osmtimestamp");
                int pointVisibleFieldIndex = osmPointFeatureClass.Fields.FindField("osmvisible");
                int pointTagsFieldIndex = osmPointFeatureClass.Fields.FindField("osmTags");

                using (ComReleaser comReleaser = new ComReleaser())
                {
                    searchCursor = osmPointFeatureClass.Search(null, false);
                    comReleaser.ManageLifetime(searchCursor);

                    System.Xml.Serialization.XmlSerializer pointSerializer = new System.Xml.Serialization.XmlSerializer(typeof(node));

                    IFeature currentFeature = searchCursor.NextFeature();

                    IWorkspace pointWorkspace = ((IDataset)osmPointFeatureClass).Workspace;

                    while (currentFeature != null)
                    {
                        if (TrackCancel.Continue() == true)
                        {
                            // convert the found point feature into a osm node representation to store into the OSM XML file
                            node osmNode = ConvertPointFeatureToOSMNode(currentFeature, pointWorkspace, pointTagsFieldIndex, pointOSMIDFieldIndex, pointChangesetFieldIndex, pointVersionFieldIndex, pointUIDFieldIndex, pointUserFieldIndex, pointTimeStampFieldIndex, pointVisibleFieldIndex, internalOSMExtensionVersion);
//.........这里部分代码省略.........
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:101,代码来源:OSMGPExport2OSM.cs

示例15: ExportActiveView

        //输出当前地图至指定的文件
        public static void ExportActiveView(IActiveView pView, Size outRect, string outPath)
        {
            try
            {
                //参数检查
                if (pView == null)
                {
                    throw new Exception("输入参数错误,无法生成图片文件!");
                }

                //根据给定的文件扩展名,来决定生成不同类型的对象
                ESRI.ArcGIS.Output.IExport export = null;
                if (outPath.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase))
                {
                    export = new ESRI.ArcGIS.Output.ExportJPEGClass();
                }
                else if (outPath.EndsWith(".tiff", StringComparison.OrdinalIgnoreCase))
                {
                    export = new ESRI.ArcGIS.Output.ExportTIFFClass();
                }
                else if (outPath.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase))
                {
                    export = new ESRI.ArcGIS.Output.ExportBMPClass();
                }
                else if (outPath.EndsWith(".emf", StringComparison.OrdinalIgnoreCase))
                {
                    export = new ESRI.ArcGIS.Output.ExportEMFClass();
                }
                else if (outPath.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
                {
                    export = new ESRI.ArcGIS.Output.ExportPNGClass();
                }
                else if (outPath.EndsWith(".gif", StringComparison.OrdinalIgnoreCase))
                {
                    export = new ESRI.ArcGIS.Output.ExportGIFClass();
                }

                SetOutputQuality(pView, 1);

                export.ExportFileName = outPath;
                IEnvelope pEnvelope = pView.Extent;
                //导出参数
                export.Resolution = 300;

                tagRECT exportRect = new tagRECT();
                exportRect.left = exportRect.top = 0;
                exportRect.right = outRect.Width;
                exportRect.bottom = (int)(exportRect.right * pEnvelope.Height / pEnvelope.Width);
                ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
                //输出范围
                envelope.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom);
                export.PixelBounds = envelope;
                //可用于取消操作
                ITrackCancel pCancel = new CancelTrackerClass();
                export.TrackCancel = pCancel;
                pCancel.Reset();
                //点击ESC键时,中止转出
                pCancel.CancelOnKeyPress = true;
                pCancel.CancelOnClick = false;
                pCancel.ProcessMessages = true;
                //获取handle
                System.Int32 hDC = export.StartExporting();
                //开始转出
                pView.Output(hDC, (System.Int32)export.Resolution, ref exportRect, pEnvelope, pCancel);
                bool bContinue = pCancel.Continue();
                //捕获是否继续
                if (bContinue)
                {
                    export.FinishExporting();
                    export.Cleanup();
                }
                else
                {
                    export.Cleanup();
                }

                bContinue = pCancel.Continue();
            }
            catch (Exception e)
            {
                //错误信息提示
            }
        }
开发者ID:niwho,项目名称:ArcGISFundation,代码行数:84,代码来源:PrintHelper.cs


注:本文中的CancelTrackerClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。