예제 #1
0
        /// <summary>
        /// Save the preferences for one Population Interaction Unit
        /// </summary>
        /// <param name="scenarioName">PIU Name</param>
        /// <param name="blockSize">Block size</param>
        /// <param name="selectedDisplaSet">Selected DisplaySet name</param>
        /// <param name="displaySets">Customized DisplaySet list</param>
        public void SavePopulationInfo(string scenarioName, int blockSize, string selectedDisplaSet, List <DisplaySetInformation> displaySets)
        {
            // In the scenario is in the cache, update it
            PopulationPrefs popScenario = GetScenarioPrefs(scenarioName) as PopulationPrefs;

            if (popScenario != null)
            {
                popScenario.DisplaySets.RemoveRange(0, popScenario.DisplaySets.Count);
            }
            else
            {
                // Population Scenario doesn't exist in the cache. Create a new one
                popScenario = new PopulationPrefs(scenarioName, blockSize);
                mScenarioPreferences.Insert(0, popScenario);
            }
            popScenario.SelectedDisplaySetName = selectedDisplaSet;
            // Add the DisplaySet to the scenario
            foreach (DisplaySetInformation displaySet in displaySets)
            {
                if (displaySet.Custom)
                {
                    popScenario.DisplaySets.Add(displaySet);
                }
            }

            // Save in the Preferences Server
            SaveScenario(popScenario);
        }
예제 #2
0
        private IScenarioPrefs CreatePreference(XmlNode scenarioNode)
        {
            if (scenarioNode.ChildNodes.Count == 0)
            {
                return(null);
            }

            string type    = scenarioNode.Attributes["Type"].Value;
            string version = scenarioNode.Attributes["Version"].Value;
            string name    = scenarioNode.Attributes["Name"].Value;

            IScenarioPrefs pref = null;

            switch (type)
            {
            case "INS":
            {
                pref = new InstancePrefs(name);
                pref.Deserialize(scenarioNode.ChildNodes[0], version);
                break;
            }

            case "POP":
            {
                pref = new PopulationPrefs(name, 0);
                pref.Deserialize(scenarioNode.ChildNodes[0], version);
                break;
            }

            case "FORM":
            {
                pref = new FormPrefs(name);
                pref.Deserialize(scenarioNode.ChildNodes[0], version);
                break;
            }
            }

            return(pref);
        }
        /// <summary>
        /// Process the user preferences for this scenario
        /// </summary>
        /// <param name="preferences"></param>
        public void SetPreferences(PopulationPrefs preferences)
        {
            // Gets the custom DIsplaySets
            if (preferences == null)
                return;

            // Add teh custom DisplaySets to the DisplaySet List
            foreach (DisplaySetInformation displaySet in preferences.DisplaySets)
            {
                DisplaySet.DisplaySetList.Add(displaySet);
            }

            // Assign the selected DisplaySet
            if (!preferences.SelectedDisplaySetName.Equals(""))
            {
                DisplaySetInformation displaySet = DisplaySet.GetDisplaySetByName(preferences.SelectedDisplaySetName);
                if (displaySet != null)
                {
                    DisplaySet.CurrentDisplaySet = displaySet;
                }
            }

            Context.BlockSize = preferences.BlockSize;
        }
예제 #4
0
        private IScenarioPrefs CreatePreference(XmlNode scenarioNode)
        {
            if (scenarioNode.ChildNodes.Count == 0)
                return null;

            string type = scenarioNode.Attributes["Type"].Value;
            string version = scenarioNode.Attributes["Version"].Value;
            string name = scenarioNode.Attributes["Name"].Value;

            IScenarioPrefs pref = null;

            switch (type)
            {
                case "INS":
                    {
                        pref = new InstancePrefs(name);
                        pref.Deserialize(scenarioNode.ChildNodes[0], version);
                        break;
                    }
                case "POP":
                    {
                        pref = new PopulationPrefs(name, 0);
                        pref.Deserialize(scenarioNode.ChildNodes[0], version);
                        break;
                    }
                case "FORM":
                    {
                        pref = new FormPrefs(name);
                        pref.Deserialize(scenarioNode.ChildNodes[0], version);
                        break;
                    }
            }

            return pref;
        }
예제 #5
0
        /// <summary>
        /// Save the preferences for one Population Interaction Unit
        /// </summary>
        /// <param name="scenarioName">PIU Name</param>
        /// <param name="blockSize">Block size</param>
        /// <param name="selectedDisplaSet">Selected DisplaySet name</param>
        /// <param name="displaySets">Customized DisplaySet list</param>
        public void SavePopulationInfo(string scenarioName, int blockSize, string selectedDisplaSet, List<DisplaySetInformation> displaySets)
        {
            // In the scenario is in the cache, update it
            PopulationPrefs popScenario = GetScenarioPrefs(scenarioName) as PopulationPrefs;
            if (popScenario != null)
            {
                popScenario.DisplaySets.RemoveRange(0, popScenario.DisplaySets.Count);
            }
            else
            {
                // Population Scenario doesn't exist in the cache. Create a new one
                popScenario = new PopulationPrefs(scenarioName,blockSize);
                mScenarioPreferences.Insert(0, popScenario);
            }
            popScenario.SelectedDisplaySetName = selectedDisplaSet;
            // Add the DisplaySet to the scenario
            foreach (DisplaySetInformation displaySet in displaySets)
            {
                if (displaySet.Custom)
                {
                    popScenario.DisplaySets.Add(displaySet);
                }
            }

            // Save in the Preferences Server
            SaveScenario(popScenario);
        }