Esempio n. 1
0
        public static ProjectTreeNode Load(ZipArchive archive, string directoryPath, ProjectTreeNode parent)
        {
            ZipArchiveEntry entry = archive.GetEntry(directoryPath + "node.xml");
            ProjectTreeNode node;

            using (StreamReader reader = new StreamReader(entry.Open(), Encoding.UTF8))
            {
                System.Xml.Serialization.XmlSerializer serializer =
                    new System.Xml.Serialization.XmlSerializer(typeof(SaveData));
                var savedata = (SaveData)serializer.Deserialize(reader);
                if (savedata.Class == "Node_Project")
                {
                    node = new Node_Project(null);
                }
                else if (savedata.Class == "Node_RawTireData")
                {
                    node = new Node_RawTireData(null, parent as Node_Project);
                }
                else if (savedata.Class == "Node_DataSelector")
                {
                    node = new Node_DataSelector(null, parent as Node_TireDataSet, false);
                }
                else// if (savedata.Class == typeof(Node_MagicFormula))
                {
                    node = new Node_MagicFormula(null, parent as Node_TireDataSet);
                }
                node.savedata = savedata;
            }
            if (node.OnLoad(archive, directoryPath))
            {
                node.State = ProjectTreeState.NotChanged;
            }
            return(node);
        }
Esempio n. 2
0
        public static ProjectTree.ProjectTreeNode CopyProjectTree(ProjectTree.ProjectTreeNode original, ProjectTree.ProjectTreeNode parent)
        {
            ProjectTree.ProjectTreeNode newNode = null;
            bool childrenToUpdate = false;

            if (original is ProjectTree.Node_DataSelector)
            {
                var nds = new ProjectTree.Node_DataSelector(original.Name, parent as ProjectTree.Node_TireDataSet, true);
                nds.TDSS.CopyFrom((original as ProjectTree.Node_DataSelector).TDSS.Copy());
                newNode = nds;
            }
            else if (original is ProjectTree.Node_MagicFormula)
            {
                var nmf = new ProjectTree.Node_MagicFormula(original.Name, parent as ProjectTree.Node_TireDataSet);
                nmf.MFFD.CopyFrom((original as ProjectTree.Node_MagicFormula).MFFD.Copy(), original.Parent == parent);
                newNode          = nmf;
                childrenToUpdate = original.Parent != parent;
            }
            else if (original is ProjectTree.Node_RawTireData)
            {
                var nrt = new ProjectTree.Node_RawTireData(original.Name, parent as ProjectTree.Node_Project);
                nrt.RTDM.CopyFrom((original as ProjectTree.Node_RawTireData).RTDM);
                newNode = nrt;
            }
            newNode.Copying = true;
            foreach (var child in original.Children)
            {
                if (child.Copying)
                {
                    continue;
                }
                var node = CopyProjectTree(child, newNode);
                //newNode.Children.Add(node);
            }
            if (childrenToUpdate)
            {
                newNode.ConfirmNotUpdated();
            }
            return(newNode);
        }