/// <summary> /// Activate this display view /// </summary> public void Activate() { //Create a list of our parameters List <Object> DisplayObjects = new List <object>(); DisplayObjects.Add(MM_Repository.OverallDisplay); DisplayObjects.Add(MM_Repository.SubstationDisplay); foreach (MM_AlarmViolation_Type ViolType in MM_Repository.ViolationTypes.Values) { DisplayObjects.Add(ViolType); } foreach (MM_KVLevel KVLevel in MM_Repository.KVLevels.Values) { DisplayObjects.Add(KVLevel); } //Now, retrieve our base view if we're the default if (this.BaseElement.Name == "DisplayParameters") { MM_Repository.ReinitializeDisplayParameters(); } //Now, go through each command, and update. foreach (KeyValuePair <String, String> kvp in DisplayParameters) { String[] splStr = kvp.Key.Split('.'); Object FoundObject = null; //Now, check the first element to find what we're looking for foreach (Object obj in DisplayObjects) { if ((obj.GetType().GetProperty("Name") != null) && (obj.GetType().GetProperty("Name").GetValue(obj, null).ToString() == splStr[0])) { FoundObject = obj; } else if ((obj.GetType().GetField("Name") != null) && (obj.GetType().GetField("Name").GetValue(obj).ToString() == splStr[0])) { FoundObject = obj; } } //Now keep going through all sub-elements, and handle accordingly. for (int a = 1; a < splStr.Length - 1; a++) { //First check through our properties if (FoundObject.GetType().GetProperty(splStr[a]) != null) { FoundObject = FoundObject.GetType().GetProperty(splStr[a]).GetValue(FoundObject, null); } //Now check through our fields if (FoundObject.GetType().GetField(splStr[a]) != null) { FoundObject = FoundObject.GetType().GetField(splStr[a]).GetValue(FoundObject); } } //Now go the final step, and set our value. if (FoundObject != null) { MM_Repository.SetProperty(FoundObject, splStr[splStr.Length - 1], kvp.Value); } } //Now tell the repository we're active MM_Repository.SetActiveView(this); }