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; }
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); }
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."; }
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; }
public UILibraryRootViewModel(UIEditorBaseViewModel editor, [NotNull] UILibraryViewModel asset, IEnumerable <UIElementDesign> rootElements) : base(editor, asset, rootElements) { NotifyGameSidePartAdded().Forget(); }
public static UILibraryEditorViewModel Create([NotNull] UILibraryViewModel asset) { return(new UILibraryEditorViewModel(asset, x => new UILibraryEditorController(asset, (UILibraryEditorViewModel)x))); }
/// <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) { }