public void RenderRenderings() { Clear(); var placeHolders = Device.LayoutPlaceHolders.Split(','); var usedRenderings = new List <RenderingItem>(); foreach (var name in placeHolders) { var placeHolderName = name.Trim(); if (string.IsNullOrEmpty(placeHolderName)) { continue; } var placeHolderTreeViewItem = new PlaceHolderTreeViewItem(this, placeHolderName); placeHolderTreeViewItem.IsExpanded = AppHost.Settings.GetBool(LayoutTreeView.LayoutDesignerTreeviewPlaceholders, placeHolderTreeViewItem.Text, placeHolderName == "Page.Body"); Items.Add(placeHolderTreeViewItem); var placeHolderPath = "/" + placeHolderName; RenderRenderings(placeHolderTreeViewItem.Items, placeHolderPath, placeHolderName, usedRenderings); } var unusedRenderings = Device.Renderings.Where(rendering => !usedRenderings.Contains(rendering)).ToList(); RenderUnusedRenderings(unusedRenderings); }
public RenderingTreeViewItem AddRendering([NotNull] PlaceHolderTreeViewItem placeHolderTreeViewItem, [NotNull] RenderingItem rendering, int treeViewIndex, int renderingIndex) { Assert.ArgumentNotNull(placeHolderTreeViewItem, nameof(placeHolderTreeViewItem)); Assert.ArgumentNotNull(rendering, nameof(rendering)); var renderingTreeViewItem = new RenderingTreeViewItem(this, rendering); return(AddRendering(placeHolderTreeViewItem, renderingTreeViewItem, treeViewIndex, renderingIndex)); }
public RenderingTreeViewItem AddRendering([NotNull] PlaceHolderTreeViewItem placeHolderTreeViewItem, [NotNull] IItem item, int treeViewIndex, int renderingIndex) { Assert.ArgumentNotNull(placeHolderTreeViewItem, nameof(placeHolderTreeViewItem)); Assert.ArgumentNotNull(item, nameof(item)); var rendering = new RenderingItem(Device, item) { PlaceholderKey = new PlaceHolderKey(placeHolderTreeViewItem.PlaceHolderName) }; return(AddRendering(placeHolderTreeViewItem, rendering, treeViewIndex, renderingIndex)); }
public RenderingTreeViewItem AddRendering([NotNull] PlaceHolderTreeViewItem placeHolderTreeViewItem, [NotNull] RenderingTreeViewItem renderingTreeViewItem, int treeViewIndex, int renderingIndex) { Assert.ArgumentNotNull(placeHolderTreeViewItem, nameof(placeHolderTreeViewItem)); Assert.ArgumentNotNull(renderingTreeViewItem, nameof(renderingTreeViewItem)); Action completed = delegate { foreach (var placeHolder in renderingTreeViewItem.Rendering.GetPlaceHolderNames()) { var p = new PlaceHolderTreeViewItem(this, placeHolder) { IsExpanded = AppHost.Settings.GetBool(LayoutTreeView.LayoutDesignerTreeviewPlaceholders, placeHolder, true) }; renderingTreeViewItem.Items.Add(p); } }; renderingTreeViewItem.Rendering.GetRenderingParameters(renderingTreeViewItem.Rendering.ItemUri, completed); renderingTreeViewItem.Rendering.Modified += (sender, args) => Device.PageModel.RaiseModified(); if (treeViewIndex < 0 || treeViewIndex >= placeHolderTreeViewItem.Items.Count) { placeHolderTreeViewItem.Items.Add(renderingTreeViewItem); } else { // weird WPF workd-around - renderingTreeViewItem should never have a parent if (renderingTreeViewItem.Parent != null) { renderingTreeViewItem.Remove(); } placeHolderTreeViewItem.Items.Insert(treeViewIndex, renderingTreeViewItem); } if (renderingIndex < 0 || treeViewIndex >= Device.Renderings.Count) { Device.Renderings.Add(renderingTreeViewItem.Rendering); } else { Device.Renderings.Insert(renderingIndex, renderingTreeViewItem.Rendering); } return(renderingTreeViewItem); }
private void RenderRenderings([NotNull] ItemCollection items, [NotNull] string placeHolderPath, [NotNull] string placeHolderName, [NotNull] List <RenderingItem> usedRenderings) { Debug.ArgumentNotNull(items, nameof(items)); Debug.ArgumentNotNull(placeHolderPath, nameof(placeHolderPath)); Debug.ArgumentNotNull(placeHolderName, nameof(placeHolderName)); Debug.ArgumentNotNull(usedRenderings, nameof(usedRenderings)); foreach (var rendering in Device.Renderings) { var key = rendering.PlaceholderKey.Key; if (string.IsNullOrEmpty(key)) { continue; } if (string.Compare(key, placeHolderName, StringComparison.InvariantCultureIgnoreCase) != 0 && string.Compare(key, placeHolderPath, StringComparison.InvariantCultureIgnoreCase) != 0) { continue; } var renderingTreeViewItem = new RenderingTreeViewItem(this, rendering); renderingTreeViewItem.IsExpanded = AppHost.Settings.GetBool(LayoutTreeView.LayoutDesignerTreeviewRenderings, renderingTreeViewItem.Rendering.ItemId, true); items.Add(renderingTreeViewItem); usedRenderings.Add(rendering); foreach (var placeHolder in rendering.GetPlaceHolderNames()) { var placeHolderTreeViewItem = new PlaceHolderTreeViewItem(this, placeHolder); placeHolderTreeViewItem.IsExpanded = AppHost.Settings.GetBool(LayoutTreeView.LayoutDesignerTreeviewPlaceholders, placeHolderTreeViewItem.Text, true); renderingTreeViewItem.Items.Add(placeHolderTreeViewItem); RenderRenderings(placeHolderTreeViewItem.Items, placeHolderPath + "/" + placeHolder, placeHolder, usedRenderings); } } }