Inheritance: System.Windows.Forms.TreeNode
Beispiel #1
0
        private void CheckForMissingCustomFile(BaseElementTreeNode baseElementTreeNode)
        {
            if (baseElementTreeNode != null)
            {
                IElement element = baseElementTreeNode.SaveObjectAsElement;

                string fileToSearchFor = FileManager.RelativeDirectory + element.Name + ".cs";

                if (!System.IO.File.Exists(fileToSearchFor))
                {
                    MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
                    mbmb.MessageText = "The following file is missing\n\n" + fileToSearchFor + "\n\nwhich is used by\n\n" + element.ToString() + "\n\nWhat would you like to do?";
                    mbmb.AddButton("Re-create an empty custom code file", DialogResult.OK);
                    mbmb.AddButton("Ignore this problem", DialogResult.Cancel);

                    DialogResult result = mbmb.ShowDialog(MainGlueWindow.Self);

                    switch (result)
                    {
                        case DialogResult.OK:

                            CodeWriter.GenerateAndAddElementCustomCode(element);

                            break;
                        case DialogResult.Cancel:
                            // Ignore, do nothing
                            break;

                    }
                }

            }
        }
        internal static void AddNewNamedObjectToElementTreeNode(BaseElementTreeNode elementTreeNode, NamedObjectSave namedObject, bool modifyNamedObject)
        {
            // We no longer need to modify new named objects this way
            // AttachToContainer defaults to true and won't do anything
            // on Screens.  It looks like AddToManagers was always true.
            //if (modifyNamedObject)
            //{
            //    if (elementTreeNode.SaveObjectAsElement is EntitySave)
            //    {
            //        namedObject.AddToManagers = !(elementTreeNode.SaveObjectAsElement as EntitySave).IsUnique;

            //        namedObject.AddToManagers = true;
            //    }
            //    else
            //    {
            //        // Vic says - when a file is loaded in a Screen, 
            //        // it is added to managers.  When it is loaded in
            //        // Entities, it is not and components of it are cloned
            //        // Therefore, if we're in a Screen, we should assume that
            //        // we are going to load from a file for this new object and
            //        // not set the AddToManagers to true.  But IF the new object
            //        // is going to be an Entity, then the PropetyGrid will handle
            //        // setting its AddToManagers to true.
            //    }
            //}

            elementTreeNode.SaveObjectAsElement.NamedObjects.Add(namedObject);

            elementTreeNode.UpdateReferencedTreeNodes();

            CodeWriter.GenerateCode(elementTreeNode.SaveObjectAsElement);

            // Highlight the newly created object
            TreeNode treeNode = EditorLogic.CurrentElementTreeNode.GetTreeNodeFor(namedObject);
            if (treeNode != null)
            {
                MainGlueWindow.Self.ElementTreeView.SelectedNode = treeNode;
            }
        }