Exemplo n.º 1
0
 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 });
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        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 });
                    }
                }
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
		public static OutlineNode Create(DesignItem designItem)
		{
			OutlineNode node;
			if (!outlineNodes.TryGetValue(designItem, out node)) {
				node = new OutlineNode(designItem);
				outlineNodes[designItem] = node;
			}
			return node;
		}
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
		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});
		}
Exemplo n.º 8
0
 void UpdateChildrenCore(IEnumerable <DesignItem> items)
 {
     foreach (var item in items)
     {
         if (ModelTools.CanSelectComponent(item))
         {
             var node = OutlineNode.Create(item);
             Children.Add(node);
         }
     }
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
		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];
		}
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
		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();
			}
		}
Exemplo n.º 13
0
		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);
			}
		}
Exemplo n.º 14
0
		public void Intialize()
		{
			_grid = CreateGridContextWithDesignSurface("<Button/><StackPanel><Button/></StackPanel>");
			_outline = OutlineNode.Create(_grid);
			Assert.IsNotNull(_outline);
		}
Exemplo n.º 15
0
		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;
		}
Exemplo n.º 16
0
		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");
		}
Exemplo n.º 17
0
		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");
		}