Esempio n. 1
0
        private void CuboidRotZ_ValueChanged(object sender, EventArgs e)
        {
            if (CuboidRotZ.Value < 0)
            {
                CuboidRotZ.Value += 360;
            }
            else if (CuboidRotZ.Value == 360)
            {
                CuboidRotZ.Value = 0;
            }
            Cuboid cube = SelectedFigure as Cuboid;

            cube.RotZ = (float)CuboidRotZ.Value * (float)Math.PI / 180f;
            FigureDataGrid.Refresh();
        }
Esempio n. 2
0
        private void FigureDataGrid_SelectionChanged(object sender, EventArgs e)
        {
            CuboidGroupBox.Visible   = false;
            SphereGroupBox.Visible   = false;
            CylinderGroupBox.Visible = false;
            ConeGroupBox.Visible     = false;
            if (FigureDataGrid.SelectedRows.Count != 0)
            {
                SelectedFigure = (IFigure)FigureDataGrid.SelectedRows[0].DataBoundItem;
                if (SelectedFigure is Cuboid)
                {
                    Cuboid cube = SelectedFigure as Cuboid;
                    CuboidGroupBox.Visible = true;
                    CuboidPosX.Value       = (decimal)cube.Center.X;
                    CuboidPosY.Value       = (decimal)cube.Center.Y;
                    CuboidPosZ.Value       = (decimal)cube.Center.Z;

                    CuboidDimX.Value = (decimal)cube.DimX;
                    CuboidDimY.Value = (decimal)cube.DimY;
                    CuboidDimZ.Value = (decimal)cube.DimZ;

                    CuboidRotX.Value = (decimal)(cube.RotX * 180f / Math.PI);
                    CuboidRotY.Value = (decimal)(cube.RotY * 180f / Math.PI);
                    CuboidRotZ.Value = (decimal)(cube.RotZ * 180f / Math.PI);

                    CuboidX.Value = (decimal)cube.X;
                    CuboidY.Value = (decimal)cube.Y;
                    CuboidZ.Value = (decimal)cube.Z;

                    using (FastBitmap fast = ((Bitmap)CuboidColor.Image).FastLock())
                    {
                        fast.Clear(cube.Color);
                    }
                    CuboidColor.Refresh();
                }
                else if (SelectedFigure is Sphere)
                {
                    SphereGroupBox.Visible = true;
                    Sphere sphere = SelectedFigure as Sphere;
                    SpherePosX.Value = (decimal)sphere.Center.X;
                    SpherePosY.Value = (decimal)sphere.Center.Y;
                    SpherePosZ.Value = (decimal)sphere.Center.Z;

                    SphereDimX.Value = (decimal)sphere.DimX;
                    SphereDimY.Value = (decimal)sphere.DimY;
                    SphereDimZ.Value = (decimal)sphere.DimZ;

                    SphereRotX.Value = (decimal)(sphere.RotX * 180f / Math.PI);
                    SphereRotY.Value = (decimal)(sphere.RotY * 180f / Math.PI);
                    SphereRotZ.Value = (decimal)(sphere.RotZ * 180f / Math.PI);

                    SphereLat.Value    = (decimal)sphere.Lat;
                    SphereLon.Value    = (decimal)sphere.Lon;
                    SphereRadius.Value = (decimal)sphere.Radius;

                    using (FastBitmap fast = ((Bitmap)SphereColor.Image).FastLock())
                    {
                        fast.Clear(sphere.Color);
                    }
                    SphereColor.Refresh();
                }
                else if (SelectedFigure is Cylinder)
                {
                    CylinderGroupBox.Visible = true;
                    Cylinder cylinder = SelectedFigure as Cylinder;
                    CylinderPosX.Value = (decimal)cylinder.Center.X;
                    CylinderPosY.Value = (decimal)cylinder.Center.Y;
                    CylinderPosZ.Value = (decimal)cylinder.Center.Z;

                    CylinderDimX.Value = (decimal)cylinder.DimX;
                    CylinderDimY.Value = (decimal)cylinder.DimY;
                    CylinderDimZ.Value = (decimal)cylinder.DimZ;

                    CylinderRotX.Value = (decimal)(cylinder.RotX * 180f / Math.PI);
                    CylinderRotY.Value = (decimal)(cylinder.RotY * 180f / Math.PI);
                    CylinderRotZ.Value = (decimal)(cylinder.RotZ * 180f / Math.PI);

                    CylinderDiv.Value    = (decimal)cylinder.Division;
                    CylinderHeight.Value = (decimal)cylinder.Height;
                    CylinderRadius.Value = (decimal)cylinder.Radius;

                    using (FastBitmap fast = ((Bitmap)CylinderColor.Image).FastLock())
                    {
                        fast.Clear(cylinder.Color);
                    }
                    CylinderColor.Refresh();
                }
                else if (SelectedFigure is Cone)
                {
                    ConeGroupBox.Visible = true;
                    Cone cone = SelectedFigure as Cone;
                    ConePosX.Value = (decimal)cone.Center.X;
                    ConePosY.Value = (decimal)cone.Center.Y;
                    ConePosZ.Value = (decimal)cone.Center.Z;

                    ConeDimX.Value = (decimal)cone.DimX;
                    ConeDimY.Value = (decimal)cone.DimY;
                    ConeDimZ.Value = (decimal)cone.DimZ;

                    ConeRotX.Value = (decimal)(cone.RotX * 180f / Math.PI);
                    ConeRotY.Value = (decimal)(cone.RotY * 180f / Math.PI);
                    ConeRotZ.Value = (decimal)(cone.RotZ * 180f / Math.PI);

                    ConeDiv.Value    = (decimal)cone.Division;
                    ConeHeight.Value = (decimal)cone.Height;
                    ConeRadius.Value = (decimal)cone.Radius;

                    using (FastBitmap fast = ((Bitmap)ConeColor.Image).FastLock())
                    {
                        fast.Clear(cone.Color);
                    }
                    ConeColor.Refresh();
                }
            }
        }