private void btnOK_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { _currentTemplate = listView1.SelectedItems[0].Tag as IEditTemplate; } }
static private bool AnalyzeItem2(string searchTerm, IEditTemplate template, ref int inName, ref int inTags, ref int inLayerName, ref int inDesc, ref int inPartial) { inName = inTags = inLayerName = inDesc = inPartial = 0; Match match = MatchSearchTerm(template.Name, searchTerm); if (match == Match.eFull) { inName += 1; } else if (match == Match.ePartial) { inPartial += 1; } match = MatchSearchTerm(template.Tags, searchTerm); if (match == Match.eFull) { inTags += 1; } else if (match == Match.ePartial) { inPartial += 1; } ILayer layer = template.Layer; if (layer != null) { match = MatchSearchTerm(layer.Name, searchTerm); if (match == Match.eFull) { inLayerName += 1; } else if (match == Match.ePartial) { inPartial += 1; } } match = MatchSearchTerm(template.Description, searchTerm); if (match == Match.eFull) { inDesc += 1; } else if (match == Match.ePartial) { inPartial += 1; } return(inName + inDesc + inTags + inLayerName + inPartial > 0); }
internal TemplateForm(IEditTemplate edit) { InitializeComponent(); m_Edit = edit; if (m_Edit == null) { IEnvironmentFactory f = EnvironmentContainer.Factory; m_Edit = f.CreateTemplate(); } m_TableFactory = new TableFactory(); m_Table = null; m_Edit.BeginEdit(); }
public PointsAlongLineForm(IEditor3 editor) { InitializeComponent(); m_editor = editor; m_edSketch = m_editor as IEditSketch3; m_polyline = m_edSketch.Geometry as IPolyline; tbLineLength.Text = (m_polyline.Length.ToString("F")); //get the template m_editTemplate = m_editor.CurrentTemplate; m_featureLayer = m_editTemplate.Layer as IFeatureLayer; m_featureClass = m_featureLayer.FeatureClass; }
private SortByRank(ListView list, string filterTypeStr) { m_list = list; if (!list.IsHandleCreated) { return; } List <int> removeIndex = new List <int>(); // Replace item data with pointer with new RankTemplate struct. for (int i = 0; i < m_list.Items.Count; i++) { IEditTemplate template = m_list.Items[i].Tag as IEditTemplate; int nName, nTags, nLayerName, nDesc, nPartial; if (!AnalyzeItem(filterTypeStr, template, out nName, out nTags, out nLayerName, out nDesc, out nPartial)) { removeIndex.Insert(0, i); continue; } m_list.Items[i].Tag = new RankTemplate(FindRank(nName, nTags, nLayerName, nDesc, nPartial), template); } for (int i = 0; i < removeIndex.Count(); i++) { m_list.Items.RemoveAt(removeIndex[i]); } IComparer oldComparer = m_list.ListViewItemSorter; m_list.ListViewItemSorter = this as IComparer; //assigning performs the sort m_list.ListViewItemSorter = null; // Restore item data from RankTemplate struct. for (int i = 0; i < m_list.Items.Count; i++) { RankTemplate rankTemplate = m_list.Items[i].Tag as RankTemplate; if (rankTemplate != null) { m_list.Items[i].Tag = rankTemplate.Template; } } }
static private bool AnalyzeItem(string filterTypeStr, IEditTemplate template, out int nName, out int nTags, out int nLayerName, out int nDesc, out int nPartial) { nName = nTags = nLayerName = nDesc = nPartial = 0; foreach (string word in filterTypeStr.ToUpperInvariant().Split(' ')) { int inName = 0, inTags = 0, inLayerName = 0, inDesc = 0, inPartial = 0; if (AnalyzeItem2(word, template, ref inName, ref inTags, ref inLayerName, ref inDesc, ref inPartial)) { nName += inName; nTags += inTags; nLayerName += inLayerName; nDesc += inDesc; nPartial += inPartial; } else { return(false); } } return(nName + nTags + nLayerName + nDesc + nPartial > 0); }
private static bool AnalyzeItem2(string searchTerm, IEditTemplate template, ref int inName, ref int inTags, ref int inLayerName, ref int inDesc, ref int inPartial) { inName = inTags = inLayerName = inDesc = inPartial = 0; Match match = MatchSearchTerm(template.Name, searchTerm); if (match == Match.eFull) inName += 1; else if (match == Match.ePartial) inPartial += 1; match = MatchSearchTerm(template.Tags, searchTerm); if (match == Match.eFull) inTags += 1; else if (match == Match.ePartial) inPartial += 1; ILayer layer = template.Layer; if (layer != null) { match = MatchSearchTerm(layer.Name, searchTerm); if (match == Match.eFull) inLayerName += 1; else if (match == Match.ePartial) inPartial += 1; } match = MatchSearchTerm(template.Description, searchTerm); if (match == Match.eFull) inDesc += 1; else if (match == Match.ePartial) inPartial += 1; return inName + inDesc + inTags + inLayerName + inPartial > 0; }
private static bool AnalyzeItem(string filterTypeStr, IEditTemplate template, out int nName, out int nTags, out int nLayerName, out int nDesc, out int nPartial) { nName = nTags = nLayerName = nDesc = nPartial = 0; foreach (string word in filterTypeStr.ToUpperInvariant().Split(' ')) { int inName = 0, inTags = 0, inLayerName = 0, inDesc = 0, inPartial = 0; if (AnalyzeItem2(word, template, ref inName, ref inTags, ref inLayerName, ref inDesc, ref inPartial)) { nName += inName; nTags += inTags; nLayerName += inLayerName; nDesc += inDesc; nPartial += inPartial; } else return false; } return nName + nTags + nLayerName + nDesc + nPartial > 0; }
private static bool CreateLateralFromMainPoint(ref IApplication app, ref IEditor editor, IFeature pointFeature, IFeatureLayer mainLineFLayer, IFeatureLayer targetLineFLayer, IEditTemplate targetLineEditTemplate, List<pointAlongSettings> pointAlongLayers, bool startAtMain, FromToField[] fromToPairs, LateralLine_AngleDetails latDet, bool SearchOnLayer, bool CheckSelection) { List<IFeature> pointsAlong = new List<IFeature>(); //IGeometry pGeometry; IPolyline polyline; //IPoint pToPoint; //IPoint pFromPoint; //IConstructPoint pConstructPoint; UID pId = new UID(); IFeature pFeat; // double pi; double dblDegrees; double dblAngleRad; double dblLateralLength; //Find LineAngle field in the layer //iLayerLineAngleFieldPos = pFC.FindField(c_sLineAngleFieldName) //If iLayerLineAngleFieldPos < 0 Then // MsgBox c_sLineAngleFieldName & " was not found in the highlighted layer.", vbCritical, c_sTitle // Exit Sub //End If if (targetLineFLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline) { //MsgBox "Edit target must be a polyline layer (i.e. laterals).", vbCritical, c_sTitle return false; } dblDegrees = 90; if (!Globals.IsNumeric(latDet.AngleField)) { int fldIdx = Globals.GetFieldIndex(pointFeature.Class.Fields, latDet.AngleField); if (fldIdx > -1) { string temp = pointFeature.get_Value(fldIdx).ToString(); if (Globals.IsNumeric(temp)) { Double.TryParse(temp, out dblDegrees); } } } else { Double.TryParse(latDet.AngleField, out dblDegrees); } dblLateralLength = 10; if (!Globals.IsNumeric(latDet.LengthField)) { int fldIdx = Globals.GetFieldIndex(pointFeature.Class.Fields, latDet.LengthField); if (fldIdx > -1) { string temp = pointFeature.get_Value(fldIdx).ToString(); if (Globals.IsNumeric(temp)) { Double.TryParse(temp, out dblLateralLength); } } } else { Double.TryParse(latDet.LengthField, out dblLateralLength); } if (latDet.AngleType.ToUpper() == "CLOCK") { dblAngleRad = Globals.ConvertDegToRads(Globals.ConvertClockPositionToDegrees(dblDegrees)); } else if (latDet.AngleType.ToUpper() == "RADIANS") dblAngleRad = Globals.ConvertDegToRads(dblDegrees); else dblAngleRad = dblDegrees; string dirVal = latDet.DirectionField; if (dirVal != "") { int fldIdx = Globals.GetFieldIndex(pointFeature.Class.Fields, dirVal); if (fldIdx > -1) { dirVal = pointFeature.get_Value(fldIdx).ToString(); } } else { dirVal = ""; } if (dirVal.ToUpper() == latDet.LookingUpstreamValue.ToUpper()) { dblAngleRad = Globals.ConvertDegToRads(Globals.ConvertRadsToDegrees(dblAngleRad) + 180); } else if (dirVal == latDet.LookingDownstreamValue) { } else { } if (latDet.OnlyPerp.ToUpper() == "TRUE") { double val = Globals.ConvertRadsToDegrees(dblAngleRad); if (val >= 0.0 && val <= 180.0) { dblAngleRad = Globals.ConvertDegToRads(90); } else { dblAngleRad = Globals.ConvertDegToRads(270); } } polyline = Globals.CreateAngledLineFromLocationOnLine((IPoint)pointFeature.Shape, mainLineFLayer, SearchOnLayer, dblAngleRad, dblLateralLength, latDet.AddAngleToLineAngle, startAtMain, CheckSelection); //Add that line to Laterals lateral if (targetLineEditTemplate != null) { pFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } pFeat.Store(); if (pointAlongLayers != null) { foreach (pointAlongSettings pPointAlongLayer in pointAlongLayers) { if (pPointAlongLayer.PolygonIntersectLayer != null) pointsAlong.Add(Globals.AddPointAlongLineWithIntersect(ref app, ref editor, polyline as ICurve, pPointAlongLayer.PointAlongLayer, pPointAlongLayer.PointAlongDistance, pPointAlongLayer.DistanceIsPercent, pPointAlongLayer.PointAlongEditTemplate, pPointAlongLayer.PolygonIntersectLayer, pPointAlongLayer.PolygonIntersectSide)); else pointsAlong.Add(Globals.AddPointAlongLine(ref app, ref editor, polyline as ICurve, pPointAlongLayer.PointAlongLayer, pPointAlongLayer.PointAlongDistance, pPointAlongLayer.DistanceIsPercent, pPointAlongLayer.PointAlongEditTemplate)); // idx++; } } if (pFeat is INetworkFeature) { INetworkFeature pNF = (INetworkFeature)pFeat; pNF.CreateNetworkElements(); //pNF.Connect(); } return true; }
private static bool CreateSingle(ref IApplication app, ref IEditor editor, IFeature pointFeature, IFeatureLayer matchLineFLayer, IFeatureLayer targetLineFLayer, IEditTemplate targetLineEditTemplate, List<pointAlongSettings> pointAlongLayers, bool startAtMain, bool deleteExistingLines, FromToField[] fromToPairs, double doglegDistance, bool DistAsPercent, double tolerenceForDelete, bool store, bool SearchOnLayer, int searchDistance, double angle, bool checkSelection) { IFeature lineFeature = null; IPoint thisPoint = null; IPoint turnPoint = null; IPoint toPoint = null; ICurve mainCurve = null; IPolyline polyline = null; IFeature pFeat = null; try { // Get closest main to point1 thisPoint = (IPoint)pointFeature.ShapeCopy; lineFeature = Globals.GetClosestFeature(thisPoint, matchLineFLayer, Convert.ToDouble(searchDistance), SearchOnLayer, checkSelection); // (_app.Document as IMxDocument).FocusMap.ClearSelection(); if (lineFeature != null) { //Delete any existing lateral lines at this location if (deleteExistingLines) { DeleteExistingFeatures(pointFeature, targetLineFLayer, pointAlongLayers, tolerenceForDelete); } //Determine To and Turn Points mainCurve = lineFeature.ShapeCopy as ICurve; CreateToAndTurnPoints(mainCurve, thisPoint, out toPoint, out turnPoint, doglegDistance, DistAsPercent); //Create the new line polyline = Globals.CreatePolylineFromPointsNewTurn(thisPoint, turnPoint, toPoint, ref matchLineFLayer, ref lineFeature, SearchOnLayer, angle, editor.Map.SpatialReference); //If requested, store pipe id in the point StorePipeInfoPointFeature(lineFeature, pointFeature, fromToPairs, store); if (polyline.Length > 0) { if (startAtMain) polyline.ReverseOrientation(); if (targetLineEditTemplate != null) { pFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } if (pFeat == null) { editor.AbortOperation(); return false; } //Globals.SetFlowDirection(pFeat, targetLineFLayer); try { if (pFeat != null) { Globals.ValidateFeature(pFeat); pFeat.Store(); } //if (pFeat is INetworkFeature) //{ // INetworkFeature pNF = (INetworkFeature)pFeat; // pNF.Connect(); //} } catch (Exception ex) { // MessageBox.Show("The Feature could not be stored, this is typically because the layer has Z and the geometric network was not created to honors, you need to drop the network and recreate it with Z's enabled\n" + ex.Message); } //Old Way //IFeature pFeat = CreateLineFeature(targetLineFLayer, newPolyLine, targetLineValue, targetLineFieldName, targetLineSubtype); //Optionally, create new point along line // int idx = 0; if (pointAlongLayers != null) { foreach (pointAlongSettings pPointAlongLayer in pointAlongLayers) { if (pPointAlongLayer.PolygonIntersectLayer != null) Globals.AddPointAlongLineWithIntersect(ref app, ref editor, polyline as ICurve, pPointAlongLayer.PointAlongLayer, pPointAlongLayer.PointAlongDistance, pPointAlongLayer.DistanceIsPercent, pPointAlongLayer.PointAlongEditTemplate, pPointAlongLayer.PolygonIntersectLayer, pPointAlongLayer.PolygonIntersectSide); else Globals.AddPointAlongLine(ref app, ref editor, polyline as ICurve, pPointAlongLayer.PointAlongLayer, pPointAlongLayer.PointAlongDistance, pPointAlongLayer.DistanceIsPercent, pPointAlongLayer.PointAlongEditTemplate); // idx++; } } //Globals.SetFlowDirection(pFeat, targetLineFLayer,((IMxDocument)app.Document).FocusMap); //try //{ // if (pFeat != null) // { // // Globals.ValidateFeature(pFeat); // pFeat.Store(); // } // //if (pFeat is INetworkFeature) // //{ // // INetworkFeature pNF = (INetworkFeature)pFeat; // // pNF.Connect(); // //} //} //catch (Exception ex) //{ // // MessageBox.Show("The Feature could not be stored, this is typically because the layer has Z and the geometric network was not created to honors, you need to drop the network and recreate it with Z's enabled\n" + ex.Message); //} return true; //AddPointAlongLine(newPolyLine as ICurve, targetPointFLayer, targetPointDistance, targetPointDistanceIsPercent, targetPointSubtype, targetPointValue, targetPointFieldName); } else { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_6")); return false; } } else { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_5a") + matchLineFLayer.Name + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_5b") + searchDistance + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_5c")); return false; } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsLbl_3") + "\n" + ex.Message, ex.Source); return false; } finally { lineFeature = null; thisPoint = null; turnPoint = null; toPoint = null; mainCurve = null; polyline = null; pFeat = null; } }
private static bool CreateDual(ref IApplication app, ref IEditor editor, IFeature pointFeature, IFeature pointFeature2, ILine distanceLine, IFeatureLayer matchLineFLayer, IFeatureLayer targetLineFLayer, IEditTemplate targetLineEditTemplate, List<pointAlongSettings> pointAlongLayers, bool deleteExistingLines, bool startAtMain, bool squareDualLines, FromToField[] fromToPairs, double doglegDistance, bool DistAsPercent, double tolerenceForDelete, bool store, bool SearchOnLayer, int searchDistance, double angle, bool checkSelection) { IPoint point = null; IPoint point2 = null; IPoint turnPoint = null; IPoint toPoint = null; IPoint joinPoint = null; IPoint sqPoint1 = null; IPoint sqPoint2 = null; IPoint midPoint = null; IFeature lineFeature = null; IPolyline polyline = null; IFeature pLineFeat = null; ICurve mainCurve = null; try { point = (IPoint)pointFeature.Shape; point2 = (IPoint)pointFeature2.Shape; //Determine mid point midPoint = new PointClass(); distanceLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, true, midPoint); // Get closest main to midpoint (if a single main was not selected) lineFeature = Globals.GetClosestFeature(midPoint, matchLineFLayer, Convert.ToDouble(searchDistance), SearchOnLayer, checkSelection); if (lineFeature != null) { //Delete any existing lateral lines at these locations if (deleteExistingLines) { DeleteExistingFeatures(pointFeature, targetLineFLayer, pointAlongLayers, tolerenceForDelete); DeleteExistingFeatures(pointFeature2, targetLineFLayer, pointAlongLayers, tolerenceForDelete); } //Determine To and Turn Points (and possible square points) mainCurve = lineFeature.ShapeCopy as ICurve; CreateToAndTurnPointsDual(mainCurve, midPoint, distanceLine, out toPoint, out turnPoint, out joinPoint, out sqPoint1, out sqPoint2, doglegDistance, DistAsPercent, squareDualLines, tolerenceForDelete); //Create the new base line (possibly hooked) polyline = Globals.CreatePolylineFromPointsNewTurn(joinPoint, turnPoint, toPoint, ref matchLineFLayer, ref lineFeature, SearchOnLayer, angle,editor.Map.SpatialReference); //If requested, store pipe id in the point StorePipeInfoPointFeature(lineFeature, pointFeature, fromToPairs, store); StorePipeInfoPointFeature(lineFeature, pointFeature2, fromToPairs, store); if (polyline.Length != 0.0) { if (startAtMain) polyline.ReverseOrientation(); if (targetLineEditTemplate != null) { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } pLineFeat.Store(); // Globals.SetFlowDirection(pLineFeat, targetLineFLayer, ((IMxDocument)app.Document).FocusMap); if (pointAlongLayers != null) { foreach (pointAlongSettings pPointAlongLayer in pointAlongLayers) { if (pPointAlongLayer.PolygonIntersectLayer != null) Globals.AddPointAlongLineWithIntersect(ref app, ref editor, polyline as ICurve, pPointAlongLayer.PointAlongLayer, pPointAlongLayer.PointAlongDistance, pPointAlongLayer.DistanceIsPercent, pPointAlongLayer.PointAlongEditTemplate, pPointAlongLayer.PolygonIntersectLayer, pPointAlongLayer.PolygonIntersectSide); else Globals.AddPointAlongLine(ref app, ref editor, polyline as ICurve, pPointAlongLayer.PointAlongLayer, pPointAlongLayer.PointAlongDistance, pPointAlongLayer.DistanceIsPercent, pPointAlongLayer.PointAlongEditTemplate); } } if (squareDualLines) { //Create Arm 1 polyline = Globals.CreatePolylineFromPoints(point, sqPoint1, joinPoint); if (startAtMain) polyline.ReverseOrientation(); if (targetLineEditTemplate != null) { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } // Globals.SetFlowDirection(pLineFeat, targetLineFLayer,((IMxDocument)app.Document).FocusMap); //Create Arm 2 polyline = Globals.CreatePolylineFromPoints(point2, sqPoint2, joinPoint); if (startAtMain) polyline.ReverseOrientation(); pLineFeat.Store(); if (targetLineEditTemplate != null) { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } // Globals.SetFlowDirection(pLineFeat, targetLineFLayer,((IMxDocument)app.Document).FocusMap); pLineFeat.Store(); return true; } else { //Create Arm 1 polyline = Globals.CreatePolylineFromPoints(point, joinPoint); if (startAtMain) polyline.ReverseOrientation(); if (targetLineEditTemplate != null) { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } // Globals.SetFlowDirection(pLineFeat, targetLineFLayer,((IMxDocument)app.Document).FocusMap); //Create Arm 2 polyline = Globals.CreatePolylineFromPoints(point2, joinPoint); if (startAtMain) polyline.ReverseOrientation(); pLineFeat.Store(); if (targetLineEditTemplate != null) { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } //idx = 0; // Globals.SetFlowDirection(pLineFeat, targetLineFLayer,((IMxDocument)app.Document).FocusMap); pLineFeat.Store(); return true; } } else { //Create branch 1 polyline = Globals.CreatePolylineFromPoints(point, joinPoint); if (polyline.Length != 0.0) { if (startAtMain) polyline.ReverseOrientation(); if (targetLineEditTemplate != null) { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } // Globals.SetFlowDirection(pLineFeat, targetLineFLayer,((IMxDocument)app.Document).FocusMap); pLineFeat.Store(); if (pointAlongLayers != null) { foreach (pointAlongSettings pPointAlongLayer in pointAlongLayers) { Globals.AddPointAlongLine(ref app, ref editor, polyline as ICurve, pPointAlongLayer.PointAlongLayer, pPointAlongLayer.PointAlongDistance, pPointAlongLayer.DistanceIsPercent, pPointAlongLayer.PointAlongEditTemplate); // idx++; } } //Create branch 2 polyline = Globals.CreatePolylineFromPoints(point2, joinPoint); if (startAtMain) polyline.ReverseOrientation(); if (targetLineEditTemplate != null) { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineEditTemplate, editor, app, false, false, true); } else { pLineFeat = Globals.CreateFeature(polyline as IGeometry, targetLineFLayer, editor, app, false, false, true); } // Globals.SetFlowDirection(pLineFeat, targetLineFLayer,((IMxDocument)app.Document).FocusMap); pLineFeat.Store(); if (pointAlongLayers != null) { foreach (pointAlongSettings pPointAlongLayer in pointAlongLayers) { Globals.AddPointAlongLine(ref app, ref editor, polyline as ICurve, pPointAlongLayer.PointAlongLayer, pPointAlongLayer.PointAlongDistance, pPointAlongLayer.DistanceIsPercent, pPointAlongLayer.PointAlongEditTemplate); // idx++; } } return true; } else { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_6")); return false; } } } else { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_7")); return false; } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + A4LGSharedFunctions.Localizer.GetString("ConstructionToolsLbl_4") + "\n" + ex.Message, ex.Source); return false; } finally { point = null; point2 = null; turnPoint = null; toPoint = null; joinPoint = null; sqPoint1 = null; sqPoint2 = null; midPoint = null; lineFeature = null; polyline = null; pLineFeat = null; mainCurve = null; } }
void Events5_OnCurrentTemplateChanged(IEditTemplate editTemplate) { try { _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Edit template changed."); if (editTemplate == null || editTemplate.Layer == null) { return; } if (editTemplate.Layer as IFeatureLayer == null) { return; } IFeatureLayer fLayer = editTemplate.Layer as IFeatureLayer; IFeatureClass fc; if ((fc = fLayer.FeatureClass) != null) { ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)fc; string tableName = GdbUtils.ParseTableName(dataset); // ------------------------------------------------- // Checks for different feature types of interest. // Show the appropriate dialogs for any that need it // ------------------------------------------------- // ----------------------------- // Fiber // ----------------------------- if (0 == string.Compare(ConfigUtil.FiberCableFtClassName, tableName, true)) { // Is the current template chosen properly configured with default values... // Needs number of buffer tubes and no of strands of fiber if (editTemplate.get_DefaultValue(ConfigUtil.NumberOfBuffersFieldName) == null || editTemplate.get_DefaultValue(ConfigUtil.NumberOfFibersFieldName) == null) { IEditor3 editor = ArcMap.Editor as IEditor3; editor.CurrentTemplate = null; MessageBox.Show("Template item has not been configured with # Buffer Tubes or # Strands per Tube. \n\nRight click this item and change these values in the properties.\n\nCreate new template items in the 'Organize Templates' window at the top of this area."); } else { int buffers = (int)editTemplate.get_DefaultValue(ConfigUtil.NumberOfBuffersFieldName); int fibers = (int)editTemplate.get_DefaultValue(ConfigUtil.NumberOfFibersFieldName); FiberCableConfiguration cf = new FiberCableConfiguration( buffers, fibers, "", ""); _fiberCableHelper.FiberCableConfig = cf; } // Enable the configuration helper //_fiberCableHelper.onStartEditing(); } else { //_fiberCableHelper.onStopEditing(); } // ----------------------------- // Fiber Devices // ----------------------------- if (ConfigUtil.IsDeviceClassName(tableName)) { // Is the current template chosen properly configured with default values... // Needs number of buffer tubes and no of strands of fiber if (editTemplate.get_DefaultValue(ConfigUtil.InputPortsFieldName) == null || editTemplate.get_DefaultValue(ConfigUtil.OutputPortsFieldName) == null) { IEditor3 editor = ArcMap.Editor as IEditor3; editor.CurrentTemplate = null; MessageBox.Show("Template item has not been configured with # Input Ports or # Output Ports. \n\nRight click this item and change these values in the properties.\n\nCreate new template items in the 'Organize Templates' window at the top of this area."); } else { int inputPorts = (int)editTemplate.get_DefaultValue(ConfigUtil.InputPortsFieldName); int outputPorts = (int)editTemplate.get_DefaultValue(ConfigUtil.OutputPortsFieldName); _fiberDeviceHelper.InputPorts = inputPorts; _fiberDeviceHelper.OutputPorts = outputPorts; } //_fiberDeviceHelper.onStartEditing(); } else { //_fiberDeviceHelper.onStopEditing(); } } } catch (Exception ex) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Error changing edit template.", ex.ToString()); } }
private void LoadListView() { IEditTemplateManager editTemplateMgr = null; //IFeatureLayer2 fl2 = null; ListViewGroup lvg = null; try { if (_featLayer == null) { return; } listView1.SmallImageList = new ImageList(); //fl2 = featLayer as IFeatureLayer2; //get templates for the layer editTemplateMgr = Globals.GetEditTemplateManager(_featLayer); if (editTemplateMgr == null) { return; } //create listviewgroup for the layer lvg = new ListViewGroup(_featLayer.Name); //loop through each template for the layer and assign to listviewgroup for (int i = 0; i < editTemplateMgr.Count; i++) { IEditTemplate editTemplate = editTemplateMgr.get_EditTemplate(i); //Create listviewitem for the template and populate ListViewItem lvi = new ListViewItem(lvg); lvi.Text = editTemplate.Name; lvi.Tag = editTemplate; //if (_currentTemplate == null) // _currentTemplate = editTemplate; //get the templates symbol as a bitmap Bitmap bitmap = Globals.BitmapFromTemplate(editTemplate, this.listView1); //add template bitmap to the listview's image list int index = listView1.SmallImageList.Images.Add(bitmap, Color.Transparent); lvi.ImageIndex = index; listView1.Items.Add(lvi); } listView1.Groups.Add(lvg); //sort listviewgroup by layer name ListViewGroup[] groupsArray = new ListViewGroup[listView1.Groups.Count]; listView1.Groups.CopyTo(groupsArray, 0); System.Array.Sort(groupsArray, new ListViewGroupSorter(SortOrder.Ascending)); listView1.Groups.Clear(); listView1.Groups.AddRange(groupsArray); } catch { } finally { } }
void Events5_OnTemplateModified(IEditTemplate editTemplate) { IEditor3 editor = ArcMap.Editor as IEditor3; editor.CurrentTemplate = editTemplate; }
public RankTemplate(double rank, IEditTemplate template) { _rank = rank; _template = template; }
public static void UpdateMapUnitPolysFeatureTemplates(IWorkspace theWorkspace) { // Get the MapUnitPolys Layer from the ToC IFeatureLayer theLayer = commonFunctions.FindFeatureLayer(theWorkspace, "MapUnitPolys"); // If the layer was not found, don't try and update the templates! if (theLayer == null) { return; } // Get a reference to the template editor, remove current templates IEditor3 templateEditor = (IEditor3)ArcMap.Editor; templateEditor.RemoveAllTemplatesInLayer((ILayer)theLayer); // Get the DMU entries var sortedDmu = GetDmuSortedByHierarchy(theWorkspace); // Loop through the DMU, add templates to an array IArray templateArray = new ArrayClass(); foreach (KeyValuePair <string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> anEntry in sortedDmu) { // Get this DMU entry DescriptionOfMapUnitsAccess.DescriptionOfMapUnit dmuEntry = anEntry.Value; // Build the template if this is not a heading if (dmuEntry.ParagraphStyle.Contains("Heading") == true) { continue; } IEditTemplateFactory templateFactory = new EditTemplateFactoryClass(); IEditTemplate newTemplate = templateFactory.Create(dmuEntry.MapUnit + " - " + dmuEntry.Name, (ILayer)theLayer); // Set the Template's default values newTemplate.SetDefaultValue("MapUnit", dmuEntry.MapUnit, false); newTemplate.SetDefaultValue("Label", dmuEntry.Label, false); newTemplate.SetDefaultValue("IdentityConfidence", "certain", false); // Set defaults for landslide types switch (anEntry.Value.Name) { case "Rock Fall": newTemplate.SetDefaultValue("MoveType", "Fall", false); newTemplate.SetDefaultValue("MoveClass", "Rock Fall", false); newTemplate.SetDefaultValue("MoveCode", "RF", false); break; case "Earth Fall": newTemplate.SetDefaultValue("MoveType", "Fall", false); newTemplate.SetDefaultValue("MoveClass", "Earth Fall", false); newTemplate.SetDefaultValue("MoveCode", "EF", false); break; case "Debris Fall": newTemplate.SetDefaultValue("MoveType", "Fall", false); newTemplate.SetDefaultValue("MoveClass", "Debris Fall", false); newTemplate.SetDefaultValue("MoveCode", "DF", false); break; case "Rock Flow": newTemplate.SetDefaultValue("MoveType", "Flow", false); newTemplate.SetDefaultValue("MoveClass", "Rock Flow", false); newTemplate.SetDefaultValue("MoveCode", "RFL", false); break; case "Earth Flow": newTemplate.SetDefaultValue("MoveType", "Flow", false); newTemplate.SetDefaultValue("MoveClass", "Earth Flow", false); newTemplate.SetDefaultValue("MoveCode", "EFL", false); break; case "Debris Flow": newTemplate.SetDefaultValue("MoveType", "Flow", false); newTemplate.SetDefaultValue("MoveClass", "Debris Flow", false); newTemplate.SetDefaultValue("MoveCode", "DFL", false); break; case "Rock Topple": newTemplate.SetDefaultValue("MoveType", "Topple", false); newTemplate.SetDefaultValue("MoveClass", "Rock Topple", false); newTemplate.SetDefaultValue("MoveCode", "RT", false); break; case "Debris Topple": newTemplate.SetDefaultValue("MoveType", "Topple", false); newTemplate.SetDefaultValue("MoveClass", "Debris Topple", false); newTemplate.SetDefaultValue("MoveCode", "ET", false); break; case "Earth Topple": newTemplate.SetDefaultValue("MoveType", "Topple", false); newTemplate.SetDefaultValue("MoveClass", "Earth Topple", false); newTemplate.SetDefaultValue("MoveCode", "ET", false); break; case "Rock Slide-rotational": newTemplate.SetDefaultValue("MoveType", "Slide-rotational", false); newTemplate.SetDefaultValue("MoveClass", "Rock Slide-rotational", false); newTemplate.SetDefaultValue("MoveCode", "RS-R", false); break; case "Debris Slide-rotational": newTemplate.SetDefaultValue("MoveType", "Slide-rotational", false); newTemplate.SetDefaultValue("MoveClass", "Debris Slide-rotational", false); newTemplate.SetDefaultValue("MoveCode", "DS-R", false); break; case "Earth Slide-rotational": newTemplate.SetDefaultValue("MoveType", "Slide-rotational", false); newTemplate.SetDefaultValue("MoveClass", "Earth Slide-rotational", false); newTemplate.SetDefaultValue("MoveCode", "ES-R", false); break; case "Rock Slide-translational": newTemplate.SetDefaultValue("MoveType", "Slide-translational", false); newTemplate.SetDefaultValue("MoveClass", "Rock Slide-translational", false); newTemplate.SetDefaultValue("MoveCode", "RS-T", false); break; case "Debris Slide-translational": newTemplate.SetDefaultValue("MoveType", "Slide-translational", false); newTemplate.SetDefaultValue("MoveClass", "Debris Slide-translational", false); newTemplate.SetDefaultValue("MoveCode", "DS-T", false); break; case "Earth Slide-translational": newTemplate.SetDefaultValue("MoveType", "Slide-translational", false); newTemplate.SetDefaultValue("MoveClass", "Earth Slide-translational", false); newTemplate.SetDefaultValue("MoveCode", "ES-T", false); break; case "Complex": newTemplate.SetDefaultValue("MoveType", "Complex", false); newTemplate.SetDefaultValue("MoveClass", "Complex, see notes", false); newTemplate.SetDefaultValue("MoveCode", "Complex", false); break; case "Earth Slide-general": newTemplate.SetDefaultValue("MoveType", "Slide-general", false); newTemplate.SetDefaultValue("MoveClass", "Earth Slide-general", false); newTemplate.SetDefaultValue("MoveCode", "ES-G", false); break; } // Add the template to the array templateArray.Add(newTemplate); } // Add one "UNLABELED" template IEditTemplateFactory unlabeledTemplateFactory = new EditTemplateFactoryClass(); IEditTemplate unlabeledTemplate = unlabeledTemplateFactory.Create("UNLABELED", (ILayer)theLayer); unlabeledTemplate.SetDefaultValue("MapUnit", "UNLABELED", false); unlabeledTemplate.SetDefaultValue("Label", "UNLABELED", false); templateArray.Add(unlabeledTemplate); // Add the templates to the editor templateEditor.AddTemplates(templateArray); // Update the doc? ArcMap.Document.UpdateContents(); }
private void btnOK_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) _currentTemplate = listView1.SelectedItems[0].Tag as IEditTemplate; }
void Events5_OnCurrentTemplateChanged(IEditTemplate editTemplate) { try { _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Edit template changed."); if (editTemplate == null || editTemplate.Layer == null) return; if (editTemplate.Layer as IFeatureLayer == null) return; IFeatureLayer fLayer = editTemplate.Layer as IFeatureLayer; IFeatureClass fc; if ((fc = fLayer.FeatureClass) != null) { ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)fc; string tableName = GdbUtils.ParseTableName(dataset); // ------------------------------------------------- // Checks for different feature types of interest. // Show the appropriate dialogs for any that need it // ------------------------------------------------- // ----------------------------- // Fiber // ----------------------------- if (0 == string.Compare(ConfigUtil.FiberCableFtClassName, tableName, true)) { // Is the current template chosen properly configured with default values... // Needs number of buffer tubes and no of strands of fiber if (editTemplate.get_DefaultValue(ConfigUtil.NumberOfBuffersFieldName) == null || editTemplate.get_DefaultValue(ConfigUtil.NumberOfFibersFieldName) == null) { IEditor3 editor = ArcMap.Editor as IEditor3; editor.CurrentTemplate = null; MessageBox.Show("Template item has not been configured with # Buffer Tubes or # Strands per Tube. \n\nRight click this item and change these values in the properties.\n\nCreate new template items in the 'Organize Templates' window at the top of this area."); } else { int buffers = (int)editTemplate.get_DefaultValue(ConfigUtil.NumberOfBuffersFieldName); int fibers = (int)editTemplate.get_DefaultValue(ConfigUtil.NumberOfFibersFieldName); FiberCableConfiguration cf = new FiberCableConfiguration( buffers, fibers, "", ""); _fiberCableHelper.FiberCableConfig = cf; } // Enable the configuration helper //_fiberCableHelper.onStartEditing(); } else { //_fiberCableHelper.onStopEditing(); } // ----------------------------- // Fiber Devices // ----------------------------- if (ConfigUtil.IsDeviceClassName(tableName)) { // Is the current template chosen properly configured with default values... // Needs number of buffer tubes and no of strands of fiber if (editTemplate.get_DefaultValue(ConfigUtil.InputPortsFieldName) == null || editTemplate.get_DefaultValue(ConfigUtil.OutputPortsFieldName) == null) { IEditor3 editor = ArcMap.Editor as IEditor3; editor.CurrentTemplate = null; MessageBox.Show("Template item has not been configured with # Input Ports or # Output Ports. \n\nRight click this item and change these values in the properties.\n\nCreate new template items in the 'Organize Templates' window at the top of this area."); } else { int inputPorts = (int)editTemplate.get_DefaultValue(ConfigUtil.InputPortsFieldName); int outputPorts = (int)editTemplate.get_DefaultValue(ConfigUtil.OutputPortsFieldName); _fiberDeviceHelper.InputPorts = inputPorts; _fiberDeviceHelper.OutputPorts = outputPorts; } //_fiberDeviceHelper.onStartEditing(); } else { //_fiberDeviceHelper.onStopEditing(); } } } catch(Exception ex) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Error changing edit template.", ex.ToString()); } }
protected override void OnMouseUp(MouseEventArgs arg) { // Did they click the left mouse button? if (arg.Button == System.Windows.Forms.MouseButtons.Left) { // Get some application environment variables set IMxApplication mxApp = (IMxApplication)ArcMap.Application; // Get the clicked location in map units IPoint clickedPoint = mxApp.Display.DisplayTransformation.ToMapPoint(arg.Location.X, arg.Location.Y); // If this is the first click on the map... switch (numberOfClicks) { case 0: // This is the first click, giving the location of the measurement. measurementLocationX = clickedPoint.X; measurementLocationY = clickedPoint.Y; // Increment the click counter numberOfClicks = 1; // Change the cursor System.Windows.Forms.Cursor firstCursor = new System.Windows.Forms.Cursor(GetType(), "Cursors.firstPointCursor.cur"); Cursor = firstCursor; break; case 1: // This is the second click, giving the first end of the strike line, according to right-hand rule. firstEndX = clickedPoint.X; firstEndY = clickedPoint.Y; // Increment the click counter numberOfClicks = 2; // Change the cursor System.Windows.Forms.Cursor secondCursor = new System.Windows.Forms.Cursor(GetType(), "Cursors.SecondPointCursor.cur"); Cursor = secondCursor; break; case 2: // This is the third click, giving the second end of the strike line, according to right-hand rule. secondEndX = clickedPoint.X; secondEndY = clickedPoint.Y; // Increment the click counter numberOfClicks = 3; // Change the cursor //base.m_cursor = Properties.Resources.GetDipCursor; // Calculate the Strike from the two collected points int theStrike = GetStrike(firstEndX, firstEndY, secondEndX, secondEndY); // Get the dip input int theDip; string inputValue = ""; getDipValue: if (genericForms.InputBox("Digitize Structure Points", "Please enter the dip value", ref inputValue) == DialogResult.OK) { // Make sure they entered a valid dip value int dipValue; bool result = int.TryParse(inputValue, out dipValue); if (result == true) { // inputValue is an integer if (dipValue >= -90) { if (dipValue <= 90) { // inputValue is in the appropriate range theDip = int.Parse(inputValue); } else { goto getDipValue; } } else { goto getDipValue; } } else { goto getDipValue; } } else { // In this case, the action was canceled during the dip input. Reset the counter, cursor, and exit the routine. numberOfClicks = 0; //base.m_cursor = Properties.Resources.firstPointCursor; return; } // Now we need to create the feature. First we'll find the current FeatureTemplate IEditor3 templateEditor = (IEditor3)ArcMap.Editor; IEditTemplate theCurrentTemplate = templateEditor.CurrentTemplate; // If they didn't select a template, they'll need to if (theCurrentTemplate == null) { MessageBox.Show("Please select a feature template for the type of measurement that you're digitizing", "NCGMP Tools"); numberOfClicks = 0; System.Windows.Forms.Cursor locCursor = new System.Windows.Forms.Cursor(GetType(), "Cursors.StationLocCursor.cur"); Cursor = locCursor; return; } // Make sure that the template puts features into the OrientationPoints FeatureClass IFeatureClass templateFC = ((IFeatureLayer)theCurrentTemplate.Layer).FeatureClass; if (templateFC.Equals(commonFunctions.OpenFeatureClass(ArcMap.Editor.EditWorkspace, "OrientationPoints"))) { try { // Create a dummy feature and read in values from the feature template IFeature tempFeature = templateFC.CreateFeature(); theCurrentTemplate.SetDefaultValues(tempFeature); // Grab values from the dummy feature - the code is actually cleaner than grabbing the values from the FeatureTemplate string StationID = ""; string Type = tempFeature.get_Value(templateFC.FindField("Type")).ToString(); string IDConf = tempFeature.get_Value(templateFC.FindField("IdentityConfidence")).ToString(); string Label = tempFeature.get_Value(templateFC.FindField("Label")).ToString(); string Notes = tempFeature.get_Value(templateFC.FindField("Notes")).ToString(); int Plot; bool result = int.TryParse(tempFeature.get_Value(templateFC.FindField("PlotAtScale")).ToString(), out Plot); double OrientConf; result = double.TryParse(tempFeature.get_Value(templateFC.FindField("OrientationConfidenceDegrees")).ToString(), out OrientConf); int RuleID; result = int.TryParse(tempFeature.get_Value(templateFC.FindField("RuleID")).ToString(), out RuleID); string DataSourceID = commonFunctions.GetCurrentDataSourceID(); int SymbolRot = 360 - theStrike; IPoint Shape = new PointClass(); Shape.X = measurementLocationX; Shape.Y = measurementLocationY; // Remove the temporary Feature tempFeature.Delete(); // Create the new feature OrientationPointsAccess OdpAccess = new OrientationPointsAccess(ArcMap.Editor.EditWorkspace); OdpAccess.NewOrientationPoint(StationID, Type, IDConf, Label, Plot, (double)theStrike, (double)theDip, OrientConf, Notes, DataSourceID, SymbolRot, RuleID, Shape); OdpAccess.SaveOrientationPoints(); // Refresh the Active View ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, theCurrentTemplate.Layer, null); } catch { MessageBox.Show("Create feature didn't work.", "NCGMP Tools"); numberOfClicks = 0; System.Windows.Forms.Cursor locCursor = new System.Windows.Forms.Cursor(GetType(), "Cursors.StationLocCursor.cur"); Cursor = locCursor; return; } } else { // User needs to select a relevant feature template MessageBox.Show("Please select a valid feature template to digitize structural measurements.", "NCGMP Tools"); } // Finished successfully, reset the counter and cursor numberOfClicks = 0; System.Windows.Forms.Cursor theLocCursor = new System.Windows.Forms.Cursor(GetType(), "Cursors.StationLocCursor.cur"); Cursor = theLocCursor; break; default: // Don't do anything here, preventing any more input before the dip is entered and the counter resets break; } } }