/* private void setStartRectangle() { int area = 0, nr = 0; for (int i = 0; i < this.rectangles.Count; ++i) { int area1 = this.Rectangles[i].Width * this.Rectangles[i].Height; if (area1 > area) { area = area1; nr = i; } } Data.Rectangle rectangle = this.rectangles[nr]; Console.Out.WriteLine("StartRectangle: " + rectangle.Width + " : " + rectangle.Height); this.rectangles.RemoveAt(nr); this.startRectangle = rectangle; this.w = rectangle.Width; this.h = rectangle.Height; } private void sortRectangle() { List<Data.Rectangle> listSorted = new List<taio.Data.Rectangle>(); for (int i = 0; i < rectangles.Count; ++i) { Data.Rectangle rect = rectangles[i]; if (rect.Width < rect.Height) { int k = rect.Width; rect.Width = rect.Height; rect.Height = k; } int j = 0; for (j = 0; j < listSorted.Count; ++j) { if (listSorted[j].Width < rect.Width) { listSorted.Insert(j, rect); break; } if (listSorted[j].Width == rect.Width && listSorted[j].Height < rect.Height) { listSorted.Insert(j, rect); break; } } if (j == listSorted.Count) listSorted.Add(rect); } rectangles = listSorted; } */ private void saveSolution() { this.Solution.PartsOfSolution = new List<taio.Data.PartOfSolution>(); Data.PartOfSolution part = new taio.Data.PartOfSolution(); part.Xlu = 0; part.Ylu = 0; part.Xrd = this.startRectangle.Width; part.Yrd = this.startRectangle.Height; this.Solution.PartsOfSolution.Add(part); for (int i = 0; i < this.listLayer.Count; ++i) { for (int j = 0; j < this.listLayer[i].ListPartOfSolution.Count; ++j) { this.Solution.PartsOfSolution.Add(this.listLayer[i].ListPartOfSolution[j]); } } }
private void btnSave_Click(object sender, EventArgs e) { bool flag; if (rectangles.Count == 0) return; if((ratio2<0.5)||(ratio2>2)) { MessageBox.Show("Zbudowany prostok�t ma niepoprawny stosunek szeroko�ci do wysoko�ci.\n Warto�� ta musi by� sprzedzia�u [0.5, 2]"); return; } int xIndex, yIndex,x2,y2,x1,y1; for (xIndex=0;xIndex<=x;xIndex++) for (yIndex=0; yIndex <= y; yIndex++) { flag = false; foreach (GUI.rectangle r in rectangles) { x1 = r.Location.X; y1 = r.Location.Y; x2 = r.Width + r.Location.X; y2 = r.Height + r.Location.Y; if (((x1 <= xIndex) && (xIndex <= x2)) && ((y1 <= yIndex) && (yIndex <= y2))) { flag = true; break; } } if (!flag) { MessageBox.Show("Prosz� pokry� dok�adnie ��ty prostok�t !"); return; } } Data.Solution sol = new taio.Data.Solution(false); sol.Tag = txtName.Text; foreach (GUI.rectangle r in rectangles) { x1 = (int)Math.Round((r.Location.X/factor),0); y1 = (int)Math.Round((r.Location.Y / factor),0); x2 = (int)Math.Round(((r.Width + r.Location.X) / factor),0); y2 = (int)Math.Round(((r.Height + r.Location.Y) / factor),0); Data.PartOfSolution part = new taio.Data.PartOfSolution(); part.Xlu = x1; part.Ylu = y1; part.Xrd = x2; part.Yrd = y2; sol.PartsOfSolution.Add(part); } mainFrm.Engine.Solutions.Add(sol); MessageBox.Show("Stworzono nowe rozwi�zanie."); if (mainFrm.solutionsFrm != null && mainFrm.solutionsFrm.Visible) mainFrm.solutionsFrm.CreateTabs(); }