public static IFeatureLayer SaveCpl(CPolyline Cpl, string strFileName, List <string> pstrFieldNameLt = null, List <esriFieldType> pesriFieldTypeLt = null, List <List <object> > pobjectValueLtLt = null, int intRed = _intColor, int intGreen = _intColor, int intBlue = _intColor, double dblWidth = 1, int intOutlineRed = _intColor, int intOutlineGreen = _intColor, int intOutlineBlue = _intColor, esriSimpleLineStyle pesriSimpleLineStyle = esriSimpleLineStyle.esriSLSSolid, string strSymbolLayerPath = null, bool blnVisible = true) { return(SaveCGeoEb(CHelpFunc.MakeLt(Cpl), esriGeometryType.esriGeometryPolyline, strFileName, pstrFieldNameLt, pesriFieldTypeLt, pobjectValueLtLt, intRed, intGreen, intBlue, dblWidth, intOutlineRed, intOutlineGreen, intOutlineBlue, pesriSimpleLineStyle, esriSimpleFillStyle.esriSFSSolid, strSymbolLayerPath, blnVisible)); }
/// <summary> /// this method works for all data types; low efficiency /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <param name="cmp"></param> /// <returns></returns> public static bool AreAnyDuplicates <T>(this IEnumerable <T> Tself, IComparer <T> cmp = null) { cmp = CHelpFunc.SetOrDefaultCmp(cmp); var TSS = new SortedSet <T>(cmp); foreach (var item in Tself) { if (TSS.Add(item) == false) { return(true); } } return(false); }
public static Paths DilateErodeOffsetCpgExterior_Paths(CPolygon Cpg, double dblGrow, double dblDilation, double dblErosion, string strBufferStyle, double dblMiterLimit) { double dblHoleIndicator = 1; if (Cpg.IsHole == true) { dblHoleIndicator = -1; } if (Cpg.ExteriorPath == null) { Cpg.SetExteriorPath(); } var overdilationPaths = Offset_Paths(CHelpFunc.MakeLt(Cpg.ExteriorPath), dblHoleIndicator * (dblGrow + dblDilation), strBufferStyle, dblMiterLimit); var erosionpaths = Offset_Paths(overdilationPaths, dblHoleIndicator * (-dblDilation - dblErosion), strBufferStyle, dblMiterLimit); //var ExteriorPath = GeneratePathByCpgExterior(Cpg); //var growndilationPaths = Offset_Paths(CHelpFunc.MakeLt(ExteriorPath), // dblHoleIndicator * (dblGrow ), strBufferStyle, dblMiterLimit); //var overdilationPaths = Offset_Paths(growndilationPaths, // dblHoleIndicator * (dblDilation), strBufferStyle, dblMiterLimit); //var backPaths = Offset_Paths(overdilationPaths, // dblHoleIndicator * (-dblDilation), strBufferStyle, dblMiterLimit); //var erosionpaths = Offset_Paths(backPaths, // dblHoleIndicator * (- dblErosion), strBufferStyle, dblMiterLimit); //CSaveFeature.SaveCpgEb(clipperMethods.ScaleCpgLt(CHelpFunc.MakeLt(Cpg), 1 / CConstants.dblFclipper), // "Cpg"); //// CSaveFeature.SaveCEdgeEb(clipperMethods.ScaleCEdgeEb(clipperMethods.ConvertPathsToCEdgeLt( ////growndilationPaths, true), 1 / CConstants.dblFclipper), "growndilationPaths", CConstants.ParameterInitialize); //CSaveFeature.SaveCEdgeEb(clipperMethods.ScaleCEdgeEb(clipperMethods.ConvertPathsToCEdgeLt(overdilationPaths, true), // 1 / CConstants.dblFclipper), "overdilationPaths"); //// CSaveFeature.SaveCEdgeEb(clipperMethods.ScaleCEdgeEb(clipperMethods.ConvertPathsToCEdgeLt( ////backPaths, true), 1 / CConstants.dblFclipper), "backPaths", CConstants.ParameterInitialize); //CSaveFeature.SaveCEdgeEb(clipperMethods.ScaleCEdgeEb(clipperMethods.ConvertPathsToCEdgeLt(erosionpaths, true), // 1 / CConstants.dblFclipper), "erosionpaths"); return(Offset_Paths(erosionpaths, dblHoleIndicator * dblErosion, strBufferStyle, dblMiterLimit)); }
public static void CompareAndOrder <T, TOrder>(T T1, T T2, Func <T, TOrder> orderFunc, out T minT, out T maxT, IComparer <TOrder> cmp = null) { cmp = CHelpFunc.SetOrDefaultCmp(cmp); if (cmp.Compare(orderFunc(T1), orderFunc(T2)) <= 0) { minT = T1; maxT = T2; } else { minT = T2; maxT = T1; } }
/// <summary> /// 显示并返回单个插值线段 /// </summary> /// <param name="pDataRecords">数据记录</param> /// <param name="dblProp">差值参数</param> /// <returns>插值线段</returns> public static List <CPolyline> GetAndSaveInterpolation(CDataRecords pDataRecords, double dblProp) { if (dblProp < 0 || dblProp > 1) { MessageBox.Show("the parameter t is not acceptable!"); return(null); } CMorphingBaseCpl pMorphingBaseCpl = pDataRecords.ParameterResult.pMorphingBaseCpl; List <CPolyline> pInterpolatedCPlLt = pMorphingBaseCpl.GenerateInterpolatedCplLt(dblProp); CParameterInitialize pParameterInitialize = pDataRecords.ParameterInitialize; CHelpFunc.SaveCPlLt(pInterpolatedCPlLt, pParameterInitialize.strSaveFolderName + "____" + dblProp.ToString(), pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl); return(pInterpolatedCPlLt); }
public static PolyTree DilateErodeOffsetCpgExterior_PolyTree(CPolygon Cpg, double dblGrow, double dblDilation, double dblErosion, string strBufferStyle, double dblMiterLimit) { //dblDilation = dblDilation / 2; //dblErosion = dblGrow; //dblGrow = 0; //dblErosion = dblDilation; double dblHoleIndicator = 1; if (Cpg.IsHole == true) { dblHoleIndicator = -1; } if (Cpg.ExteriorPath == null) { Cpg.SetExteriorPath(); } var overdilationPaths = Offset_Paths(CHelpFunc.MakeLt(Cpg.ExteriorPath), dblHoleIndicator * (dblGrow + dblDilation), strBufferStyle, dblMiterLimit); var erosionpaths = Offset_Paths(overdilationPaths, dblHoleIndicator * (-dblDilation - dblErosion), strBufferStyle, dblMiterLimit); var normalPolyTree = Offset_PolyTree(erosionpaths, dblHoleIndicator * dblErosion, strBufferStyle, dblMiterLimit); //CSaveFeature.SavePathEbAsCpgEb(CHelpFunc.MakeLt(Cpg.ExteriorPath), // "originalpaths" , // pesriSimpleFillStyle: esriSimpleFillStyle.esriSFSNull, blnVisible: false); //CSaveFeature.SavePathEbAsCpgEb(overdilationPaths, // "overdilationPaths" + (dblGrow + dblDilation) / CConstants.dblFclipper + "m", // pesriSimpleFillStyle: esriSimpleFillStyle.esriSFSNull, blnVisible: false); //CSaveFeature.SavePathEbAsCpgEb(erosionpaths, // "erosionpaths" + (dblGrow - dblErosion) / CConstants.dblFclipper + "m", // pesriSimpleFillStyle: esriSimpleFillStyle.esriSFSNull, blnVisible: false); //CSaveFeature.SavePolyTreeAsCpgEb(normalPolyTree, // "normalPolyTree" + dblGrow / CConstants.dblFclipper + "m", // pesriSimpleFillStyle: esriSimpleFillStyle.esriSFSNull, blnVisible: false); return(normalPolyTree); }
private IFeatureLayer CreateFeatureLayer(esriGeometryType pesriGeometryType, string pstrLayerName, List <string> pstrFieldNameLt = null, List <esriFieldType> pesriFieldTypeLt = null, int intRed = _intColor, int intGreen = _intColor, int intBlue = _intColor, double dblWidth = 1, int intOutlineRed = _intColor, int intOutlineGreen = _intColor, int intOutlineBlue = _intColor, esriSimpleLineStyle pesriSimpleLineStyle = esriSimpleLineStyle.esriSLSSolid, esriSimpleFillStyle pesriSimpleFillStyle = esriSimpleFillStyle.esriSFSSolid, string strSymbolLayerPath = null, bool blnVisible = true) { var pWorkspace = CConstants.ParameterInitialize.pWorkspace; var pm_mapControl = CConstants.ParameterInitialize.m_mapControl; pstrLayerName += CHelpFunc.GetTimeStampWithPrefix(); IFeatureClass pFeatureClass = CreateFeatureClass(pesriGeometryType, pstrLayerName, pWorkspace, pm_mapControl, pstrFieldNameLt, pesriFieldTypeLt); IFeatureLayer pFLayer = new FeatureLayerClass(); pFLayer.FeatureClass = pFeatureClass; pFLayer.Name = pFeatureClass.AliasName; pFLayer.SpatialReference = pm_mapControl.SpatialReference; RenderLayer(ref pFLayer, pesriGeometryType, intRed, intGreen, intBlue, dblWidth, intOutlineRed, intOutlineGreen, intOutlineBlue, pesriSimpleLineStyle, pesriSimpleFillStyle, strSymbolLayerPath); //save Layer as layer file ".lyr" //create a new LayerFile instance ILayerFile layerFile = new LayerFileClass(); //create a new layer file layerFile.New(pWorkspace.PathName + "\\" + pstrLayerName + ".lyr"); //attach the layer file with the actual layer layerFile.ReplaceContents((ILayer)pFLayer); //save the layer file layerFile.Save(); //***********************************************是否添加到当前文档中来***********************************************// //m_mapControl.AddLayer(pFLayer,m_mapControl .LayerCount); pm_mapControl.AddLayer(pFLayer); pFLayer.Visible = blnVisible; pm_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); return(pFLayer); }
//红色线 public static void ViewPolyline(IMapControl4 pMapControl, CPolyline cpl) { //设置线段属性 ILineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Width = 2; pSimpleLineSymbol.Color = CHelpFunc.GenerateIRgbColor(255, 0, 0) as IColor; //生成线段 ILineElement pLineElement = new LineElementClass(); pLineElement.Symbol = pSimpleLineSymbol; IElement pElement = pLineElement as IElement; pElement.Geometry = cpl.pPolyline; //显示线段 IGraphicsContainer pGra = pMapControl.Map as IGraphicsContainer; IActiveView pAv = pGra as IActiveView; pGra.AddElement(pElement, 0); pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //此语句必不可少,否则添加的要素不会实时显示 }
public static List <IFeatureLayer> GetVisibleLayers(CParameterInitialize ParameterInitialize) { var blnVisibleLt = new List <bool>(); var m_mapFeature = CHelpFunc.GetAllLayers(ParameterInitialize.m_mapControl, blnVisibleLt); var pFLayerLt = new List <IFeatureLayer>(m_mapFeature.LayerCount); for (int i = 0; i < m_mapFeature.LayerCount; i++) { var pFLayer = m_mapFeature.get_Layer(i) as IFeatureLayer; if (blnVisibleLt[i] == false) { continue; } else { pFLayerLt.Add(pFLayer); } } return(pFLayerLt); }
public static void SetSavePath(CParameterInitialize ParameterInitialize, bool blnCreateFileGdbWorkspace = false) { //if we have already set a path, then we simply use that path if (ParameterInitialize.strMxdPathBackSlash != null) { return; } //_strPath, which is different from ParameterInitialize.strPath, is defined in CHelpFunc if (_strPath == null) { SaveFileDialog SFD = new SaveFileDialog(); SFD.ShowDialog(); if (SFD.FileName == null || SFD.FileName == "") { return; } _strPath = SFD.FileName; } string strFileName = _strPath + "\\" + GetTimeStamp(); //string strFileName = CHelpFunc.strPath + "MorphingResults"; ParameterInitialize.strMxdPath = _strPath; ParameterInitialize.strMxdPathBackSlash = _strPath + "\\"; ParameterInitialize.strSaveFolderName = System.IO.Path.GetFileNameWithoutExtension(strFileName); ParameterInitialize.strSavePath = strFileName; ParameterInitialize.strSavePathBackSlash = strFileName + "\\"; ParameterInitialize.pWorkspace = CHelpFunc.OpenWorkspace(strFileName); if (blnCreateFileGdbWorkspace == true) { ParameterInitialize.pFileGdbWorkspace = CreateFileGdbWorkspace(ParameterInitialize.strSavePathBackSlash, "FileGdb"); } }
///// <summary> ///// 输出系数矩阵A ///// </summary> ///// <param name="maxData">系数矩阵A(注意:该矩阵从第0行到第i行为对角矩阵,i行之后为全矩阵</param> ///// <param name="strName">文件名称</param> ///// <param name="strSavePath">保存路径</param> ///// <remarks>二维矩阵</remarks> //public static void ExportDataToExcelA(VBMatrix maxData, string strName, string strSavePath) //{ // //为应付Excel的bug,加入以下两行代码 // //System.Globalization.CultureInfo CurrentCI = System.Threading.Thread.CurrentThread.CurrentCulture; // //System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); // Excel.Application pExcelAPP = new Excel.Application(); // pExcelAPP.Visible = false; // Workbook pWorkBook = pExcelAPP.Workbooks.Add(true); // Worksheet pWorksheet = pWorkBook.Worksheets[1] as Worksheet; // string strfilename = System.IO.Path.GetFileNameWithoutExtension(strSavePath); // strfilename = strfilename + strName; // int intRowCount = maxData.Row; // int intColCount = maxData.Col; // for (int i = 0; i < intColCount; i++) // { // pWorksheet.Cells[i + 1, i + 1] = maxData[i, i]; // } // for (int i = intColCount; i < intRowCount; i++) // { // for (int j = 0; j < intColCount; j++) // { // pWorksheet.Cells[i + 1, j + 1] = maxData[i, j]; // } // } // pWorksheet.Columns.AutoFit(); // pExcelAPP.DisplayAlerts = false; // pWorkBook.SaveAs(strSavePath + "\\" + strfilename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); // pExcelAPP.Quit(); // //KillExcel(); //} ///// <summary> ///// 输出权重矩阵P(注意:P为对角矩阵) ///// </summary> ///// <param name="maxData">权重矩阵P(注意:P为对角矩阵)</param> ///// <param name="strName">文件名称</param> ///// <param name="strSavePath">保存路径</param> ///// <remarks>二维矩阵</remarks> //public static void ExportDataToExcelP(VBMatrix maxData, string strName, string strSavePath) //{ // //为应付Excel的bug,加入以下两行代码 // //System.Globalization.CultureInfo CurrentCI = System.Threading.Thread.CurrentThread.CurrentCulture; // //System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); // Excel.Application pExcelAPP = new Excel.Application(); // pExcelAPP.Visible = false; // Workbook pWorkBook = pExcelAPP.Workbooks.Add(true); // Worksheet pWorksheet = pWorkBook.Worksheets[1] as Worksheet; // string strfilename = System.IO.Path.GetFileNameWithoutExtension(strSavePath); // strfilename = strfilename + strName; // int intRowCount = maxData.Row; // int intColCount = maxData.Col; // for (int i = 0; i < intRowCount; i++) // { // pWorksheet.Cells[i + 1, i + 1] = maxData[i, i]; // } // pWorksheet.Columns.AutoFit(); // pExcelAPP.DisplayAlerts = false; // pWorkBook.SaveAs(strSavePath + "\\" + strfilename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); // pExcelAPP.Quit(); // //KillExcel(); //} ///// <summary> ///// insert a data into an existed excel file at specified cell ///// </summary> ///// <param name="strPath">the path of the file</param> //public static void InsertData(string strPath, int intRow, int intCol, double dblData) //{ // Excel.Application pExcelAPP = new Excel.Application(); // pExcelAPP.Visible = false; // Workbook pWorkBook = pExcelAPP.Workbooks.Open(strPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); // Worksheet pWorksheet = pWorkBook.Worksheets[1] as Worksheet; // pWorksheet.Cells[intRow, intCol] = dblData; // pExcelAPP.DisplayAlerts = false; // pWorkBook.Save(); // pExcelAPP.Quit(); // //KillExcel(); //} /// <summary> /// 从Excel中读入数据 /// </summary> /// <param name="strPath">文件路径</param> /// <returns>pParameterResult:较大比例尺线状要素上、较小比例尺线状要素、对应点列</returns> public static CParameterResult InputDataResultPtLt(string strPath, bool blnReverse = false) { Excel.Application pExcelAPP = new Excel.Application(); pExcelAPP.Visible = false; Workbook pWorkBook = pExcelAPP.Workbooks.Open(strPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); Worksheet pWorksheet = pWorkBook.Worksheets[1] as Worksheet; List <CCorrCpts> pCorrCptsLt = new List <CCorrCpts>(); List <CPoint> frcptlt = new List <CPoint>(); List <CPoint> tocptlt = new List <CPoint>(); int intRow = pWorksheet.UsedRange.Rows.Count; System.Array values = (System.Array)pWorksheet.UsedRange.Formula; for (int i = 0; i < intRow - 1; i++) { CPoint frcpt = new CPoint(Convert.ToInt32(values.GetValue(i + 2, 1)), Convert.ToDouble(values.GetValue(i + 2, 2)), Convert.ToDouble(values.GetValue(i + 2, 3))); CPoint tocpt = new CPoint(Convert.ToInt32(values.GetValue(i + 2, 4)), Convert.ToDouble(values.GetValue(i + 2, 5)), Convert.ToDouble(values.GetValue(i + 2, 6))); if (blnReverse == true) { CHelpFunc.Swap(frcpt, tocpt); } if ((frcpt.ID != -1) && (tocpt.ID != -1)) { frcpt.isCtrl = true; tocpt.isCtrl = true; } frcpt.CorrespondingPtLt = new List <CPoint>(); frcpt.CorrespondingPtLt.Add(tocpt); frcptlt.Add(frcpt); tocptlt.Add(tocpt); CCorrCpts pCorrCpts = new CCorrCpts(frcpt, tocpt); pCorrCptsLt.Add(pCorrCpts); } pExcelAPP.Quit(); //删除重复点,以生成frcpl for (int i = frcptlt.Count - 2; i >= 0; i--) { if (frcptlt[i].Equals2D(frcptlt[i + 1])) { frcptlt.RemoveAt(i + 1); } } //删除重复点,以生成tocpl for (int i = tocptlt.Count - 2; i >= 0; i--) { if (tocptlt[i].Equals2D(tocptlt[i + 1])) { tocptlt.RemoveAt(i + 1); } } //生成结果 CPolyline frcpl = new CPolyline(0, frcptlt); CPolyline tocpl = new CPolyline(1, tocptlt); CParameterResult pParameterResult = new CParameterResult(); pParameterResult.FromCpl = frcpl; pParameterResult.ToCpl = tocpl; double dblfr = frcpl.pPolyline.Length; double dblto = tocpl.pPolyline.Length; pParameterResult.CCorrCptsLt = pCorrCptsLt; //pParameterResult.CResultPtLt = ResultPtLt; return(pParameterResult); }
//public static void ExportEvaluationToExcel(CDataRecords pDataRecords, string strSuffix) //{ // CParameterInitialize pParameterInitialize = pDataRecords.ParameterInitialize; // CParameterResult pParameterResult = pDataRecords.ParameterResult; // StatusStrip ststMain = pParameterInitialize.ststMain; // ToolStripStatusLabel tsslTime = pParameterInitialize.tsslTime; // ToolStripStatusLabel tsslMessage = pParameterInitialize.tsslMessage; // ToolStripProgressBar tspbMain = pParameterInitialize.tspbMain; // tsslMessage.Text = "正在将指标值导出到Excel..."; // ststMain.Refresh(); // long lngStartTime = System.Environment.TickCount; // Excel.Application pExcelAPP = new Excel.Application(); // pExcelAPP.Visible = false; // Workbook pWorkBook = pExcelAPP.Workbooks.Add(true); // Worksheet pWorksheet = pWorkBook.Worksheets[1] as Worksheet; // string strSavePath = pParameterInitialize.strSavePath; // string strfilename = System.IO.Path.GetFileNameWithoutExtension(strSavePath); // switch (pParameterResult.strEvaluationMethod) // { // case "Integral": // { // ExportIntegralEvaluation(pParameterResult, ref pWorksheet, ref tspbMain); // strfilename = strfilename + "Integral"; // break; // } // case "Translation": // { // ExportTranslationEvaluation(pParameterResult, ref pWorksheet, ref tspbMain); // strfilename = strfilename + "Translation"; // break; // } // case "Deflection": // { // ExportTranslationEvaluation(pParameterResult, ref pWorksheet, ref tspbMain); // strfilename = strfilename + "Deflection"; // break; // } // default: throw new ArgumentException("调用的评价指标值导出方法不存在!"); // } // pWorksheet.Columns.AutoFit(); // pExcelAPP.DisplayAlerts = false; // pWorkBook.SaveAs(strSavePath + "\\" + strfilename + strSuffix, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); // pExcelAPP.Quit(); // long lngEndTime = System.Environment.TickCount; // long lngTime = lngEndTime - lngStartTime; // tsslTime.Text = "导出运行时间:" + Convert.ToString(lngTime) + "ms"; //显示运行时间 // tsslMessage.Text = "详细信息已导出到Excel!"; //} public static void ExportEvaluationToExcelCorr(CParameterResult pParameterResult, string strPath, string strSuffix = null) { string strEvaluationMethod = pParameterResult.enumEvaluationMethod.ToString(); string strfilename = System.IO.Path.GetFileNameWithoutExtension(strPath); List <List <CCorrCpts> > CorrCptsLtLt = pParameterResult.pMorphingBase.CorrCptsLtLt; List <List <double> > dblEvaluationLtLt = pParameterResult.pEvaluation.dblEvaluationLtLt; List <List <double> > dblSumEvaluationLtLt = pParameterResult.pEvaluation.dblSumEvaluationLtLt; for (int i = 0; i < CorrCptsLtLt.Count; i++) { string strEntireFileName = strPath + "\\" + strfilename + strEvaluationMethod + CHelpFunc.JudgeAndAddZero(i, 4) + "__" + dblSumEvaluationLtLt[i].Last().ToString(); StreamWriter sw = new StreamWriter(strEntireFileName + ".xls", false, Encoding.GetEncoding(-0)); //it's better if we can output a file with ".xlsx", but that causes problems string strColNames = "FrID\t" + "FrX\t" + "FrY\t" + "ToID\t" + "ToX\t" + "ToY\t" + "MoveID\t" + "MoveX\t" + "MoveY\t" + strEvaluationMethod + "\t" + "Sum" + strEvaluationMethod; sw.WriteLine(strColNames); int intJ = 0; foreach (CCorrCpts CorrCpt in CorrCptsLtLt[i]) { string strTemp = CorrCpt.FrCpt.ID.ToString() + "\t" + CorrCpt.FrCpt.X.ToString() + "\t" + CorrCpt.FrCpt.Y.ToString() + "\t" + CorrCpt.ToCpt.ID.ToString() + "\t" + CorrCpt.ToCpt.X.ToString() + "\t" + CorrCpt.ToCpt.Y.ToString() + "\t" + CorrCpt.pMoveVector.ID.ToString() + "\t" + CorrCpt.pMoveVector.X.ToString() + "\t" + CorrCpt.pMoveVector.Y.ToString() + "\t" + dblEvaluationLtLt[i][intJ].ToString() + "\t" + dblSumEvaluationLtLt[i][intJ].ToString(); sw.WriteLine(strTemp); intJ++; } sw.Close(); } //output the last values var dblSumEvaluationLt = new List <double>(dblSumEvaluationLtLt.Count); for (int i = 0; i < dblSumEvaluationLtLt.Count; i++) { dblSumEvaluationLt.Add(dblSumEvaluationLtLt[i].Last()); } ExportDataltToExcel(dblSumEvaluationLt, "SumEachFeature", strPath); //KillExcel(); }
public static void DrawArrow(IActiveView pActiveView, CPoint frcpt, CPoint tocpt, double dblArrowLength = 6, double dblArrowWidth = 6, int intRed = 0, int intGreen = 0, int intBlue = 0) { var iColor = CHelpFunc.GenerateIRgbColor(intRed, intGreen, intBlue) as IColor; //Define an arrow marker IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = iColor; //arrowMarkerSymbol.Size = 6; //it seems size has no effect arrowMarkerSymbol.Length = dblArrowLength; arrowMarkerSymbol.Width = dblArrowWidth; //Add an offset to make sure the square end of the line is hidden //arrowMarkerSymbol.XOffset = 0.8; //Create cartographic line symbol ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Color = iColor; cartographicLineSymbol.Width = 1; //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); //Place the arrow at the end of the line (the "To" point in the geometry below) simpleLineDecorationElement.AddPosition(1); simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; //Define line decoration ILineDecoration lineDecoration = new LineDecorationClass(); lineDecoration.AddElement(simpleLineDecorationElement); //Set line properties ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; lineProperties.LineDecoration = lineDecoration; //Define line element ILineElement lineElement = new LineElementClass(); lineElement.Symbol = (ILineSymbol)cartographicLineSymbol; var cpl = new CPolyline(-1, frcpt, tocpt); //Cast to Element and set geometry var element = (IElement)lineElement; element.Geometry = cpl.JudgeAndSetPolyline(); //Set the name //IElementProperties3 elementProperties3.Name = elementName; //Add element to graphics container pActiveView.GraphicsContainer.AddElement(element, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); #region a useful example https://community.esri.com/thread/69395 ////Set the element name //string elementName = "ArrowTest"; ////Get the graphics container from the page layout (set elsewhere) //IActiveView activeView = (IActiveView)pageLayout; //IGraphicsContainer graphicsContainer = (IGraphicsContainer)pageLayout; ////Find all existing elements with specified name ////Build a list of elements and then loop over the list to delete them //List<IElement> elementsToDelete = new List<IElement>(); //graphicsContainer.Reset(); //IElementProperties3 elementProperties3 = null; //IElement element = null; //while ((element = graphicsContainer.Next()) != null) //{ // elementProperties3 = (IElementProperties3)element; // if (elementProperties3.Name == elementName) // { // elementsToDelete.Add(element); // } //} //foreach (IElement elementToDelete in elementsToDelete) //{ // graphicsContainer.DeleteElement(elementToDelete); //} ////Define color //IRgbColor rgbColor = new RgbColorClass(); //rgbColor.RGB = Color.Black.ToArgb(); ////Define an arrow marker //IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); //arrowMarkerSymbol.Color = rgbColor; //arrowMarkerSymbol.Size = 6; //arrowMarkerSymbol.Length = 8; //arrowMarkerSymbol.Width = 6; ////Add an offset to make sure the square end of the line is hidden //arrowMarkerSymbol.XOffset = 0.8; ////Create cartographic line symbol //ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); //cartographicLineSymbol.Color = rgbColor; //cartographicLineSymbol.Width = 1; ////Define simple line decoration //ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); ////Place the arrow at the end of the line (the "To" point in the geometry below) //simpleLineDecorationElement.AddPosition(1); //simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; ////Define line decoration //ILineDecoration lineDecoration = new LineDecorationClass(); //lineDecoration.AddElement(simpleLineDecorationElement); ////Set line properties //ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; //lineProperties.LineDecoration = lineDecoration; ////Define line element //ILineElement lineElement = new LineElementClass(); //lineElement.Symbol = (ILineSymbol)cartographicLineSymbol; ////Create the line geometry //IPoint fromPoint = new PointClass(); //fromPoint.X = 4.0; //fromPoint.Y = 0.8; //IPoint toPoint = new PointClass(); //toPoint.X = 5.0; //toPoint.Y = 0.8; //IPolyline polyline = new PolylineClass(); //polyline.FromPoint = fromPoint; //polyline.ToPoint = toPoint; ////Cast to Element and set geometry //element = (IElement)lineElement; //element.Geometry = polyline; ////Set the name //elementProperties3.Name = elementName; ////Add element to graphics container //graphicsContainer.AddElement(element, 0); ////Clear the graphics selection (graphics are selected when added) //IGraphicsContainerSelect graphicsContainerSelect = (IGraphicsContainerSelect)graphicsContainer; //graphicsContainerSelect.UnselectAllElements(); //activeView.Refresh(); #endregion }
public static void FrmOperation(ref CParameterInitialize pParameterInitialize) { pParameterInitialize.m_mapFeature = CHelpFunc.GetAllLayers(pParameterInitialize.m_mapControl); LoadTocbo(pParameterInitialize); }
/** * The mandatory preamble for an ipe-file. * * @return */ public static string GetIpeStart() { var strTime = CHelpFunc.GetTimeStampForIpe(); //e.g., strTime = "20181114190553" #region strIpeStart string strIpeStart = @"<?xml version=""1.0""?> <!DOCTYPE ipe SYSTEM ""ipe.dtd""> <ipe version=""70206"" creator=""Ipe 7.2.7""> <info created=""D:" + strTime + @""" modified=""D:" + strTime + @"""/> <preamble>\usepackage[english]{babel}</preamble> <ipestyle name=""basic""> <symbol name=""arrow/arc(spx)""> <path stroke=""sym-stroke"" fill=""sym-stroke"" pen=""sym-pen""> 0 0 m -1 0.333 l -1 -0.333 l h </path> </symbol> <symbol name=""arrow/farc(spx)""> <path stroke=""sym-stroke"" fill=""white"" pen=""sym-pen""> 0 0 m -1 0.333 l -1 -0.333 l h </path> </symbol> <symbol name=""arrow/ptarc(spx)""> <path stroke=""sym-stroke"" fill=""sym-stroke"" pen=""sym-pen""> 0 0 m -1 0.333 l -0.8 0 l -1 -0.333 l h </path> </symbol> <symbol name=""arrow/fptarc(spx)""> <path stroke=""sym-stroke"" fill=""white"" pen=""sym-pen""> 0 0 m -1 0.333 l -0.8 0 l -1 -0.333 l h </path> </symbol> <symbol name=""mark/circle(sx)"" transformations=""translations""> <path fill=""sym-stroke""> 0.6 0 0 0.6 0 0 e 0.4 0 0 0.4 0 0 e </path> </symbol> <symbol name=""mark/disk(sx)"" transformations=""translations""> <path fill=""sym-stroke""> 0.6 0 0 0.6 0 0 e </path> </symbol> <symbol name=""mark/fdisk(sfx)"" transformations=""translations""> <group> <path fill=""sym-fill""> 0.5 0 0 0.5 0 0 e </path> <path fill=""sym-stroke"" fillrule=""eofill""> 0.6 0 0 0.6 0 0 e 0.4 0 0 0.4 0 0 e </path> </group> </symbol> <symbol name=""mark/box(sx)"" transformations=""translations""> <path fill=""sym-stroke"" fillrule=""eofill""> -0.6 -0.6 m 0.6 -0.6 l 0.6 0.6 l -0.6 0.6 l h -0.4 -0.4 m 0.4 -0.4 l 0.4 0.4 l -0.4 0.4 l h </path> </symbol> <symbol name=""mark/square(sx)"" transformations=""translations""> <path fill=""sym-stroke""> -0.6 -0.6 m 0.6 -0.6 l 0.6 0.6 l -0.6 0.6 l h </path> </symbol> <symbol name=""mark/fsquare(sfx)"" transformations=""translations""> <group> <path fill=""sym-fill""> -0.5 -0.5 m 0.5 -0.5 l 0.5 0.5 l -0.5 0.5 l h </path> <path fill=""sym-stroke"" fillrule=""eofill""> -0.6 -0.6 m 0.6 -0.6 l 0.6 0.6 l -0.6 0.6 l h -0.4 -0.4 m 0.4 -0.4 l 0.4 0.4 l -0.4 0.4 l h </path> </group> </symbol> <symbol name=""mark/cross(sx)"" transformations=""translations""> <group> <path fill=""sym-stroke""> -0.43 -0.57 m 0.57 0.43 l 0.43 0.57 l -0.57 -0.43 l h </path> <path fill=""sym-stroke""> -0.43 0.57 m 0.57 -0.43 l 0.43 -0.57 l -0.57 0.43 l h </path> </group> </symbol> <symbol name=""arrow/fnormal(spx)""> <path stroke=""sym-stroke"" fill=""white"" pen=""sym-pen""> 0 0 m -1 0.333 l -1 -0.333 l h </path> </symbol> <symbol name=""arrow/pointed(spx)""> <path stroke=""sym-stroke"" fill=""sym-stroke"" pen=""sym-pen""> 0 0 m -1 0.333 l -0.8 0 l -1 -0.333 l h </path> </symbol> <symbol name=""arrow/fpointed(spx)""> <path stroke=""sym-stroke"" fill=""white"" pen=""sym-pen""> 0 0 m -1 0.333 l -0.8 0 l -1 -0.333 l h </path> </symbol> <symbol name=""arrow/linear(spx)""> <path stroke=""sym-stroke"" pen=""sym-pen""> -1 0.333 m 0 0 l -1 -0.333 l </path> </symbol> <symbol name=""arrow/fdouble(spx)""> <path stroke=""sym-stroke"" fill=""white"" pen=""sym-pen""> 0 0 m -1 0.333 l -1 -0.333 l h -1 0 m -2 0.333 l -2 -0.333 l h </path> </symbol> <symbol name=""arrow/double(spx)""> <path stroke=""sym-stroke"" fill=""sym-stroke"" pen=""sym-pen""> 0 0 m -1 0.333 l -1 -0.333 l h -1 0 m -2 0.333 l -2 -0.333 l h </path> </symbol> <pen name=""heavier"" value=""0.8""/> <pen name=""fat"" value=""1.2""/> <pen name=""ultrafat"" value=""2""/> <symbolsize name=""large"" value=""5""/> <symbolsize name=""small"" value=""2""/> <symbolsize name=""tiny"" value=""1.1""/> <arrowsize name=""large"" value=""10""/> <arrowsize name=""small"" value=""5""/> <arrowsize name=""tiny"" value=""3""/> <color name=""red"" value=""1 0 0""/> <color name=""green"" value=""0 1 0""/> <color name=""blue"" value=""0 0 1""/> <color name=""yellow"" value=""1 1 0""/> <color name=""orange"" value=""1 0.647 0""/> <color name=""gold"" value=""1 0.843 0""/> <color name=""purple"" value=""0.627 0.125 0.941""/> <color name=""gray"" value=""0.745""/> <color name=""brown"" value=""0.647 0.165 0.165""/> <color name=""navy"" value=""0 0 0.502""/> <color name=""pink"" value=""1 0.753 0.796""/> <color name=""seagreen"" value=""0.18 0.545 0.341""/> <color name=""turquoise"" value=""0.251 0.878 0.816""/> <color name=""violet"" value=""0.933 0.51 0.933""/> <color name=""darkblue"" value=""0 0 0.545""/> <color name=""darkcyan"" value=""0 0.545 0.545""/> <color name=""darkgray"" value=""0.663""/> <color name=""darkgreen"" value=""0 0.392 0""/> <color name=""darkmagenta"" value=""0.545 0 0.545""/> <color name=""darkorange"" value=""1 0.549 0""/> <color name=""darkred"" value=""0.545 0 0""/> <color name=""lightblue"" value=""0.678 0.847 0.902""/> <color name=""lightcyan"" value=""0.878 1 1""/> <color name=""lightgray"" value=""0.827""/> <color name=""lightgreen"" value=""0.565 0.933 0.565""/> <color name=""lightyellow"" value=""1 1 0.878""/> <dashstyle name=""dashed"" value=""[4] 0""/> <dashstyle name=""dotted"" value=""[1 3] 0""/> <dashstyle name=""dash dotted"" value=""[4 2 1 2] 0""/> <dashstyle name=""dash dot dotted"" value=""[4 2 1 2 1 2] 0""/> <textsize name=""large"" value=""\large""/> <textsize name=""Large"" value=""\Large""/> <textsize name=""LARGE"" value=""\LARGE""/> <textsize name=""huge"" value=""\huge""/> <textsize name=""Huge"" value=""\Huge""/> <textsize name=""small"" value=""\small""/> <textsize name=""footnote"" value=""\footnotesize""/> <textsize name=""tiny"" value=""\tiny""/> <textstyle name=""center"" begin=""\begin{center}"" end=""\end{center}""/> <textstyle name=""itemize"" begin=""\begin{itemize}"" end=""\end{itemize}""/> <textstyle name=""item"" begin=""\begin{itemize}\item{}"" end=""\end{itemize}""/> <gridsize name=""4 pts"" value=""4""/> <gridsize name=""8 pts (~3 mm)"" value=""8""/> <gridsize name=""16 pts (~6 mm)"" value=""16""/> <gridsize name=""32 pts (~12 mm)"" value=""32""/> <gridsize name=""10 pts (~3.5 mm)"" value=""10""/> <gridsize name=""20 pts (~7 mm)"" value=""20""/> <gridsize name=""14 pts (~5 mm)"" value=""14""/> <gridsize name=""28 pts (~10 mm)"" value=""28""/> <gridsize name=""56 pts (~20 mm)"" value=""56""/> <anglesize name=""90 deg"" value=""90""/> <anglesize name=""60 deg"" value=""60""/> <anglesize name=""45 deg"" value=""45""/> <anglesize name=""30 deg"" value=""30""/> <anglesize name=""22.5 deg"" value=""22.5""/> <opacity name=""10%"" value=""0.1""/> <opacity name=""30%"" value=""0.3""/> <opacity name=""50%"" value=""0.5""/> <opacity name=""75%"" value=""0.75""/> <tiling name=""falling"" angle=""-60"" step=""4"" width=""1""/> <tiling name=""rising"" angle=""30"" step=""4"" width=""1""/> </ipestyle>"; #endregion return(strIpeStart); }
public static int CmpGeneric <T, TOrder>(T T1, T T2, Func <T, TOrder> orderFunc, IComparer <TOrder> cmp = null) { cmp = CHelpFunc.SetOrDefaultCmp(cmp); return(cmp.Compare(orderFunc(T1), orderFunc(T2))); }
public void RenderLayer(ref IFeatureLayer fLayer, esriGeometryType fesriGeometryType, int intRed, int intGreen, int intBlue, double fdblWidth, int intOutlineRed, int intOutlineGreen, int intOutlineBlue, esriSimpleLineStyle pesriSimpleLineStyle, esriSimpleFillStyle pesriSimpleFillStyle, string strSymbolLayerPath) { if (strSymbolLayerPath == null) { IRgbColor pRgbColor = CHelpFunc.GenerateIRgbColor(intRed, intGreen, intBlue); ISimpleRenderer pSimpleRenderer = new SimpleRendererClass(); switch (fesriGeometryType) { case esriGeometryType.esriGeometryPoint: ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Color = pRgbColor as IColor; pSimpleMarkerSymbol.Size = fdblWidth; pSimpleRenderer.Symbol = pSimpleMarkerSymbol as ISymbol; break; case esriGeometryType.esriGeometryPolyline: pSimpleRenderer.Symbol = GetSimpleLineSymbol(pRgbColor, fdblWidth, pesriSimpleLineStyle) as ISymbol; break; case esriGeometryType.esriGeometryPolygon: IRgbColor pRgbColorOutline = new RgbColorClass(); pRgbColorOutline.Red = intOutlineRed; pRgbColorOutline.Green = intOutlineGreen; pRgbColorOutline.Blue = intOutlineBlue; ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Outline = GetSimpleLineSymbol(pRgbColorOutline, fdblWidth, pesriSimpleLineStyle); pSimpleFillSymbol.Color = pRgbColor as IColor; pSimpleFillSymbol.Style = pesriSimpleFillStyle; pSimpleRenderer.Symbol = pSimpleFillSymbol as ISymbol; break; default: return; } //fLayer. IGeoFeatureLayer pGeoFeaturelayer = fLayer as IGeoFeatureLayer; pGeoFeaturelayer.Renderer = pSimpleRenderer as IFeatureRenderer; } else { //In the shapefile properties, under the Symbology tab, //you have the Import button which allow you to import the symbology definition from another shapefile or layer file. //The code below is doing exactly the same. //You need to create a layer file with the desired symbology definition and then call this sub. IGxLayer pGxLayer; IGxFile pGxFile; ILayer pSymLayer; IGeoFeatureLayer pLyr; IGeoFeatureLayer pGeoSymLyr; pGxLayer = new GxLayer(); pGxFile = pGxLayer as IGxFile; pGxFile.Path = strSymbolLayerPath; pSymLayer = pGxLayer.Layer; pLyr = fLayer as IGeoFeatureLayer; pGeoSymLyr = pSymLayer as IGeoFeatureLayer; pLyr.Renderer = pGeoSymLyr.Renderer; } }