Пример #1
0
        private void RemoveLibrary(UILibraryViewModel library)
        {
            factories.RemoveWhere(l => l.Category == library.Url);

            var node = NodeContainer.GetNode(library.Asset)[nameof(UILibraryAsset.PublicUIElements)].Target;

            node.ItemChanged -= LibraryContentChanged;
        }
Пример #2
0
        public UIElementFromLibrary(IViewModelServiceProvider serviceProvider, UILibraryViewModel library, Guid id)
            : base(serviceProvider)
        {
            this.library = library;
            Id           = id;

            var node = library.Session.AssetNodeContainer.GetNode(library.Asset)[nameof(UILibraryAsset.PublicUIElements)];

            nameBinding = new MemberGraphNodeBinding <Dictionary <Guid, string> >(node, nameof(Name), OnPropertyChanging, OnPropertyChanged, library.UndoRedoService);
        }
Пример #3
0
        public UIElementFromSystemLibrary([NotNull] IViewModelServiceProvider serviceProvider, [NotNull] UILibraryViewModel library, Guid id)
            : base(serviceProvider)
        {
            this.library = library;
            this.id      = id;

            UIElementDesign element;

            if (!library.Asset.Hierarchy.Parts.TryGetValue(id, out element))
            {
                throw new InvalidOperationException("The corresponding UI element could not be found in the library.");
            }

            Type     = element.UIElement.GetType();
            Category = TypeDescriptorFactory.Default.AttributeRegistry.GetAttribute <Core.DisplayAttribute>(Type)?.Category ?? "Misc.";
        }
Пример #4
0
        private void AddLibrary(UILibraryViewModel library)
        {
            // Don't add itself as a library or if already referenced
            if (library == Asset || factories.Any(l => l.Category == library.Url))
            {
                return;
            }

            var asset = library.Asset;
            var list  = asset.PublicUIElements.Select(x => new UIElementFromLibrary(ServiceProvider, library, x.Key)).OrderBy(x => x.Name);

            factories.AddRange(list);

            if (!library.IsEditable)
            {
                return;
            }

            var node = NodeContainer.GetOrCreateNode(asset)[nameof(UILibraryAsset.PublicUIElements)].Target;

            node.ItemChanged += LibraryContentChanged;
        }
Пример #5
0
 public UILibraryRootViewModel(UIEditorBaseViewModel editor, [NotNull] UILibraryViewModel asset, IEnumerable <UIElementDesign> rootElements)
     : base(editor, asset, rootElements)
 {
     NotifyGameSidePartAdded().Forget();
 }
Пример #6
0
 public static UILibraryEditorViewModel Create([NotNull] UILibraryViewModel asset)
 {
     return(new UILibraryEditorViewModel(asset, x => new UILibraryEditorController(asset, (UILibraryEditorViewModel)x)));
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UILibraryEditorViewModel"/> class.
 /// </summary>
 /// <param name="asset">The asset related to this editor.</param>
 /// <param name="controllerFactory">A factory to create the associated <see cref="IEditorGameController"/>.</param>
 /// <seealso cref="Create(UILibraryViewModel)"/>
 private UILibraryEditorViewModel([NotNull] UILibraryViewModel asset, [NotNull] Func <GameEditorViewModel, IEditorGameController> controllerFactory)
     : base(asset, controllerFactory)
 {
 }