상속: TreeViewItemViewModel, IEditorViewModelProvider
예제 #1
0
        protected override void LoadChildren()
        {
            base.LoadChildren();

            foreach (var entry in _manifest.Entries)
            {
                var item = new EntryItemViewModel(entry, this, _editor,
                                                  _editor.AvailableDescriptors.First(_ => _.Type == entry.Type));
                Children.Add(item);
            }
        }
예제 #2
0
        private void DoAdd(Descriptor descriptor)
        {
            var entry = new Entry {
                Type = descriptor.Type
            };

            entry.Name = string.Format("New {0}", entry.Type);
            var item = new EntryItemViewModel(entry, this, _editor, descriptor)
            {
                IsSelected = true
            };

            Children.Add(item);
            _editor.CurrentItemEditor = item.ItemEditor;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the PropertyItemViewModel class.
        /// </summary>
        public PropertyItemViewModel(DescriptorProperty descriptorProperty, EntryItemViewModel parent,
                                     ManifestEditorViewModel editor)
            : base(parent)
        {
            if (descriptorProperty == null)
            {
                throw new ArgumentNullException("descriptorProperty", "descriptorProperty is null.");
            }
            if (parent == null)
            {
                throw new ArgumentNullException("parent", "parent is null.");
            }
            if (editor == null)
            {
                throw new ArgumentNullException("editor", "editor is null.");
            }

            var referencedType = descriptorProperty.ReferencedType;

            if (!descriptorProperty.AsContainment || string.IsNullOrWhiteSpace(referencedType))
            {
                throw new ArgumentException("Invalid descriptor property");
            }

            _descriptorProperty = descriptorProperty;
            _editor             = editor;
            TreeItemLabel       = descriptorProperty.Label;

            var childDescriptors = new List <Descriptor>(
                _editor.AllDescriptors.Values.Where(
                    d => !d.IsVirtual && (
                        d.Type == referencedType ||
                        d.Supertypes.Contains(referencedType) ||
                        d.Interfaces.Contains(referencedType))));

            _entryProperty = parent.Entry.GetPropertyAndCreateIfN(descriptorProperty.Name);

            IsExpanded = true;

            MenuItems = new List <MenuItemViewModel>
            {
                new MenuItemViewModel(Properties.Resources.EDITOR_NEW_CI, null, new List <MenuItemViewModel>(
                                          from descriptor in childDescriptors
                                          select new MenuItemViewModel(descriptor.Type, new DelegateCommand(() => DoAdd(descriptor)), null)
                                          ))
            };
        }
	    /// <summary>
	    /// Initializes a new instance of the PropertyItemViewModel class.
	    /// </summary>
	    public PropertyItemViewModel(DescriptorProperty descriptorProperty, EntryItemViewModel parent,
	        ManifestEditorViewModel editor)
	        : base(parent)
	    {
	        if (descriptorProperty == null)
	            throw new ArgumentNullException("descriptorProperty", "descriptorProperty is null.");
	        if (parent == null)
	            throw new ArgumentNullException("parent", "parent is null.");
	        if (editor == null)
	            throw new ArgumentNullException("editor", "editor is null.");

	        var referencedType = descriptorProperty.ReferencedType;
	        if (!descriptorProperty.AsContainment || string.IsNullOrWhiteSpace(referencedType))
	        {
	            throw new ArgumentException("Invalid descriptor property");
	        }

	        _descriptorProperty = descriptorProperty;
	        _editor = editor;
	        TreeItemLabel = descriptorProperty.Label;

	        var childDescriptors = new List<Descriptor>(
	            _editor.AllDescriptors.Values.Where(
	                d => !d.IsVirtual && (
	                    d.Type == referencedType
	                    || d.Supertypes.Contains(referencedType)
	                    || d.Interfaces.Contains(referencedType))));

	        _entryProperty = parent.Entry.GetPropertyAndCreateIfN(descriptorProperty.Name);

	        IsExpanded = true;

	        MenuItems = new List<MenuItemViewModel>
	        {
	            new MenuItemViewModel(Properties.Resources.EDITOR_NEW_CI, null, new List<MenuItemViewModel>(
	                from descriptor in childDescriptors
	                select new MenuItemViewModel(descriptor.Type, new DelegateCommand(() => DoAdd(descriptor)), null)
	                ))
	        };
	    }
예제 #5
0
        private void DoAddEntry(Descriptor descriptor)
        {
            if (descriptor == null)
            {
                return;
            }

            var entry = new Entry {
                Type = descriptor.Type
            };

            entry.Name = string.Format("New {0}", entry.Type);
            _manifest.Entries.Add(entry);

            var item = new EntryItemViewModel(entry, this, _editor, descriptor)
            {
                IsSelected = true
            };

            Children.Add(item);
            _editor.CurrentItemEditor = item.ItemEditor;
        }
	    private void DoAdd(Descriptor descriptor)
	    {
	        var entry = new Entry {Type = descriptor.Type};
	        entry.Name = string.Format("New {0}", entry.Type);
	        var item = new EntryItemViewModel(entry, this, _editor, descriptor) {IsSelected = true};
	        Children.Add(item);
	        _editor.CurrentItemEditor = item.ItemEditor;
	    }
		public void RemoveEntryItem(EntryItemViewModel item)
		{
			Children.Remove(item);
		}
 public void RemoveEntryItem(EntryItemViewModel item)
 {
     _editor.Manifest.Entries.Remove(item.Entry);
 }
        protected override void LoadChildren()
        {
            base.LoadChildren();

            foreach (var entry in _manifest.Entries)
            {
                var item = new EntryItemViewModel(entry, this, _editor,
                                                  _editor.AvailableDescriptors.First(_ => _.Type == entry.Type));
                Children.Add(item);
            }
        }
예제 #10
0
 public void RemoveEntryItem(EntryItemViewModel item)
 {
     Children.Remove(item);
 }
예제 #11
0
 public void RemoveEntryItem(EntryItemViewModel item)
 {
     _editor.Manifest.Entries.Remove(item.Entry);
 }