333 lines
14 KiB
C#
333 lines
14 KiB
C#
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.DB.Plumbing;
|
|
using KDCS.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace KMBIM.Revit.Tools.Cmd.PipeMatchInterval
|
|
{
|
|
public partial class SetOffset : System.Windows.Forms.Form
|
|
{
|
|
public Document doc = null;
|
|
public double offsetValue = 0;
|
|
public bool isConfirmed = false;
|
|
public int m_RadIdx = 0;
|
|
|
|
public SetOffset()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
private void SetOffset_Load(object sender, EventArgs e)
|
|
{
|
|
this.KeyPreview = true;
|
|
//셀에 보여지는 순서가 반대라 역방향 해서 작업 후 [확인] 버튼 누를 때 다시 되돌리기
|
|
KMBIM.PipeMatchInterval.RightMpiLst.Reverse();
|
|
KMBIM.PipeMatchInterval.UpMpiLst.Reverse();
|
|
dgv_PipeCheckData();
|
|
//Rad_HSort.Checked = true;
|
|
//간격입력
|
|
if (Reg.getReg("MatchInterval_Offset") != "" || Reg.getReg("MatchInterval_Offset") != string.Empty)
|
|
txt_OffsetValue.Text = Reg.getReg("MatchInterval_Offset");
|
|
else
|
|
{
|
|
txt_OffsetValue.Text = "150";//간격 띄우기 Default값 150
|
|
}
|
|
//정렬방향 수평,수직
|
|
if (Reg.getReg("MatchInterval_RadIdx") != "" || Reg.getReg("MatchInterval_RadIdx") != string.Empty)
|
|
{
|
|
int RadIdx = 0;
|
|
int.TryParse(Reg.getReg("MatchInterval_RadIdx"), out RadIdx);
|
|
if (RadIdx == 0)
|
|
Rad_HSort.Checked = true;
|
|
else if (RadIdx == 1)
|
|
Rad_VSort.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
Rad_HSort.Checked = true;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
int index = 0;
|
|
|
|
private void dgv_PipeCheckData()
|
|
{
|
|
dgv_PipeCheck.Rows.Clear();
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
dgv_PipeCheck.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
|
dgv_PipeCheck.Columns[i].ReadOnly = true;
|
|
}
|
|
int dirIdx = 0;
|
|
//정렬방향-수평
|
|
if (m_RadIdx == 0)
|
|
{
|
|
int rowIdx = 0;
|
|
|
|
//List<MovePipeInfo> revRightMpiLst = KMBIM.PipeMatchInterval.RightMpiLst;
|
|
//revRightMpiLst.Reverse();
|
|
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.RightMpiLst.Count(); i++)
|
|
{
|
|
dgv_PipeCheck.Rows.Add();
|
|
dgv_PipeCheck.Rows[i].Cells[0].Value = KMBIM.PipeMatchInterval.RightMpiLst[i].PipeToMove.Name;
|
|
dgv_PipeCheck.Rows[i].Cells[1].Value = KMBIM.PipeMatchInterval.RightMpiLst[i].NormalDiameter.ToString();
|
|
dgv_PipeCheck.Rows[i].Cells[2].Value = KMBIM.PipeMatchInterval.RightMpiLst[i].OuterDiaRound.ToString();
|
|
dgv_PipeCheck.Rows[i].Cells[3].Value = KMBIM.PipeMatchInterval.RightMpiLst[i].InsultionThick.ToString();
|
|
rowIdx++;
|
|
}
|
|
|
|
dgv_PipeCheck.Rows.Add();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[0].Value = KMBIM.PipeMatchInterval.dirMpi.PipeToMove.Name;
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[1].Value = KMBIM.PipeMatchInterval.dirMpi.NormalDiameter.ToString();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[2].Value = KMBIM.PipeMatchInterval.dirMpi.OuterDiaRound.ToString();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[3].Value = KMBIM.PipeMatchInterval.dirMpi.InsultionThick.ToString();
|
|
rowIdx++;
|
|
dirIdx = rowIdx;
|
|
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.LeftMpiLst.Count(); i++)
|
|
{
|
|
dgv_PipeCheck.Rows.Add();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[0].Value = KMBIM.PipeMatchInterval.LeftMpiLst[i].PipeToMove.Name;
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[1].Value = KMBIM.PipeMatchInterval.LeftMpiLst[i].NormalDiameter.ToString();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[2].Value = KMBIM.PipeMatchInterval.LeftMpiLst[i].OuterDiaRound.ToString();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[3].Value = KMBIM.PipeMatchInterval.LeftMpiLst[i].InsultionThick.ToString();
|
|
rowIdx++;
|
|
}
|
|
}
|
|
else//정렬방향-수직
|
|
{
|
|
int rowIdx = 0;
|
|
//셀에 보여지는 순서가 반대라 확인 누르기 전까지 역방향으로 돌림.
|
|
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.UpMpiLst.Count(); i++)
|
|
{
|
|
dgv_PipeCheck.Rows.Add();
|
|
dgv_PipeCheck.Rows[i].Cells[0].Value = KMBIM.PipeMatchInterval.UpMpiLst[i].PipeToMove.Name;
|
|
dgv_PipeCheck.Rows[i].Cells[1].Value = KMBIM.PipeMatchInterval.UpMpiLst[i].NormalDiameter.ToString();
|
|
dgv_PipeCheck.Rows[i].Cells[2].Value = KMBIM.PipeMatchInterval.UpMpiLst[i].OuterDiaRound.ToString();
|
|
dgv_PipeCheck.Rows[i].Cells[3].Value = KMBIM.PipeMatchInterval.UpMpiLst[i].InsultionThick.ToString();
|
|
rowIdx++;
|
|
}
|
|
|
|
dgv_PipeCheck.Rows.Add();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[0].Value = KMBIM.PipeMatchInterval.dirMpi.PipeToMove.Name;
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[1].Value = KMBIM.PipeMatchInterval.dirMpi.NormalDiameter.ToString();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[2].Value = KMBIM.PipeMatchInterval.dirMpi.OuterDiaRound.ToString();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[3].Value = KMBIM.PipeMatchInterval.dirMpi.InsultionThick.ToString();
|
|
rowIdx++;
|
|
dirIdx = rowIdx;
|
|
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.DownMpiLst.Count(); i++)
|
|
{
|
|
dgv_PipeCheck.Rows.Add();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[0].Value = KMBIM.PipeMatchInterval.DownMpiLst[i].PipeToMove.Name;
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[1].Value = KMBIM.PipeMatchInterval.DownMpiLst[i].NormalDiameter.ToString();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[2].Value = KMBIM.PipeMatchInterval.DownMpiLst[i].OuterDiaRound.ToString();
|
|
dgv_PipeCheck.Rows[rowIdx].Cells[3].Value = KMBIM.PipeMatchInterval.DownMpiLst[i].InsultionThick.ToString();
|
|
rowIdx++;
|
|
}
|
|
}
|
|
|
|
|
|
//for (int i = 0; i < KMBIM.PipeMatchInterval.mpiList.Count(); i++)
|
|
//{
|
|
// dgv_PipeCheck.Rows.Add();
|
|
// dgv_PipeCheck.Rows[i].Cells[0].Value = KMBIM.PipeMatchInterval.mpiList[i].PipeToMove.Name;
|
|
// dgv_PipeCheck.Rows[i].Cells[1].Value = KMBIM.PipeMatchInterval.mpiList[i].NormalDiameter.ToString();
|
|
// dgv_PipeCheck.Rows[i].Cells[2].Value = KMBIM.PipeMatchInterval.mpiList[i].OuterDiaRound.ToString();
|
|
// dgv_PipeCheck.Rows[i].Cells[3].Value = KMBIM.PipeMatchInterval.mpiList[i].InsultionThick.ToString();
|
|
//}
|
|
//
|
|
//for (int i = 0; i < KMBIM.PipeMatchInterval.mpiList.Count(); i++)
|
|
//{
|
|
// if(KMBIM.PipeMatchInterval.mpiList[i].PipeToMove.Id == KMBIM.PipeMatchInterval.dirPipe.Id)
|
|
// {
|
|
// index = i;
|
|
// }
|
|
//}
|
|
index = dirIdx - 1;
|
|
//기준 배관 표시
|
|
for (int i = 0; i < dgv_PipeCheck.RowCount; i++)
|
|
{
|
|
if (index == i)
|
|
{
|
|
dgv_PipeCheck.Rows[i].Cells[0].Style.BackColor = System.Drawing.Color.Crimson;
|
|
dgv_PipeCheck.Rows[i].Cells[0].Style.ForeColor = System.Drawing.Color.White;
|
|
break;
|
|
}
|
|
}
|
|
|
|
dgv_PipeCheck.CurrentCell = null;
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
private void txt_OffsetValue_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (!(char.IsDigit(e.KeyChar) || e.KeyChar == Convert.ToChar(Keys.Back) || (e.KeyChar == '.')))
|
|
{
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
private void btn_Cancel_Click(object sender, EventArgs e)
|
|
{
|
|
isConfirmed = false;
|
|
|
|
Close();
|
|
}
|
|
|
|
private void btn_Confirm_Click(object sender, EventArgs e)
|
|
{
|
|
isConfirmed = true;
|
|
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.mpiList.Count(); i++)
|
|
{
|
|
double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[i].Cells[3].Value.ToString());
|
|
|
|
KMBIM.PipeMatchInterval.mpiList[i].UserInsultionThick = insultionThickFromUser;
|
|
|
|
if (index == i)
|
|
{
|
|
insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[i].Cells[3].Value.ToString());
|
|
|
|
//KMBIM.PipeMatchInterval.mpiList[i].UserInsultionThickCri = insultionThickFromUser;
|
|
KMBIM.PipeMatchInterval.userPipeInsulCri = insultionThickFromUser;
|
|
}
|
|
}
|
|
|
|
//정렬-수평
|
|
if (m_RadIdx == 0)
|
|
{
|
|
int rowIdx = 0;
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.RightMpiLst.Count(); i++)
|
|
{
|
|
//double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
//if (index == i)
|
|
//{
|
|
double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
KMBIM.PipeMatchInterval.RightMpiLst[i].UserInsultionThick = insultionThickFromUser;
|
|
//}
|
|
rowIdx++;
|
|
}
|
|
|
|
{
|
|
double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
KMBIM.PipeMatchInterval.dirMpi.UserInsultionThick = insultionThickFromUser;
|
|
rowIdx++;
|
|
}
|
|
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.LeftMpiLst.Count(); i++)
|
|
{
|
|
//double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
//if (index == i)
|
|
//{
|
|
double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
KMBIM.PipeMatchInterval.LeftMpiLst[i].UserInsultionThick = insultionThickFromUser;
|
|
//}
|
|
rowIdx++;
|
|
}
|
|
//셀에 보여지는 순서가 반대라 역방향 한 것 되돌리기
|
|
KMBIM.PipeMatchInterval.RightMpiLst.Reverse();
|
|
}
|
|
else//정렬-수직
|
|
{
|
|
int rowIdx = 0;
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.UpMpiLst.Count(); i++)
|
|
{
|
|
//double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
//if (index == i)
|
|
//{
|
|
double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
KMBIM.PipeMatchInterval.UpMpiLst[i].UserInsultionThick = insultionThickFromUser;
|
|
//}
|
|
rowIdx++;
|
|
}
|
|
|
|
{
|
|
double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
KMBIM.PipeMatchInterval.dirMpi.UserInsultionThick = insultionThickFromUser;
|
|
rowIdx++;
|
|
}
|
|
|
|
for (int i = 0; i < KMBIM.PipeMatchInterval.DownMpiLst.Count(); i++)
|
|
{
|
|
//double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
//if (index == i)
|
|
//{
|
|
double insultionThickFromUser = double.Parse(dgv_PipeCheck.Rows[rowIdx].Cells[3].Value.ToString());
|
|
KMBIM.PipeMatchInterval.DownMpiLst[i].UserInsultionThick = insultionThickFromUser;
|
|
//}
|
|
rowIdx++;
|
|
}
|
|
//셀에 보여지는 순서가 반대라 역방향 한 것 되돌리기
|
|
KMBIM.PipeMatchInterval.UpMpiLst.Reverse();
|
|
}
|
|
|
|
|
|
offsetValue = double.Parse(txt_OffsetValue.Text);//간격 띄우기 입력값
|
|
|
|
Close();
|
|
}
|
|
|
|
private void dgv_PipeCheck_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
//라디오버튼 정렬방향 수평
|
|
private void Rad_HSort_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
m_RadIdx = 0;
|
|
Reg.setReg("MatchInterval_RadIdx", "0");
|
|
dgv_PipeCheckData();
|
|
}
|
|
//라디오버튼 정렬방향 수직
|
|
private void Rad_VSort_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
m_RadIdx = 1;
|
|
Reg.setReg("MatchInterval_RadIdx", "1");
|
|
dgv_PipeCheckData();
|
|
}
|
|
|
|
private void txt_OffsetValue_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (double.TryParse(txt_OffsetValue.Text, out offsetValue) == false) offsetValue = 0;
|
|
else
|
|
{
|
|
Reg.setReg("MatchInterval_Offset", txt_OffsetValue.Text);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void SetOffset_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Escape)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
else if (e.KeyCode == Keys.Enter)
|
|
{
|
|
this.DialogResult = DialogResult.OK;
|
|
}
|
|
}
|
|
}
|
|
} |