/// <summary>
 /// Initializes a new instance of the <see cref="EntityHierarchyEditorViewModel"/> 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 EntityHierarchyEditorViewModel([NotNull] EntityHierarchyViewModel asset, [NotNull] Func <GameEditorViewModel, IEditorGameController> controllerFactory)
     : base(asset, controllerFactory)
 {
     Controller.Loader.AssetLoading += (s, e) => asset.Dispatcher.InvokeAsync(() => CompilingAssets = e.ContentLoadingCount > 0);
     Controller.Loader.AssetLoaded  += (s, e) => asset.Dispatcher.InvokeAsync(() => CompilingAssets = e.ContentLoadingCount > 0);
     Camera                         = new EditorCameraViewModel(ServiceProvider, Controller);
     Transform                      = new EntityTransformationViewModel(ServiceProvider, Controller);
     Grid                           = new EditorGridViewModel(ServiceProvider, Controller);
     Navigation                     = new EditorNavigationViewModel(ServiceProvider, Controller, this);
     Lighting                       = new EditorLightingViewModel(ServiceProvider, Controller, this);
     Rendering                      = new EditorRenderingViewModel(ServiceProvider, Controller);
     EntityGizmos                   = new EntityGizmosViewModel(ServiceProvider, Controller);
     CreateEntityCommand            = new AnonymousTaskCommand <IEntityFactory>(ServiceProvider, x => CreateEntity(true, x, ActiveRoot ?? HierarchyRoot));
     CreateEntityInRootCommand      = new AnonymousTaskCommand <IEntityFactory>(ServiceProvider, x => CreateEntity(false, x, ActiveRoot ?? HierarchyRoot));
     CreateFolderInRootCommand      = new AnonymousCommand <IEntityFactory>(ServiceProvider, x => CreateFolder(HierarchyRoot.Asset, ActiveRoot ?? HierarchyRoot, true));
     CreateEntityInSelectionCommand = new AnonymousTaskCommand <IEntityFactory>(ServiceProvider, x => CreateEntity(false, x, (EntityHierarchyItemViewModel)SelectedContent.FirstOrDefault() ?? ActiveRoot ?? HierarchyRoot));
     CreateFolderInSelectionCommand = new AnonymousCommand <IEntityFactory>(ServiceProvider, x =>
     {
         var element = (EntityHierarchyItemViewModel)SelectedContent.FirstOrDefault() ?? ActiveRoot ?? HierarchyRoot;
         CreateFolder(element.Asset, element, true);
     });
     OpenPrefabEditorCommand          = new AnonymousCommand(ServiceProvider, OpenPrefabEditor);
     SelectPrefabCommand              = new AnonymousCommand(ServiceProvider, SelectPrefab);
     SetActiveRootCommand             = new AnonymousCommand(ServiceProvider, SetActiveRoot);
     BreakLinkToPrefabCommand         = new AnonymousCommand(ServiceProvider, BreakLinkToPrefab);
     CreatePrefabFromSelectionCommand = new AnonymousCommand(ServiceProvider, CreatePrefabFromSelection);
     UpdateCommands();
     debugPage = new DebugEntityHierarchyEditorUserControl(this);
     EditorDebugTools.RegisterDebugPage(debugPage);
 }
Exemplo n.º 2
0
        /// <inheritdoc />
        protected override ISet <UIElementViewModel> DuplicateSelection()
        {
            // save elements to copy
            var elementsToDuplicate = GetCommonRoots(SelectedItems);

            // check that the selected elements can be duplicated
            if (elementsToDuplicate.Any(e => !e.CanDuplicate()))
            {
                return(elementsToDuplicate);
            }

            // clear selection
            ClearSelection();

            // duplicate the elements
            var duplicatedElements = new HashSet <UIElementViewModel>();

            using (var transaction = UndoRedoService.CreateTransaction())
            {
                duplicatedElements.AddRange(elementsToDuplicate.Select(x => x.Duplicate()));
                UndoRedoService.SetName(transaction, "Duplicate elements");
            }

            // set selection to new copied elements.
            SelectedContent.AddRange(duplicatedElements);

            return(duplicatedElements);
        }
Exemplo n.º 3
0
        private void SetCurrentSelection(AbsoluteId elementId)
        {
            var element = FindPartViewModel(elementId);

            if (element == null)
            {
                return;
            }

            ClearSelection();

            SelectedContent.Add(element);
        }
Exemplo n.º 4
0
        public PxContentValueFootnote CreateContentValueFootnote(PxObject context)
        {
            PxContentValueFootnote cvf = new PxContentValueFootnote();

            cvf.FootnoteNo = FootnoteNo;
            FootnoteNo++;
            cvf.FootnoteText        = "Shenim i ri";
            cvf.FootnoteTextEnglish = "New Footnote";
            cvf.MandOption          = "M";
            cvf.ShowFootnote        = "B";
            cvf.IsNew    = true;
            cvf.Variable = SelectedVariable;
            cvf.Value    = SelectedValue;
            SelectedContent.ContentValueFootnotes.Add(cvf);
            SelectedContent.MarkAsDirty();
            SelectedMainTable.MarkAsDirty();
            return(cvf);
        }
Exemplo n.º 5
0
        public void Select(Guid elementId, bool isAdditive)
        {
            var partId  = new AbsoluteId(Asset.Id, elementId);
            var element = FindPartViewModel(partId);

            if (element == null)
            {
                return;
            }

            if (SelectedContent.Contains(element))
            {
                return;
            }

            if (!isAdditive)
            {
                ClearSelection();
            }
            SelectedContent.Add(element);
        }
 private void FixContent(object obj)
 {
     SelectedContent.InitializeContentParts((string)obj);
 }