public void ReplicateSlotContentState(SlotContent sourceSlotContent) { foreach (var viewSource in sourceSlotContent.sources) { var ourSite = this.sites[viewSource]; var siteToCopy = sourceSlotContent.sites[viewSource]; ourSite.View.ReplicateEphemeralViewState(siteToCopy.View); } }
IEnumerable <XElement> BuildViewStateElements(SlotContent content) { var activeViews = this.existingSlotContents.Values.Select(sc => sc.TopmostViewSite).ToDictionary(vc => vc.ViewSource.Id); return(content.ViewSites.Select(vc => new XElement("View", new XAttribute("RegisteredName", vc.View.ViewCreationCommand.RegisteredName), new XAttribute("SlotName", vc.ViewSource.SlotName), new XAttribute("Id", vc.ViewSource.Id), new XAttribute("Title", vc.ViewSource.Title), activeViews.ContainsKey(vc.ViewSource.Id) ? new XAttribute("IsSelected", "true") : null, new XElement("ViewState", vc.View.GetViewState())))); }
public void EnsureSlotContentPopulation() { // This is a mark-and-sweep style operation. Mark all existing content objects; any that // aren't touched by the loop below will die. foreach (var content in this.existingSlotContents.Values) { content.Mark(); foreach (var site in content.ViewSites) { if (site.View != null) { site.View.Activated -= OnViewActivated; } } } foreach (var source in this.LayoutDefinition.ViewSources) { SlotContent content; if (!this.existingSlotContents.TryGetValue(source.SlotName, out content)) { content = new SlotContent(this, source.SlotName); this.existingSlotContents.Add(source.SlotName, content); } content.ConfirmViewSource(source); } List <string> removals = null; bool modified = false; foreach (var kvp in this.existingSlotContents) { if (!kvp.Value.Sweep(this.IsInEditMode, this.singleViewContentTemplate, this.tabbedViewContentTemplate, this.serviceContainer)) { if (removals == null) { removals = new List <string>(); } removals.Add(kvp.Key); } } if (removals != null) { foreach (var slotName in removals) { this.existingSlotContents.Remove(slotName); } modified = true; } foreach (var content in this.existingSlotContents.Values) { foreach (var site in content.ViewSites) { if (site.View != null) { site.View.Activated += OnViewActivated; } } } if (modified) { ToolsUIApplication.Instance.RequestViewBindingUpdate(); var handler = this.LayoutChanged; if (handler != null) { handler(this, EventArgs.Empty); } } }