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

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

            // Save in the Preferences Server
            SaveScenario(insScenario);
        }
예제 #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);
        }
예제 #3
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;
        }
예제 #4
0
        /// <summary>
        /// Save the preferences for one Instance Interaction Unit
        /// </summary>
        /// <param name="scenarioName">PIU Name</param>
        /// <param name="selectedDisplaSet">Selected DisplaySet name</param>
        /// <param name="displaySets">Customized DisplaySet list</param>
        public void SaveInstanceInfo(string scenarioName, string selectedDisplaSet, List<DisplaySetInformation> displaySets)
        {
            // In the scenario is in the cache, update it
            InstancePrefs insScenario = GetScenarioPrefs(scenarioName) as InstancePrefs;
            if (insScenario != null)
            {
                insScenario.DisplaySets.RemoveRange(0, insScenario.DisplaySets.Count);
            }
            else
            {
                // Instance Scenario doesn't exist in the cache. Create a new one
                insScenario = new InstancePrefs(scenarioName);
                mScenarioPreferences.Add(insScenario);
            }
            insScenario.SelectedDisplaySetName = selectedDisplaSet;
            // Add the DisplaySet to the scenario
            foreach (DisplaySetInformation displaySet in displaySets)
            {
                if (displaySet.Custom)
                {
                    insScenario.DisplaySets.Add(displaySet);
                }
            }

            // Save in the Preferences Server
            SaveScenario(insScenario);
        }
        /// <summary>
        /// Assign the preferences to this controller
        /// </summary>
        /// <param name="preferences"></param>
        public void SetPreferences(InstancePrefs 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;
                }
            }
        }