/// <summary>
        ///     Create a new group and move the items into the group
        /// </summary>
        private void MoveToNewGroup()
        {
            // Create the group
            var state = new ItemState(
                _projectManager.GetNextGroupID(),
                "Group",
                item.transform.parent.name,
                Utility.GetNeighbourID(item.transform)
                );
            var createCommand = new CreateCommand(true, state);

            _commandGroup = new CommandGroup();
            _undoService.AddCommand(_commandGroup);
            _commandGroup.AddToGroup(createCommand);
            createCommand.Redo();

            // Move the items
            _dragItem =
                Utility.FindChild(hierarchyView.transform, state.ID).GetComponent <HierarchyItemController>();
            _insertion     = true;
            _selectedItems = hierarchyViewController.GetSelectedItems();
            InsertItems();

            // Scroll to First selected Game object
            var groupItem = gameObject.transform.parent.parent;

            hierarchyViewController.ScrollToItem(groupItem.GetComponent <RectTransform>());
            groupItem.GetComponent <HierarchyItemController>().RenameItem(true, _commandGroup);
        }
        /// <summary>
        ///     Apply a rename action
        /// </summary>
        private void ApplyRenaming()
        {
            // Check if there's a name given
            var newName = nameInput.text;

            if (newName == "")
            {
                toast.Error(Toast.Short, "Name cannot be empty!");

                // Reset name if empty
                nameInput.text = nameText.text;
                CancelRenaming();

                return;
            }

            // Hide the input field an show the name field
            nameInputObject.SetActive(false);
            nameTextObject.SetActive(true);
            showStation.SetActive(IsStation);

            // Check if nothing is changed
            if (nameInput.text == nameText.text)
            {
                return;
            }

            var renameCommand = new RenameCommand(item.name, nameText.text, newName);

            // Add the Command to the group if there is "Group Selected"
            if (_isRenameInitial)
            {
                _commandGroup.AddToGroup(renameCommand);
                renameCommand.Redo();
                _isRenameInitial = false;
            }
            else
            {
                _undoService.AddCommand(renameCommand);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Create an assembly station
        /// </summary>
        private void CreateAssemblyStation()
        {
            var state = new ItemState(
                _projectManager.GetNextGroupID(),
                "Assembly Station",
                _projectManager.CurrentProject.ObjectModel.name,
                ItemState.Last
                );

            // Add the new action to the undo redo service
            var createCommand = new CreateCommand(true, state);
            var commandGroup  = new CommandGroup();

            _undoService.AddCommand(commandGroup);
            commandGroup.AddToGroup(createCommand);
            createCommand.Redo();

            // Scroll to the created station
            var stationItem = hierarchyView.transform.GetChild(hierarchyView.transform.childCount - 1);

            ScrollToItem(stationItem.GetComponent <RectTransform>());
            stationItem.GetComponent <HierarchyItemController>().RenameItem(true, commandGroup);
        }
        /// <summary>
        ///     Add new group
        /// </summary>
        private void AddGroup()
        {
            // Save the item state
            var state = new ItemState(
                _projectManager.GetNextGroupID(),
                "Group",
                item.name,
                ItemState.Last
                );

            // Add the new action to the undo redo service
            var createCommand = new CreateCommand(true, state);

            _commandGroup = new CommandGroup();
            _undoService.AddCommand(_commandGroup);
            _commandGroup.AddToGroup(createCommand);
            createCommand.Redo();

            // Scroll to the created group in the group
            var groupItem = childrenContainer.transform.GetChild(childrenContainer.transform.childCount - 1);

            hierarchyViewController.ScrollToItem(groupItem.GetComponent <RectTransform>());
            groupItem.GetComponent <HierarchyItemController>().RenameItem(true, _commandGroup);
        }