private void MouseDblClkProc_XayDungLuoiLoMin(int hWnd, int Button, int Flags, int Xwin, int Ywin, double Xdrw, double Ydrw) { int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL); if (mgCircles == null) { mgCircles = new ManageCircle(); } else { Lcad.LayerClear(layerLoMin, hBlockModel); Lcad.LayerClear(layerLuoiKichThuoc, hBlockModel); mgCircles = new ManageCircle(); } int hEntCircle = Lcad.BlockAddCircle(hBlockModel, Xdrw, Ydrw, banKinh, false); Lcad.PropPutInt(hEntCircle, Lcad.LC_PROP_ENT_KEY, keyCircle); Lcad.PropPutStr(hEntCircle, Lcad.LC_PROP_ENT_LAYER, "LoMin"); Lcad.BlockUnselect(hBlockModel); //tạo danh sách cột đầu tiên List<Circle> listCotDau = new List<Circle>(); Circle root = new Circle(hEntCircle); listCotDau.Add(root); //tạo cột đầu tiên từ điểm gốc (số điểm trong cột ứng với số hàng trừ đi điểm gốc) for (int i = 0; i < soHang - 1; i++) { int newHEnt = Lcad.BlockAddClone(hBlockModel, listCotDau[i].GetHandle()); Lcad.PropPutInt(newHEnt, Lcad.LC_PROP_ENT_KEY, keyCircle); Lcad.BlockSelectEnt(hBlockModel, newHEnt, true); Lcad.BlockSelMove(hBlockModel, 0, khoangCachHang, false, true); Lcad.BlockUnselect(hBlockModel); listCotDau.Add(new Circle(newHEnt)); } mgCircles.AddListCircle(listCotDau); //thêm các cột còn lại (ứng với số cột trừ đi cột đầu) for (int i = 0; i < soCot - 1; i++) { List<Circle> listCotGanNhat = new List<Circle>(); List<Circle> listCotMoi = new List<Circle>(); if (khoangCachCot > 0) { listCotGanNhat = mgCircles.GetListCirleOfLastColumn(); } else { listCotGanNhat = mgCircles.GetListCirleOfFirstColumn(); } foreach (var circle in listCotGanNhat) { int newHEnt = Lcad.BlockAddClone(hBlockModel, circle.GetHandle()); Lcad.PropPutInt(newHEnt, Lcad.LC_PROP_ENT_KEY, keyCircle); Lcad.BlockSelectEnt(hBlockModel, newHEnt, true); Lcad.BlockSelMove(hBlockModel, khoangCachCot, 0, false, true); Lcad.BlockUnselect(hBlockModel); listCotMoi.Add(new Circle(newHEnt)); } mgCircles.AddListCircle(listCotMoi); } //hiển thị lưới kích thước if (this.banVeChinh.HienKhoangCach) { DungLuoiKichThuoc(); } //load lại //MessageBox.Show("hang" + soHang + "\ncot" + soCot + "\nkc hang" + khoangCachHang + "\nkc cot" + khoangCachCot + "\nX" + Xdrw + "\nY" + Ydrw); Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); Lcad.OnEventMouseDblClk(_EventMouseDbclick_LoMin); LuuHoChieu(this.hoChieuChinh.MaHoChieu); //ăn gian... BS_LiteCAD.ShowNotifyAutoHide(elementHost1, "Xây dựng lưới lỗ khoan - hoàn thành"); }
//hiện thông báo //private void ShowNotifyAutoHide(String text) //{ // UserControl_Notify note = new UserControl_Notify(text); // elementHost1.Child = note; // note.ShowNotifyAutoHide(); //} //lấy danh sách lỗ khoan trên bản vẽ private void GetCirlcesFromAutocadFile() { int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL); int hEnt = Lcad.BlockGetFirstEnt(hBlockModel); List<Circle> listCircles = new List<Circle>(); while (hEnt != 0) { int entType = Lcad.PropGetInt(hEnt, Lcad.LC_PROP_ENT_TYPE); if (!Lcad.PropGetBool(hEnt, Lcad.LC_PROP_ENT_DELETED)) //kiểm tra xem ent bị xóa hay không { if (entType == Lcad.LC_ENT_CIRCLE) { listCircles.Add(new Circle(hEnt)); } //cách khác (dùng key, vì cái gì đấy mà ko lấy được LC_PROP_ENT_TYPE) - do thư viện.... else { int _key = Lcad.PropGetInt(hEnt, Lcad.LC_PROP_ENT_KEY); if (_key == keyCircle) { listCircles.Add(new Circle(hEnt)); } } } hEnt = Lcad.BlockGetNextEnt(hBlockModel, hEnt); } mgCircles = new ManageCircle(); mgCircles.AddListCircle(listCircles); }
private void loadFile_FormMoBanVeDatabase(String idHoChieu) { this.hoChieuChinh = BS_HoChieu.HoChieu(idHoChieu); this.banVeChinh = BS_BanVe.BanVe(this.hoChieuChinh.MaBanVe); List<LoKhoan> danhSachLoKhoan = BS_LoKhoan.DanhSachLoKhoan(idHoChieu); List<Circle> danhSachCircle = new List<Circle>(); mgCircles = new ManageCircle(); //dựng bản vẽ mới //this.banVeChinh.HienKhoangCach = false; this.Text = "Bản vẽ: [" + this.banVeChinh.TenBanVe + "]"; Lcad.DrwLoad(hDrw, BS_Template.ChonTemplate(this.banVeChinh.Template).DuongDan, this.Handle, hWnd); layerLoMin = Lcad.DrwAddLayer(hDrw, "LoMin", "cyan", 0, Lcad.LC_LWEIGHT_DEFAULT); layerLuoiKichThuoc = Lcad.DrwAddLayer(hDrw, "LuoiKichThuoc", "foreground", 0, Lcad.LC_LWEIGHT_DEFAULT); int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL); foreach (LoKhoan value in danhSachLoKhoan) { int hEntCircle = Lcad.BlockAddCircle(hBlockModel, value.ToaDoX, value.ToaDoY, value.BanKinh, false); Lcad.PropPutInt(hEntCircle, Lcad.LC_PROP_ENT_ID, int.Parse(value.MaLoKhoan)); Lcad.PropPutInt(hEntCircle, Lcad.LC_PROP_ENT_KEY, keyCircle); Lcad.PropPutStr(hEntCircle, Lcad.LC_PROP_ENT_LAYER, "LoMin"); danhSachCircle.Add(new Circle(hEntCircle)); } mgCircles.AddListCircle(danhSachCircle); if (banVeChinh.HienKhoangCach) { Lcad.LayerClear(layerLuoiKichThuoc, hBlockModel); DungLuoiKichThuoc(); } //vẽ lại hình Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); BS_LiteCAD.ShowNotifyAutoHide(elementHost1, this.banVeChinh.TenBanVe + " - đã mở"); //mở form dựng lưới lỗ khoan if(mgCircles.GetListCircles().Count == 0) { FormXayDungLoKhoan fm = new FormXayDungLoKhoan(); fm.MyGetData = new FormXayDungLoKhoan.GetData(loadFile_FormXayDungLoKhoan); fm.Show(); } }
private void barButtonItem_Move_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //select toàn bộ lỗ khoan int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL); int hEnt = Lcad.BlockGetFirstEnt(hBlockModel); List<Circle> listCircles = new List<Circle>(); while (hEnt != 0) { int entType = Lcad.PropGetInt(hEnt, Lcad.LC_PROP_ENT_TYPE); if (!Lcad.PropGetBool(hEnt, Lcad.LC_PROP_ENT_DELETED)) //kiểm tra xem ent bị xóa hay không { if (entType == Lcad.LC_ENT_CIRCLE) { Lcad.BlockSelectEnt(hBlockModel, hEnt, true); } //cách khác (dùng key, vì cái gì đấy mà ko lấy được LC_PROP_ENT_TYPE) - do thư viện.... else { int _key = Lcad.PropGetInt(hEnt, Lcad.LC_PROP_ENT_KEY); if (_key == keyCircle) { Lcad.BlockSelectEnt(hBlockModel, hEnt, true); } } } hEnt = Lcad.BlockGetNextEnt(hBlockModel, hEnt); } //chạy hàm move bool flag = Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_MOVE, 0); if (flag) { mgCircles = new ManageCircle(); GetCirlcesFromAutocadFile(); if (this.banVeChinh.HienKhoangCach) { DungLuoiKichThuoc(); } } }
private void loadFile_FormBanVeMoi(String idHoChieu) { this.hoChieuChinh = BS_HoChieu.HoChieu(idHoChieu); this.banVeChinh = BS_BanVe.BanVe(this.hoChieuChinh.MaBanVe); mgCircles = new ManageCircle(); //dựng bản vẽ mới this.Text = "Hộ chiếu: [" + this.hoChieuChinh.TenHoChieu + "]"; Lcad.DrwLoad(hDrw, BS_Template.ChonTemplate(this.banVeChinh.Template).DuongDan, this.Handle, hWnd); layerLoMin = Lcad.DrwAddLayer(hDrw, "LoMin", "cyan", 0, Lcad.LC_LWEIGHT_DEFAULT); layerLuoiKichThuoc = Lcad.DrwAddLayer(hDrw, "LuoiKichThuoc", "foreground", 0, Lcad.LC_LWEIGHT_DEFAULT); //vẽ lại hình Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); //mở form dựng lưới lỗ khoan if (mgCircles.GetListCircles().Count == 0) { FormXayDungLoKhoan fm = new FormXayDungLoKhoan(); fm.MyGetData = new FormXayDungLoKhoan.GetData(loadFile_FormXayDungLoKhoan); fm.Show(); } }
private void barButtonItem_DauSongSong_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ManageCircle temp = new ManageCircle(); temp = mgCircles; List<Circle> firstCollum = temp.GetListCirleOfFirstColumn(); List<Circle> lastCollum = temp.GetListCirleOfLastColumn(); int rowNumber = temp.GetRowCount(); double sumY1 = 0, sumY2 = 0; double x1 = 0, y1 = 0, x2 = 0, y2 = 0; foreach (Circle c in firstCollum) { x1 = c.GetX(); sumY1 += c.GetY(); } foreach (Circle c in lastCollum) { x2 = c.GetX(); sumY2 += c.GetY(); } y1 = y2 = sumY1 / rowNumber; x1 = x1 - banVeChinh.DeltaX; x2 = x2 + banVeChinh.DeltaX; foreach(Circle c in firstCollum) { DrawLine(c.GetX(), c.GetY(), x1, y1); } foreach (Circle c in lastCollum) { DrawLine(c.GetX(), c.GetY(), x2, y2); } int lineIndex = 1; do { List<Circle> currentRow = temp.GetListCircleRow(lineIndex); for (int i = 0; i < currentRow.Count - 1; i++) { DrawLine_X(currentRow[i], currentRow[i + 1]); } lineIndex++; //temp.RemoveListCircles(currentRow); } while (lineIndex <= temp.GetRowCount()); Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); }
private void barButtonItem_DauNoiTiep_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ManageCircle temp = new ManageCircle(); temp = mgCircles; int lineIndex = 1; do { List<Circle> currentRow = temp.GetListCircleRow(lineIndex); for (int i = 0; i < currentRow.Count - 1; i++) { DrawLine_X(currentRow[i], currentRow[i + 1]); } if(lineIndex % 2 != 0) { List<Circle> currentCollum = temp.GetListCirleOfLastColumn(); if(currentCollum.Count > 1) { DrawLine_Y(currentCollum[0], currentCollum[1]); } } else { List<Circle> currentCollum = temp.GetListCirleOfFirstColumn(); if (currentCollum.Count > 1) { DrawLine_Y(currentCollum[0], currentCollum[1]); } } //temp.RemoveListCircles(currentRow); lineIndex++; } while (lineIndex <= temp.GetRowCount()); Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); }
private void MouseDblClkProc_XayDungLuoiLoMin(int hWnd, int Button, int Flags, int Xwin, int Ywin, double Xdrw, double Ydrw) { if (mgCircles == null) { mgCircles = new ManageCircle(); } int hModelBlock = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL); double r = 0.5; int hEntCircle = Lcad.BlockAddCircle(hModelBlock, Xdrw, Ydrw, r, false); Lcad.BlockUnselect(hModelBlock); // Add a column of new Circles List<Circle> listCotDau = new List<Circle>(); Circle root = new Circle(hEntCircle); listCotDau.Add(root); //Them hang //khoangCachHang = khoangCachHang * -1; for (int i = 0; i < soHang - 1; i++) { int newHEnt = Lcad.BlockAddClone(hModelBlock, listCotDau[i].GetHandle()); Lcad.BlockSelectEnt(hModelBlock, newHEnt, true); Lcad.BlockSelMove(hModelBlock, 0, khoangCachHang, false, true); Lcad.BlockUnselect(hModelBlock); listCotDau.Add(new Circle(newHEnt)); } mgCircles.AddListCircle(listCotDau); //Them cot for (int i = 0; i < soCot - 1; i++) { List<Circle> listCotGanNhat = new List<Circle>(); List<Circle> listCotMoi = new List<Circle>(); if (khoangCachCot > 0) { listCotGanNhat = mgCircles.GetListCirleOfLastColumn(); } else { listCotGanNhat = mgCircles.GetListCirleOfFirstColumn(); } foreach (var circle in listCotGanNhat) { int newHEnt = Lcad.BlockAddClone(hModelBlock, circle.GetHandle()); Lcad.BlockSelectEnt(hModelBlock, newHEnt, true); Lcad.BlockSelMove(hModelBlock, khoangCachCot, 0, false, true); Lcad.BlockUnselect(hModelBlock); listCotMoi.Add(new Circle(newHEnt)); } mgCircles.AddListCircle(listCotMoi); } MessageBox.Show("hang" + soHang + "\ncot" + soCot + "\nkc hang" + khoangCachHang + "\nkc cot" + khoangCachCot + "\nX" + Xdrw + "\nY" + Ydrw); Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); Lcad.OnEventMouseDblClk(_EventMouseDbclick_LoMin); }
private void LoadFile_FormStart(String id, String path) { if (id.Equals("-1")) { mgCircles = new ManageCircle(); this.Text = path; this.nameOfBlock = 1; Lcad.DrwLoad(hDrw, path, this.Handle, hWnd); Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); } else { //lấy danh sách lỗ khoan List<LoKhoan> danhSachLoKhoan = BS_LoKhoan.DanhSachLoKhoan(id); this.Text = path; this.nameOfBlock = 1; Lcad.DrwLoad(hDrw, path, this.Handle, hWnd); int hBlockModel = Lcad.PropGetHandle(hDrw, Lcad.LC_PROP_DRW_BLOCK_MODEL); foreach (LoKhoan value in danhSachLoKhoan) { int maLK = int.Parse(value.MaLoKhoan); int x = int.Parse(value.ToaDoX.ToString()); int y = int.Parse(value.ToaDoY.ToString()); double r = value.BanKinh; int hEntCircle = Lcad.BlockAddCircle(hBlockModel, x, y, r, false); Lcad.PropPutInt(hEntCircle, Lcad.LC_PROP_ENT_ID, maLK); } Lcad.DrwRegenViews(hDrw, 0); Lcad.WndExeCommand(hWnd, Lcad.LC_CMD_ZOOM_EXT, 0); //getCircleFromAutocadFile(); } }