private void ProcessLine(XmlElement xElementControl, RLine control) { control.对齐方式 = (LineAlignment)this.GetInteger(xElementControl.Attributes, "Alignment"); control.ForeColor = Color.FromName(this.GetString(xElementControl.Attributes, "ForeColor")); control.线段类型 = (LineStyle)this.GetInteger(xElementControl.Attributes, "LineStyle"); control.线宽 = this.GetInteger(xElementControl.Attributes, "LineWeight"); }
public static DataTable ReadPLD_Line(string strFileName) { String RLine; using (StreamReader SR = new StreamReader(strFileName, Encoding.Default, true)) { CTrans <_st_typePLD_Line> Trans_PLD_Line = new CTrans <_st_typePLD_Line>(); CMakeDataTable <_st_typePLD_Line> MakeTablePLD_Line = new CMakeDataTable <_st_typePLD_Line>(); bool chk99 = false; bool bRead = false; decimal tCnt = 0; int nInc = 0; while ((RLine = SR.ReadLine()) != null) { if (RLine.Trim().Length <= 0) { continue; } if (RLine.Substring(0, 3) == "-99") { chk99 = true; continue; } if (chk99) { tCnt = Convert.ToDecimal(RLine.Substring(0, 5).ToString()); if (tCnt > 0) { chk99 = false; bRead = true; } continue; } if (bRead) { if (nInc < tCnt) { _st_typePLD_Line st_typePLD_Line = Trans_PLD_Line.ByteToStruct(RLine); MakeTablePLD_Line.AddData(st_typePLD_Line); nInc++; } else { continue; } } } return(MakeTablePLD_Line.DATATABLE); } }
//=================================================================== // 点到直线距离(垂直距离) // dist_Point_to_Line(): get the distance of a point to a line // Input: a Point P and a Line L (in any dimension) // Return: the shortest distance from P to L public static double dist_Point_to_Line(RPoint P, RLine L) { Vector3d v = L.P1 - L.P0; Vector3d w = P - L.P0; double c1 = RMath.dot(w, v); double c2 = RMath.dot(v, v); double b = c1 / c2; RPoint Pb = L.P0 + b * v; return(RMath.d(P, Pb)); }
private void button8_Click(object sender, EventArgs e) { String FileName; String RLine; CPLD LToR = new CPLD(); LToR.m_dt.Clear(); gridControl3.DataSource = LToR.m_dt; int nIndex = 0; int nRecLine = 0; using (OpenFileDialog openDlg = new OpenFileDialog()) { openDlg.Filter = "PLD 파일 (*.PLD)|*.PLD|모든파일(*.*)|*.*"; openDlg.Multiselect = true; if (openDlg.ShowDialog() == DialogResult.OK) { foreach (string strFileName in openDlg.FileNames) { FileName = Path.GetFileName(strFileName); using (StreamReader SR = new StreamReader(strFileName, Encoding.Default)) { nIndex = 0; while ((RLine = SR.ReadLine()) != null) { nIndex++; if (nIndex <= 2) { continue; } if (RLine.Substring(0, 3) == "-99") { break; } LToR.LineToRecord(FileName, RLine); } } } gridControl3.DataSource = LToR.m_dt; //MessageBox.Show(LToR.m_dt.Rows.Count.ToString()); } } }
private void DrawLine(Graphics g, RLine control, int x1, int y1, int x2, int y2) { Pen pen = new Pen(control.ForeColor, control.线宽); if (control.线段类型 == LineStyle.虚线) { pen.DashStyle = DashStyle.Dot; pen.DashCap = DashCap.Flat; } else { pen.DashStyle = DashStyle.Solid; } g.DrawLine(pen, x1, y1, x2, y2); }
public override void OnMouseDown(int x, int y, MouseEventArgs e) { n++; if (n <= 1) { line = new RLine(); line.P0 = new RPoint(x, y, 0); line.P1 = new RPoint(x, y, 0); } else { line.P1 = new RPoint(x, y, 0); PointF p1 = new PointF((float)line.P0.X, (float)line.P0.Y); PointF p2 = new PointF((float)line.P1.X, (float)line.P1.Y); mScreenDisplay.DrawPolyline(Pens.Blue, p1, p2); n = 0; } }
private void DrawLine(RLine control, int offset) { int num = offset + ((int)Utils.ConvertPixelToDisplay(control.垂直位置)); int esquerda = 0; int num3 = 0; int direita = 0; int num5 = 0; int num6 = offset + ((int)Utils.ConvertPixelToDisplay(control.垂直位置)); int num7 = num6 + this.altura; switch (control.对齐方式) { case LineAlignment.靠顶: esquerda = this.esquerda; num3 = num6; direita = this.direita; num5 = num; break; case LineAlignment.靠底: esquerda = this.esquerda; num3 = num7 - 1; direita = this.direita; num5 = num7 - 1; break; case LineAlignment.靠左: esquerda = this.esquerda; num3 = num6; direita = this.esquerda; num5 = num7; break; case LineAlignment.靠右: esquerda = this.direita - 1; num3 = num6; direita = this.direita - 1; num5 = num7; break; } this.DrawLine(this.page, control, esquerda, num3, direita, num5); }
private void AddControlLine(XmlElement xElementRoot, RLine control) { this.AddAtributo(xElementRoot, "Alignment", ((int)control.对齐方式).ToString()); this.AddAtributo(xElementRoot, "LineStyle", Convert.ToInt16(control.线段类型).ToString()); this.AddAtributo(xElementRoot, "LineWeight", control.线宽.ToString()); }
/// <summary> /// 点在直线上 /// </summary> /// <param name="rPt"></param> /// <param name="rLine"></param> /// <returns></returns> public static bool IsInLine(RPoint rPt, RLine rLine) { bool flag = false; return(flag); }
private void simpleButton1_Click(object sender, EventArgs e) { ///marshal 로 처리 하려 하였으나 ///원래 PLH파일의 처리가 잘 못되어 있어 Marshal 처리 불가능 String FileName; String Extension; String RLine; CPLHMngr PLHMngr = new CPLHMngr(); XtraOpenFileDialog Opendlg; using (Opendlg = new XtraOpenFileDialog()) { //Opendlg.Filter = "PLH 파일 (*.PLH)|*.PLD|모든파일(*.*)|*.*"; Opendlg.Filter = "모든파일(*.*)|*.*"; Opendlg.Multiselect = true; if (Opendlg.ShowDialog() == DialogResult.OK) { foreach (string strFileName in Opendlg.FileNames) { FileName = Path.GetFileName(strFileName); Extension = Path.GetExtension(strFileName); if (Extension.ToUpper() == ".PLD") { DataTable ddt = CReadPLD.ReadPLD_Line(strFileName); if (ddt != null) { CPLHData PLHData = new CPLHData(); PLHData.FileName = Path.GetFileNameWithoutExtension(strFileName); PLHData.PLDLineData = ddt; PLHMngr.AddPLDData(PLHData); } } using (StreamReader SR = new StreamReader(strFileName, Encoding.Default, true)) { if (Extension.ToUpper() == ".PLH") { CTrans <_st_typePLH> Trans_PLH = new CTrans <_st_typePLH>(); CMakeDataTable <_st_typePLH> MakeTable = new CMakeDataTable <_st_typePLH>(); while ((RLine = SR.ReadLine()) != null) { if (RLine.Substring(0, 2) != "NO") { continue; } //RLine = RLine.Replace('+', ' '); _st_typePLH st_typePLH = Trans_PLH.ByteToStruct(RLine); MakeTable.AddData(st_typePLH); } if (MakeTable.DATATABLE != null) { DataTable dt = MakeTable.DATATABLE; CPLHData PLHData = new CPLHData(); PLHData.FileName = Path.GetFileNameWithoutExtension(strFileName); PLHData.PLHData = dt; PLHMngr.AddPLHData(PLHData); } } else if (Extension.ToUpper() == ".PLD") { CTrans <_st_typePLD> Trans_PLD = new CTrans <_st_typePLD>(); CMakeDataTable <_st_typePLD> MakeTablePLD = new CMakeDataTable <_st_typePLD>(); while ((RLine = SR.ReadLine()) != null) { if (RLine.Contains("CROSS") == false) { continue; } _st_typePLD st_typePLD = Trans_PLD.ByteToStruct(RLine); MakeTablePLD.AddData(st_typePLD); } if (MakeTablePLD.DATATABLE != null) { DataTable dt = MakeTablePLD.DATATABLE; CPLHData PLHData = new CPLHData(); PLHData.FileName = Path.GetFileNameWithoutExtension(strFileName); PLHData.PLDData = dt; PLHMngr.AddPLDData(PLHData); } } } } } else { //취소하면 이후 처리는 SKIP return; } CPLHDataProc DataProc = new CPLHDataProc(PLHMngr); DataProc.MakePipeToolData(); gridControl2.DataSource = PLHMngr.GetData(); ExportToSpreadSheet(DataProc); ExportToSpread2(DataProc); } }