Beispiel #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);
        }
Beispiel #2
0
        public MyTreeNode GetTreeView(ProjectTree.ProjectTreeNode node)
        {
            MyTreeNode mtn;

            if (node is ProjectTree.Node_Project)
            {
                mtn = new TreeViewNode_Project(ProjectTreeView, node as ProjectTree.Node_Project);
            }
            else if (node is ProjectTree.Node_RawTireData)
            {
                mtn = new TreeViewNode_RawTireData(ProjectTreeView, node as ProjectTree.Node_RawTireData);
            }
            else if (node is ProjectTree.Node_DataSelector)
            {
                mtn = new TreeViewNode_Selector(ProjectTreeView, node as ProjectTree.Node_DataSelector);
            }
            else// if (node is ProjectTree.Node_MagicFormula)
            {
                mtn = new TreeViewNode_MagicFormula(ProjectTreeView, node as ProjectTree.Node_MagicFormula);
            }
            foreach (var child in node.Children)
            {
                mtn.Nodes.Add(GetTreeView(child));
            }
            return(mtn);
        }
Beispiel #3
0
        static ProjectTree.ProjectTreeNode LoadAll(ProjectTree.ProjectTreeNode parent, ZipArchive archive, string path, List <string> folderTree, UserControls.ProgressDialog pd = null)
        {
            var lastPath = folderTree.Last();

            while (lastPath != null && lastPath.Contains(path))
            {
                var node = ProjectTree.ProjectTreeNode.Load(archive, lastPath + "\\", parent);
                if (pd != null)
                {
                    ++pd.Value;
                }

                folderTree.RemoveAt(folderTree.Count - 1);
                if (folderTree.Count == 0)
                {
                    return(node);
                }


                LoadAll(node, archive, lastPath, folderTree, pd);
                if (folderTree.Count == 0)
                {
                    return(node);
                }
                lastPath = folderTree.Last();
            }
            return(null);
        }
Beispiel #4
0
 public Node_TireDataSet(string name, ProjectTreeNode parent)
     : base(parent)
 {
     if (name != null && name != "")
     {
         Name = name;
     }
 }
Beispiel #5
0
 public static void ResetCopyFlag(ProjectTree.ProjectTreeNode original)
 {
     original.Copying = false;
     foreach (var child in original.Children)
     {
         ResetCopyFlag(child);
     }
 }
Beispiel #6
0
 static void GetAllGUID(List <string> list, ProjectTree.ProjectTreeNode node)
 {
     list.Add(node.ID.ToString());
     foreach (var child in node.Children)
     {
         GetAllGUID(list, child);
     }
 }
Beispiel #7
0
 static void SaveAll(ZipArchive archive, ProjectTree.ProjectTreeNode node, string path)
 {
     path += node.ID.ToString() + "\\";
     node.Save(archive, path);
     foreach (var child in node.Children)
     {
         SaveAll(archive, child, path);
     }
 }
Beispiel #8
0
 private void GetTireDataSet(ProjectTreeNode node, List <Node_TireDataSet> list)
 {
     if (node is Node_TireDataSet)
     {
         list.Add(node as Node_TireDataSet);
     }
     foreach (var child in node.Children)
     {
         GetTireDataSet(child, list);
     }
 }
Beispiel #9
0
        private void GetMagicFormula(ProjectTreeNode node, List <Node_MagicFormula> list, bool containNotInitialized)
        {
            if (node is Node_MagicFormula)
            {
                var mfn = node as Node_MagicFormula;
                if (mfn.MFFD.Initialized || containNotInitialized)
                {
                    list.Add(node as Node_MagicFormula);
                }
            }

            foreach (var child in node.Children)
            {
                GetMagicFormula(child, list, containNotInitialized);
            }
        }
Beispiel #10
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);
        }
Beispiel #11
0
 public ProjectTreeNode(ProjectTreeNode parent)
 {
     Parent   = parent;
     Children = new List <ProjectTreeNode>();
     if (parent != null)
     {
         parent.Children.Add(this);
     }
     OnStateChanged       += ChangeParentAndChildrenState;
     OnUpdateStateChanged += ChangeParentAndChildrenState;
     ID = Guid.NewGuid();
     if (parent != null)
     {
         Updated = parent.Updated;
     }
     else
     {
         Updated = UpdateState.Normal;
     }
     Expand         = true;
     savedata.Class = GetClass();
 }
Beispiel #12
0
 public static MyTreeNode GetTreeView(ProjectTree.ProjectTreeNode node)
 {
     return(MainWindow.Instance.GetTreeView(node));
 }