public static GenerateSelectedElementCode ( ) : void | ||
리턴 | void |
public static TreeNode MoveEntityOn(EntityTreeNode treeNodeMoving, TreeNode targetNode) { TreeNode newTreeNode = null; #region Moving the Entity into (or out of) a directory if (targetNode.IsDirectoryNode() || targetNode.IsRootEntityNode()) { MoveEntityToDirectory(treeNodeMoving, targetNode); } #endregion #region Moving an Entity onto another element to create an instance else if (targetNode.IsEntityNode() || targetNode.IsScreenNode() || targetNode.IsRootNamedObjectNode()) { bool isValidDrop = true; // Make sure that we don't drop an Entity into its own Objects if (targetNode.IsRootNamedObjectNode()) { if (treeNodeMoving == targetNode.GetContainingElementTreeNode()) { isValidDrop = false; } } if (isValidDrop) { newTreeNode = MoveEntityOntoElement(treeNodeMoving, targetNode, newTreeNode); } } #endregion #region Moving an Entity onto a NamedObject (currently supports only Lists) else if (targetNode.IsNamedObjectNode()) { // Allow drop only if it's a list or Layer NamedObjectSave targetNamedObjectSave = targetNode.Tag as NamedObjectSave; if (!targetNamedObjectSave.IsList && !targetNamedObjectSave.IsLayer) { MessageBox.Show("The target is not a List or Layer so we can't add an Object to it.", "Target not valid"); } if (targetNamedObjectSave.IsLayer) { TreeNode parent = targetNode.Parent; newTreeNode = MoveEntityOn(treeNodeMoving, parent); // this created a new NamedObjectSave. Let's put that on the Layer MoveNamedObject(newTreeNode, targetNode); } else { // Make sure that the two types match string listType = targetNamedObjectSave.SourceClassGenericType; bool isOfTypeOrInherits = listType == treeNodeMoving.EntitySave.Name || treeNodeMoving.EntitySave.InheritsFrom(listType); if (isOfTypeOrInherits == false) { MessageBox.Show("The target list type is of type\n\n" + listType + "\n\nBut the Entity is of type\n\n" + treeNodeMoving.EntitySave.Name + "\n\nCould not add an instance to the list", "Could not add instance"); } else { NamedObjectSave namedObject = new NamedObjectSave(); namedObject.InstanceName = FileManager.RemovePath(treeNodeMoving.EntitySave.Name) + "1"; StringFunctions.MakeNameUnique <NamedObjectSave>( namedObject, targetNamedObjectSave.ContainedObjects); // Not sure if we need to set this or not, but I think // any instance added to a list will not be defined by base namedObject.DefinedByBase = false; NamedObjectSaveExtensionMethodsGlue.AddNamedObjectToCurrentNamedObjectList(namedObject); ElementViewWindow.GenerateSelectedElementCode(); // Don't save the Glux, the caller of this method will take care of it // GluxCommands.Self.SaveGlux(); } } } #endregion else if (targetNode.IsGlobalContentContainerNode()) { AskAndAddAllContainedRfsToGlobalContent(treeNodeMoving.SaveObjectAsElement); } return(newTreeNode); }
private static void MoveNamedObject(TreeNode treeNodeMoving, TreeNode targetNode) { if (targetNode != null) { NamedObjectSave targetNos = targetNode.Tag as NamedObjectSave; NamedObjectSave movingNos = treeNodeMoving.Tag as NamedObjectSave; bool succeeded = false; if (targetNode == null) { // Didn't move on to anything } else if (targetNode.IsRootNamedObjectNode()) { succeeded = MoveObjectOnObjectsRoot(treeNodeMoving, targetNode, movingNos, succeeded); } else if (targetNode.IsRootCustomVariablesNode()) { MoveObjectOnRootCustomVariablesNode(treeNodeMoving, targetNode); } else if (targetNode.Tag is IElement) { succeeded = DragDropNosIntoElement(movingNos, targetNode.Tag as IElement); } else if (targetNode.IsRootEventsNode()) { succeeded = DragDropNosOnRootEventsNode(treeNodeMoving, targetNode); } else if (targetNos != null && targetNos.SourceType == SourceType.FlatRedBallType) { string targetClassType = targetNos.SourceClassType; #region Failure cases if (string.IsNullOrEmpty(targetClassType)) { MessageBox.Show("The target Object does not have a defined type. This operation is not valid"); } #endregion #region Moving on to a Layer else if (targetClassType == "Layer") { // Only allow this if the NOS's are on the same object if (ObjectFinder.Self.GetElementContaining(movingNos) == ObjectFinder.Self.GetElementContaining(targetNos)) { succeeded = true; movingNos.LayerOn = targetNos.InstanceName; MainGlueWindow.Self.PropertyGrid.Refresh(); } } #endregion #region Moving on to a PositionedObjectList else if (targetClassType == "PositionedObjectList<T>") { succeeded = HandleDropOnList(treeNodeMoving, targetNode, targetNos, movingNos); } #endregion } else { MessageBox.Show("Invalid movement"); } if (succeeded) { if (EditorLogic.CurrentElement != null) { ElementViewWindow.GenerateSelectedElementCode(); } else { ContentLoadWriter.UpdateLoadGlobalContentCode(); } ProjectManager.SaveProjects(); GluxCommands.Self.SaveGlux(); } } }