void UpdateChildrenCore(IEnumerable <DesignItem> items) { foreach (var item in items) { if (ModelTools.CanSelectComponent(item)) { var node = OutlineNode.Create(item); Children.Add(node); } else { var content = item.ContentProperty; if (content != null) { if (content.IsCollection) { UpdateChildrenCore(content.CollectionElements); } else { if (content.Value != null) { UpdateChildrenCore(new[] { content.Value }); } } } } } }
public virtual void Insert(IEnumerable <IOutlineNode> nodes, IOutlineNode after, bool copy) { using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) { if (copy) { nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); } else { foreach (var node in nodes) { node.DesignItem.Remove(); } } var index = after == null ? 0 : Children.IndexOf(after) + 1; var content = DesignItem.ContentProperty; if (content.IsCollection) { foreach (var node in nodes) { content.CollectionElements.Insert(index++, node.DesignItem); } } else { content.SetValue(nodes.First().DesignItem); } moveTransaction.Commit(); } }
protected override void UpdateChildren() { Children.Clear(); foreach (var prp in DesignItem.AllSetProperties) { if (prp.Name != DesignItem.ContentPropertyName) { if (prp.Value != null) { var propertyNode = PropertyOutlineNode.Create(prp.Name); var node = OutlineNode.Create(prp.Value); propertyNode.Children.Add(node); Children.Add(propertyNode); } } } if (DesignItem.ContentPropertyName != null) { var content = DesignItem.ContentProperty; if (content.IsCollection) { UpdateChildrenCore(content.CollectionElements); } else { if (content.Value != null) { UpdateChildrenCore(new[] { content.Value }); } } } }
public void Insert(IEnumerable <OutlineNode> nodes, OutlineNode after, bool copy) { if (copy) { nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())); } else { foreach (var node in nodes) { node.DesignItem.Remove(); } } var index = after == null ? 0 : Children.IndexOf(after) + 1; var content = DesignItem.ContentProperty; if (content.IsCollection) { foreach (var node in nodes) { content.CollectionElements.Insert(index++, node.DesignItem); } } else { content.SetValue(nodes.First().DesignItem); } }
public static OutlineNode Create(DesignItem designItem) { OutlineNode node; if (!outlineNodes.TryGetValue(designItem, out node)) { node = new OutlineNode(designItem); outlineNodes[designItem] = node; } return node; }
public static IOutlineNode Create(DesignItem designItem) { IOutlineNode node = null; if (designItem != null && !outlineNodes.TryGetValue(designItem, out node)) { node = new OutlineNode(designItem); outlineNodes[designItem] = node; } return(node); }
public void Intialize() { _grid = CreateGridContextWithDesignSurface("<Button/><StackPanel><Button/></StackPanel>"); _outline = OutlineNode.Create(_grid); Assert.IsNotNull(_outline); var selection = _grid.Services.Selection; var stackPanel = _grid.ContentProperty.CollectionElements[1]; var stackPanelButton = stackPanel.ContentProperty.CollectionElements[0]; selection.SetSelectedComponents(new[] {stackPanel, stackPanelButton}); }
void UpdateChildrenCore(IEnumerable <DesignItem> items) { foreach (var item in items) { if (ModelTools.CanSelectComponent(item)) { var node = OutlineNode.Create(item); Children.Add(node); } } }
public bool CanInsert(IEnumerable <OutlineNode> nodes, OutlineNode after, bool copy) { var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); var placementBehavior = DesignItem.GetBehavior <IPlacementBehavior>(); if (operation != null) { return(placementBehavior.CanEnterContainer(operation)); } return(false); }
public void Intialize() { _grid = CreateGridContextWithDesignSurface("<Button/><StackPanel><Button/></StackPanel>"); _outline = OutlineNode.Create(_grid); Assert.IsNotNull(_outline); _gridButton = _grid.ContentProperty.CollectionElements[0]; _stackPanel = _grid.ContentProperty.CollectionElements[1]; _stackPanelButton = _stackPanel.ContentProperty.CollectionElements[0]; _gridButtonNode = _outline.Children[0]; _stackPanelNode = _outline.Children[1]; _stackPanelButtonNode = _stackPanelNode.Children[0]; }
bool UpdateChildrenCore(IEnumerable <DesignItem> items, int index = -1) { var retVal = false; foreach (var item in items) { if (ModelTools.CanSelectComponent(item)) { if (Children.All(x => x.DesignItem != item)) { var node = OutlineNode.Create(item); if (index > -1) { Children.Insert(index++, node); retVal = true; } else { Children.Add(node); retVal = true; } } } else { var content = item.ContentProperty; if (content != null) { if (content.IsCollection) { UpdateChildrenCore(content.CollectionElements); retVal = true; } else { if (content.Value != null) { UpdateChildrenCore(new[] { content.Value }); retVal = true; } } } } } return(retVal); }
public void Insert(IEnumerable<OutlineNode> nodes, OutlineNode after, bool copy) { using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) { if (copy) { nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); } else { foreach (var node in nodes) { node.DesignItem.Remove(); } } var index = after == null ? 0 : Children.IndexOf(after) + 1; var content = DesignItem.ContentProperty; if (content.IsCollection) { foreach (var node in nodes) { content.CollectionElements.Insert(index++, node.DesignItem); } } else { content.SetValue(nodes.First().DesignItem); } moveTransaction.Commit(); } }
public void Insert(IEnumerable<OutlineNode> nodes, OutlineNode after, bool copy) { if (copy) { nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())); } else { foreach (var node in nodes) { node.DesignItem.Remove(); } } var index = after == null ? 0 : Children.IndexOf(after) + 1; var content = DesignItem.ContentProperty; if (content.IsCollection) { foreach (var node in nodes) { content.CollectionElements.Insert(index++, node.DesignItem); } } else { content.SetValue(nodes.First().DesignItem); } }
public void Intialize() { _grid = CreateGridContextWithDesignSurface("<Button/><StackPanel><Button/></StackPanel>"); _outline = OutlineNode.Create(_grid); Assert.IsNotNull(_outline); }
public bool CanInsert(IEnumerable<OutlineNode> nodes, OutlineNode after, bool copy) { var placementBehavior = DesignItem.GetBehavior<IPlacementBehavior>(); if (placementBehavior == null) return false; var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); if (operation != null) { bool canEnter = placementBehavior.CanEnterContainer(operation, true); operation.Abort(); return canEnter; } return false; }
void UpdateDesign() { OutlineRoot = null; using (var xmlReader = XmlReader.Create(new StringReader(Text))) { DesignSurface.LoadDesigner(xmlReader, null); } if (DesignContext.RootItem != null) { OutlineRoot = OutlineNode.Create(DesignContext.RootItem); UndoService.UndoStackChanged += new EventHandler(UndoService_UndoStackChanged); } RaisePropertyChanged("SelectionService"); RaisePropertyChanged("XamlErrorService"); }
void UpdateDesign() { OutlineRoot = null; using (var xmlReader = XmlReader.Create(new StringReader(Text))) { XamlLoadSettings settings = new XamlLoadSettings(); foreach (var assNode in Toolbox.Instance.AssemblyNodes) { settings.DesignerAssemblies.Add(assNode.Assembly); } settings.TypeFinder = MyTypeFinder.Instance; DesignSurface.LoadDesigner(xmlReader, settings); } if (DesignContext.RootItem != null) { OutlineRoot = OutlineNode.Create(DesignContext.RootItem); UndoService.UndoStackChanged += new EventHandler(UndoService_UndoStackChanged); } RaisePropertyChanged("SelectionService"); RaisePropertyChanged("XamlErrorService"); }