Пример #1
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            if (this.cbShape.SelectedIndex == 0 && this.cbAddOrDelete.SelectedIndex == 0)
            {
                double             d_BoxWidth   = Convert.ToDouble(this.nudBoxWidth.Value);
                double             d_BoxHeight  = Convert.ToDouble(this.nudBoxHeight.Value);
                double             d_BoxLength  = Convert.ToDouble(this.nudBoxLength.Value);
                double             d_BoxCenterX = Convert.ToDouble(this.nudBoxCenterX.Value);
                double             d_BoxCenterY = Convert.ToDouble(this.nudBoxCenterY.Value);
                double             d_BoxCenterZ = Convert.ToDouble(this.nudBoxCenterZ.Value);
                bool               rendered     = (this.cbBoxRendered.Checked == true) ? true : false;
                Shapes.BoundingBox b            = new Shapes.BoundingBox(this.txtBoxName.Text, d_BoxWidth, d_BoxHeight, d_BoxLength);
                boxes.Add(b);
                Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
                m_ucCharting3D.plotSetup(b, randomColor);
                p3D.Point3D c = new p3D.Point3D(d_BoxCenterX, d_BoxCenterY, d_BoxCenterZ);
                box_centers.Add(c);
                box_rendered.Add(rendered);
                this.txtBoxName.Text       = "";
                this.nudBoxWidth.Value     = 0;
                this.nudBoxHeight.Value    = 0;
                this.nudBoxLength.Value    = 0;
                this.nudBoxCenterX.Value   = 0;
                this.nudBoxCenterY.Value   = 0;
                this.nudBoxCenterZ.Value   = 0;
                this.cbBoxRendered.Checked = false;
                controlsEnabled(false);
                Task.Run(() =>
                {
                    BeginInvoke(new Action(() =>
                    {
                        plotShapes();
                        controlsEnabled(true);
                    }));
                });
            }

            else if (this.cbShape.SelectedIndex == 1 && this.cbAddOrDelete.SelectedIndex == 0)
            {
                double          d_CylinderRadius      = Convert.ToDouble(this.nudCylinderRadius.Value);
                double          d_CylinderFacetNumber = Convert.ToDouble(this.nudCylinderFacetNumber.Value);
                double          d_CylinderP1X         = Convert.ToDouble(this.nudCylinderP1X.Value);
                double          d_CylinderP1Y         = Convert.ToDouble(this.nudCylinderP1Y.Value);
                double          d_CylinderP1Z         = Convert.ToDouble(this.nudCylinderP1Z.Value);
                double          d_CylinderP2X         = Convert.ToDouble(this.nudCylinderP2X.Value);
                double          d_CylinderP2Y         = Convert.ToDouble(this.nudCylinderP2Y.Value);
                double          d_CylinderP2Z         = Convert.ToDouble(this.nudCylinderP2Z.Value);
                bool            rendered = (this.cbCylinderRendered.Checked == true) ? true : false;
                Shapes.Cylinder c        = new Shapes.Cylinder(this.txtCylinderName.Text, d_CylinderRadius, d_CylinderFacetNumber, 1);
                cylinders.Add(c);
                Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
                m_ucCharting3D.plotSetup(c, randomColor);
                p3D.Point3D p1 = new p3D.Point3D(d_CylinderP1X, d_CylinderP1Y, d_CylinderP1Z);
                cylinder_centers1.Add(p1);
                p3D.Point3D p2 = new p3D.Point3D(d_CylinderP2X, d_CylinderP2Y, d_CylinderP2Z);
                cylinder_centers2.Add(p2);
                cylinder_rendered.Add(rendered);
                this.txtCylinderName.Text         = "";
                this.nudCylinderRadius.Value      = 0;
                this.nudCylinderFacetNumber.Value = 0;
                this.nudCylinderP1X.Value         = 0;
                this.nudCylinderP1Y.Value         = 0;
                this.nudCylinderP1Z.Value         = 0;
                this.nudCylinderP2X.Value         = 0;
                this.nudCylinderP2Y.Value         = 0;
                this.nudCylinderP2Z.Value         = 0;
                this.cbCylinderRendered.Checked   = false;
                controlsEnabled(false);
                Task.Run(() =>
                {
                    BeginInvoke(new Action(() =>
                    {
                        plotShapes();
                        controlsEnabled(true);
                    }));
                });
            }

            else if (this.cbShape.SelectedIndex == 2 && this.cbAddOrDelete.SelectedIndex == 0)
            {
                double       d_PointX = Convert.ToDouble(this.nudPointX.Value);
                double       d_PointY = Convert.ToDouble(this.nudPointY.Value);
                double       d_PointZ = Convert.ToDouble(this.nudPointZ.Value);
                Shapes.Point p        = new Shapes.Point(this.txtPointName.Text);
                points.Add(p);
                Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
                m_ucCharting3D.plotSetup(p, randomColor);
                p3D.Point3D c = new p3D.Point3D(d_PointX, d_PointY, d_PointZ);
                point_centers.Add(c);
                this.txtPointName.Text = "";
                this.nudPointX.Value   = 0;
                this.nudPointY.Value   = 0;
                this.nudPointZ.Value   = 0;
                controlsEnabled(false);
                Task.Run(() =>
                {
                    BeginInvoke(new Action(() =>
                    {
                        plotShapes();
                        controlsEnabled(true);
                    }));
                });
            }

            else if (this.cbShape.SelectedIndex == 3 && this.cbAddOrDelete.SelectedIndex == 0)
            {
                double         d_LabelX = Convert.ToDouble(this.nudLabelX.Value);
                double         d_LabelY = Convert.ToDouble(this.nudLabelY.Value);
                double         d_LabelZ = Convert.ToDouble(this.nudLabelZ.Value);
                TextAnnotation l        = new TextAnnotation();
                labels.Add(l);
                m_ucCharting3D.plotSetup(l);
                label_texts.Add(this.txtLabelText.Text);
                p3D.Point3D c = new p3D.Point3D(d_LabelX, d_LabelY, d_LabelZ);
                label_centers.Add(c);
                label_names.Add(this.txtLabelName.Text);
                this.txtLabelText.Text = "";
                this.nudLabelX.Value   = 0;
                this.nudLabelY.Value   = 0;
                this.nudLabelZ.Value   = 0;
                controlsEnabled(false);
                Task.Run(() =>
                {
                    BeginInvoke(new Action(() =>
                    {
                        plotShapes();
                        controlsEnabled(true);
                    }));
                });
            }

            else if (this.cbShape.SelectedIndex == 0 && this.cbAddOrDelete.SelectedIndex == 1)
            {
                List <int> indexes = new List <int>();

                foreach (Shapes.BoundingBox box in boxes)
                {
                    if (box.Name == this.txtDeleteName.Text)
                    {
                        indexes.Add(boxes.IndexOf(box));
                    }
                }

                foreach (int index in indexes)
                {
                    m_ucCharting3D.deleteShape(boxes[index]);
                    boxes.Remove(boxes[index]);
                    box_centers.Remove(box_centers[index]);
                }
                this.txtDeleteName.Text = "";
            }

            else if (this.cbShape.SelectedIndex == 1 && this.cbAddOrDelete.SelectedIndex == 1)
            {
                List <int> indexes = new List <int>();
                foreach (Shapes.Cylinder cylinder in cylinders)
                {
                    if (cylinder.Name == this.txtDeleteName.Text)
                    {
                        indexes.Add(cylinders.IndexOf(cylinder));
                    }
                }

                foreach (int index in indexes)
                {
                    m_ucCharting3D.deleteShape(cylinders[index]);
                    cylinders.Remove(cylinders[index]);
                    cylinder_centers1.Remove(cylinder_centers1[index]);
                    cylinder_centers2.Remove(cylinder_centers2[index]);
                }
                this.txtDeleteName.Text = "";
            }

            else if (this.cbShape.SelectedIndex == 2 && this.cbAddOrDelete.SelectedIndex == 1)
            {
                List <int> indexes = new List <int>();
                foreach (Shapes.Point point in points)
                {
                    if (point.Name == this.txtDeleteName.Text)
                    {
                        indexes.Add(points.IndexOf(point));
                    }
                }
                foreach (int index in indexes)
                {
                    m_ucCharting3D.deleteShape(points[index]);
                    points.Remove(points[index]);
                    point_centers.Remove(point_centers[index]);
                }
                this.txtDeleteName.Text = "";
            }

            else if (this.cbShape.SelectedIndex == 3 && this.cbAddOrDelete.SelectedIndex == 1)
            {
                List <int> indexes = new List <int>();
                foreach (string label in label_names)
                {
                    if (label == this.txtDeleteName.Text)
                    {
                        indexes.Add(label_names.IndexOf(label));
                    }
                }
                foreach (int index in indexes)
                {
                    m_ucCharting3D.deleteShape(labels[index]);
                    labels.Remove(labels[index]);
                    label_texts.Remove(label_texts[index]);
                    label_centers.Remove(label_centers[index]);
                    label_names.Remove(label_names[index]);
                }
                this.txtDeleteName.Text = "";
            }

            else
            {
                this.tcChartingTabs.SelectedIndex = 0;
            }
        }
Пример #2
0
 /// <summary>
 /// Creates an cylinder shape for serialisation.
 /// </summary>
 /// <param name="shapeComponent">The component to create a shape for.</param>
 /// <returns>A shape instance suitable for configuring to generate serialisation messages.</returns>
 protected override Shapes.Shape CreateSerialisationShape(ShapeComponent shapeComponent)
 {
     Shapes.Shape shape = new Shapes.Cylinder();
     ConfigureShape(shape, shapeComponent);
     return(shape);
 }