From 70e58e492be60e1fb35005dd3241427520c0e187 Mon Sep 17 00:00:00 2001 From: GREMIAR <70177742+GREMIAR@users.noreply.github.com> Date: Sun, 11 Jul 2021 00:24:30 +0300 Subject: [PATCH] fix --- Charts/MainForm.Designer.cs | 57 ++++++++++++++++--------------- Charts/MainForm.cs | 68 ++++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 59 deletions(-) diff --git a/Charts/MainForm.Designer.cs b/Charts/MainForm.Designer.cs index 8caf695..e8fe184 100644 --- a/Charts/MainForm.Designer.cs +++ b/Charts/MainForm.Designer.cs @@ -28,10 +28,10 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.AreaPaint = new System.Windows.Forms.PictureBox(); this.viewTable = new System.Windows.Forms.Panel(); @@ -167,20 +167,20 @@ private void InitializeComponent() // // nowTable // - dataGridViewCellStyle19.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(218)))), ((int)(((byte)(189)))), ((int)(((byte)(171))))); - dataGridViewCellStyle19.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(218)))), ((int)(((byte)(189)))), ((int)(((byte)(171))))); - dataGridViewCellStyle19.SelectionForeColor = System.Drawing.Color.WhiteSmoke; - this.nowTable.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle19; + dataGridViewCellStyle23.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(218)))), ((int)(((byte)(189)))), ((int)(((byte)(171))))); + dataGridViewCellStyle23.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(218)))), ((int)(((byte)(189)))), ((int)(((byte)(171))))); + dataGridViewCellStyle23.SelectionForeColor = System.Drawing.Color.WhiteSmoke; + this.nowTable.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle23; this.nowTable.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(205)))), ((int)(((byte)(184))))); this.nowTable.BorderStyle = System.Windows.Forms.BorderStyle.None; - dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle20.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(168)))), ((int)(((byte)(148))))); - dataGridViewCellStyle20.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(254))); - dataGridViewCellStyle20.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle20.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle20.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle20.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.nowTable.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle20; + dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle24.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(168)))), ((int)(((byte)(148))))); + dataGridViewCellStyle24.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(254))); + dataGridViewCellStyle24.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle24.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle24.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle24.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.nowTable.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle24; this.nowTable.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.nowTable.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column1, @@ -402,19 +402,19 @@ private void InitializeComponent() // // tableA // - dataGridViewCellStyle17.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(218)))), ((int)(((byte)(189)))), ((int)(((byte)(171))))); - dataGridViewCellStyle17.SelectionBackColor = System.Drawing.Color.DarkTurquoise; - dataGridViewCellStyle17.SelectionForeColor = System.Drawing.Color.WhiteSmoke; - this.tableA.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle17; + dataGridViewCellStyle21.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(218)))), ((int)(((byte)(189)))), ((int)(((byte)(171))))); + dataGridViewCellStyle21.SelectionBackColor = System.Drawing.Color.DarkTurquoise; + dataGridViewCellStyle21.SelectionForeColor = System.Drawing.Color.WhiteSmoke; + this.tableA.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle21; this.tableA.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(205)))), ((int)(((byte)(184))))); - dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle18.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(168)))), ((int)(((byte)(148))))); - dataGridViewCellStyle18.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(254))); - dataGridViewCellStyle18.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle18.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle18.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.tableA.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle18; + dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle22.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(168)))), ((int)(((byte)(148))))); + dataGridViewCellStyle22.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(254))); + dataGridViewCellStyle22.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle22.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle22.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle22.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.tableA.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle22; this.tableA.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.tableA.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, @@ -827,6 +827,7 @@ private void InitializeComponent() this.button3.TabIndex = 20; this.button3.Text = "Сформировать"; this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); // // MainForm // diff --git a/Charts/MainForm.cs b/Charts/MainForm.cs index ba5d297..60e5911 100644 --- a/Charts/MainForm.cs +++ b/Charts/MainForm.cs @@ -227,23 +227,6 @@ private void radioButton_CheckedChanged(object sender, EventArgs e) AreaPaint.Refresh(); tableupdate = true; } - else - { - tableA.Rows.Clear(); - for (int i = 0; i < nowTable.Rows.Count - 1; i++) - { - tableA.Rows.Add(nowTable.Rows[i].Cells[0].Value, nowTable.Rows[i].Cells[1].Value); ; - } - dopPoints = new PointF[tableA.Rows.Count - 1]; - for (int i = 0; i < tableA.Rows.Count - 1; i++) - { - dopPoints[i].X = float.Parse(tableA.Rows[i].Cells[0].Value.ToString()); - dopPoints[i].Y = -float.Parse(tableA.Rows[i].Cells[1].Value.ToString()); - } - tableupdate = false; - AreaPaint.Refresh(); - tableupdate = true; - } } private void SlowDrawing_CheckedChanged(object sender, EventArgs e) @@ -419,8 +402,9 @@ void PaintChart(Graphics graphics) { int minY = -((AreaPaint.Height) / 2 / plusM + GeneralRestrictions(CentralY)) - 1; int limitationDownY; - if (LimitationUpY.Text != "" && Int32.TryParse(LimitationUpY.Text, out limitationDownY)) + if (LimitationDownY.Text != "" && Int32.TryParse(LimitationDownY.Text, out limitationDownY)) { + limitationDownY = -limitationDownY; if (limitationDownY < minY) { limitationDownY = minY; @@ -432,9 +416,9 @@ void PaintChart(Graphics graphics) } int limitationUpY = 0; int maxY = (AreaPaint.Height) / plusM + minY + 1; - if (LimitationDownY.Text != "" && Int32.TryParse(LimitationDownY.Text, out limitationUpY)) + if (LimitationUpY.Text != "" && Int32.TryParse(LimitationUpY.Text, out limitationUpY)) { - if (limitationUpY > maxY) + if (-limitationUpY > maxY) { limitationUpY = maxY; } @@ -523,13 +507,13 @@ void PaintChart(Graphics graphics) void RemoveUnnecessary(PointF point, ref PointF[] allPoints, ref int countAllPoint, int limitationDownY, int limitationUpY, List segments, float x) { float checkedNumber = (point.Y); - if (checkedNumber <= -limitationDownY && checkedNumber >= -limitationUpY) + if (checkedNumber <= limitationUpY && checkedNumber >= limitationDownY) { - if(countAllPoint==0) + if (countAllPoint == 0) { Charts.TranslatingExpression translating = new Charts.TranslatingExpression(); - PointF pointF = new PointF(point.X-1/(float)plusM, translating.Translating(functionMain.Text, point.X - 1/(float)plusM)); - if(!float.IsNaN(pointF.X) && !float.IsNaN(pointF.Y) && !float.IsInfinity(pointF.Y)) + PointF pointF = new PointF(point.X - (float)1 / (float)plusM, translating.Translating(functionMain.Text, point.X - (float)1 / (float)plusM)); + if (!float.IsNaN(pointF.X) && !float.IsNaN(pointF.Y) && !float.IsInfinity(pointF.Y)) { allPoints[countAllPoint] = pointF; allPoints[countAllPoint].X = allPoints[countAllPoint].X * plusM + centralX; @@ -537,7 +521,7 @@ void RemoveUnnecessary(PointF point, ref PointF[] allPoints, ref int countAllPoi countAllPoint++; } } - if(countAllPoint< allPoints.Length) + if (countAllPoint < allPoints.Length) { if (!float.IsNaN(point.X) && !float.IsNaN(point.Y) && !float.IsInfinity(point.Y)) { @@ -550,10 +534,10 @@ void RemoveUnnecessary(PointF point, ref PointF[] allPoints, ref int countAllPoi } else { - if (allPoints.Length > 1) + if (countAllPoint > 1) { Charts.TranslatingExpression translating = new Charts.TranslatingExpression(); - PointF pointF = new PointF(x, translating.Translating(functionMain.Text, x)); + PointF pointF = new PointF(x , translating.Translating(functionMain.Text, x)); if (!float.IsNaN(pointF.X) && !float.IsNaN(pointF.Y) && !float.IsInfinity(pointF.Y)) { if (countAllPoint < allPoints.Length) @@ -567,11 +551,11 @@ void RemoveUnnecessary(PointF point, ref PointF[] allPoints, ref int countAllPoi Array.Resize(ref allPoints, countAllPoint); segments.Add(allPoints); } - allPoints = new PointF[AreaPaint.Width + +plusM+2]; + allPoints = new PointF[AreaPaint.Width + +plusM + 2]; countAllPoint = 0; } } - + async void SpeedDrawing(Graphics graphics, List segments) { if (segments.Count > 0) @@ -677,6 +661,24 @@ private void CountPoints_TextChanged(object sender, EventArgs e) AreaPaint.Refresh(); } + private void button3_Click(object sender, EventArgs e) + { + tableA.Rows.Clear(); + for (int i = 0; i < nowTable.Rows.Count - 1; i++) + { + tableA.Rows.Add(nowTable.Rows[i].Cells[0].Value, nowTable.Rows[i].Cells[1].Value); ; + } + dopPoints = new PointF[tableA.Rows.Count - 1]; + for (int i = 0; i < tableA.Rows.Count - 1; i++) + { + dopPoints[i].X = float.Parse(tableA.Rows[i].Cells[0].Value.ToString()); + dopPoints[i].Y = -float.Parse(tableA.Rows[i].Cells[1].Value.ToString()); + } + tableupdate = false; + AreaPaint.Refresh(); + tableupdate = true; + } + void tableCompletion() { List nowPoints = new List(); @@ -734,6 +736,10 @@ void tableCompletion() Charts.TranslatingExpression translating = new Charts.TranslatingExpression(); for (int i = 0; x1<=e1; i++) { + if(x1==-13) + { + + } temporaryPoint[i] = new PointF(x1, translating.Translating(functionMain.Text, x1)); float checkedNumber = (temporaryPoint[i].Y); if (checkedNumber <= -limitationDownY && checkedNumber >= -limitationUpY) @@ -750,7 +756,7 @@ void tableCompletion() } else { - if (allPoints.Length > 1) + if (countAllPoint > 1) { Array.Resize(ref allPoints, countAllPoint); segments.Add(allPoints); @@ -765,7 +771,7 @@ void tableCompletion() } } Array.Resize(ref allPoints, countAllPoint); - if (allPoints.Length > 1) + if (countAllPoint > 1) { segments.Add(allPoints); }