Exemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //Save the setting
            defaultSystemLengthUnit = (Length.LengthUnit) this.cboLengthUnit.SelectedItem;

            GEMS.Designer.Properties.Settings.Default.DefaultLengthUnit = (int)defaultSystemLengthUnit;

            this.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new GEMSEnvironment object with default values
        /// </summary>
        public GEMSEnvironment()
        {
            try
            {
                //From the application settings to reader the current default length unit
                this.defaultLengthUnit = (Length.LengthUnit)GEMS.Designer.Properties.Settings.Default.DefaultLengthUnit;
            }
            catch {
                this.defaultLengthUnit = Length.LengthUnit.mm;
            }

            this.gridSize = new Length(0.2f, this.defaultLengthUnit);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a new GEMSEnvironment object and load the information from the specified file
        /// </summary>
        public GEMSEnvironment(XPathNavigator navigator)
        {
            //Read the Unit information
            navigator.MoveToChild("Units", string.Empty);
            navigator.MoveToFirstChild();
            defaultLengthUnit = (Length.LengthUnit)Enum.Parse(typeof(Length.LengthUnit), navigator.GetAttribute("value", string.Empty));
            navigator.MoveToParent();
            navigator.MoveToParent();

            //Read the grid information
            navigator.MoveToChild("Grid", "");
            gridSize = new Length(navigator.GetAttribute("size", ""), navigator.GetAttribute("unit", string.Empty));
            navigator.MoveToParent();
        }
Exemplo n.º 4
0
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            CreateCone newCone = new CreateCone(modelSpace.Project.CreateNewOperationId());

            //The width,height,depth of cuboid is setted with default value now
            //We'll improve it next version by using mouse draging
            Length.LengthUnit unit   = modelSpace.Project.Environment.DefaultLengthUnit;
            float             value1 = modelSpace.Project.Environment.GridSize.Value;
            float             value2 = modelSpace.Project.Environment.GridSize.Value * 2;

            newCone.Height       = new Length(value2, unit);
            newCone.BottomRadius = new Length(value1, unit);
            newCone.TopRadius    = new Length(0f, unit);

            //Get the refPoint
            Vector3 center = modelSpace.SceneRender.DisplayedGridPoint;

            newCone.Center = new Vector3WithUnit(center, modelSpace.Project.Environment.DefaultLengthUnit);

            //Set the aline axis
            switch (modelSpace.Project.Environment.GridPlane)
            {
            case GridPlane.XY:
                newCone.AlineAxis = Axis.Z;
                break;

            case GridPlane.XZ:
                newCone.AlineAxis = Axis.Y;
                break;

            case GridPlane.YZ:
                newCone.AlineAxis = Axis.X;
                break;

            default:
                newCone.AlineAxis = Axis.Z;
                break;
            }

            //Create the new single
            modelSpace.Project.CreateNewSingle(newCone);

            workspace.SelectTool();
        }
Exemplo n.º 5
0
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            CreateSphere newSphere = new CreateSphere(modelSpace.Project.CreateNewOperationId());

            //The width,height,depth of cuboid is setted with default value now
            //We'll improve it next version by using mouse draging
            Length.LengthUnit unit  = modelSpace.Project.Environment.DefaultLengthUnit;
            float             value = modelSpace.Project.Environment.GridSize.Value;

            newSphere.Radius = new Length(value, unit);

            //Get the refPoint
            Vector3 center = modelSpace.SceneRender.DisplayedGridPoint;

            newSphere.Center = new Vector3WithUnit(center, modelSpace.Project.Environment.DefaultLengthUnit);

            //Create the new single
            modelSpace.Project.CreateNewSingle(newSphere);

            workspace.SelectTool();
        }
Exemplo n.º 6
0
            public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
            {
                if (value is string)
                {
                    try
                    {
                        string s = ((string)value).Trim( );
                        if (s != string.Empty)
                        {
                            string[] units = Enum.GetNames(typeof(Length.LengthUnit));

                            for (int i = 0; i < units.Length; i++)
                            {
                                int   unitLoc = s.IndexOf(units[i]);  //Find the unit in the string
                                float length;

                                if ((unitLoc != -1) && float.TryParse(s.Substring(0, unitLoc), out length))
                                {
                                    Length.LengthUnit unit        = (Length.LengthUnit)Enum.Parse(typeof(Length.LengthUnit), units[i]);
                                    Length            lengthValue = new Length(length, unit);

                                    return(lengthValue);
                                }
                            }
                        }
                        else
                        {
                            throw new ArgumentException("Can not convert '" + (string)value + "' to type Length");
                        }
                    }
                    catch
                    {
                        throw new ArgumentException("Can not convert '" + (string)value + "' to type Length");
                    }
                }

                return(base.ConvertFrom(context, culture, value));
            }
Exemplo n.º 7
0
        public GeneralOptionsForm()
        {
            InitializeComponent();

            defaultSystemLengthUnit = (Length.LengthUnit)GEMS.Designer.Properties.Settings.Default.DefaultLengthUnit;
        }
Exemplo n.º 8
0
 public Vector3 GetDirectXVector(Length.LengthUnit unit)
 {
     return(new Vector3(x.ChangeUnit(unit), y.ChangeUnit(unit), z.ChangeUnit(unit)));
 }
Exemplo n.º 9
0
 public Vector3WithUnit(Vector3 vector, Length.LengthUnit unit)
 {
     this.x = new Length(vector.X, unit);
     this.y = new Length(vector.Y, unit);
     this.z = new Length(vector.Z, unit);
 }
Exemplo n.º 10
0
 public Vector3WithUnit(float value, Length.LengthUnit unit)
 {
     this.x = new Length(value, unit);
     this.y = new Length(value, unit);
     this.z = new Length(value, unit);
 }
Exemplo n.º 11
0
 public static float RatioValue(Length.LengthUnit unit)
 {
     return(Ratio[(int)unit]);
 }