internal DisplayList Load(string filename) { // Load the json object from the file JObject JsonDisplayList = JObject.Parse(File.ReadAllText(filename)); // Declare my new list DisplayList newlist = new DisplayList(); // Add my inherent properties of the display list this.Name = (string)JsonDisplayList.SelectToken("Name"); // Get my array of displays var displays = (JArray)JsonDisplayList.SelectToken("Displays"); foreach (JObject disp in displays) { string dispType = (string)disp.SelectToken("Type"); switch (dispType) { case "DisplaySite": Display newDisplay = new Display_Styles.DisplaySite(); newDisplay.load(disp); newlist.Displays.Add(newDisplay); break; default: throw new NotImplementedException(); } } return(newlist); }
// Load the JSON file private void LoadDisplayListFile(string filename) { if (!File.Exists(filename)) { return; } CurrentDisplayList = CurrentDisplayList.Load(filename); LoadDisplayList(CurrentDisplayList); DisplaySelector.ItemsSource = CurrentDisplayList.Displays; SetDisplay(CurrentDisplayList.CurrentDisplay()); }
private void LoadDisplayList(DisplayList list) { // remove anything currently in the display region foreach (UIElement child in DisplayRegion.Children) { Display display = child as Display; display.Destroy(); } // Remove all the current children of the display region. DisplayRegion.Children.RemoveRange(0, DisplayRegion.Children.Count); // set up all of the new displays foreach (Display display in list.Displays) { display.Setup(); DisplayRegion.Children.Add(display); } SetDisplay(CurrentDisplayList.Displays.First()); }