Exemple #1
0
        public bool EditStructElement <TElement>
            (UInt64 id, Coordinate <TElement> coordinate, TElement d, string name, TypeStructElement type)
            where TElement : IComparable, new()
        {
            for (int i = 0; i < structElements.Count; ++i)
            {
                object       obj      = structElements[i];
                Type         typeObj  = obj.GetType();
                PropertyInfo propInfo = typeObj.GetProperty("Id");

                //if (structElements[i].Id == id)
                if (propInfo.Equals(id))
                {
                    StructElement <TElement> structElement;

                    switch (type)
                    {
                    case (TypeStructElement.slotDirect):
                    {
                        try
                        {
                            structElement     = new SlotDirect <TElement>(name, coordinate, d);
                            structElements[i] = structElement;
                        }
                        catch
                        {
                            return(false);
                        }

                        break;
                    }

                    case (TypeStructElement.slotEvolvent):
                    {
                        try
                        {
                            structElement     = new SlotEvolvent <TElement>(name, coordinate, d);
                            structElements[i] = structElement;
                        }
                        catch
                        {
                            return(false);
                        }

                        break;
                    }

                    case (TypeStructElement.fillet):
                    {
                        try
                        {
                            structElement     = new Fillet <TElement>(name, coordinate, d);
                            structElements[i] = structElement;
                        }
                        catch
                        {
                            return(false);
                        }

                        break;
                    }

                    case (TypeStructElement.chamfer):
                    {
                        try
                        {
                            structElement     = new Chamfer <TElement>(name, coordinate, d);
                            structElements[i] = structElement;
                        }
                        catch
                        {
                            return(false);
                        }

                        break;
                    }

                    case (TypeStructElement.dowel):
                    {
                        try
                        {
                            structElement     = new Dowel <TElement>(name, coordinate, d);
                            structElements[i] = structElement;
                        }
                        catch
                        {
                            return(false);
                        }

                        break;
                    }

                    case (TypeStructElement.thread):
                    {
                        try
                        {
                            structElement     = new Thread <TElement>(name, coordinate, d);
                            structElements[i] = structElement;
                        }
                        catch
                        {
                            return(false);
                        }

                        break;
                    }
                    }

                    break;
                }
            }

            return(true);
        }
Exemple #2
0
        public bool AddStructElement <TElement>
            (string name, TypeStructElement type)
            where TElement : IComparable, new()
        {
            StructElement <TElement> structElement;

            switch (type)
            {
            case (TypeStructElement.slotDirect):
            {
                try
                {
                    structElement = new SlotDirect <TElement>();
                    structElements.Add(structElement);
                }
                catch
                {
                    return(false);
                }

                break;
            }

            case (TypeStructElement.slotEvolvent):
            {
                try
                {
                    structElement = new SlotEvolvent <TElement>();
                    structElements.Add(structElement);
                }
                catch
                {
                    return(false);
                }

                break;
            }

            case (TypeStructElement.fillet):
            {
                try
                {
                    structElement = new Fillet <TElement>();
                    structElements.Add(structElement);
                }
                catch
                {
                    return(false);
                }

                break;
            }

            case (TypeStructElement.chamfer):
            {
                try
                {
                    structElement = new Chamfer <TElement>();
                    structElements.Add(structElement);
                }
                catch
                {
                    return(false);
                }

                break;
            }

            case (TypeStructElement.dowel):
            {
                try
                {
                    structElement = new Dowel <TElement>();
                    structElements.Add(structElement);
                }
                catch
                {
                    return(false);
                }
                break;
            }

            case (TypeStructElement.thread):
            {
                try
                {
                    structElement = new Thread <TElement>();
                    structElements.Add(structElement);
                }
                catch
                {
                    return(false);
                }
                break;
            }
            }

            return(true);
        }