public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { downPoint = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); if (m_pNewLineFeedback == null) { ISimpleLineSymbol pSLnSym; m_pNewLineFeedback = new NewLineFeedbackClass(); pSLnSym = (ISimpleLineSymbol)m_pNewLineFeedback.Symbol; Color color = ColorTranslator.FromHtml(SystemInfo.Instance.LineColor); IColor pColor = new RgbColorClass(); pColor.RGB = color.B * 65536 + color.G * 256 + color.R; pSLnSym.Color = pColor; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; m_pNewLineFeedback.Display = this.m_pMapControl.ActiveView.ScreenDisplay; m_pNewLineFeedback.Start(downPoint); } else { m_pNewLineFeedback.AddPoint(downPoint); } m_pRecordPointArray.Add(downPoint); base.OnMouseDown(button, shift, x, y, mapX, mapY); }
public override void OnMouseMove(int button, int shift, int x, int y, double mapX, double mapY) { // TODO: 添加 DrawRectSide2P.OnMouseMove 实现 base.OnMouseMove(button, shift, x, y, mapX, mapY); m_pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); m_pAnchorPoint = m_pPoint; //+++++++++++++开始捕捉+++++++++++++++++++++ //CommonFunction.Snap(m_MapControl,m_App.CurrentConfig.cfgSnapEnvironmentSet,(IGeometry)m_pLastPoint,m_pAnchorPoint); if (m_bInUse == true) { if (m_mouseDownCount == 1) //计数器=1时 { m_pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); m_pAnchorPoint = m_pPoint; m_pFeedback.MoveTo(m_pAnchorPoint); } else if (m_mouseDownCount == 2) { m_pLineFeed.Stop(); //if(m_bFixDirection && m_bInputWindowCancel == false) //固定m_pAnchorPoint使其在一个固定方向上 //{ // m_pPoint = Class.Common.GetTwoPoint_FormPointMousePointFixDirection(m_pLastPoint,m_pPoint,m_dblFixDirection); // m_pAnchorPoint = m_pPoint; //} if (!m_bFixSideLength) //获取矩形一边长 { m_dblSideLength = Class.Common.GetRectangleOfSide_Length((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1), m_pAnchorPoint); } //else if (m_bInputWindowCancel == false)//按S键,用户输入边长,修正m_dblSideLength值 //{ // bool bRight;//判断鼠标是否位于P1到P2方向的右边 // bRight = CommonFunction.GetRectP0_Right((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1),m_pAnchorPoint); // if (bRight) m_dblSideLength = - m_dblSideLength;//对输入值反号 //} //获取矩形另两点坐标 m_pSavePointArray.RemoveAll(); m_pSavePointArray = Class.Common.GetPointRectangle2((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1), m_dblSideLength); Class.Common.DisplaypSegmentColToScreen(m_MapControl, ref m_pUndoArray); //绘制矩形 m_pLineFeed.Start((IPoint)m_pUndoArray.get_Element(1)); m_pLineFeed.AddPoint((IPoint)m_pSavePointArray.get_Element(0)); m_pLineFeed.AddPoint((IPoint)m_pSavePointArray.get_Element(1)); m_pLineFeed.AddPoint((IPoint)m_pUndoArray.get_Element(0)); m_pSavePointArray.Add((IPoint)m_pUndoArray.get_Element(0)); m_pSavePointArray.Add((IPoint)m_pUndoArray.get_Element(1)); m_pSavePointArray.Add((IPoint)m_pSavePointArray.get_Element(0)); }//m_mouseDownCount == 2 } }
private void CalculateCornerMouseDown(IPoint pPoint) { IGeometry pGeom = null; if (!m_bInUse) //如果命令没有使用 { m_pPoint1 = pPoint; m_pLastPoint = pPoint; m_pRecordPointArray.Add(m_pPoint1); m_bInUse = true; m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint1); } else //如果命令正在使用 { m_pPoint2 = pPoint; m_pRecordPointArray.Add(pPoint); m_bInUse = true; m_pLineFeed.AddPoint(pPoint); CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint2); if (m_pRecordPointArray.Count > 2) { IPolyline pPolyline; pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray); pGeom = (IGeometry)pPolyline; CommonFunction.AddElement(m_MapControl, pGeom); double dblZimuth = CommonFunction.GetAngleZuo_P123(m_pPoint1, (IPoint)m_pRecordPointArray.get_Element(1), m_pPoint2); dblZimuth = CommonFunction.RadToDeg(dblZimuth); System.Windows.Forms.DialogResult result; string strResult = "三点夹角:" + dblZimuth.ToString(".#####") + "(°′″)"; strResult = strResult + CRLF; strResult = strResult + "第一点坐标 X=" + m_pPoint1.X.ToString(".###") + "Y=" + m_pPoint1.Y.ToString(".###"); strResult = strResult + CRLF; strResult = strResult + "第二点坐标 X=" + ((IPoint)m_pRecordPointArray.get_Element(1)).X.ToString(".###") + "Y=" + ((IPoint)m_pRecordPointArray.get_Element(1)).Y.ToString(".###"); strResult = strResult + CRLF; strResult = strResult + "第三点坐标 X=" + m_pPoint2.X.ToString(".###") + "Y=" + m_pPoint2.Y.ToString(".###"); result = MessageBox.Show(strResult, "三点夹角计算", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { Reset(); //复位; } } } }
public void Add(T item) { if (Size() == array.Size() * capacity) { array.Add(new VectorArray <T>(capacity)); } array.Get(array.Size() - 1).Add(item); size++; }
private void CalculateZimuthMouseDown(IPoint pPoint) { IGeometry pGeom = null; if (!m_bInUse) //如果命令没有使用 { m_pPoint1 = pPoint; m_pLastPoint = pPoint; m_pRecordPointArray.Add(m_pPoint1); m_bInUse = true; m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, m_pPoint1); } else //如果命令正在使用 { m_pPoint2 = pPoint; m_pRecordPointArray.Add(m_pPoint2); CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, m_pPoint2); IPolyline pPolyline; pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray); pGeom = (IGeometry)pPolyline; CommonFunction.AddElement(m_pMapControl, pGeom); double dblZimuth = CommonFunction.GetAzimuth_P12(m_pPoint1.Y, m_pPoint1.X, m_pPoint2.Y, m_pPoint2.X); dblZimuth = CommonFunction.RadToDeg(dblZimuth); strResult1 = dblZimuth.ToString(".#####") + " (°) "; strResult2 = "X=" + m_pPoint1.X.ToString(".##") + "; " + "Y=" + m_pPoint1.Y.ToString(".##"); strResult3 = "X=" + m_pPoint2.X.ToString(".##") + "; " + "Y=" + m_pPoint2.Y.ToString(".##"); if (strResult1 != null && strResult2 != null && strResult3 != null) { FrmAzimuthAngle frmAzimuthAngle = FrmAzimuthAngle.Instance(); frmAzimuthAngle.ShowDialog(); } if (m_pRecordPointArray.Count != 0) { m_pRecordPointArray.RemoveAll(); } m_bInUse = false; } }
public static void addValues(IArray <string> array, int count, string addedElement = "") { for (int i = 0; i < count; i += 1) { if (addedElement == "") { array.Add(i.ToString()); } else { array.Add(addedElement); } } }
private void DrawLineMouseDown(IPoint pPoint) { if (!m_bInUse) //如果命令没有使用 { m_bInUse = true; m_pUndoArray.Add(pPoint); m_pLastPoint = pPoint; Class.Common.DrawPointSMSSquareSymbol(m_MapControl, pPoint); m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } if (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { //若当前图层是面层,则显示回馈开始点到鼠标点的线段 m_pLastFeedback = new NewLineFeedbackClass(); m_pLastLineFeed = (INewLineFeedback)m_pLastFeedback; m_pLastLineFeed.Start(pPoint); if (m_pLastFeedback != null) { m_pLastFeedback.Display = m_pActiveView.ScreenDisplay; } } } else //若果命令正使用中 { m_pLineFeed.Stop(); m_pLineFeed.Start(pPoint); IPoint tempPoint = new PointClass(); tempPoint.X = pPoint.X; tempPoint.Y = pPoint.Y; m_pUndoArray.Add(tempPoint); m_pLastPoint = m_pAnchorPoint; Class.Common.DisplaypSegmentColToScreen(m_MapControl, ref m_pUndoArray); //可以刷新屏幕了 } }
/// <summary> /// 将一个地图、图层组中的所有可显示图层加到一个IList中 /// </summary> /// <param name="obj"></param> /// <param name="list"></param> private void AddLayerVisibleToIArray(object obj, ref IArray list) { if (obj is IMap) { IMap pMap = obj as IMap; for (int i = 0; i < pMap.LayerCount; i++) { AddLayerVisibleToIArray(pMap.get_Layer(i), ref list); } } else if (obj is IGroupLayer) { if ((obj as IGroupLayer).Visible) { ICompositeLayer comLayer = obj as ICompositeLayer; for (int i = 0; i < comLayer.Count; i++) { AddLayerVisibleToIArray(comLayer.get_Layer(i), ref list); } } } else if (obj is IFeatureLayer) { if (list != null && (obj as ILayer).Visible) { list.Add(obj); } } }
private static bool FeatureLayerIdentify(IBasicMap ibasicMap_0, IFeatureLayer ifeatureLayer_0, IGeometry igeometry_0, IArray iarray_0) { bool flag; ISpatialFilter spatialFilterClass = new SpatialFilter() { Geometry = igeometry_0, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects }; try { IFeatureCursor featureCursor = ifeatureLayer_0.FeatureClass.Search(spatialFilterClass, false); for (IFeature i = featureCursor.NextFeature(); i != null; i = featureCursor.NextFeature()) { AEFeatureIdentifyObject aEFeatureIdentifyObject = new AEFeatureIdentifyObject() { BasicMap = ibasicMap_0, Feature = i }; iarray_0.Add(aEFeatureIdentifyObject); } ComReleaser.ReleaseCOMObject(featureCursor); flag = true; return(flag); } catch (Exception exception) { Logger.Current.Error("", exception, ""); } flag = false; return(flag); }
/* #region //由CAD二次曲线特征点数组生成二次B样条曲线点数组 Cad->Arcgis * // * * public static void BMLine2_CADpArray(IArray CADpArray, int Sum, ref IArray BmpArray) * { * //循环求曲线数组 * for (int i = 0; i < CADpArray.Count - 2; i++) * { * BMLine2_P123((IPoint)CADpArray.get_Element(i), (IPoint)CADpArray.get_Element(i+1), (IPoint)CADpArray.get_Element(i+2), Sum, ref BmpArray); * } * } #endregion * #region //由CAD三次曲线特征点数组生成三次B样条曲线点数组 Cad->Arcgis * // * public static void BMLine3_CADpArray(IArray CADpArray, int Sum, ref IArray BmpArray) * { * //循环求曲线数组 * for (int i = 0; i < CADpArray.Count - 3; i++) * { * BMLine3_P123((IPoint)CADpArray.get_Element(i), (IPoint)CADpArray.get_Element(i+1), (IPoint)CADpArray.get_Element(i+2),(IPoint)CADpArray.get_Element(i+3), Sum, ref BmpArray); * } * } #endregion */ #region //由p1,p2,p3生成p1到p3二次B样条曲线点数组 // public static void Cardinal_P123(IPoint pk_1, IPoint pk, IPoint pk1, int Sum, ref IArray pArray) { //pArray.RemoveAll(); double xk_1 = pk_1.X; double yk_1 = pk_1.Y; double zk_1 = pk_1.Z; double xk = pk.X; double yk = pk.Y; double zk = pk.Z; double xk1 = pk1.X; double yk1 = pk1.Y; double zk1 = pk1.Z; for (double u = 0; u <= 1; u = u + 1.0 / Sum) { double B0 = u * u - 2 * u + 1; double B1 = 2 * u * u - 2 * u - 1; double B2 = u * u; double x = xk_1 * B0 - xk * B1 + xk1 * B2; double y = yk_1 * B0 - yk * B1 + yk1 * B2; double z = zk_1 * B0 - zk * B1 + zk1 * B2; IPoint p = new PointClass(); p.X = x / 2; p.Y = y / 2; p.Z = z / 2; pArray.Add(p); } }
private void method_0(IArray iarray_0, IGeometry igeometry_0) { IRelationalOperator igeometry0 = igeometry_0 as IRelationalOperator; IList arrayLists = new ArrayList(); int i = 0; while (true) { if (i < iarray_0.Count) { IGeometry element = iarray_0.Element[i] as IGeometry; if (igeometry0.Within(element)) { break; } if (igeometry0.Contains(element)) { arrayLists.Add(i); } i++; } else { for (i = arrayLists.Count - 1; i >= 0; i--) { iarray_0.Remove(i); } iarray_0.Add(igeometry_0); break; } } }
static double addValueInEnd(IArray <string> array) { Stopwatch stopWatch = Stopwatch.StartNew(); array.Add("end"); stopWatch.Stop(); return(stopWatch.Elapsed.TotalMilliseconds); }
public void InitFabricState() { //get the fabric layers from the map IArray pFabricSubLayerArray; bool bHasFabricLayers = GetAllFabricSubLayers(out pFabricSubLayerArray); //bool bHasFabricLayers = GetFabricSubLayersByClass(esriCadastralFabricTable.esriCFTParcels, out pFabricSubLayerArray); //return the parcels fabric class as a feature class if (bHasFabricLayers) { _fabricLayers = pFabricSubLayerArray; for (int i = 0; i < pFabricSubLayerArray.Count; i++) { IFeatureLayer pFLyr = (IFeatureLayer)pFabricSubLayerArray.get_Element(i); IFeatureClass featureClass = (IFeatureClass)pFLyr.FeatureClass; int iObjClassID = featureClass.ObjectClassID; if (_fabricInMemTablesLookUp == null) { _fabricInMemTablesLookUp = new Dictionary <int, ITable>(); } if (_fabricObjectClasses == null) { _fabricObjectClasses = new ArrayClass(); } if (!_fabricInMemTablesLookUp.ContainsKey(iObjClassID)) { _fabricObjectClasses.Add(featureClass); IWorkspace pWS = CreateInMemoryWorkspace(); try { IFields NewFields = createFieldsFromSourceFields(featureClass.Fields); IDataset pDS = featureClass as IDataset; ITable InMemTable = createTableInMemory(pDS.Name, NewFields, pWS); if (InMemTable != null) { _fabricInMemTablesLookUp.Add(iObjClassID, InMemTable); } } catch (Exception ex) { MessageBox.Show("Error Creating In Memory Fabric Table" + Environment.NewLine + ex.Message); } } if (_fabricObjectClassIds == null) { _fabricObjectClassIds = new List <int>(); } if (!_fabricObjectClassIds.Contains(iObjClassID)) { _fabricObjectClassIds.Add(iObjClassID); } } WireFabricTableEditEvents(); } }
private void DrawRectSide2PMouseDown(IPoint pPoint) { IPoint tempPoint = new PointClass(); m_mouseDownCount = m_mouseDownCount + 1; if (m_mouseDownCount < 3) //点击鼠标次数小于3时 { //绘制线 if (m_bInUse == false) { m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); tempPoint.X = pPoint.X; tempPoint.Y = pPoint.Y; Class.Common.DrawPointSMSSquareSymbol(m_MapControl, pPoint); m_pUndoArray.Add(tempPoint);//将第一个点保存到变量 m_pLastPoint = pPoint; m_bInUse = true; } else { m_pLineFeed = (INewLineFeedback)m_pFeedback; tempPoint.X = m_pAnchorPoint.X; tempPoint.Y = m_pAnchorPoint.Y; m_pLineFeed.AddPoint(tempPoint); Class.Common.DrawPointSMSSquareSymbol(m_MapControl, tempPoint); m_pUndoArray.Add(tempPoint);; //将第二个点保存到变量 } if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } } else if (m_mouseDownCount == 3) //点击鼠标次数等于3后,停止绘制 { EndDrawRectSide2P(); } }
// public static void Cardinal_P1234(IPoint pk_1, IPoint pk, IPoint pk1, IPoint pk2, int Sum, ref IArray pArray) { //pArray.RemoveAll(); double xk_1 = pk_1.X; double yk_1 = pk_1.Y; double zk_1 = pk_1.Z; double xk = pk.X; double yk = pk.Y; double zk = pk.Z; double xk1 = pk1.X; double yk1 = pk1.Y; double zk1 = pk1.Z; double xk2 = pk2.X; double yk2 = pk2.Y; double zk2 = pk2.Z; // double u = 0; double t = 0; double CAR0 = 0; double CAR1 = 0; double CAR2 = 0; double CAR3 = 0; // double s = (1 - t)/2; for (t = 0; t <= 1; t = t + 1.0 / Sum) { // double CAR0 = 2*s * Math.Pow(u,2) - s * Math.Pow(u,3) - s*u; // double CAR1 = (2 - s) * Math.Pow(u,3) + (s - 3) * Math.Pow(u,2) + 1; // double CAR2 = (s - 2) * Math.Pow(u,3) + (3 - 2*s) * Math.Pow(u,2) + s*u; // double CAR3 = s * Math.Pow(u,3) - s * Math.Pow(u,2); CAR0 = (3 * Math.Pow(t, 2) - Math.Pow(t, 3) - 3 * t + 1) / 6; CAR1 = (3 * Math.Pow(t, 3) - 6 * Math.Pow(t, 2) + 4) / 6; CAR2 = (3 * Math.Pow(t, 2) - 3 * Math.Pow(t, 3) + 3 * t + 1) / 6; CAR0 = Math.Pow(t, 3) / 6; double x = xk_1 * CAR0 + xk * CAR1 + xk1 * CAR2 + xk2 * CAR3; double y = yk_1 * CAR0 + yk * CAR1 + yk1 * CAR2 + yk2 * CAR3; double z = zk_1 * CAR0 + zk * CAR1 + zk1 * CAR2 + zk2 * CAR3; IPoint p = new PointClass(); IZAware pZA = (IZAware)p; pZA.ZAware = true; p.X = x; p.Y = y; p.Z = z; pArray.Add(p); } }
public void Add(T item) { if (_size == _array.Size * _vector) { _array.Add(new T[_vector]); } _array.Get(_size / _vector)[_size % _vector] = item; _size++; }
private void CalculateAreaeMouseDown(IPoint pPoint) { if (!m_bInUse)//如果命令没有使用 { m_bInUse = true; m_pRecordPointArray.Add(pPoint); m_pLastPoint = pPoint; CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, pPoint); m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } m_pLastFeedback = new NewLineFeedbackClass(); m_pLastLineFeed = (INewLineFeedback)m_pLastFeedback; m_pLastLineFeed.Start(pPoint); if (m_pLastFeedback != null) { m_pLastFeedback.Display = m_pActiveView.ScreenDisplay; } } else//若果命令正使用中 { m_pLineFeed.Stop(); m_pLineFeed.Start(pPoint); IPoint tempPoint = new PointClass(); tempPoint.X = pPoint.X; tempPoint.Y = pPoint.Y; m_pRecordPointArray.Add(tempPoint); m_pLastPoint = tempPoint; CommonFunction.DisplaypSegmentColToScreen(m_MapControl, ref m_pRecordPointArray);//可以刷新屏幕了 } }
static double addValueInPositionRandom(IArray <string> array) { var rand = new Random(); int index = rand.Next(0, array.Size()); Stopwatch stopWatch = Stopwatch.StartNew(); array.Add("rand", index); stopWatch.Stop(); return(stopWatch.Elapsed.TotalMilliseconds); }
private static void AddLayer(ILayer mLayer, ref IArray mArray, string name, IGroupLayer mGroupLayer) { LayerAndGrouplayerName Layerinfo = new LayerAndGrouplayerName(); Layerinfo.grouplayer = mGroupLayer; Layerinfo.GrouplayerName = name; Layerinfo.layer = mLayer; Layerinfo.layername = mLayer.Name; mArray.Add(Layerinfo); }
public static void AddToEndTest(IArray <string> array) { int length = 100; string addedElement = "1000"; addValues(array, length); array.Add(addedElement); Assert.AreEqual(addedElement, array.Get(array.Size() - 1), "Последний элемент не равен добавленному"); }
//将点添加到m_pUnDoArray数组 private void AddPointUndoArray(IPoint pPoint, double drawType, ref IArray pUndoArray) { PointStruct pointStruct = new PointStruct(); pointStruct.Point = pPoint; pointStruct.Type = (int)drawType; pUndoArray.Add(pointStruct); return; }
public void AddClass(IFeatureClass pClass) { for (int i = 0; i < m_array.Count; i++) { IFeatureClass pClass1 = m_array.Element[i] as IFeatureClass; if (pClass == pClass1) { return; } } m_array.Add(pClass); }
public clsMapExport(IWorkspace m_Workspace, IMap pMap, string mapScale) { gisReader = new GisReadFromWeb(); cadWriter = new CadWrite(true); pWorkspace = m_Workspace; ArrayList pFeaClassNameList = CommonFunction.GetFeactureClassName_From_AccessWorkSpace(pWorkspace, mapScale); for (int i = 0; i < pFeaClassNameList.Count; i++) { pLayerArr.Add(pFeaClassNameList[i]); } }
public static void RemoveFirstElement(IArray <string> array) { int length = 100; addValues(array, length, "element"); array.Add("RemovedElement", 0); string removeElement = array.Pop(); Assert.AreNotEqual(removeElement, array.Get(0), "Элемент совпадает с удаленным"); }
public static void RemoveLasteElement(IArray <string> array) { int length = 100; addValues(array, length, "element"); array.Add("RemovedElement"); string removeElement = array.Pop(); Assert.AreNotEqual(removeElement, array.Get(array.Size() - 1), "Последний элемент совпадает с удаленным"); }
public override void OnMouseUp(int button, int shift, int x, int y, double mapX, double mapY) { // TODO: 添加 DrawTraceLine.OnMouseUp 实现 base.OnMouseUp(button, shift, x, y, mapX, mapY); if (!m_bIsSelect) { return; } if (bBegineMove) { return; } IGeometry pEnv; if (m_pFeedbackEnve != null) { pEnv = m_pFeedbackEnve.Stop(); m_FocusMap.SelectByShape(pEnv, null, false); } else { IEnvelope pRect; double dblConst; dblConst = CommonFunction.ConvertPixelsToMapUnits(m_pActiveView, 8); //8个象素大小 pRect = CommonFunction.NewRect(m_pPoint, dblConst); m_FocusMap.SelectByShape(pRect, null, false); } IArray tempArray = CommonFunction.GetSelectFeatureSaveToArray(m_FocusMap); for (int i = 0; i < tempArray.Count; i++) { m_OriginFeatureArray.Add((IFeature)tempArray.get_Element(i)); } tempArray.RemoveAll(); if (m_OriginFeatureArray.Count == 0) { //选择复位 m_pFeedbackEnve = null; m_bIsSelect = false; return; } m_MapControl.ActiveView.FocusMap.ClearSelection(); //清空地图选择的要素 CommonFunction.ShowSelectionFeatureArray(m_MapControl, m_OriginFeatureArray); //高亮显示选择的要素 //选择复位 m_pFeedbackEnve = null; m_bIsSelect = false; }
public static IEvaluatedNetworkAttribute AddScaleSubsetAttribute(IDENetworkDataset deNet, INetworkAttribute2 baseNetAttribute) { if (baseNetAttribute == null) { return(null); } if (baseNetAttribute.UsageType != esriNetworkAttributeUsageType.esriNAUTCost) { return(null); } IArray netAttributes = deNet.Attributes; IEvaluatedNetworkAttribute netAttribute = new EvaluatedNetworkAttributeClass() as IEvaluatedNetworkAttribute; string netAttributeName = BaseParameterName; netAttributeName += "_"; netAttributeName += baseNetAttribute.Name; netAttribute.Name = netAttributeName; netAttribute.UsageType = baseNetAttribute.UsageType; netAttribute.DataType = baseNetAttribute.DataType; netAttribute.Units = baseNetAttribute.Units; List <INetworkSource> allNetSources = SubsetHelper.GetSourceList(deNet.Sources); List <INetworkSource> netSources = SubsetHelper.GetSourceList(allNetSources, esriNetworkElementType.esriNETEdge); List <string> netSourceNames = SubsetHelper.GetSourceNames(netSources); ResetScaleSubsetParameters((INetworkAttribute2)netAttribute, netSourceNames); bool supportTurns = deNet.SupportsTurns; //default evaluators SubsetHelper.SetDefaultEvaluator(netAttribute, 0, esriNetworkElementType.esriNETEdge); SubsetHelper.SetDefaultEvaluator(netAttribute, 0, esriNetworkElementType.esriNETJunction); if (supportTurns) { SubsetHelper.SetDefaultEvaluator(netAttribute, 0, esriNetworkElementType.esriNETTurn); } //sourced evaluators foreach (INetworkSource netSource in netSources) { SubsetHelper.SetEvaluators(netAttribute, netSource, typeof(ScaleSubsetEvaluator)); } netAttributes.Add(netAttribute); deNet.Attributes = netAttributes; return(netAttribute); }
public void Add(T item, int index) { if (size == array.Size() * vector) { array.Add(new T[vector]); } int slice = index / vector; int pos = index % vector; if (index < size) { int lastSlice = size / vector; int lastSize = size % vector; int currentSlice = lastSlice; T[] currentArray = array.Get(array.Size() - 1); if (currentSlice > slice) { if (lastSize > 0) { Utils.MoveForward <T>(currentArray, 0, lastSize); } T[] prevArray = array.Get(currentSlice - 1); currentArray[0] = prevArray[vector - 1]; currentArray = prevArray; --currentSlice; while (currentSlice > slice) { Utils.MoveForward <T>(currentArray, 0, vector - 1); prevArray = array.Get(currentSlice - 1); currentArray[0] = prevArray[vector - 1]; currentArray = prevArray; --currentSlice; } if (pos < vector) { Utils.MoveForward <T>(currentArray, pos, vector - pos - 1); } } else { if (pos < lastSize) { Utils.MoveForward <T>(currentArray, pos, lastSize - pos); } } } array.Get(slice)[pos] = item; ++size; }
private void CalculateDistanceMouseDown(IPoint pPoint) { if (!m_bInUse)//如果命令没有使用 { m_bInUse = true; m_pRecordPointArray.Add(pPoint); m_pLastPoint = pPoint; CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, pPoint); m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } } else//若果命令正使用中 { m_pLineFeed.Stop(); m_pLineFeed.Start(pPoint); IPoint tempPoint = new PointClass(); tempPoint.X = pPoint.X; tempPoint.Y = pPoint.Y; m_pRecordPointArray.Add(tempPoint); m_pLastPoint = tempPoint; m_dblDistance = CommonFunction.GetDistance_P12((IPoint)m_pRecordPointArray.get_Element(m_pRecordPointArray.Count - 2), m_pLastPoint); //最后一段的长度 m_dblTotalDistance = m_dblTotalDistance + m_dblDistance; //总长度 CommonFunction.DisplaypSegmentColToScreen(m_MapControl, ref m_pRecordPointArray); //可以刷新屏幕了 } }
public static void AddToRandomPositionTest(IArray <string> array) { int length = 100; string addedElement = "1000"; addValues(array, length); var rand = new Random(); int index = rand.Next(0, array.Size()); array.Add(addedElement, index); Assert.AreEqual(addedElement, array.Get(index), "Не совпадают"); }
//根据多段线和阀门数组创建高程剖面 public static void ProfileCreateGraph(MainFrm pMainFrm, IPolyline pPolyline, IArray pSewerElevArray) { AxMapControl axMap = pMainFrm.getMapControl(); IZ pPolylineZ = pPolyline as IZ; IRasterLayer pRasterLyr = FindRasterLayer("Elevation", pMainFrm); //获得表面进行插值 ISurface pSurface = GetSurface(pRasterLyr); //创建Polyline z-ware; IZAware pZAwareLineZ = pPolyline as IZAware; pZAwareLineZ.ZAware = true; //'* work around for InterpolateFromSurface sometimes flipping polyline IPoint pPtOrigFrom = pPolyline.FromPoint; IPoint pPtOrigTo = pPolyline.ToPoint; //添加Z值到多边形上 pPolylineZ.InterpolateFromSurface(pSurface); if (pPolyline.FromPoint.X != pPtOrigFrom.X || pPolyline.FromPoint.Y != pPtOrigFrom.Y) pPolyline.ReverseOrientation(); //添加M值到线上 IMSegmentation pMSegmentation = pPolyline as IMSegmentation; IMAware pMAware = pPolyline as IMAware; pMAware.MAware = true; pMSegmentation.SetMsAsDistance(false); //创建表格 ITable pTable = ProfileCreateTable(); int i=0; if (pTable != null) { //在图层列表控件中要确保该表格还不存在,如果存在则删除它 IStandaloneTableCollection pStandAloneTabColl = axMap.ActiveView.FocusMap as IStandaloneTableCollection; for ( i = 0; i<=pStandAloneTabColl.StandaloneTableCount - 1; i++) { if (pStandAloneTabColl.get_StandaloneTable(i).Name == "xxprofiletable") pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.get_StandaloneTable(i)); } //创建一个新的独立表,并把它添加到地图集合中 IStandaloneTable pStandAloneTab = new StandaloneTableClass(); pStandAloneTab.Table = pTable; pStandAloneTabColl = axMap.ActiveView.FocusMap as IStandaloneTableCollection; pStandAloneTabColl.AddStandaloneTable(pStandAloneTab); pTable = pStandAloneTab as ITable; //为两个字段设置别名 ITableFields pTableFields = pStandAloneTab as ITableFields; IFieldInfo pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("Z")); pFieldInfo.Alias = "Ground Elevation"; pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("SewerElev")); pFieldInfo.Alias = "Sewer Line Elevation"; //为表格获得一个插入光标 ICursor pCursor=pTable.Insert(true); IRowBuffer pRowBuff; // IPointCollection pPtCollection = pPolyline as IPointCollection; IEnumVertex pEnumVertex = pPtCollection.EnumVertices; pEnumVertex.Reset(); IPoint pPT; int iPartIndex; int iVertexIndex; i = 0; //添加节点XYZ到新表格中 pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex); while (pPT != null) { pRowBuff = pTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("X"),pPT.X); pRowBuff.set_Value(pRowBuff.Fields.FindField("Y"),pPT.Y); pRowBuff.set_Value(pRowBuff.Fields.FindField("Z"),pPT.Z); pRowBuff.set_Value( pRowBuff.Fields.FindField("M"),pPT.M); pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), Convert.ToDouble(pSewerElevArray.get_Element(i))); pCursor.InsertRow(pRowBuff); pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex); i = i + 1; } pCursor.Flush(); pCursor = null; pCursor = pTable.Search(null, false); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = "SewerElev <> -99"; ICursor pCursorSewerElev = pTable.Search(pQueryFilter, false); pCursor = null; pCursor = pTable.Update(null, false); pRowBuff = pCursor.NextRow(); double m = 0; double Mmin=0; double Mmax=0; double deltaM=0; double deltaSewerElev=0; double sewerelev=0; double newZ=0; int j = 0; double minSewerElev=0; double maxSewerElev=0; IRow pRowSewerElev; while (pRowBuff != null) { if (Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("SewerElev"))) == -99) { m = Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("M"))); newZ = (((m - Mmin) / deltaM) * deltaSewerElev) + sewerelev; pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), newZ); pCursor.UpdateRow(pRowBuff as IRow); } else { if (j == 0) { pRowSewerElev = pCursorSewerElev.NextRow(); minSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmin = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); pRowSewerElev = pCursorSewerElev.NextRow(); maxSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); } else { pRowSewerElev = pCursorSewerElev.NextRow(); if (pRowSewerElev != null) { minSewerElev = maxSewerElev; Mmin = Mmax; maxSewerElev =Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); } } deltaSewerElev = maxSewerElev - minSewerElev; deltaM = Mmax - Mmin; sewerelev = minSewerElev; j = j + 1; } pRowBuff = pCursor.NextRow() as IRowBuffer; } pCursor.Flush(); //从表格中创建图形 m_SewerElevStructArray = new ArrayClass(); pCursor = null; pCursor = pTable.Search(null, false); pRowSewerElev = null; pRowSewerElev = pCursor.NextRow(); while (pRowSewerElev != null) { clsProfileStruct pProfileDataStruct = new clsProfileStruct(); pProfileDataStruct.M = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); pProfileDataStruct.Z = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Z"))); pProfileDataStruct.dSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Sewerelev"))); m_SewerElevStructArray.Add(pProfileDataStruct); pRowSewerElev = pCursor.NextRow(); } frmDrawProfile frmDrawProfile1 = new frmDrawProfile(m_SewerElevStructArray); frmDrawProfile1.Show(); } }
public void addDataTypeName(ref IArray Names, string Name, string DisplayName, IGPDataTypeFactory Factory) { IGPName gpName = CreateDataTypeName(Name, DisplayName, Factory); Names.Add(gpName); }
private void btnAddAllValues_Click(object sender, EventArgs e) { //��ʼ���ͼ��ı����ֶε���Ϣ IFillSymbol pSymbol; IColor pColor; IColor pNextUniqueColor; IEnumColors pEnumRamp; IQueryFilter pQueryFilter; ICursor pCursor; IRow pNextRow; IRowBuffer pNextRowBuffer; object objTempValue=""; object objCodeValue; ITable pTable = pFeatLayer as ITable; IRandomColorRamp pColorRamp = new RandomColorRampClass(); m_colValues=new ArrayClass(); if (comboBoxUnique.Text != "") { int iFieldNo = pTable.FindField(comboBoxUnique.Text); if (iFieldNo != -1) { for (int i = 0; i <= 2; i++) { if (comboBoxEx1.SelectedIndex == i) { pColorRamp.StartHue = m_intColorRampArray[i, 0]; pColorRamp.EndHue = m_intColorRampArray[i, 1]; pColorRamp.MinValue = m_intColorRampArray[i, 2]; pColorRamp.MaxValue = m_intColorRampArray[i, 3]; pColorRamp.MinSaturation = m_intColorRampArray[i, 4]; pColorRamp.MaxSaturation = m_intColorRampArray[i, 5]; } } pColorRamp.Size = 100; bool ok=true; pColorRamp.CreateRamp(out ok); pEnumRamp = pColorRamp.Colors; pQueryFilter = new QueryFilterClass(); pQueryFilter.AddField(comboBoxUnique.Text); pCursor = pTable.Search(pQueryFilter, true); pNextRow = pCursor.NextRow(); m_intSymbolsNum = 0; //�����״ͼ�� if (m_strShapeType == "Fill Symbols") { IFillSymbol pFillSymbol = new SimpleFillSymbolClass(); m_pSymbolsArray = new ESRI.ArcGIS.esriSystem.ArrayClass(); while (pNextRow != null) { pNextRowBuffer = pNextRow as IRowBuffer; objCodeValue=pNextRowBuffer.get_Value(iFieldNo); if ((objTempValue != objCodeValue) || (m_intSymbolsNum == 0)) { pNextUniqueColor = pEnumRamp.Next(); if (pNextUniqueColor == null) { pEnumRamp.Reset(); pNextUniqueColor = pEnumRamp.Next(); } pFillSymbol.Color = pNextUniqueColor; m_pSymbolsArray.Add(pFillSymbol); m_colValues.Add(objCodeValue); m_intSymbolsNum += 1; objTempValue = objCodeValue; pFillSymbol = null; } pNextRow = pCursor.NextRow(); } } //��ͼ�� if (m_strShapeType == "Line Symbols") { ILineSymbol pLineSymbol = new SimpleLineSymbolClass(); m_pSymbolsArray.RemoveAll(); while (pNextRow != null) { pNextRowBuffer = pNextRow as IRowBuffer; objCodeValue = pNextRowBuffer.get_Value(iFieldNo); if ((objTempValue != objCodeValue) || (m_intSymbolsNum == 0)) { pNextUniqueColor = pEnumRamp.Next(); if (pNextUniqueColor == null) { pEnumRamp.Reset(); pNextUniqueColor = pEnumRamp.Next(); } pLineSymbol.Color = pNextUniqueColor; m_pSymbolsArray.Add(pLineSymbol); m_colValues.Add(objCodeValue); m_intSymbolsNum += 1; objTempValue = objCodeValue; pLineSymbol = null; } pNextRow = pCursor.NextRow(); } } //��ͼ�� if (m_strShapeType == "Marker Symbols") { IMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); m_pSymbolsArray.RemoveAll(); while (pNextRow != null) { pNextRowBuffer = pNextRow as IRowBuffer; objCodeValue = pNextRowBuffer.get_Value(iFieldNo); if ((objTempValue != objCodeValue) || (m_intSymbolsNum == 0)) { pNextUniqueColor = pEnumRamp.Next(); if (pNextUniqueColor == null) { pEnumRamp.Reset(); pNextUniqueColor = pEnumRamp.Next(); } pMarkerSymbol.Color = pNextUniqueColor; m_pSymbolsArray.Add(pMarkerSymbol); m_colValues.Add(objCodeValue); m_intSymbolsNum += 1; pMarkerSymbol = null; } pNextRow = pCursor.NextRow(); } } pColorRamp = null; pQueryFilter = null; pColorRamp = null; //��ʾ���� } } }
//////////////////////////////////�����������ǰ���ý����С�� public static void ProfileSetJunctionFlag(AxMapControl ppAxMapControl, ref IArray pNetFlagArray, IPoint pPoint, IGeometricNetwork pGeoNetwork) { try { //�����ͼ��ѡ�� ppAxMapControl.ActiveView.FocusMap.ClearSelection(); INetElements pNetElements = pGeoNetwork.Network as INetElements; IPointToEID pPtToEID = new PointToEIDClass(); int pJunctionID = 0; int iUserClassID; int iUserID; int iUserSubID; IPoint pLocation; pPtToEID.SourceMap = ppAxMapControl.ActiveView.FocusMap; pPtToEID.GeometricNetwork = pGeoNetwork; pPtToEID.SnapTolerance = ppAxMapControl.ActiveView.Extent.Envelope.Width / 100; pPtToEID.GetNearestJunction(pPoint, out pJunctionID, out pLocation); if (pJunctionID == 0) { MessageBox.Show("û�в������ٽ��ĵ�"); } else { pNetElements.QueryIDs(pJunctionID, esriElementType.esriETJunction, out iUserClassID, out iUserID, out iUserSubID); INetFlag ipNetFlag = new JunctionFlagClass(); ipNetFlag.UserClassID = iUserClassID; ipNetFlag.UserID = iUserID; ipNetFlag.UserSubID = iUserSubID; IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass(); IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Green = 0; pRGBColor.Blue = 0; pMarkerSym.Color = pRGBColor; pMarkerSym.Size = 20; //���Ƹõ� IScreenDisplay pScreenDisplay = ppAxMapControl.ActiveView.ScreenDisplay; pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0); pScreenDisplay.SetSymbol(pMarkerSym as ISymbol); pScreenDisplay.DrawPoint(pLocation); pScreenDisplay.FinishDrawing(); if (pLocation != null) { pNetFlagArray.Add(ipNetFlag); } if (pNetFlagArray.Count == 2) { //�����ٽ�� ProfileFindPath(ppAxMapControl, pNetFlagArray, pGeoNetwork); } } } catch (Exception eX) { MessageBox.Show(eX.Message); } }