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(); } }
public void LoadItemsCollection(DesignItem item) { Debug.Assert(item.View is ItemsControl); _item = item; _componentService = item.Services.Component; item.Services.Selection.SelectionChanged += delegate { PropertyGridView.SelectedItems = item.Services.Selection.SelectedItems; }; var control = item.View as ItemsControl; if (control != null) { TypeMappings.TryGetValue(control.GetType(), out _type); if (_type != null) { IOutlineNode node = OutlineNode.Create(item); Outline.Root = node; PropertyGridView.PropertyGrid.SelectedItems = item.Services.Selection.SelectedItems; } else { PropertyGridView.IsEnabled = false; Outline.IsEnabled = false; AddItem.IsEnabled = false; RemoveItem.IsEnabled = false; MoveUpItem.IsEnabled = false; MoveDownItem.IsEnabled = false; } } }
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}); }
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 }); }
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]; }
public bool CanInsert(IEnumerable <IOutlineNode> nodes, IOutlineNode 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))) { 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"); }
public void Intialize() { _grid = CreateGridContextWithDesignSurface("<Button/><StackPanel><Button/></StackPanel>"); _outline = OutlineNode.Create(_grid); Assert.IsNotNull(_outline); }
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(); } }
public bool CanInsert(IEnumerable<IOutlineNode> nodes, IOutlineNode 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; }