void CreatePolki(string value) { string outStr = ""; try { //if (textBox5.Text != value) //{ // if (stroka3 != "") // { // value = stroka3; // stroka3 = ""; // } // textBox5.Text = value; //} string[] temp1 = textBox5.Text.Trim().Split(new Char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < temp1.Length; i++) { string H = temp1[i].Replace("н", "").Split(new Char[1] { '(' })[0]; int col = 0; try { col = int.Parse(SuperStr.SubString(temp1[i], "(", ")")); } catch { } if (col == 0) { continue; } outStr += "н" + H.ToString().Trim() + "("; float nisha = (float)Decimal.Round((decimal)((float.Parse(H) - (col * 18)) / (col + 1)), 1); for (int j = 1; j < col + 1; j++) { outStr += (float.Parse(polki[i].ToString().Replace(",", ".")) - 18 + (nisha + 18) * j).ToString(); if (col != j) { outStr += ";"; } } outStr += ")"; if (i != temp1.Length - 1) { outStr += "; "; } } } catch { } fullDraw(outStr); }
void load() { polki = new ArrayList(); urovni = new ArrayList(); int heightPenal = getint(form1.getHpenal() * 0.3f); int nullpos = heightPenal + 20; int widthPenal = getint(form1.getWpenal() * 0.3f); int xnul = getint(panel1.Width / 2 - widthPenal / 2); #region Фасады if (form1.fasadi != null) { for (int i = 0; i < form1.fasadi.Count; i++) { string[] temp = form1.fasadi[i].ToString().Replace("ф", "").Split('-'); float y = float.Parse(temp[0]); float высота = float.Parse(temp[1]); int top = getint(y * 0.3f); int height = getint(высота * 0.3f); panel1.Controls.Add(new blok(высота, y) { Left = xnul + 1, Top = nullpos - top - height, Width = widthPenal - 2, Height = height, BackColor = System.Drawing.Color.Linen, BorderStyle = BorderStyle.FixedSingle }); } } #endregion panel1.Controls.Add(new Panel() { Left = xnul, Top = nullpos - heightPenal, Width = 6, Height = heightPenal, BackColor = System.Drawing.Color.Linen, BorderStyle = BorderStyle.FixedSingle }); panel1.Controls.Add(new Panel() { Left = xnul + widthPenal - 6, Top = nullpos - heightPenal, Width = 6, Height = heightPenal, BackColor = System.Drawing.Color.Linen, BorderStyle = BorderStyle.FixedSingle }); #region Уровни tex_urovni = new PolikTipView[form1.arrUrovni.Count]; if (form1.arrUrovni != null) { for (int i = 0; i < form1.arrUrovni.Count; i++) { float urr = float.Parse(form1.arrUrovni[i].ToString().Replace(",", ".")); urovni.Add(urr); int top = getint(urr * 0.3f); panel1.Controls.Add(new Panel() { Left = xnul + 6, Top = nullpos - top - 3, Width = widthPenal - 12, Height = 6, BackColor = System.Drawing.Color.Linen, BorderStyle = BorderStyle.FixedSingle, AccessibleName = "полки" }); tex_urovni[i] = new PolikTipView() { Left = xnul + widthPenal + 5, Top = nullpos - top - 8 }; panel1.Controls.Add(tex_urovni[i]); } } #endregion #region Полки try { string[] newStrokaPolki = SuperStr.SubStrings(form1.textBox6.Text, "(", ")", SubStringsOptions.RemoveEmptyEntries); foreach (string i in newStrokaPolki) { string[] temp = i.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string v in temp) { try { float urovenR = float.Parse(v); float urovenL = urovenR; polki.Add(urovenR); int top = getint(urovenR * 0.3f); panel1.Controls.Add(new Panel() { Left = xnul + 7, Top = nullpos - top - 6, Width = widthPenal - 14, Height = 6, BackColor = System.Drawing.Color.Linen, BorderStyle = BorderStyle.FixedSingle, AccessibleName = "полки" }); } catch { } } } } catch { } #endregion }
void createNishiPolok() { polki = new ArrayList(); ArrayList fullUrovni = new ArrayList(); if (textBox8.Text == "") { return; } string[] уровниМасс = textBox8.Text.ToLower().Replace('.', ',').Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); fullUrovni.Add(-9); foreach (string v in уровниМасс) { fullUrovni.Add(v); } fullUrovni.Add((getHpenal() + 9).ToString()); ArrayList nishiPolok = new ArrayList(); string outString = ""; for (int i = 0; i < fullUrovni.Count - 1; i++) { try { float max = float.Parse(fullUrovni[i + 1].ToString().Replace(",", ".")); float min = float.Parse(fullUrovni[i].ToString().Replace(",", ".")); float H = (float)Math.Round(max - min - 18); if (H < 50) { continue; } int col = 0; if (H > 500) { col++; } if (H > 800) { col++; } if (H > 1150) { col++; } for (int j = 0; j < nishi.Count; j++) { float getUroven = float.Parse(SuperStr.SubString(nishi[j].ToString(), "н", "-")); if (getUroven < float.Parse(fullUrovni[i + 1].ToString().Replace(",", ".")) && getUroven > float.Parse(fullUrovni[i].ToString().Replace(",", "."))) { col = 0; break; } } polki.Add(Math.Floor(float.Parse(fullUrovni[i].ToString().Replace(",", "."))) + 9); outString += "н" + H.ToString() + "(" + col.ToString() + "); "; } catch { } } if (stroka3 != null) { outString = stroka3; stroka3 = null; } if (textBox5.Text == outString) { CreatePolki(outString); } textBox5.Text = outString; //CreatePolki(outString); }
void DrawPotok(Object formObj) { SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1); Form1 form = (Form1)formObj; Bitmap img = new Bitmap(1260, 1782); Graphics g = Graphics.FromImage(img); form.Лприсадка = new ArrayList(); form.Пприсадка = new ArrayList(); g.Clear(Color.White); try { float getWpenal = form.getWpenal(); float getHpenal = form.getHpenal(); string strPenal = form.textBox3.Text; string strPolki = form.textBox5.Text; string strHpenal = form.textBox1.Text; bool chekRight = form.checkBox1.Checked; bool chekLeft = form.checkBox2.Checked; if (strPenal == "" || strPolki == "") { return; } if (form.arrUrovni == null && form.fasadi == null && form.nishi == null) { return; } int drawTip = 0; string[] separator = new string[1] { "-" }; if (chekRight && !chekLeft) { drawTip = 1; } if (!chekRight && chekLeft) { drawTip = 2; } if (chekRight && chekLeft) { drawTip = 3; } if (getHpenal > 0 && strHpenal != "") { if (getHpenal != float.Parse(strHpenal)) { g.Clear(Color.White); g.DrawString("Построение невозможно, не хватает высоты!", new Font("Arial", 25, FontStyle.Bold), Brushes.Red, 280, 10); form.pictureBox1.Image = new Bitmap(img, 489, 692); g.Clear(Color.White); return; } else { form.label5.Text = ""; } } if (strHpenal == "") { form.label5.Text = ""; } Font font1 = new System.Drawing.Font("Arial", 20, FontStyle.Regular); string info = ""; string[] tempInfo = strPenal.Split(separator, StringSplitOptions.None); float hPenalStr = 0; string[] values = strPenal.Replace('.', ',').Replace("з", "").Replace("н", "").Replace("ф", "").Split(separator, StringSplitOptions.None); foreach (string v in values) { try { hPenalStr += float.Parse(v); } catch { } } if (!chekRight) { form.Пприсадка.Add(new деталь("9", "дно")); } if (!chekLeft) { form.Лприсадка.Add(new деталь("9", "дно")); } for (int i = 0; i < tempInfo.Length; i++) { if (tempInfo[i].Replace("ф", "").Replace("н", "").Replace("з", "").Trim() == "") { try { float zazor = getHpenal - hPenalStr; if (zazor < 0) { g.Clear(Color.White); g.DrawString("Построение невозможно, не хватает высоты!", new Font("Arial", 25, FontStyle.Bold), Brushes.Red, 280, 10); form.pictureBox1.Image = new Bitmap(img, 489, 692); g.Clear(Color.White); return; } tempInfo[i] += zazor.ToString(); } catch { } } info += tempInfo[i]; if (i != tempInfo.Length - 1) { info += "-"; } } info = info.Replace("з", "").ToUpper(); info += " (" + getHpenal.ToString() + ")"; if (form.textBox4.Text != "") { info += " " + form.textBox4.Text; } g.DrawString(info, font1, Brushes.Black, 10, 10); double pixel = img.Height * 0.9 / getHpenal; for (; ;) { if (img.Width * 0.6 < getWpenal * pixel) { pixel = pixel * 0.9; } else { break; } } int nuulPointY = img.Height - (img.Height - (int)Math.Round(getHpenal * pixel)) / 2; int nuulPointX = (img.Width - ((int)Math.Round(getWpenal * pixel))) / 2; int minusH1 = 19; int minusH2 = 19; if (chekLeft) { minusH1 = 2; } if (chekRight) { minusH2 = 2; } g.DrawRectangle(new Pen(Brushes.Black, 3), nuulPointX, nuulPointY - (int)Math.Round((getHpenal - 0.5f) * pixel), (int)Math.Round(pixel * 18), (int)Math.Round((getHpenal - minusH1) * pixel)); g.DrawRectangle(new Pen(Brushes.Black, 3), nuulPointX + (int)Math.Round((getWpenal - 18) * pixel), nuulPointY - (int)Math.Round((getHpenal - 0.5f) * pixel), (int)Math.Round(pixel * 18), (int)Math.Round((getHpenal - minusH2) * pixel)); #region Щиты if (form.arrUrovni != null) { for (int i = 0; i < form.arrUrovni.Count; i++) { int tols = 18; float wPolik = getWpenal - 36; if (i == 0) { switch (drawTip) { case 0: tols = 0; wPolik += 36; break; case 1: tols = 0; wPolik += 18; break; case 2: tols = 18; wPolik += 18; break; } } g.DrawRectangle(new Pen(Brushes.Black, 3), nuulPointX + (int)Math.Round(tols * pixel), nuulPointY - (int)Math.Round((float.Parse(form.arrUrovni[i].ToString()) + 9) * pixel), (int)Math.Round((wPolik) * pixel), (int)Math.Round(18 * pixel)); Point point1 = new Point(nuulPointX + (int)Math.Round((getWpenal - 18) * pixel), nuulPointY - (int)Math.Round(float.Parse(form.arrUrovni[i].ToString()) * pixel)); Point point2 = new Point((int)Math.Round(img.Width * 0.85), nuulPointY - (int)Math.Round(float.Parse(form.arrUrovni[i].ToString()) * pixel)); Point point3 = new Point((int)Math.Round(img.Width * 0.15), nuulPointY - (int)Math.Round(float.Parse(form.arrUrovni[i].ToString()) * pixel)); Point point4 = new Point(nuulPointX + (int)Math.Round(18 * pixel), nuulPointY - (int)Math.Round(float.Parse(form.arrUrovni[i].ToString()) * pixel)); float urovenR = float.Parse(form.arrUrovni[i].ToString()); if (!chekRight) { g.DrawLine(Pens.Black, new Point(point1.X, nuulPointY - (int)Math.Round(18 * pixel)), new Point(point2.X, nuulPointY - (int)Math.Round(18 * pixel))); urovenR -= 18; } else { g.DrawLine(Pens.Black, new Point(point1.X, nuulPointY), new Point(point2.X, nuulPointY)); } if (i != 0 || chekRight) { g.DrawString(urovenR.ToString(), font1, Brushes.Black, new Point((int)Math.Round(img.Width * 0.85), (int)point1.Y)); g.DrawLine(Pens.Black, point1, point2); } if (urovenR > 0) { form.Пприсадка.Add(new деталь(urovenR.ToString(), "щит")); } float urovenL = float.Parse(form.arrUrovni[i].ToString()); if (!chekLeft) { urovenL -= 18; } if (chekRight != chekLeft) { if (!chekLeft) { g.DrawLine(Pens.Black, new Point(point3.X, nuulPointY - (int)Math.Round(18 * pixel)), new Point(point4.X, nuulPointY - (int)Math.Round(18 * pixel))); } else { g.DrawLine(Pens.Black, new Point(point3.X, nuulPointY), new Point(point4.X, nuulPointY)); } if (i != 0 || chekLeft) { g.DrawString(urovenL.ToString(), font1, Brushes.Black, new Point((int)Math.Round(img.Width * 0.07), (int)point1.Y)); g.DrawLine(Pens.Black, point3, point4); } } if (urovenL > 0) { form.Лприсадка.Add(new деталь(urovenL.ToString(), "щит")); } } } #endregion #region Полки try { string[] newStrokaPolki = SuperStr.SubStrings(form.textBox6.Text, "(", ")", SubStringsOptions.RemoveEmptyEntries); foreach (string i in newStrokaPolki) { string[] temp = i.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string v in temp) { try { float urovenR = float.Parse(v); float urovenL = urovenR; g.DrawRectangle(new Pen(Brushes.Black, 3), nuulPointX + (int)Math.Round(18 * pixel), nuulPointY - (int)Math.Round((urovenR + 18) * pixel), (int)Math.Round((getWpenal - 36) * pixel), (int)Math.Round(18 * pixel)); Point point1 = new Point(nuulPointX + (int)Math.Round((getWpenal - 18) * pixel), nuulPointY - (int)Math.Round(urovenR * pixel)); Point point2 = new Point((int)Math.Round(img.Width * 0.85), nuulPointY - (int)Math.Round(urovenR * pixel)); Point point3 = new Point((int)Math.Round(img.Width * 0.15), nuulPointY - (int)Math.Round(urovenL * pixel)); Point point4 = new Point(nuulPointX + (int)Math.Round(18 * pixel), nuulPointY - (int)Math.Round(urovenL * pixel)); if (!chekRight) { urovenR -= 18; } g.DrawString(urovenR.ToString() + "(полка)", font1, Brushes.Black, new Point((int)Math.Round(img.Width * 0.83), (int)point1.Y)); g.DrawLine(Pens.Black, point1, point2); if (!chekLeft) { urovenL -= 18; } if (chekRight != chekLeft) { g.DrawString(urovenL.ToString() + "(полка)", font1, Brushes.Black, new Point((int)Math.Round(img.Width * 0.05), (int)point1.Y)); g.DrawLine(Pens.Black, point3, point4); } form.Лприсадка.Add(new деталь(urovenL.ToString(), "полка")); form.Пприсадка.Add(new деталь(urovenR.ToString(), "полка")); } catch { } } } } catch { } #endregion #region Фасады if (form.fasadi != null) { for (int i = 0; i < form.fasadi.Count; i++) { try { string tekValue = form.fasadi[i].ToString().Replace("ф", ""); float H = float.Parse(tekValue.Split(separator, StringSplitOptions.None)[1]); float pointH = float.Parse(tekValue.Split(separator, StringSplitOptions.None)[0]); g.DrawRectangle(new Pen(Brushes.Black, 1), nuulPointX + (int)Math.Round(4 * pixel), nuulPointY - (int)Math.Round((pointH + H - 2) * pixel), (int)Math.Round((getWpenal - 8) * pixel), (int)Math.Round((H - 4) * pixel)); g.DrawString("ф" + H.ToString(), new Font("Arial", 35, FontStyle.Italic), Brushes.Black, new Point((img.Width / 2 - 50), (int)(img.Height / 2 + (getHpenal / 2 - pointH - H / 2) * pixel))); } catch { } } } #endregion #region Ниши if (form.nishi != null) { for (int i = 0; i < form.nishi.Count; i++) { try { string tekValue = form.nishi[i].ToString().Replace("н", ""); float H = float.Parse(tekValue.Split(separator, StringSplitOptions.None)[1]); float pointH = float.Parse(tekValue.Split(separator, StringSplitOptions.None)[0]); g.DrawString("ниша" + H.ToString(), new Font("Arial", 35, FontStyle.Italic), Brushes.Black, new Point((img.Width / 2 - 80), (int)(img.Height / 2 + (getHpenal / 2 - pointH) * pixel))); } catch { } } } #endregion } catch { } try { form.pictureBox1.Image = new Bitmap(img, 489, 692); form.img = new Bitmap(img); } catch { } }