Inheritance: MonoBehaviour
        public void TestFlattering()
        {
            var source = new ModelObject
                {
                    BaseDate = DateTime.Now,
                    Sub = new ModelSubObject
                    {
                        ProperName = "Some name",
                        SubSub = new ModelSubSubObject
                        {
                            IAmACoolProperty = "Cool daddy-o"
                        }
                    },
                    Sub2 = new ModelSubObject
                    {
                        ProperName = "Sub 2 name"
                    },
                    SubWithExtraName = new ModelSubObject
                    {
                        ProperName = "Some other name"
                    },
                };

            var mapper = ObjectMapperManager.DefaultInstance.GetMapper<ModelObject, ModelDto>(
                new FlatteringConfig()
            );

            var b = mapper.Map(source);
        }
Example #2
0
        public void TestFlattering()
        {
            var source = new ModelObject
            {
                BaseDate = DateTime.Now,
                Sub = new ModelSubObject
                {
                    ProperName = "Some name",
                    SubSub = new ModelSubSubObject
                    {
                        IAmACoolProperty = "Cool daddy-o"
                    }
                },
                Sub2 = new ModelSubObject
                {
                    ProperName = "Sub 2 name"
                },
                SubWithExtraName = new ModelSubObject
                {
                    ProperName = "Some other name"
                },
            };

            var b =Mapper.Map<ModelObject, ModelDto>(source);

            Assert.AreEqual(source.BaseDate, b.BaseDate);
            Assert.AreEqual(source.Sub.ProperName, b.SubProperName);
            Assert.AreEqual(source.Sub2.ProperName, b.Sub2ProperName);
            Assert.AreEqual(source.SubWithExtraName.ProperName, b.SubWithExtraNameProperName);
            Assert.AreEqual(source.Sub.SubSub.IAmACoolProperty, b.SubSubSubIAmACoolProperty);
        }
Example #3
0
 protected override void Because_of()
 {
     var model = new ModelObject
     {
         Child = new SubChildModelObject {ChildProperty = "child property value"}
     };
     _result = Mapper.Map<ModelObject, DtoObject>(model);
 }
Example #4
0
 //Controller rausgenommen
 public Waffen(ModelObject MO, int Lebenspunkte, float Schusswinkel, float ShootSpeed, string Waffentyp)
 {
     mo = MO;
     lebenspunkte = Lebenspunkte;
     schusswinkel = Schusswinkel;
     waffentyp = Waffentyp;
     shootspeed = ShootSpeed;
 }
Example #5
0
 public void AddInstance(ModelObject obj)
 {
     if (obj.MModel != null && obj.MModel != this)
     {
         throw new ModelException("The object "+obj+" is already contained by another model.");
     }
     else
     {
         this.instances.Add(obj);
         obj.MModel = this;
     }
 }
Example #6
0
        internal static dynamic[] Parse(Stream stream, string key)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            var objects = new List<ModelObject>();

            using (BinaryReader reader = new BinaryReader(stream))
            {
                while (stream.Position < stream.Length)
                {
                    reader.ReadByte();
                    var language = reader.ReadByte();
                    int id = 0x100 * reader.ReadByte() | reader.ReadByte();

                    dynamic entry = new ModelObject();
                    entry.id = id;

                    string name;

                    if ((id & 0xFF) == 0)
                    {
                        var bracket_name_data = reader.ReadBytes(0x20);
                        var name_data = reader.ReadBytes(0x20);
                        var phrases = reader.ReadInt32();
                        var block_size = reader.ReadInt32();

                        var length = 0;
                        for (; name_data[length] != 0x00; ++length);

                        name = ShiftJISFF11Encoding.ShiftJISFF11.GetString(name_data, 0, length);
                    }
                    else
                    {
                        var length = reader.ReadByte();
                        name = ShiftJISFF11Encoding.ShiftJISFF11.GetString(reader.ReadBytes(length), 0, length - 1);

                        if (language == 1)
                        {
                            reader.ReadBytes(reader.ReadByte());
                        }
                    }

                    entry[key] = name;

                    objects.Add(entry);
                }
            }

            return objects.ToArray();
        }
 public void ModeViewStart()
 {
     folderStype = buttonSetup(win.skinDefault.button, 130);
     if (modelLib != null)
     {
         var gameObj = modelLib.models.First().gameObj;
         sgo = InitModel((GameObject)Instantiate(gameObj), gameObj.name);
     }
     grid = new GameObject("Grid").AddComponent<Grid>();
     grid.renderAwalys = true;
     grid.enabled = false;
     grid.cellBig = 0;
 }
Example #8
0
            protected override void Establish_context()
            {
                Mapper.AddFormatter<HardEncoder>();
                Mapper.AddFormatter(new SoftEncoder());
                Mapper.AddFormatter(typeof(RokkenEncoder));
                Mapper.AddFormatExpression(context => context.SourceValue + " Medium");

                Mapper.CreateMap<ModelObject, ModelDto>();

                var modelObject = new ModelObject { Value = 14 };

                _modelDto = Mapper.Map<ModelObject, ModelDto>(modelObject);
            }
Example #9
0
        //private static List<Waffen> waffenListe = new List<Waffen>();
        public static Objekte createObj(int auswahl, Spieler spieler, float xPos, Vector2 rHv2s)
        {
            idnummer++;
            Vector3 startort = new Vector3(xPos, 2, -5);
            SceneObject newobj;
            Objekte dasobj;

            if (auswahl == 1)//Würfel
            {
                newobj = buildbox(startort, new Vector3(0.4f, 0.4f, 0.4f));
                DrawHelper.setmoney(spieler, -150, rHv2s);
                /*spieler.setMoney(spieler.getMoney() - 150); //Rohkosten abziehen
                Gamestart.setShowGeld(-150, 100);           //Kosten visualisieren
                */
                newobj.Physics.Mass = 1f;
            }
            else if (auswahl == 2)
            {
                ModelObject l = new ModelObject(startort, Quaternion.CreateFromAxisAngle(new Vector3(1,2,0),(float)Math.PI), new Vector3(1, 1, 1), CollisionType.ExactMesh, "", "L", 1f);
                l.SubModels[0].RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                l.SubModels[0].RenderMaterial.Specular = new Vector4(0.1f, 0.1f, 0.1f, 1);
                newobj = l;
                DrawHelper.setmoney(spieler, -200, rHv2s);
            }
            else if (auswahl == 3) // Latte
            {
                newobj = buildbox(startort, new Vector3(1.2f, 0.1f, 0.4f));
                DrawHelper.setmoney(spieler, -200, rHv2s);
                newobj.Physics.Mass = 2f;
            }
            else if (auswahl == 4) // Quader       das kommentierte ist die //Pyramide
            {
                newobj = buildbox(startort, new Vector3(0.8f, 0.4f, 0.4f));
                newobj.Physics.Mass = 2f;
                DrawHelper.setmoney(spieler, -200, rHv2s);
            }
            else
            {
                newobj = buildbox(startort, new Vector3(0.1f, 0.1f, 0.1f));
            }

            //TODO z-Achse sperren
            newobj.Physics.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous;
            newobj.Tag = idnummer;
            newobj.PhysicsMaterial.Bounciness = 0.2f;
            scene.Add(newobj);
            dasobj = new Objekte(newobj, 1, "blank");
            objListe.Add(dasobj); //Liste hinzufügen
            return dasobj;
        }
        //private static List<Waffen> waffenListe = new List<Waffen>();

        public static Objekte createObj(int auswahl, Spieler spieler, float xPos)
        {
            idnummer++;
            Vector3 startort = new Vector3(xPos, 2, -5);
            SceneObject newobj;
            Objekte dasobj;

            if (auswahl == 1)//Würfel
            {
                newobj = buildbox(startort, new Vector3(0.4f, 0.4f, 0.4f));
                spieler.setMoney(spieler.getMoney() - 150); //Rohkosten abziehen
                newobj.Physics.Mass = 1f;
            }
            else if (auswahl == 2)
            {
                ModelObject l = new ModelObject(startort, Quaternion.CreateFromAxisAngle(new Vector3(1,2,0),(float)Math.PI), new Vector3(1, 1, 1), CollisionType.ExactMesh, "", "L", 2f);
                newobj = l;
                spieler.setMoney(spieler.getMoney() - 200);
            }
            else if (auswahl == 3) // Latte
            {
                newobj = buildbox(startort, new Vector3(1.2f, 0.1f, 0.4f));
                spieler.setMoney(spieler.getMoney() - 200); //Rohkosten abziehen
                newobj.Physics.Mass = 2f;
            }
            else if (auswahl == 4) // Quader       das kommentierte ist die //Pyramide
            {
                newobj = buildbox(startort, new Vector3(0.8f, 0.4f, 0.4f));
                newobj.Physics.Mass = 2f;
                /*ModelObject p = new ModelObject(startort, Quaternion.CreateFromAxisAngle(new Vector3(1, 2, 0), (float)Math.PI), new Vector3(1, 1, 1), CollisionType.ExactMesh, "", "Pyramide", 1f);
                newobj = p;*/
                spieler.setMoney(spieler.getMoney() - 200);
            }
            else
            {
                newobj = buildbox(startort, new Vector3(0.1f, 0.1f, 0.1f));
            }

            //TODO z-Achse sperren
            newobj.Physics.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous;
            newobj.Tag = idnummer;
            newobj.PhysicsMaterial.Bounciness = 0.2f;
            scene.Add(newobj);
            dasobj = new Objekte(newobj, 1, "blank");
            objListe.Add(dasobj); //Liste hinzufügen
            return dasobj;
        }
Example #11
0
        public void LoadStartObjects(int level)
        {
            if (level == 1)
            {
                Scene.ShowTriangleCount = true;
                ModelObject Welt = new ModelObject(new Vector3(0, -1.5f, -5f), Quaternion.Identity, new Vector3(1, 1, 1), CollisionType.ExactMesh, " ", "Welt_xna_rotiert", 0f);
                Welt.PhysicsMaterial.Bounciness = 0.2f;
                Welt.SubModels[0].RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                Welt.SubModels[0].RenderMaterial.Specular = new Vector4(0.1f, 0.1f, 0.1f, 0.1f);

                Welt.Name = "Welt";
                scene.Add(Welt);
                Objektverwaltung.addToUmgebungsListe(Welt);

                //Lädt Spielhintergrund
                LoadBackground("himmel");
            }
        }
Example #12
0
        internal static dynamic[] Parse(Stream stream, string key)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            Header header = stream.Read<Header>(0);
            // First valid value was included in the header to get the table size
            stream.Position -= 4;

            if (header.FileSize != stream.Length - 4)
            {
                throw new InvalidOperationException("Data is corrupt.");
            }

            var data = new byte[header.FileSize];
            stream.Read(data, 0, data.Length);
            for (var i = 0; i < data.Length; ++i)
            {
                data[i] ^= 0x80;
            }
            int[] table;
            using (var datastream = new MemoryStream(data))
            {
                table = datastream.ReadArray<int>((int)header.TableSize);
            }

            dynamic objects = new ModelObject[header.TableSize];

            for (var i = 0; i < table.Length; ++i)
            {
                var offset = table[i];
                var length = (int)(i + 1 < table.Length ? table[i + 1] : data.Length) - offset;

                for (; data[offset + length - 1] == 0; --length) ;

                objects[i] = new ModelObject {
                    {key, ShiftJISFF11Encoding.ShiftJISFF11.GetString(data, offset, length)}
                };
            }

            return objects;
        }
Example #13
0
            protected override void Establish_context()
            {
                Mapper.Reset();

                var model = new ModelObject
                {
                    Child = new SubChildModelObject {ChildProperty = "child property value"}
                };

                Mapper.CreateMap<ModelObject, DtoObject>();

                Mapper.CreateMap<IChildModelObject, DtoChildObject>()
                    .Include<SubChildModelObject, SubDtoChildObject>();

                Mapper.CreateMap<SubChildModelObject, SubDtoChildObject>();

                Mapper.AssertConfigurationIsValid();

                _result = Mapper.Map<ModelObject, DtoObject>(model);
            }
 public static void MyClassInitialize(TestContext testContext)
 {
     mapping     = new BaseRebarGroupMapping();
     modelObject = TestObjectsHandler.GetRebarGroup();
 }
Example #15
0
 public void RemoveInstance(ModelObject obj)
 {
     this.instances.Remove(obj);
     obj.MModel = null;
 }
Example #16
0
        /// <summary>The get property.</summary>
        /// <param name="propertyOwner">The property owner.</param>
        /// <param name="propertyName">The property name.</param>
        /// <param name="isReportProperty">The is report property.</param>
        /// <param name="returnValue">The return value.</param>
        /// <returns>The System.Boolean.</returns>
        private static bool GetProperty(
            ModelObject propertyOwner, string propertyName, bool isReportProperty, ref double returnValue)
        {
            bool result;
            var  stringValue = string.Empty;

            if (isReportProperty)
            {
                if (propertyName.Contains("EXTERNAL.") || propertyName.Contains("TOP_LEVEL"))
                {
                    // If reference model object, try first getting string and converting it to double
                    result = propertyOwner.GetReportProperty(propertyName, ref stringValue);

                    // Try converting from fractional imperial units
                    if (stringValue.Contains("'") || stringValue.Contains("\""))
                    {
                        try
                        {
                            Distance.UseFractionalFormat = true;
                            Distance topLevel;

                            if (Distance.TryParse(
                                    stringValue.Trim(), CultureInfo.CurrentCulture, Distance.UnitType.Inch, out topLevel))
                            {
                                returnValue = topLevel.Value;
                                result      = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex);
                        }
                    }
                    else if (string.IsNullOrEmpty(stringValue))
                    {
                        result = propertyOwner.GetReportProperty(propertyName, ref returnValue);

                        // Try double if no string was returned.
                    }
                    else
                    {
                        try
                        {
                            var tempStringValue = stringValue;

                            // Top level is cultured string. And returnend in meters in default. With three decimals. Great.
                            if (propertyName.Contains("TOP_LEVEL"))
                            {
                                tempStringValue = stringValue.Replace(".", string.Empty);
                            }

                            if (
                                !double.TryParse(
                                    tempStringValue, NumberStyles.Any, CultureInfo.CurrentCulture, out returnValue))
                            {
                                // Both ,  and . accepted in all cultures.
                                if (stringValue.Contains("."))
                                {
                                    tempStringValue = stringValue.Replace(".", ",");
                                }
                                else if (stringValue.Contains(","))
                                {
                                    tempStringValue = stringValue.Replace(",", ".");
                                }
                            }

                            if (
                                !double.TryParse(
                                    tempStringValue, NumberStyles.Any, CultureInfo.CurrentCulture, out returnValue))
                            {
                                Debug.WriteLine("GetProperty: string was not convertable.");
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex);
                        }
                    }
                }
                else
                {
                    result = propertyOwner.GetReportProperty(propertyName, ref returnValue);
                }
            }
            else
            {
                result = propertyOwner.GetUserProperty(propertyName, ref returnValue);
            }

            return(result);
        }
Example #17
0
 protected abstract ModelDto Flatten(ModelObject model);
    public void UpdateDoorElement(GameObject obj)
    {
        ModelObject modelObject = obj.GetComponent <ModelObject>();

        if (modelObject.Name.Contains("Double") || modelObject.Name.Contains("Dbl"))
        {
            return;
        }



        int frameCounting = 0;

        if (modelObject.HasFrame())
        {
            GameObject frame = new GameObject("Door Frame [" + modelObject.Id + "]");
            frame.transform.parent        = modelObject.transform;
            frame.transform.localScale    = new Vector3(1, 1, 1);
            frame.transform.localPosition = new Vector3(0, 0, 0);
            frame.transform.localRotation = new Quaternion();
            frame.AddComponent <MeshFilter>();
            frame.AddComponent <MeshCollider>();
            frame.AddComponent <MeshRenderer>();
            AddFrame(modelObject, frame);
            frameCounting = 1;
        }



        GameObject panel = new GameObject("Door Panel [" + modelObject.Id + "]");

        panel.transform.parent        = modelObject.transform;
        panel.transform.localScale    = new Vector3(1, 1, 1);
        panel.transform.localPosition = new Vector3(0, 0, 0);
        panel.transform.localRotation = new Quaternion();

        BoxCollider box = panel.GetComponent <BoxCollider> ();

        if (box == null)
        {
            box = panel.AddComponent <BoxCollider> ();
        }
        box.isTrigger = true;
        box.size      = new Vector3(1, 1, 2);
        //box.center = new Vector3 (0, 0, 0);

        for (int i = 0 + frameCounting; i < modelObject.GetComponent <MeshFilter>().sharedMesh.subMeshCount; i++)
        {
            AddComponentDoorPanel(modelObject, panel, i);
        }

        DoorPanel doorPanel = panel.GetComponent <DoorPanel>();

        if (doorPanel == null)
        {
            doorPanel = panel.AddComponent <DoorPanel>();
        }


        modelObject.GetComponent <MeshRenderer>().enabled = false;
        modelObject.GetComponent <MeshCollider>().enabled = false;

        doorPanel.UpdateOpeningDirection();

        if (panel.GetComponent <DoorScript> () == null)
        {
            panel.AddComponent <DoorScript> ();
        }
    }
Example #19
0
 private bool SetClass(string value, ModelObject modelObject)
 {
     (modelObject as BooleanPart).OperativePart.Class = value;
     return(modelObject.Modify());
 }
 protected override ModelDto Flatten(ModelObject model)
 {
     return((ModelDto) new ModelDto().InjectFrom <FlatLoopInjection>(model));
 }
Example #21
0
 protected override void Because_of()
 {
     var model = new ModelObject
     {
         SomeValue = "Some value"
     };
     _result = Mapper.Map<ModelObject, ModelDto>(model);
 }
Example #22
0
            protected override void Because_of()
            {
                var model = new ModelObject();

                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
Example #23
0
 protected override void Because_of()
 {
     _model = new ModelObject();
     _dto   = Mapper.Map <ModelObject, ModelDto>(_model);
 }
Example #24
0
        private void button5_Click(object sender, RoutedEventArgs e)
        {
            string  rfid = textBox1.Text;
            NewRoom room = rooms[0];

            for (int i = 0; i < room.myStore.Count; i++)
            {
                ModelObject ex   = (ModelObject)room.myStore.GetByIndex(i);
                string      RFID = room.myStore.GetKey(i).ToString();
                if (RFID == rfid)
                {
                    switch (ex.type)
                    {
                    case 1:
                    {
                        MessageBox.Show("查询设备是服务器");
                        break;
                    }

                    case 2:
                    {
                        ex.materiala[4].Brush  = Brushes.Red;
                        ex.materiala[5].Brush  = Brushes.Red;
                        ex.materiala[6].Brush  = Brushes.Red;
                        ex.materiala[7].Brush  = Brushes.Red;
                        ex.materiala[8].Brush  = Brushes.Red;
                        ex.materiala[9].Brush  = Brushes.Red;
                        ex.materiala[10].Brush = Brushes.Red;
                        ex.materiala[11].Brush = Brushes.Red;

                        ex.materialb[1].Brush  = Brushes.Red;
                        ex.materialb[2].Brush  = Brushes.Red;
                        ex.materialb[3].Brush  = Brushes.Red;
                        ex.materialb[4].Brush  = Brushes.Red;
                        ex.materialb[5].Brush  = Brushes.Red;
                        ex.materialb[6].Brush  = Brushes.Red;
                        ex.materialb[7].Brush  = Brushes.Red;
                        ex.materialb[8].Brush  = Brushes.Red;
                        ex.materialb[9].Brush  = Brushes.Red;
                        ex.materialb[10].Brush = Brushes.Red;
                        ex.materialb[11].Brush = Brushes.Red;

                        ex.materialc[1].Brush  = Brushes.Red;
                        ex.materialc[2].Brush  = Brushes.Red;
                        ex.materialc[3].Brush  = Brushes.Red;
                        ex.materialc[4].Brush  = Brushes.Red;
                        ex.materialc[5].Brush  = Brushes.Red;
                        ex.materialc[8].Brush  = Brushes.Red;
                        ex.materialc[9].Brush  = Brushes.Red;
                        ex.materialc[10].Brush = Brushes.Red;
                        ex.materialc[11].Brush = Brushes.Red;

                        ex.materiald[1].Brush  = Brushes.Red;
                        ex.materiald[2].Brush  = Brushes.Red;
                        ex.materiald[3].Brush  = Brushes.Red;
                        ex.materiald[6].Brush  = Brushes.Red;
                        ex.materiald[7].Brush  = Brushes.Red;
                        ex.materiald[8].Brush  = Brushes.Red;
                        ex.materiald[9].Brush  = Brushes.Red;
                        ex.materiald[10].Brush = Brushes.Red;
                        ex.materiald[11].Brush = Brushes.Red;

                        ex.materialf[1].Brush  = Brushes.Red;
                        ex.materialf[2].Brush  = Brushes.Red;
                        ex.materialf[3].Brush  = Brushes.Red;
                        ex.materialf[4].Brush  = Brushes.Red;
                        ex.materialf[5].Brush  = Brushes.Red;
                        ex.materialf[6].Brush  = Brushes.Red;
                        ex.materialf[7].Brush  = Brushes.Red;
                        ex.materialf[10].Brush = Brushes.Red;
                        ex.materialf[11].Brush = Brushes.Red;
                        MessageBox.Show("查询设备是机柜");
                        break;
                    }

                    case 3:
                    {
                        MessageBox.Show("查询设备是UPS设备");
                        break;
                    }

                    case 4:
                    {
                        MessageBox.Show("查询设备是空调");
                        break;
                    }
                    }
                }
            }
        }
    private void AddComponentDoorPanel(ModelObject modelObject, GameObject panel, int submeshIndex)
    {
        GameObject component = new GameObject("Component " + submeshIndex);

        component.transform.parent        = panel.transform;
        component.transform.localScale    = new Vector3(1, 1, 1);
        component.transform.localPosition = new Vector3(0, 0, 0);
        component.transform.localRotation = new Quaternion();

        MeshFilter   meshFilter   = component.AddComponent <MeshFilter>();
        MeshCollider meshCollider = component.AddComponent <MeshCollider>();
        MeshRenderer meshRenderer = component.AddComponent <MeshRenderer>();

        Mesh myMesh = modelObject.GetComponent <MeshFilter>().sharedMesh;
//		List<Vector2> myUVs = new List<Vector2> ();
//		myMesh.GetUVs(submeshIndex,myUVs);
//
        Mesh panelMesh = new Mesh();

        int[] oldTrianges = myMesh.GetTriangles(submeshIndex);

        int count = 0;
        Dictionary <int, int> dictionary = new Dictionary <int, int>();

        for (int x = 0; x < oldTrianges.Length; x++)
        {
            int current = oldTrianges[x];

            if (!dictionary.ContainsKey(current))
            {
                dictionary.Add(current, count);
                count = count + 1;
            }
        }

        int[] newTriangles = new int[oldTrianges.Length];
        for (int x = 0; x < oldTrianges.Length; x++)
        {
            newTriangles[x] = dictionary[oldTrianges[x]];
        }

        Vector3[] oldVerts = myMesh.vertices;
        Vector3[] newVerts = new Vector3[count];
        foreach (KeyValuePair <int, int> pair in dictionary)
        {
            int oldVertIndex = pair.Key;
            int newVertIndex = pair.Value;
            newVerts[newVertIndex] = oldVerts[oldVertIndex];
        }

        panelMesh.vertices  = newVerts;
        panelMesh.triangles = newTriangles;


//		panelMesh.SetUVs(0, myUVs);

        Vector2[] uvs = new Vector2[newVerts.Length];

        for (int i = 0; i < newVerts.Length; i++)
        {
            uvs [i] = new Vector2(newVerts [i].x, newVerts [i].z);
        }

        panelMesh.uv = uvs;
        //panelMesh.RecalculateBounds();
        panelMesh.RecalculateNormals();
        panelMesh.Optimize();

        meshRenderer.material   = modelObject.GetComponent <MeshRenderer>().sharedMaterials[submeshIndex];
        meshFilter.mesh         = panelMesh;
        meshCollider.sharedMesh = panelMesh;
    }
    public void ParseElements()
    {
        ModelObjects.Clear();

        //bool elementRemoved;

        int children = transform.childCount;

        for (int i = children - 1; i >= 0; i--)
        {
            GameObject child = transform.GetChild(i).gameObject;

            if (!ValidObject(child))
            {
                DestroyImmediate(child);
                //elementRemoved = true;
                //break;
            }
            else if (child.name.Contains("_Light"))
            {
                var light = child.GetComponent <Light>();
                if (light == null)
                {
                    light = child.AddComponent <Light>();
                }
                light.enabled = false;
                light.type    = LightType.Point;
                light.shadows = LightShadows.Soft;
                light.range   = 5;

                //FIX ME: Light Shadows Two Sides
            }
            else
            {
                int startIndex = child.name.IndexOf('[') + 1;
                int endIndex   = child.name.LastIndexOf(']');
                int length     = endIndex - startIndex;

                if (endIndex < 0)
                {
                    DestroyImmediate(gameObject);
                    continue;
                }

                string id   = child.name.Substring(startIndex, length);
                string name = child.name.Substring(0, startIndex - 1);

                ModelObject obj = child.GetComponent <ModelObject>();

                if (obj == null)
                {
                    obj = child.AddComponent <ModelObject>();
                }

                obj.Id     = id;
                obj.Name   = name;
                obj.Object = child;

                if (!ModelObjects.Contains(child))
                {
                    ModelObjects.Add(child);
                }

                child.GetComponent <MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
            }
        }
    }
Example #27
0
 private static void PrintScope(string indent, ModelObject scope)
 {
     foreach (var entry in scope.MChildren)
     {
         Console.WriteLine(indent + entry);
         if (entry.IsMetaScope())
         {
             PrintScope(indent + "  ", entry);
         }
     }
 }
Example #28
0
 /// <summary>
 /// Apply this load to an object, if possible
 /// </summary>
 /// <param name="mObj"></param>
 /// <returns>True if the load could be applied.</returns>
 public abstract bool ApplyTo(ModelObject mObj);
Example #29
0
        public void Should_throw_a_mapping_exception()
        {
            var model = new ModelObject();
            model.NullableDate = "Lorem Ipsum";

            typeof(AutoMapperMappingException).ShouldBeThrownBy(() => Mapper.Map<ModelObject, ModelDto>(model));
        }
Example #30
0
 /// <summary>
 /// Is this load applied to the specified model object?
 /// </summary>
 /// <param name="mObj"></param>
 /// <returns></returns>
 public abstract bool IsAppliedTo(ModelObject mObj);
Example #31
0
 private bool SetProfile(string value, ModelObject modelObject)
 {
     (modelObject as BooleanPart).OperativePart.Profile.ProfileString = value;
     return(modelObject.Modify());
 }
Example #32
0
 public void Init()
 {
     instance = new ModelObject();
 }
Example #33
0
            protected override void Establish_context()
            {
                Mapper
                    .CreateMap<ModelObject, ModelDto>()
                    .ForMember(dto => dto.ValueOne, opt => opt.FormatNullValueAs("I am null"));

                var model = new ModelObject { ValueOne = null };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
Example #34
0
 public Player(ModelObject modelObject, IController controller) :
     base(modelObject, controller)
 {
     this.handItem = null;
 }
Example #35
0
        private static bool GetAttributeByUDAFormula(
            PresentedPropertiesXml presentedPropertiesInstance,
            ModelObject modelObj,
            string udaEquation,
            out double resultValue)
        {
            var          removeChar = new[] { '+', '-', '*', '/', '(', ')' };
            const string DelimStr   = " ";
            var          delimiter  = DelimStr.ToCharArray();
            string       insertAddstr;
            var          findIndex = 0;
            double       doubleValue;
            var          culInfo   = CultureInfo.CurrentCulture;
            var          usCulInfo = new CultureInfo("en-us");

            resultValue = 0.0;
            var findString = udaEquation;

            for (var i = 0; i < removeChar.Length; i++)
            {
                findString = findString.Replace(removeChar[i].ToString(CultureInfo.InvariantCulture), " ");
            }

            var splitKey = findString.Split(delimiter);
            var tempKey  = new string[splitKey.Length];

            for (var i = 0; i < splitKey.Length; i++)
            {
                if (splitKey[i].Length <= 0)
                {
                    continue;
                }

                var isDouble = double.TryParse(splitKey[i], NumberStyles.Any, culInfo, out doubleValue);

                if (isDouble == false)
                {
                    isDouble = double.TryParse(splitKey[i], NumberStyles.Any, usCulInfo, out doubleValue);
                }

                if (isDouble == false)
                {
                    tempKey[i] = splitKey[i];

                    insertAddstr = "_UDA_" + i.ToString(CultureInfo.InvariantCulture);
                    findIndex    = udaEquation.IndexOf(splitKey[i], findIndex, StringComparison.Ordinal);

                    findIndex   = findIndex + splitKey[i].Length;
                    udaEquation = udaEquation.Insert(findIndex, insertAddstr);
                }
            }

            for (var i = 0; i < tempKey.Length; i++)
            {
                if (null == tempKey[i] || tempKey[i].Length == 0)
                {
                    continue;
                }

                PresentedProperties property = null;

                if (!presentedPropertiesInstance.GetPropertyByNameOrModelPropertyName(tempKey[i], ref property))
                {
                    continue;
                }

                // Maybe should use just visible property name?
                var propertvalueY = GetPropertvalueYBasedOnType(
                    presentedPropertiesInstance, modelObj, property, true, false);

                try
                {
                    doubleValue  = Convert.ToDouble(propertvalueY);
                    insertAddstr = tempKey[i] + "_UDA_" + i.ToString(CultureInfo.InvariantCulture);
                    udaEquation  = udaEquation.Replace(insertAddstr, doubleValue.ToString(CultureInfo.InvariantCulture));
                }
                catch (Exception ee)
                {
                    Debug.WriteLine(ee);
                    return(false);
                }
            }

            var mathEval = new MathEvaluate();

            if (mathEval.Parse(udaEquation) && mathEval.Error == false)
            {
                mathEval.Infix2Postfix();
                mathEval.EvaluatePostfix();
            }

            if (mathEval.Error)
            {
                if (mathEval.ErrorDescription != MathEvaluate.DivideByZero)
                {
                    return(false);
                }
            }
            else
            {
                resultValue = mathEval.Result;
            }

            return(true);
        }
Example #36
0
        private static void ParseFields(string name)
        {
            bool result = false;

            try
            {
                dynamic[] parsed = null;

                foreach (var filepair in DatLut[name])
                {
                    using (FileStream stream = File.OpenRead(GetPath(filepair.Key)))
                    {
                        var single = DatParser.Parse(stream, filepair.Value);
                        if (parsed == null)
                        {
                            parsed = single;
                            continue;
                        }

                        for (var i = 0; i < Math.Min(parsed.Length, single.Length); ++i)
                        {
                            parsed[i].Merge(single[i]);
                        }
                    }
                }

                if (model[name].Count > 0)
                {
                    foreach (var obj in model[name])
                    {
                        obj.Merge(parsed[obj.id]);
                    }
                }
                else
                {
                    for (var i = 0; i < parsed.Length; ++i)
                    {
                        dynamic obj = new ModelObject();
                        obj.id = i;

                        obj.Merge(parsed[i]);

                        model[name].Add(obj);
                    }
                }

                result = true;
            }
            finally
            {
                DisplayResult(result);
            }
        }
Example #37
0
        /// <summary>The get property value based on type.</summary>
        /// <param name="presentedPropertiesInstance">The presented properties instance.</param>
        /// <param name="part">The part value.</param>
        /// <param name="thisProperty">The this property.</param>
        /// <param name="isReportProperty">The is report property.</param>
        /// <param name="roundDoubles">The round doubles.</param>
        /// <returns>The System.String.</returns>
        private static string GetPropertvalueYBasedOnType(
            PresentedPropertiesXml presentedPropertiesInstance,
            ModelObject part,
            PresentedProperties thisProperty,
            bool isReportProperty,
            bool roundDoubles = true)
        {
            var type         = thisProperty.PropertyType;
            var decimals     = thisProperty.Decimals;
            var propertyName = thisProperty.ReportPropertyName;

            if (!isReportProperty)
            {
                propertyName = thisProperty.UdaPropertyName;
            }

            var result       = string.Empty;
            var intValue     = 0;
            var doubleValue  = 0.0;
            var stringValue  = string.Empty;
            var baseDate     = new DateTime(1970, 1, 1);
            var doubleFromat = roundDoubles ? "N" + decimals.ToString(CultureInfo.InvariantCulture) : "G";

            switch (type.ToLower())
            {
            case PropertyTypes.Pieces:
                result = "1";
                break;

            case PropertyTypes.Formula:
                if (GetAttributeByUDAFormula(presentedPropertiesInstance, part, propertyName, out doubleValue))
                {
                    result = doubleValue.ToString(doubleFromat);
                }

                break;

            case PropertyTypes.Int:
                GetProperty(part, propertyName, isReportProperty, ref intValue);
                result = intValue.ToString(CultureInfo.InvariantCulture);
                break;

            case PropertyTypes.Mm:
            case PropertyTypes.Mm2:
            case PropertyTypes.Mm3:
            case PropertyTypes.Double:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                result = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.String:
                GetProperty(part, propertyName, isReportProperty, ref stringValue);
                result = stringValue;
                break;

            case PropertyTypes.Date:
                if (!propertyName.StartsWith("EXTERNAL."))
                {
                    GetProperty(part, propertyName, isReportProperty, ref intValue);

                    if (intValue != 0)
                    {
                        baseDate = baseDate.AddSeconds(intValue);
                        result   = baseDate.ToString(CultureInfo.InvariantCulture);
                    }
                }
                else
                {
                    GetProperty(part, propertyName, isReportProperty, ref stringValue);
                    result = stringValue;
                }

                break;

            case PropertyTypes.Kg:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                result = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Ton:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 1000;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Cm:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 10;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.M:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 1000;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Cm2:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 100;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.M2:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 1000000;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Cm3:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 1000;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.M3:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 1000000000;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Inch:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 25.4;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Inch2:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 645.16;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Inch3:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 16387.064;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Ft:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 304.8;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Ft2:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 92903.04;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Ft3:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 28316846.6;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Yard:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 914.4;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Yard2:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 836127.36;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Yard3:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 764554857.984;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.Lbs:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 0.45359237;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.TonShort:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 907.18474;
                result      = doubleValue.ToString(doubleFromat);
                break;

            case PropertyTypes.TonLong:
                GetProperty(part, propertyName, isReportProperty, ref doubleValue);
                doubleValue = doubleValue / 1016.0469088;
                result      = doubleValue.ToString(doubleFromat);
                break;
            }

            return(result ?? string.Empty);
        }
Example #38
0
        private static void PostProcess()
        {
            Console.WriteLine("Post-processing parsed data...");

            bool success = false;
            try
            {
                // Add log names for non-english languages
                foreach (var buff in model.buffs)
                {
                    if (buff.ContainsKey("ja"))
                    {
                        buff.jal = buff.ja;
                    }
                }

                // Populate ability recast table with proper names
                foreach (var recast in model.ability_recasts)
                {
                    foreach (var action in model.actions)
                    {
                        if (recast.id == action.recast_id)
                        {
                            recast.en = action.en;
                            recast.ja = action.ja;
                            break;
                        }
                    }
                }

                // Add categories to key items
                var category = "";
                for (var i = model.key_items.Count - 1; i >= 0; --i)
                {
                    dynamic ki = model.key_items[i];
                    if (ki.en.StartsWith("-"))
                    {
                        category = ki.en.Substring(1);
                        model.key_items.Remove(ki);
                    }
                    else
                    {
                        ki.category = category;
                    }
                }

                // Move item descriptions into separate table
                //TODO: Remove when shared resources are implemented
                model.item_descriptions = new List<dynamic> { };
                foreach (var item in model.items)
                {
                    dynamic item_description = new ModelObject();
                    item_description.id = item.id;
                    item_description.en = item.endesc;
                    item_description.ja = item.jadesc;

                    item.endesc = null;
                    item.jadesc = null;

                    model.item_descriptions.Add(item_description);
                }

                // Fill in linked auto-translate names
                foreach (var at in model.auto_translates)
                {
                    if (at.en.StartsWith("@"))
                    {
                        int id = int.Parse(at.en.Substring(2), NumberStyles.HexNumber);

                        string key;
                        switch ((char)at.en[1])
                        {
                        case 'A':
                            key = "zones";
                            break;
                        case 'C':
                            key = "spells";
                            break;
                        case 'J':
                            key = "jobs";
                            break;
                        case 'Y':
                            key = "actions";
                            break;
                        default:
                            throw new InvalidDataException(string.Format("Unknown auto-translate code: {0}", at.en));
                        }

                        dynamic item = null;
                        foreach (var i in model[key])
                        {
                            if (i.id == id)
                            {
                                item = i;
                                break;
                            }
                        }

                        if (item != null)
                        {
                            at.en = item.en;
                            at.ja = item.ja;
                        }
                        else
                        {
                            //throw new InvalidDataException(string.Format("Unknown auto-translate ID for {0}: {1}", key, id));
                        }
                    }
                }

                // Split abilities into categories
                foreach (var action in model.actions)
                {
                    // Weapon skill
                    if (action.id >= 0x0000 && action.id < 0x0200)
                    {
                        action.monster_level = null;
                        action.mp_cost = null;
                        action.recast_id = null;
                        action.tp_cost = null;
                        action.type = null;

                        model.weapon_skills.Add(action);
                    }
                    // Job ability
                    else if (action.id >= 0x0200 && action.id < 0x0600)
                    {
                        action.id -= 0x0200;

                        action.monster_level = null;

                        model.job_abilities.Add(action);
                    }
                    // Job traits
                    else if (action.id >= 0x0600 && action.id < 0x0700)
                    {
                        action.id -= 0x0600;

                        action.monster_level = null;
                        action.mp_cost = null;
                        action.prefix = null;
                        action.recast_id = null;
                        action.tp_cost = null;
                        action.type = null;

                        model.job_traits.Add(action);
                    }
                    // Monstrosity
                    else if (action.id >= 0x0700)
                    {
                        action.id -= 0x0700;

                        action.mp_cost = null;
                        action.recast_id = null;
                        action.type = null;

                        // Remove names, as they are parsed separately
                        action.en = null;
                        action.ja = null;

                        if (action.id < model.monster_abilities.Count)
                        {
                            model.monster_abilities[action.id].Merge(action);
                        }
                    }
                }
                model.actions = null;

                // Shift monster abilities up by 0x100
                foreach (var monster_ability in model.monster_abilities)
                {
                    monster_ability.id += 0x100;
                }

                // Split merit point names/descriptions and filter garbage values
                foreach (var merit_point in model.merit_points)
                {
                    // The first 64 entries contain the category names
                    if (merit_point.id < 0x40 || merit_point.en.StartsWith("Meripo"))
                    {
                        merit_point.id = 0;
                        continue;
                    }

                    // Uneven entries contain the descriptions for the previous entry
                    if (merit_point.id % 2 == 1)
                    {
                        model.merit_points[merit_point.id - 1].endesc = merit_point.en;
                        model.merit_points[merit_point.id - 1].jadesc = merit_point.ja;

                        merit_point.id = 0;
                    }
                }
                ((List<dynamic>)model.merit_points).RemoveAll(merit_point => merit_point.id == 0);

                // Split job point names/descriptions and filter garbage values
                foreach (var job_point in model.job_points)
                {
                    // The first 64 entries contain the category names
                    if (job_point.id < 0x40 || job_point.en == "カテゴリー名" || job_point.en == "ヘルプ文")
                    {
                        job_point.id = 0;
                        continue;
                    }

                    // Uneven entries contain the descriptions for the previous entry
                    if (job_point.id % 2 == 1)
                    {
                        model.job_points[job_point.id - 1].endesc = job_point.en;
                        model.job_points[job_point.id - 1].jadesc = job_point.ja;

                        job_point.id = 0;
                    }
                }
                ((List<dynamic>)model.job_points).RemoveAll(job_point => job_point.id == 0);

                success = true;
            }
            finally
            {
                DisplayResult(success);
            }
        }
Example #39
0
        private void InitializeSkyBox(int scale)
        {
            Transform3D transform = null;
            ModelObject clone     = null;
            ModelObject archetype = null;

            #region Plane Archetype
            transform = new Transform3D(Vector3.Zero,
                                        Vector3.Zero, scale * Vector3.One, Vector3.UnitZ, Vector3.UnitY);

            ColorParameters colorParameters = new ColorParameters(
                this.textureDictionary["checkerboard"]);

            archetype = new ModelObject("arch plane",
                                        ActorType.Decorator, transform,
                                        this.modelDictionary["plane1"],
                                        colorParameters, this.skyBoxEffect);
            #endregion

            #region Back
            clone = archetype.Clone() as ModelObject;
            clone.Transform.Translation = new Vector3(0, 0, -scale / 2.0f);
            clone.ColorParameters       = new ColorParameters(
                this.textureDictionary["back"]);
            this.object3DManager.Add(clone);
            #endregion

            #region Left
            clone = archetype.Clone() as ModelObject;
            clone.Transform.Translation = new Vector3(-scale / 2.0f, 0, 0);
            clone.Transform.Rotation    = new Vector3(0, 90, 0);
            clone.ColorParameters       = new ColorParameters(
                this.textureDictionary["left"]);
            this.object3DManager.Add(clone);
            #endregion

            #region Right
            clone = archetype.Clone() as ModelObject;
            clone.Transform.Translation = new Vector3(scale / 2.0f, 0, 0);
            clone.Transform.Rotation    = new Vector3(0, -90, 0);
            clone.ColorParameters       = new ColorParameters(
                this.textureDictionary["right"]);
            this.object3DManager.Add(clone);
            #endregion

            #region Top
            clone = archetype.Clone() as ModelObject;
            clone.Transform.Translation = new Vector3(0, scale / 2.0f, 0);
            clone.Transform.Rotation    = new Vector3(90, 270, 0);
            clone.ColorParameters       = new ColorParameters(
                this.textureDictionary["sky"]);
            this.object3DManager.Add(clone);
            #endregion

            #region Front
            clone = archetype.Clone() as ModelObject;
            clone.Transform.Translation = new Vector3(0, 0, scale / 2.0f);
            clone.Transform.Rotation    = new Vector3(0, 180, 0);
            clone.ColorParameters       = new ColorParameters(
                this.textureDictionary["front"]);
            this.object3DManager.Add(clone);
            #endregion
        }
 protected override ModelDto Flatten(ModelObject model)
 {
     return(Mapper.Map(model).ToANew <ModelDto>());
 }
Example #41
0
 private bool SetPartPrefix(string value, ModelObject modelObject)
 {
     (modelObject as BooleanPart).OperativePart.PartNumber.Prefix = value;
     return(modelObject.Modify());
 }
Example #42
0
        private void CreatePadFootings(object sender, EventArgs e)
        {
            // Always remember to check that you really have working connection
            if (MyModel.GetConnectionStatus())
            {
                double wsp3 = int.Parse(textBox1.Text);
                double wsp4 = double.Parse(textBox2.Text);

                Picker piku = new Picker();

                //askjdhygausgfdyzjusrgfafsa
                ArrayList info = new ArrayList();
                info = new ArrayList {
                    "END_X", "END_Y", "END_Z", "START_X", "START_Y", "START_Z"
                };
                ArrayList info2 = new ArrayList();
                info2 = new ArrayList {
                    "END_X", "END_Y", "END_Z", "START_X", "START_Y", "START_Z"
                };
                ModelObject part  = new Beam();
                ModelObject part2 = new Beam();
                Hashtable   p1    = new Hashtable();
                Hashtable   p2    = new Hashtable();

                part = piku.PickObject(Picker.PickObjectEnum.PICK_ONE_PART);
                part.GetDoubleReportProperties(info, ref p1);
                part2 = piku.PickObject(Picker.PickObjectEnum.PICK_ONE_PART);
                part2.GetDoubleReportProperties(info2, ref p2);
                Point st1 = new Point();
                Point st2 = new Point();
                st1 = piku.PickPoint();
                st2 = piku.PickPoint();
                Point st3 = new Point(st1);
                Point st4 = new Point(st2);

                //wektory belek
                Vector v1 = new Vector((Convert.ToDouble(p1["START_X"]) - Convert.ToDouble(p1["END_X"])) / 10000, (Convert.ToDouble(p1["START_Y"]) - Convert.ToDouble(p1["END_Y"])) / 10000, (Convert.ToDouble(p1["START_Z"]) - Convert.ToDouble(p1["END_Z"])) / 10000);
                Vector v2 = new Vector((Convert.ToDouble(p2["START_X"]) - Convert.ToDouble(p2["END_X"])) / 10000, (Convert.ToDouble(p2["START_Y"]) - Convert.ToDouble(p2["END_Y"])) / 10000, (Convert.ToDouble(p2["START_Z"]) - Convert.ToDouble(p2["END_Z"])) / 10000);
                double v1d = v1.GetLength(); double ile1 = 30 / v1d;
                double v2d = v2.GetLength(); double ile2 = 30 / v2d;
                double v1dd = v1.GetLength(); double ile3 = wsp4 / v1d;
                double v2dd = v2.GetLength(); double ile4 = wsp4 / v2d;

                st3.Translate((-v1.X) * ile3, (-v1.Y) * ile3, (-v1.Z) * ile3);
                st1.Translate((v1.X) * ile1, (v1.Y) * ile1, (v1.Z) * ile1);
                st4.Translate((-v2.X) * ile2, (-v2.Y) * ile2, (-v2.Z) * ile2);
                st2.Translate((v2.X) * ile4, (v2.Y) * ile4, (v2.Z) * ile4);

                Contour      testowy = new Contour();
                ContourPoint point1  = new ContourPoint(st1, null);
                ContourPoint point2  = new ContourPoint(st3, new Chamfer(45, 0, Chamfer.ChamferTypeEnum.CHAMFER_ROUNDING));
                ContourPoint point3  = new ContourPoint(st4, null);
                testowy.AddContourPoint(point1);
                testowy.AddContourPoint(point2);
                testowy.AddContourPoint(point3);

                Contour      testowy3 = new Contour();
                ContourPoint point10  = new ContourPoint(st4, null);
                ContourPoint point20  = new ContourPoint(st2, new Chamfer(45, 0, Chamfer.ChamferTypeEnum.CHAMFER_ROUNDING));
                ContourPoint point30  = new ContourPoint(st3, null);
                testowy3.AddContourPoint(point10);
                testowy3.AddContourPoint(point20);
                testowy3.AddContourPoint(point30);

                bool strona = radioButton1.Checked;

                ModelObject nb  = CreateBlacha(testowy, strona);
                ModelObject nb3 = CreateBlacha(testowy3, strona);
                nb.Insert();
                nb3.Insert();

                double l1 = 0.0;
                nb.GetReportProperty("LENGTH", ref l1);


                double l2 = 0.0;
                nb3.GetReportProperty("LENGTH", ref l2);

                nb.Delete();
                nb3.Delete();



                Contour testowy2 = new Contour();
                testowy2.AddContourPoint(point1);
                testowy2.AddContourPoint(point2);
                Point        point4v = new Point(dlugosc(point2, point3, l1));
                ContourPoint point4  = new ContourPoint(point4v, null);
                testowy2.AddContourPoint(point4);
                ModelObject nb2 = CreateBlacha(testowy2, strona);

                Contour testowy4 = new Contour();
                testowy4.AddContourPoint(point10);
                testowy4.AddContourPoint(point20);
                Point        point40v = new Point(dlugosc(point20, point30, l2));
                ContourPoint point40  = new ContourPoint(point40v, null);
                testowy4.AddContourPoint(point40);
                ModelObject nb4 = CreateBlacha(testowy4, strona);


                nb2.Insert();
                BoltArray b2 = sruby(point1, point2, nb2 as Part);
                b2.PartToBoltTo = part as Part;
                b2.BoltSize     = Convert.ToDouble(comboBox3.Text);
                b2.BoltStandard = comboBox2.Text;
                b2.Insert();
                nb4.Insert();
                BoltArray b4 = sruby(point10, point20, nb4 as Part);
                b4.BoltSize     = Convert.ToDouble(comboBox3.Text);
                b4.BoltStandard = comboBox2.Text;
                b4.PartToBoltTo = part2 as Part;
                b4.Insert();

                Point point4st  = new Point(dlugosc(point40, point4, 130));
                Point point40st = new Point(dlugosc(point4, point40, 130));

                Point pointsplit = new Point(dlugosc(point4st, point40st, wsp3 + 180));

                if (comboBox1.Text == "D16")
                {
                    Beam st16 = CreateStezenie16(point4st, point40st, strona);
                    st16.Insert();
                    Weld w  = new Weld();
                    Weld w2 = new Weld();
                    w.MainObject      = st16;
                    w.SecondaryObject = nb2;
                    w.ShopWeld        = true;
                    w.Insert();
                    w2.MainObject      = st16;
                    w2.SecondaryObject = nb4;
                    w2.ShopWeld        = true;
                    w2.Insert();
                    Beam       st161 = Operation.Split(st16, pointsplit);
                    Connection sr    = new Connection();
                    sr.Name   = "Po³¹czenie œrub¹ rzymsk¹";
                    sr.Number = 126;
                    sr.LoadAttributesFromFile("82269_M16");
                    sr.SetPrimaryObject(st161);
                    sr.SetSecondaryObject(st16);
                    sr.Insert();
                }
                if (comboBox1.Text == "D20")
                {
                    Beam st16 = CreateStezenie20(point4st, point40st, strona);
                    st16.Insert();
                    Weld w  = new Weld();
                    Weld w2 = new Weld();
                    w.MainObject      = st16;
                    w.SecondaryObject = nb2;
                    w.ShopWeld        = true;
                    w.Insert();
                    w2.MainObject      = st16;
                    w2.SecondaryObject = nb4;
                    w2.ShopWeld        = true;
                    w2.Insert();
                    Beam       st161 = Operation.Split(st16, pointsplit);
                    Connection sr    = new Connection();
                    sr.Name   = "Po³¹czenie œrub¹ rzymsk¹";
                    sr.Number = 126;
                    sr.LoadAttributesFromFile("82269_M20");
                    sr.SetPrimaryObject(st161);
                    sr.SetSecondaryObject(st16);
                    sr.Insert();
                }
                if (comboBox1.Text == "D12")
                {
                    Beam st16 = CreateStezenie12(point4st, point40st, strona);
                    st16.Insert();
                    Weld w  = new Weld();
                    Weld w2 = new Weld();
                    w.MainObject      = st16;
                    w.SecondaryObject = nb2;
                    w.ShopWeld        = true;
                    w.Insert();
                    w2.MainObject      = st16;
                    w2.SecondaryObject = nb4;
                    w2.ShopWeld        = true;
                    w2.Insert();
                    Beam       st161 = Operation.Split(st16, pointsplit);
                    Connection sr    = new Connection();
                    sr.Name   = "Po³¹czenie œrub¹ rzymsk¹";
                    sr.Number = 126;
                    sr.LoadAttributesFromFile("82269_M12");
                    sr.SetPrimaryObject(st161);
                    sr.SetSecondaryObject(st16);
                    sr.Insert();
                }
            }
            MyModel.CommitChanges();
        }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         if (CurrentItem != null)
         {
             if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentAuditProperty))
             {
                 if (solutionContext.CurrentAuditProperty != null)
                 {
                     AuditProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- AuditProperty: ").Append(solutionContext.CurrentAuditProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentCollection))
             {
                 if (solutionContext.CurrentCollection != null)
                 {
                     Collection.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Collection: ").Append(solutionContext.CurrentCollection.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEntity))
             {
                 if (solutionContext.CurrentEntity != null)
                 {
                     Entity.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Entity: ").Append(solutionContext.CurrentEntity.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEntityReference))
             {
                 if (solutionContext.CurrentEntityReference != null)
                 {
                     EntityReference.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- EntityReference: ").Append(solutionContext.CurrentEntityReference.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEnumeration))
             {
                 if (solutionContext.CurrentEnumeration != null)
                 {
                     Enumeration.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Enumeration: ").Append(solutionContext.CurrentEnumeration.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentFeature))
             {
                 if (solutionContext.CurrentFeature != null)
                 {
                     Feature.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Feature: ").Append(solutionContext.CurrentFeature.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentIndex))
             {
                 if (solutionContext.CurrentIndex != null)
                 {
                     Index.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Index: ").Append(solutionContext.CurrentIndex.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentIndexProperty))
             {
                 if (solutionContext.CurrentIndexProperty != null)
                 {
                     IndexProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- IndexProperty: ").Append(solutionContext.CurrentIndexProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentMethod))
             {
                 if (solutionContext.CurrentMethod != null)
                 {
                     Method.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Method: ").Append(solutionContext.CurrentMethod.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentMethodRelationship))
             {
                 if (solutionContext.CurrentMethodRelationship != null)
                 {
                     MethodRelationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- MethodRelationship: ").Append(solutionContext.CurrentMethodRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModel))
             {
                 if (solutionContext.CurrentModel != null)
                 {
                     Model.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Model: ").Append(solutionContext.CurrentModel.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModelObject))
             {
                 if (solutionContext.CurrentModelObject != null)
                 {
                     ModelObject.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ModelObject: ").Append(solutionContext.CurrentModelObject.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModelProperty))
             {
                 if (solutionContext.CurrentModelProperty != null)
                 {
                     ModelProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ModelProperty: ").Append(solutionContext.CurrentModelProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentObjectInstance))
             {
                 if (solutionContext.CurrentObjectInstance != null)
                 {
                     ObjectInstance.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ObjectInstance: ").Append(solutionContext.CurrentObjectInstance.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentParameter))
             {
                 if (solutionContext.CurrentParameter != null)
                 {
                     Parameter.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Parameter: ").Append(solutionContext.CurrentParameter.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentProject))
             {
                 if (solutionContext.CurrentProject != null)
                 {
                     Project.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Project: ").Append(solutionContext.CurrentProject.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentProperty))
             {
                 if (solutionContext.CurrentProperty != null)
                 {
                     Property.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Property: ").Append(solutionContext.CurrentProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyInstance))
             {
                 if (solutionContext.CurrentPropertyInstance != null)
                 {
                     PropertyInstance.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyInstance: ").Append(solutionContext.CurrentPropertyInstance.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyReference))
             {
                 if (solutionContext.CurrentPropertyReference != null)
                 {
                     PropertyReference.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyReference: ").Append(solutionContext.CurrentPropertyReference.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyRelationship))
             {
                 if (solutionContext.CurrentPropertyRelationship != null)
                 {
                     PropertyRelationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyRelationship: ").Append(solutionContext.CurrentPropertyRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentRelationship))
             {
                 if (solutionContext.CurrentRelationship != null)
                 {
                     Relationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Relationship: ").Append(solutionContext.CurrentRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentRelationshipProperty))
             {
                 if (solutionContext.CurrentRelationshipProperty != null)
                 {
                     RelationshipProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- RelationshipProperty: ").Append(solutionContext.CurrentRelationshipProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStage))
             {
                 if (solutionContext.CurrentStage != null)
                 {
                     Stage.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Stage: ").Append(solutionContext.CurrentStage.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStageTransition))
             {
                 if (solutionContext.CurrentStageTransition != null)
                 {
                     StageTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StageTransition: ").Append(solutionContext.CurrentStageTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentState))
             {
                 if (solutionContext.CurrentState != null)
                 {
                     State.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- State: ").Append(solutionContext.CurrentState.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStateModel))
             {
                 if (solutionContext.CurrentStateModel != null)
                 {
                     StateModel.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StateModel: ").Append(solutionContext.CurrentStateModel.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStateTransition))
             {
                 if (solutionContext.CurrentStateTransition != null)
                 {
                     StateTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StateTransition: ").Append(solutionContext.CurrentStateTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStep))
             {
                 if (solutionContext.CurrentStep != null)
                 {
                     Step.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Step: ").Append(solutionContext.CurrentStep.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStepTransition))
             {
                 if (solutionContext.CurrentStepTransition != null)
                 {
                     StepTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StepTransition: ").Append(solutionContext.CurrentStepTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentValue))
             {
                 if (solutionContext.CurrentValue != null)
                 {
                     Value.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Value: ").Append(solutionContext.CurrentValue.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentView))
             {
                 if (solutionContext.CurrentView != null)
                 {
                     View.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- View: ").Append(solutionContext.CurrentView.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentViewProperty))
             {
                 if (solutionContext.CurrentViewProperty != null)
                 {
                     ViewProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ViewProperty: ").Append(solutionContext.CurrentViewProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentWorkflow))
             {
                 if (solutionContext.CurrentWorkflow != null)
                 {
                     Workflow.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Workflow: ").Append(solutionContext.CurrentWorkflow.InnerXmlData);
                     }
                 }
             }
             #region protected
             #endregion protected
             else
             {
                 LogException(solutionContext, templateContext, modelContext, String.Format(DisplayValues.Exception_CouldNotDeleteItem, CurrentItem.CurrentItemName), interpreterType);
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Example #44
0
        // Starts a new thread that continuously indexes new search items
        // as they become available
        private void BeginIndexing()
        {
            // An anonymous method that loops and does the
            // indexing when appropriate
            ThreadStart index = delegate
            {
                while (true)
                {
                    // Wait if there is no work to do
                    this.queueResetEvent.WaitOne();

                    // Get the next indexing operation, if one is available
                    ModelObject       modelObject       = null;
                    IndexingOperation indexingOperation = IndexingOperation.Register;
                    lock (this.indexingQueue)
                    {
                        // If there are no indexing operations available, set
                        // the status to ready and wait for more work
                        if (this.indexingQueue.Count == 0)
                        {
                            this.Status = IndexingStatus.Ready;
                            this.queueResetEvent.Reset();
                            continue;
                        }
                        // Otherwise, dequeue the next work item
                        else
                        {
                            foreach (KeyValuePair <ModelObject, IndexingOperation> entry in this.indexingQueue)
                            {
                                modelObject       = entry.Key;
                                indexingOperation = entry.Value;
                                break;
                            }

                            if (modelObject != null)
                            {
                                this.indexingQueue.Remove(modelObject);
                            }
                        }
                    }

                    // Process the indexing operation
                    if (modelObject != null)
                    {
                        if (indexingOperation == IndexingOperation.Register)
                        {
                            this.RegisterModelObject(modelObject);
                        }
                        else if (indexingOperation == IndexingOperation.Unregister)
                        {
                            this.UnregisterModelObject(modelObject);
                        }
                    }
                }
            };

            // Create a new thread and start the indexing loop
            Thread thread = new Thread(index);

            thread.Name         = "Search Engine Indexer";
            thread.IsBackground = true;
            thread.Priority     = ThreadPriority.BelowNormal;
            thread.Start();
        }
Example #45
0
 protected override void Because_of()
 {
     var model = new ModelObject();
     _result = Mapper.Map<ModelObject, ModelDto>(model);
 }
Example #46
0
            protected override void Establish_context()
            {
                Mapper.ForSourceType<DateTime>().AddFormatter<ShortDateFormatter>();
                Mapper.ForSourceType<int>().AddFormatExpression(context => ((int)context.SourceValue + 1).ToString());

                Mapper.CreateMap<ModelObject, ModelDto>();

                var model = new ModelObject { StartDate = new DateTime(2004, 12, 25), OtherValue = 43 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
Example #47
0
 protected override void Because_of()
 {
     _model = new ModelObject();
     _dto = Mapper.Map<ModelObject, ModelDto>(_model);
 }
Example #48
0
            protected override void Establish_context()
            {
                Mapper.AddFormatter<CrazyEncoder>();

                Mapper.Reset();

                Mapper.CreateMap<ModelObject, ModelDto>();

                var modelObject = new ModelObject { Value = 14 };

                _modelDto = Mapper.Map<ModelObject, ModelDto>(modelObject);
            }
Example #49
0
 private void CheckXsdNamespace(SoalType type, ModelObject symbol)
 {
     if (!type.HasXsdNamespace())
     {
         this.Diagnostics.AddError("The type of this element has no XSD namespace.", this.FileName, symbol);
     }
 }
Example #50
0
            protected override void Establish_context()
            {
                Mapper.AddFormatter<SampleFormatter>();
                Mapper.ForSourceType<int>().SkipFormatter<SampleFormatter>();

                Mapper.CreateMap<ModelObject, ModelDto>();

                var model = new ModelObject { ValueOne = 24 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
 public DisplayModelMember(ModelObject model, PropertyInfo propertyInfo, DisplayInfo displayInfo)
     : base(model, propertyInfo, displayInfo)
 {
 }
Example #52
0
        public bool Load(Stream rsw, Map owner)
        {
            BinaryReader br     = new BinaryReader(rsw);
            string       header = ((char)br.ReadByte()).ToString() + ((char)br.ReadByte()) + ((char)br.ReadByte()) + ((char)br.ReadByte());

            if (header != "GRSW")
            {
                return(false);
            }

            majorVersion = br.ReadByte();
            minorVersion = br.ReadByte();

            if (!(majorVersion == 1 && minorVersion >= 2 && minorVersion <= 9) &&
                !(majorVersion == 2 && minorVersion <= 2))
            {
                return(false);
            }

            _iniFile      = br.ReadCString(40);
            _groundFile   = br.ReadCString(40);
            _altitudeFile = br.ReadCString(40);
            _scrFile      = br.ReadCString(40);

            _waterInfo.Load(br, majorVersion, minorVersion);
            _lightInfo.Load(br, majorVersion, minorVersion);
            _groundInfo.Load(br, majorVersion, minorVersion);

            _models = new List <ModelObject>();

            Logger.TabLevel++;

            int count = br.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                int type     = br.ReadInt32();
                int skipSize = 0;

                if (type == 1)
                {
                    ModelObject mo = new ModelObject();

                    mo.Load(br, majorVersion, minorVersion, owner.Ground);

                    Vector3 tmp = mo.Position;
                    tmp.X       = (mo.Position.X / 5) + owner.Ground.Width;
                    tmp.Z       = (mo.Position.Z / 5) + owner.Ground.Height;
                    mo.Position = tmp;

                    _models.Add(mo);
                }
                else if (type == 2)
                {
                    skipSize = 80 + sizeof(float) * 3 + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(float);
                }
                else if (type == 3)
                {
                    skipSize = 80 + 80 + sizeof(float) * 3 + sizeof(float) + sizeof(int) + sizeof(int) + sizeof(float);

                    if (majorVersion >= 2)
                    {
                        skipSize += sizeof(float);
                    }
                }
                else if (type == 4)
                {
                    skipSize = 80 + sizeof(float) * 3 + sizeof(int) + sizeof(float) + sizeof(float) * 4;
                }

                if (skipSize > 0)
                {
                    br.ReadBytes(skipSize);
                }
            }

            Logger.TabLevel--;

            Logger.WriteLine("Loading water type {0} textures...", _waterInfo.Type);
            SetupWater(_waterInfo.Type);

            Logger.WriteLine("Creating water vertex buffer...");
            UpdateWaterVertices(owner);

            Logger.WriteLine("World v{0}.{1} status: {2} objects - {3} models", majorVersion, minorVersion, count, _models.Count);
            Logger.WriteLine("    Water height: {0}", _waterInfo.Level);
            Logger.WriteLine("    Water type: {0}", _waterInfo.Type);

            return(true);
        }
Example #53
0
            protected override void Establish_context()
            {
                Mapper.AddFormatExpression(context => string.Format("{0} Value", context.SourceValue));
                Mapper.ForSourceType<int>().AddFormatExpression(context => ((int)context.SourceValue + 1).ToString());

                Mapper.CreateMap<ModelObject, ModelDto>();

                var model = new ModelObject { OtherValue = 43 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
Example #54
0
        public override void Convert(ResourceLocation source, ResourceLocation dest)
        {
            XmlReader xml = XmlReader.Create(source.GetStream);

            MeshData[] entities = null;
            ModelObject[] modelObjects = null;

            List<Material> materials = new List<Material>();
            List<TapeHelper> targetHelpers = new List<TapeHelper>();

            xml.Read();

            string srcPath = Path.GetDirectoryName(((FileLocation)source).Path);

            int depth;
            int index = 0;

            while (xml.Read())
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    switch (xml.Name)
                    {
                        case "Info":
                            depth = xml.Depth;
                            while (xml.Read() && xml.Depth > depth)
                            {
                                if (xml.IsStartElement() && !xml.IsEmptyElement)
                                {
                                    if (xml.Name == "MeshCount")
                                    {
                                        int meshCount = int.Parse(xml.ReadString());
                                        entities = new MeshData[meshCount];
                                        modelObjects = new ModelObject[meshCount];
                                    }
                                }
                            }
                            break;
                        case "Material":
                            //XmlReader xmlMats = xml.ReadSubtree();
                            depth = xml.Depth;
                            while (xml.Read() && xml.Depth > depth)
                            {
                                if (xml.IsStartElement() && !xml.IsEmptyElement)
                                {
                                    if (xml.Name == "Slot")
                                    {
                                        materials.Add(ParseMaterial(xml, dest, srcPath));
                                    }
                                }
                            }

                            Material defMat = new Material(null);
                            defMat.Ambient = Material.DefaultMaterial.Ambient;
                            defMat.Diffuse = Material.DefaultMaterial.Diffuse;
                            defMat.Specular = Material.DefaultMaterial.Specular;
                            defMat.Emissive = Material.DefaultMaterial.Emissive;
                            materials.Add(defMat);
                            //materialArray = materials.ToArray();
                            //xmlMats.Close();
                            break;
                        case "Object":
                            string objName = xml.GetAttribute("Name");
                            string objClass = xml.GetAttribute("Class");
                            int oindex = int.Parse(xml.GetAttribute("ID"));

                            switch (objClass)
                            {
                                case "Editable_mesh":
                                    modelObjects[index] = ParseMeshData(xml);

                                    modelObjects[index].Index = oindex;

                                    entities[index] = modelObjects[index].Mesh;
                                    entities[index].Name = objName;

                                    index++;
                                    break;

                                //case "Tape":
                                //    Vector3 pos = ParseTapeTarget(xml);


                                //    break;
                                //case "Targetobject":
                                //    pos = ParseTapeTarget(xml);


                                //    break;
                                case "BoneGeometry":

                                    break;
                            }
                            break;
                    }
                }
            }

            xml.Close();

            for (int i = 0; i < entities.Length; i++)
            {
                bool[] useState = new bool[materials.Count];
                for (int j = 0; j < entities[i].Faces.Length; j++)
                {
                    int mId = entities[i].Faces[j].MaterialIndex;
                    if (mId == -1)
                    {
                        mId = materials.Count - 1;
                        entities[i].Faces[j].MaterialIndex = mId;
                    }
                    useState[mId] = true;
                }

                int[] matIdxShift = new int[materials.Count];
                int shifts = 0;
                List<Material> entMats = new List<Material>();
                for (int j = 0; j < materials.Count; j++)
                {
                    if (useState[j])
                    {
                        entMats.Add(materials[j]);
                        matIdxShift[j] = shifts;
                    }
                    else
                    {
                        shifts++;
                    }
                }

                entities[i].Materials = new Material[entMats.Count][];  //entMats.ToArray();
                entities[i].MaterialAnimation = new MaterialAnimationInstance[entMats.Count];
                
                for (int j = 0; j < entMats.Count; j++)
                {
                    entities[i].Materials[j] = new Material[] { entMats[j] };

                    entities[i].MaterialAnimation[j] = new MaterialAnimationInstance(new MaterialAnimation(1, 1));
                }
                    
                for (int j = 0; j < entities[i].Faces.Length; j++)
                {
                    entities[i].Faces[j].MaterialIndex -= matIdxShift[entities[i].Faces[j].MaterialIndex];
                }
            }

            EditableModel mdl = new EditableModel();
            mdl.Entities = entities;

            #region
            TransformAnimation tranAnim = new TransformAnimation(entities.Length);
            for (int i = 0; i < entities.Length; i++) 
            {
                tranAnim.Nodes[i].Transforms[0] = modelObjects[i].LocalTransform;
            }
            #endregion


            new TransformAnimationInstance(tranAnim);
//#warning impl skeleton
//            mdl.ModelAnimation = new NoAnimation(GraphicsDevice.Instance.Device, trans);

            EditableModel.ToStream(mdl, dest.GetStream);

            mdl.Dispose();
        }
Example #55
0
            protected override void Establish_context()
            {
                Mapper.ForSourceType<int>().AddFormatter<SampleFormatter>();

                Mapper
                    .CreateMap<ModelObject, ModelDto>()
                    .ForMember(d => d.ValueTwo, opt => opt.SkipFormatter<SampleFormatter>());

                var model = new ModelObject { ValueOne = 24, ValueTwo = 42 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
Example #56
0
        private void InsertComponents(ModelObject mObj, List <TSM.Component> components)
        {
            TransformationPlane originalTransformationplane = null;
            WorkPlaneHandler    wHandler = null;

            try {
                wHandler = model.GetWorkPlaneHandler();
                originalTransformationplane = wHandler.GetCurrentTransformationPlane();
                ComponentInput compInput  = new ComponentInput();
                Part           fatherpart = mObj as Part;
                Assembly       assembly   = fatherpart.GetAssembly();

                // Get the transformationplane from objects coordinate systems vectors and because objects coordinate system is not the same XY plane as of models,
                // so cross product needs to be made for the Y-axis
                TransformationPlane fatherpartsTransformationPlane = new TransformationPlane(fatherpart.GetCoordinateSystem().Origin, fatherpart.GetCoordinateSystem().AxisX, Vector.Cross(fatherpart.GetCoordinateSystem().AxisY, fatherpart.GetCoordinateSystem().AxisX));
                lock (wHandler) {
                    wHandler.SetCurrentTransformationPlane(fatherpartsTransformationPlane);
                }
                double minX            = fatherpart.GetSolid().MinimumPoint.X;
                double minY            = fatherpart.GetSolid().MinimumPoint.Y;
                double minZ            = fatherpart.GetSolid().MinimumPoint.Z;
                double maxX            = fatherpart.GetSolid().MaximumPoint.X;
                double maxY            = fatherpart.GetSolid().MaximumPoint.Y;
                double maxZ            = fatherpart.GetSolid().MaximumPoint.Z;
                bool   changeDirection = false;

                if (data.Direction == "y-")
                {
                    double temp = maxY;
                    maxY            = minY;
                    minY            = temp;
                    changeDirection = true;
                }

                Solid          s     = fatherpart.GetSolid();
                FaceEnumerator fEnum = s.GetFaceEnumerator();
                StringBuilder  sb    = new StringBuilder();
                while (fEnum.MoveNext())
                {
                }
                Point        p1            = null;
                Point        p2            = null;
                List <Point> cutPartPoints = new List <Point>()
                {
                    new Point(),
                    new Point(),
                    new Point(),
                    new Point()
                };
                ContourPlate cutpart = null;

                for (int i = 0; i < components.Count; i++)
                {
                    cutpart                         = new ContourPlate();
                    cutpart.Name                    = "Leikkaus";
                    cutpart.Position.Depth          = Position.DepthEnum.MIDDLE;
                    cutpart.Position.Plane          = Position.PlaneEnum.MIDDLE;
                    cutpart.Class                   = BooleanPart.BooleanOperativeClassName;
                    cutpart.Material.MaterialString = "Reikä";
                    cutpart.Profile.ProfileString   = "PL135";
                    BooleanPart bPart = new BooleanPart();
                    compInput = new ComponentInput();
                    double[] variables;
                    switch (i)
                    {
                    case 0:
                        p1        = new Point(maxX - data.LeftShoeDist, 0, minZ);
                        p2        = new Point(maxX - data.LeftShoeDist, maxY, minZ);
                        variables = WallShoeUtils.GetComponentVariables(components[i]);
                        if (variables[0] != 0)
                        {
                            AddWallShoeCut(variables, p1, minY, maxY, changeDirection, fatherpart);
                        }
                        break;

                    case 1:
                        p1        = new Point(minX + data.RightShoeDist, 0, minZ);
                        p2        = new Point(minX + data.RightShoeDist, maxY, minZ);
                        variables = WallShoeUtils.GetComponentVariables(components[i]);
                        if (variables[0] != 0)
                        {
                            AddWallShoeCut(variables, p1, minY, maxY, changeDirection, fatherpart);
                        }
                        break;

                    case 2:
                        p1 = new Point(maxX - data.LeftBoltDist, 0, maxZ + data.LeftBoltOffset);
                        p2 = new Point(maxX - data.LeftBoltDist, maxY, maxZ + data.LeftBoltOffset);
                        break;

                    case 3:
                        p1 = new Point(minX + data.RightBoltDist, 0, maxZ + data.RightBoltOffset);
                        sb.AppendLine(data.RightBoltDist + " " + data.RightBoltOffset);
                        p2 = new Point(minX + data.RightBoltDist, maxY, maxZ + data.RightBoltOffset);
                        break;
                    }
                    compInput.AddOneInputPosition(p1);
                    compInput.AddOneInputPosition(p2);
                    components[i].SetComponentInput(compInput);
                    if (!components[i].Insert())
                    {
                        TSM.Operations.Operation.DisplayPrompt("Komponentin " + i + " asettaminen epäonnistui!");
                        WriteLog("Komponentin " + i + " asettaminen epäonnistui!");
                    }
                }
                foreach (TSM.Component c in components)
                {
                    assembly.Add(c);
                    assembly.Modify();
                }
            } catch (Exception ex) {
                WriteLog(ex.Message + "\n" + ex.StackTrace);
            } finally {
                lock (wHandler) {
                    wHandler.SetCurrentTransformationPlane(originalTransformationplane);
                }
            }
        }
Example #57
0
            protected override void Establish_context()
            {
                Mapper
                    .CreateMap<ModelObject, ModelDto>()
                    .ForMember(dto => dto.ValueOne, opt => opt.AddFormatter<SampleFormatter>());

                var model = new ModelObject { ValueOne = 24 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
Example #58
0
 private void OnPropertyChanged(ModelObject sender, UndoablePropertyChangedEventArgs eventArgs)
 {
     this.UnregisterModelObject(eventArgs.OldValue as ModelObject);
     this.RaisePropertyChangedEvent(sender, eventArgs);
     this.RegisterModelObject(eventArgs.NewValue as ModelObject);
 }
Example #59
0
 private bool UnregisterProperty(ModelObject modelObject, PropertyDescriptor propertyDescriptor)
 {
     return(this.UnregisterProperty(modelObject, propertyDescriptor, EditorSearchEngine <T> .requestPropertyQuery));
 }
Example #60
0
 private bool SetFinish(string value, ModelObject modelObject)
 {
     (modelObject as BooleanPart).OperativePart.Finish = value;
     return(modelObject.Modify());
 }