FlatRedBall.Glue.SaveClasses.ScreenSave.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : string
return string
        public override string ToString()
        {
            return this.Name + " (Screen)";
        }

Usage Example

        public static void RemoveScreen(ScreenSave screenToRemove, List<string> filesThatCouldBeRemoved)
        {
            List<ScreenSave> inheritingScreens = ObjectFinder.Self.GetAllScreensThatInheritFrom(screenToRemove);
            string message = null;
            if (inheritingScreens.Count != 0)
            {
                message = "The Screen " + screenToRemove.ToString() + " is the base for the following Screens:";
                for (int i = 0; i < inheritingScreens.Count; i++)
                {
                    message += "\n" + inheritingScreens[i].ToString();
                }
            }
            DialogResult result = DialogResult.Yes;
            if (message != null)
            {
                message += "\n\nDo you really want to remove this Screen?";
                result = MessageBox.Show(message, "Are you sure?", MessageBoxButtons.YesNo);
            }

            if (result == DialogResult.Yes)
            {


                // Remove objects before removing files.  Otherwise Glue will complain if any objects reference the files.
                #region Remove the NamedObjectSaves

                for (int i = screenToRemove.NamedObjects.Count - 1; i > -1; i--)
                {
                    NamedObjectSave nos = screenToRemove.NamedObjects[i];

                    ProjectManager.RemoveNamedObject(nos, false, false, null);
                }

                #endregion


                // remove all the files this references first before removing the Screen itself.
                // For more information see the RemoveEntity function
                for (int i = screenToRemove.ReferencedFiles.Count - 1; i > -1; i--)
                {
                    GluxCommands.Self.RemoveReferencedFile(screenToRemove.ReferencedFiles[i], filesThatCouldBeRemoved);
                }

                ProjectManager.GlueProjectSave.Screens.Remove(screenToRemove);
                // If we're going to remove the Screen, we should remove all referenced objects that it references
                // as well as any ReferencedFiles
                
                RemoveUnreferencedFiles(screenToRemove, filesThatCouldBeRemoved);

                // test this!
                if (screenToRemove.Name == ProjectManager.GlueProjectSave.StartUpScreen)
                {
                    ProjectManager.StartUpScreen = "";
                }

                for (int i = 0; i < inheritingScreens.Count; i++)
                {
                    ScreenSave inheritingScreen = inheritingScreens[i];

                    DialogResult resetInheritance = MessageBox.Show("Reset the inheritance for " + inheritingScreen.Name + "?",
                        "Reset Inheritance?", MessageBoxButtons.YesNo);

                    if (resetInheritance == DialogResult.Yes)
                    {
                        inheritingScreen.BaseScreen = "";

                        CodeWriter.GenerateCode(inheritingScreen);
                    }
                }

                TaskManager.Self.OnUiThread(() =>
                    {
                        ElementViewWindow.RemoveScreen(screenToRemove);
                    });
                IElement element = screenToRemove;

                ProjectManager.RemoveCodeFilesForElement(filesThatCouldBeRemoved, element);


                ProjectManager.SaveProjects();
                GluxCommands.Self.SaveGlux();
            }
        }