Beispiel #1
0
        // Note: constructor needed by UIElementViewModelFactory
        public PanelViewModel([NotNull] UIEditorBaseViewModel editor, [NotNull] UIBaseViewModel asset, [NotNull] UIElementDesign elementDesign)
            : base(editor, asset, elementDesign, GetOrCreateChildPartDesigns((UIAssetBase)asset.Asset, elementDesign))
        {
            childrenNode              = editor.NodeContainer.GetOrCreateNode(AssetSidePanel)[nameof(Panel.Children)].Target;
            childrenNode.ItemChanged += ChildrenContentChanged;

            ChangeLayoutTypeCommand = new AnonymousCommand <IUIElementFactory>(ServiceProvider, ChangeLayoutType);
            UngroupCommand          = new AnonymousCommand(ServiceProvider, Ungroup);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UIBaseViewModel"/> 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>
        protected UIEditorBaseViewModel([NotNull] UIBaseViewModel asset, [NotNull] Func <GameEditorViewModel, IEditorGameController> controllerFactory)
            : base(asset, controllerFactory)
        {
            Camera = new EditorCameraViewModel(ServiceProvider, Controller);

            BreakLinkToLibraryCommand        = new AnonymousCommand(ServiceProvider, BreakLinkToLibrary);
            CreateLibraryCommand             = new AnonymousCommand(ServiceProvider, CreateLibraryFromSelection);
            CreatePageCommand                = new AnonymousCommand(ServiceProvider, CreatePageFromSelection);
            GroupIntoCommand                 = new AnonymousCommand <IUIElementFactory>(ServiceProvider, GroupInto);
            OpenLibraryEditorCommand         = new AnonymousCommand(ServiceProvider, OpenLibraryEditor);
            RefreshSelectableElementsCommand = new AnonymousCommand(ServiceProvider, RefreshSelectableElements);
            ResetZoomCommand                 = new AnonymousCommand(ServiceProvider, ResetZoom);
            SelectLibraryCommand             = new AnonymousCommand(ServiceProvider, SelectLibrary);
            SetCurrentSelectionCommand       = new AnonymousCommand <AbsoluteId>(ServiceProvider, SetCurrentSelection);
            ShowPropertiesCommand            = new AnonymousCommand(ServiceProvider, ShowAssetProperties);
            ZoomInCommand  = new AnonymousCommand(ServiceProvider, () => Zoom(-1));
            ZoomOutCommand = new AnonymousCommand(ServiceProvider, () => Zoom(+1));
            UpdateCommands();
        }
Beispiel #3
0
        protected UIElementViewModel([NotNull] UIEditorBaseViewModel editor, [NotNull] UIBaseViewModel asset, [NotNull] UIElementDesign elementDesign, [CanBeNull] IEnumerable <UIElementDesign> children)
            : base(editor, asset, children)
        {
            AssetSideUIElement = elementDesign.UIElement;
            ElementType        = AssetSideUIElement.GetType();
            UIElementDesign    = elementDesign;
            var assetNode = editor.NodeContainer.GetOrCreateNode(elementDesign.UIElement);

            nameNodeBinding = new MemberGraphNodeBinding <string>(assetNode[nameof(UIElement.Name)], nameof(Name), OnPropertyChanging, OnPropertyChanged, Editor.UndoRedoService);

            propagator = new GameEditorChangePropagator <UIElementDesign, UIElement, UIElementViewModel>(Editor, this, elementDesign.UIElement);

            PanelCommand  = new AnonymousCommand <PanelCommandMode>(ServiceProvider, PanelCommandImpl);
            RenameCommand = new AnonymousCommand(ServiceProvider, () => IsEditing = true);

            UpdateSourceLibrary();
            var basePrefabNode = Editor.NodeContainer.GetNode(UIElementDesign)[nameof(UIElementDesign.Base)];

            basePrefabNode.ValueChanged += BaseElementChanged;
        }
 // Note: constructor needed by UIElementViewModelFactory
 public ContentControlViewModel([NotNull] UIEditorBaseViewModel editor, [NotNull] UIBaseViewModel asset, [NotNull] UIElementDesign elementDesign)
     : base(editor, asset, elementDesign, GetOrCreateChildPartDesigns((UIAssetBase)asset.Asset, elementDesign))
 {
     contentNode = editor.NodeContainer.GetOrCreateNode(AssetSideUIElement)[nameof(ContentControl.Content)];
     contentNode.ValueChanged += ContentChanged;
 }
Beispiel #5
0
 // Note: constructor needed by UIElementViewModelFactory
 public UIElementViewModel([NotNull] UIEditorBaseViewModel editor, [NotNull] UIBaseViewModel asset, [NotNull] UIElementDesign elementDesign)
     : this(editor, asset, elementDesign, null)
 {
 }
Beispiel #6
0
 protected UIRootViewModel([NotNull] UIEditorBaseViewModel editor, [NotNull] UIBaseViewModel asset, IEnumerable <UIElementDesign> rootElements)
     : base(editor, asset, rootElements)
 {
     rootPartsNode              = Editor.NodeContainer.GetNode(UIAsset.Hierarchy)[nameof(AssetCompositeHierarchyData <UIElementDesign, UIElement> .RootParts)].Target;
     rootPartsNode.ItemChanged += RootUIElementsChanged;
 }
        public UIElementViewModel ProvideViewModel([NotNull] UIEditorBaseViewModel editor, [NotNull] UIBaseViewModel asset, [NotNull] UIElementDesign elementDesign)
        {
            if (editor == null)
            {
                throw new ArgumentNullException(nameof(editor));
            }
            if (elementDesign == null)
            {
                throw new ArgumentNullException(nameof(elementDesign));
            }

            var elementViewModelType = typeof(UIElementViewModel);
            // try to get the viewmodel type
            var elementType = elementDesign.UIElement.GetType();

            while (elementType != null)
            {
                if (elementViewModelTypes.ContainsKey(elementType))
                {
                    elementViewModelType = elementViewModelTypes[elementType];
                    break;
                }

                elementType = elementType.BaseType;
            }

            return((UIElementViewModel)Activator.CreateInstance(elementViewModelType, editor, asset, elementDesign));
        }