Пример #1
0
        public void Initialize()
        {
            BodySet.Clear();
            foreach (var item in BodyList)
            {
                var desc  = DescPair[item];
                var unit  = UnitPair[item];
                var value = "";
                if (InitValPair.ContainsKey(item))
                {
                    value = InitValPair[item];
                }

                BodySet.Add(new Spec(item, desc, value, unit));
            }

            EnvSet.Clear();
            foreach (var item in EnvList)
            {
                var desc  = DescPair[item];
                var unit  = UnitPair[item];
                var value = "";
                if (InitValPair.ContainsKey(item))
                {
                    value = InitValPair[item];
                }

                EnvSet.Add(new Spec(item, desc, value, unit));
            }

            WindSet.Clear();
            foreach (var item in WindList)
            {
                var desc  = DescPair[item];
                var unit  = UnitPair[item];
                var value = "";
                if (InitValPair.ContainsKey(item))
                {
                    value = InitValPair[item];
                }

                WindSet.Add(new Spec(item, desc, value, unit));
            }

            MotorSet.Clear();
            foreach (var item in MotorList)
            {
                var desc  = DescPair[item];
                var unit  = UnitPair[item];
                var value = "";
                if (InitValPair.ContainsKey(item))
                {
                    value = InitValPair[item];
                }

                MotorSet.Add(new Spec(item, desc, value, unit));
            }
        }
Пример #2
0
        public void LoadItem(string loadPath)
        {
            // Initialize data
            BodySet.Clear();
            EnvSet.Clear();
            WindSet.Clear();

            // From Json to ObservableCollection
            var rawAllText = File.ReadAllText(loadPath);
            var groupList  = JObject.Parse(rawAllText);

            // Set each group.
            var bodyList  = groupList["Rocket"];
            var motorList = groupList["Motor"];
            var envList   = groupList["Environment"];
            var windList  = groupList["Wind"];

            // Add all key and value to dataSet.
            foreach (JProperty item in bodyList)
            {
                var nameDesc = DescPair[item.Name];
                var unit     = UnitPair[item.Name];
                BodySet.Add(new Spec(item.Name, nameDesc, item.Value.ToString(), unit));
            }

            MotorPath = motorList["Path"].ToString();

            foreach (JProperty item in envList)
            {
                var nameDesc = DescPair[item.Name];
                var unit     = UnitPair[item.Name];
                EnvSet.Add(new Spec(item.Name, nameDesc, item.Value.ToString(), unit));
            }

            foreach (JProperty item in windList)
            {
                var nameDesc = DescPair[item.Name];
                var unit     = UnitPair[item.Name];
                WindSet.Add(new Spec(item.Name, nameDesc, item.Value.ToString(), unit));
            }
        }