private void PopulateElementSavesFromReferences(string projectRootDirectory, out string errors) { errors = ""; Screens.Clear(); Components.Clear(); StandardElements.Clear(); foreach (ElementReference reference in ScreenReferences) { ScreenSave toAdd = null; try { toAdd = reference.ToElementSave <ScreenSave>(projectRootDirectory, ScreenExtension, ref errors); } catch (Exception e) { errors += "\nError loading " + reference.Name + ":\n" + e.Message; } if (toAdd != null) { Screens.Add(toAdd); } } foreach (ElementReference reference in ComponentReferences) { ComponentSave toAdd = null; try { toAdd = reference.ToElementSave <ComponentSave>(projectRootDirectory, ComponentExtension, ref errors); } catch (Exception e) { errors += "\nError loading " + reference.Name + ":\n" + e.Message; } if (toAdd != null) { Components.Add(toAdd); } } foreach (ElementReference reference in StandardElementReferences) { StandardElementSave toAdd = null; try { toAdd = reference.ToElementSave <StandardElementSave>(projectRootDirectory, StandardExtension, ref errors); } catch (Exception e) { errors += "\nError loading " + reference.Name + ":\n" + e.Message; } if (toAdd != null) { StandardElements.Add(toAdd); } } }
public void ReloadElement(ElementSave element) { string projectRootDirectory = FileManager.GetDirectory(this.FullFileName); var gumLoadResult = new GumLoadResult(); if (element is ScreenSave) { var matchingReference = ScreenReferences.FirstOrDefault(item => item.Name == element.Name); ScreenSave newScreen = matchingReference?.ToElementSave <ScreenSave>( projectRootDirectory, GumProjectSave.ScreenExtension, gumLoadResult); if (newScreen != null) { Screens.Remove(element as ScreenSave); Screens.Add(newScreen); } } else if (element is ComponentSave) { var matchingReference = ComponentReferences.FirstOrDefault(item => item.Name == element.Name); ComponentSave newComonent = matchingReference?.ToElementSave <ComponentSave>( projectRootDirectory, GumProjectSave.ComponentExtension, gumLoadResult); if (newComonent != null) { Components.Remove(element as ComponentSave); Components.Add(newComonent); } } else if (element is StandardElementSave) { var matchingReference = StandardElementReferences.FirstOrDefault(item => item.Name == element.Name); StandardElementSave newStandardElement = matchingReference?.ToElementSave <StandardElementSave>( projectRootDirectory, GumProjectSave.ComponentExtension, gumLoadResult); if (newStandardElement != null) { StandardElements.Remove(element as StandardElementSave); StandardElements.Add(newStandardElement); } } }
private void PopulateElementSavesFromReferences(string projectRootDirectory, LinkLoadingPreference linkLoadingPreference, GumLoadResult result) { string errors = ""; Screens.Clear(); Components.Clear(); StandardElements.Clear(); Behaviors.Clear(); foreach (ElementReference reference in ScreenReferences) { ScreenSave toAdd = null; try { toAdd = reference.ToElementSave <ScreenSave>(projectRootDirectory, ScreenExtension, result); } catch (Exception e) { errors += "\nError loading " + reference.Name + ":\n" + e.Message; } if (toAdd != null) { Screens.Add(toAdd); } } foreach (ElementReference reference in ComponentReferences) { ComponentSave toAdd = null; try { toAdd = reference.ToElementSave <ComponentSave>(projectRootDirectory, ComponentExtension, result); } catch (Exception e) { errors += "\nError loading " + reference.Name + ":\n" + e.Message; } if (toAdd != null) { Components.Add(toAdd); } } foreach (ElementReference reference in StandardElementReferences) { StandardElementSave toAdd = null; try { toAdd = reference.ToElementSave <StandardElementSave>(projectRootDirectory, StandardExtension, result); } catch (Exception e) { errors += "\nError loading " + reference.Name + ":\n" + e.Message; } if (toAdd != null) { StandardElements.Add(toAdd); } } foreach (var reference in BehaviorReferences) { BehaviorSave toAdd = null; try { toAdd = reference.ToBehaviorSave(projectRootDirectory); } catch (Exception e) { errors += "\nError loading " + reference.Name + ":\n" + e.Message; } if (toAdd != null) { Behaviors.Add(toAdd); } } result.ErrorMessage += errors; }