示例#1
0
 public AnalyticGeometryControl()
 {
     InitializeComponent();
     Geometry = new Box();
     cb_main.Items.AddRange(AnalyticGeometry.TypeNames);
     cb_main.SelectedIndex = 0;
 }
示例#2
0
 private void txtGeom_TextChanged(object sender, EventArgs e)
 {
     try
     {
         double x1    = Convert.ToDouble(txtX1.Text);
         double x2    = Convert.ToDouble(txtX2.Text);
         double y1    = Convert.ToDouble(txtY1.Text);
         double y2    = Convert.ToDouble(txtY2.Text);
         double ratio = Convert.ToDouble(txtRazon.Text);
         txtDistance.Text = AnalyticGeometry.GetDistanceBetweenTwoPoints(x1, y1, x2, y2).ToString();
         double[] middlePoint = AnalyticGeometry.GetMiddlePoint(x1, y1, x2, y2);
         txtMiddle.Text = middlePoint[0] + ", " + middlePoint[1];
         txtSlope.Text  = AnalyticGeometry.GetSlope(x1, y1, x2, y2).ToString();
         double[] ratioPoint = AnalyticGeometry.GetPointInRatio(x1, y1, x2, y2, ratio);
         txtRatioPoint.Text = ratioPoint[0] + ", " + ratioPoint[1];
     }
     catch
     {
     }
 }
示例#3
0
        private void OnSelectedValueChanged(object sender, EventArgs e)
        {
            if (geometry.TypeName != (string)cb_main.SelectedItem)
            {
                switch (cb_main.SelectedItem)
                {
                case "Box":
                    geometry = new Box();
                    pg_main.SelectedObject = geometry;
                    break;

                case "Sphere":
                    geometry = new Sphere();
                    pg_main.SelectedObject = geometry;
                    break;

                case "Cone":
                    geometry = new Cone();
                    pg_main.SelectedObject = geometry;
                    break;
                }
            }
        }