Exemplo n.º 1
0
 void OnEnable()
 {
     model    = target as EditableModel;
     tempFace = new int[3] {
         -1, -1, -1
     };
 }
Exemplo n.º 2
0
 public DisplayForm()
 {
     InitializeComponent();
     ClientSize = new Size(800, 600);
     InitializeRendering();
     Model = new EditableModel(this);
 }
Exemplo n.º 3
0
        public void TestStaticOf()
        {
            var input = new object();
            EditableModel <object> result = EditableModel.Of(input);

            Assert.AreEqual(input, result.Value);
        }
Exemplo n.º 4
0
    public void Save(EditableModel model, Guid sceneGuid)
    {
        var data = model.GetData();
        var path = PathHelper.GetModelBinPath(data.Guid, sceneGuid);

        Loader.SaveObj(path, data);
    }
Exemplo n.º 5
0
        public void TestChangedValue()
        {
            var objectUnderTest = new EditableModel <string>(InitialValue);

            objectUnderTest.Value = ChangedValue;

            Assert.AreEqual(ChangedValue, objectUnderTest.Value);
        }
Exemplo n.º 6
0
        public void TestToStringNull()
        {
            var objectUnderTest = new EditableModel <object>(null);

            string resultString = objectUnderTest.ToString();

            Assert.AreEqual("", resultString);
        }
Exemplo n.º 7
0
        public void TestCancelWithoutBeginDoesNotRevert()
        {
            var objectUnderTest = new EditableModel <string>(InitialValue);

            objectUnderTest.Value = ChangedValue;
            objectUnderTest.CancelEdit();

            Assert.AreEqual(ChangedValue, objectUnderTest.Value);
        }
Exemplo n.º 8
0
        public void TestToString()
        {
            const string testString      = "test string";
            var          objectUnderTest = new EditableModel <object>(Mock.Of <object>(o => o.ToString() == testString));

            string resultString = objectUnderTest.ToString();

            Assert.AreEqual(testString, resultString);
        }
Exemplo n.º 9
0
        private void CompareFiles(object parameter = null)
        {
            _compareResults = EditableModelChangeHistoryEntry.CompareEditableModel(
                em1: FileA, em2: FileB, includeNonChanged: true);

            ObservableCollection <BlockModel> blocks       = new ObservableCollection <BlockModel>();
            EditableModelChangeHistoryEntry   blockResults = _compareResults.ChangedItems
                                                             .FirstOrDefault(r => r.Property == "Blocks");

            if (blockResults != null)
            {
                for (int b = 0; b < blockResults.ChangedItems.Count; b++)
                {
                    var blockResult   = blockResults.ChangedItems[b];
                    var originalBlock = blockResult.OldValue as BlockModel;
                    var modifiedBlock = blockResult.NewValue as BlockModel;
                    EditableModelChangeHistoryEntry chunkResults = blockResult.ChangedItems
                                                                   .FirstOrDefault(r => r.Property == "Chunks");

                    if (originalBlock != null)
                    {
                        EditableModel.SetChangeHistory(originalBlock, blockResult);
                    }

                    if (modifiedBlock != null)
                    {
                        EditableModel.SetChangeHistory(modifiedBlock, blockResult);
                    }

                    blocks.Add(modifiedBlock == null ? originalBlock : modifiedBlock);

                    if (chunkResults != null)
                    {
                        for (int c = 0; c < chunkResults.ChangedItems.Count; c++)
                        {
                            var chunkResult   = chunkResults.ChangedItems[c];
                            var originalChunk = chunkResult.OldValue as ChunkModel;
                            var modifiedChunk = chunkResult.NewValue as ChunkModel;

                            if (originalChunk != null)
                            {
                                EditableModel.SetChangeHistory(originalChunk, chunkResult);
                            }

                            if (modifiedChunk != null)
                            {
                                EditableModel.SetChangeHistory(modifiedChunk, chunkResult);
                            }
                        }
                    }
                }
            }

            Blocks = blocks;
        }
Exemplo n.º 10
0
        protected virtual void FillEditableModel(EditableModel <PK> em, bool isInsert)
        {
            var userIdentity = GetUserIdentity();

            if (isInsert)
            {
                em.CreateTime     = DateTime.Now;
                em.CreateUserId   = userIdentity.UserId;
                em.CreateUserName = userIdentity.RealName;
            }
            em.ModifyTime     = DateTime.Now;
            em.ModifyUserId   = userIdentity.UserId;
            em.ModifyUserName = userIdentity.RealName;
        }
Exemplo n.º 11
0
        public void TestUpdateValueNotifies()
        {
            var objectUnderTest  = new EditableModel <string>(InitialValue);
            var eventHandlerMock = new Mock <Action <object, PropertyChangedEventArgs> >();

            objectUnderTest.PropertyChanged += new PropertyChangedEventHandler(eventHandlerMock.Object);

            objectUnderTest.Value = ChangedValue;

            eventHandlerMock.Verify(
                h => h(
                    objectUnderTest,
                    It.Is <PropertyChangedEventArgs>(args => args.PropertyName == nameof(objectUnderTest.Value))),
                Times.Once);
        }
Exemplo n.º 12
0
        private void UpdateChunks()
        {
            if (SelectedBlock == null)
            {
                OriginalChunks = null;
                ModifiedChunks = null;
            }

            else
            {
                EditableModelChangeHistoryEntry chunkResults = EditableModel.GetChangeHistory(SelectedBlock)
                                                               .ChangedItems.FirstOrDefault(r => r.Property == "Chunks");

                if (chunkResults != null)
                {
                    OriginalChunks = (IList)chunkResults.OldValue;
                    ModifiedChunks = (IList)chunkResults.NewValue;
                }
            }
        }
Exemplo n.º 13
0
 public static bool GetInstanceAndServices(ITypeDescriptorContext ctx, out object instance, out FlexDesignerHostServices services)
 {
     if (ctx == null)
     {
         instance = null;
         services = null;
         return(false);
     }
     else if (ctx.Instance is EditableModel)
     {
         EditableModel model = (EditableModel)ctx.Instance;
         instance = model.Instance;
         services = model.Services;
         return(true);
     }
     else
     {
         // worst case. I don't like using static prop but have no better ideas.
         instance = ctx.Instance;
         services = MainForm.TheMainForm.DesignerHostServices;
         return(true);
     }
 }
Exemplo n.º 14
0
 public static void SetModelValidation(EditableModel obj, ModelValidation value)
 {
     obj.SetValue(ModelValidationProperty, value);
 }
Exemplo n.º 15
0
 public static ModelValidation GetModelValidation(EditableModel obj)
 {
     return((ModelValidation)obj.GetValue(ModelValidationProperty));
 }
Exemplo n.º 16
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();
        }
Exemplo n.º 17
0
        public void TestDefaultValue()
        {
            var objectUnderTest = new EditableModel <string>();

            Assert.IsNull(objectUnderTest.Value);
        }