상속: System.Windows.Forms.Form
예제 #1
0
        private void NewClassButton_Click(object sender, EventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();

            tiw.DisplayText = "Enter new class name";

            DialogResult result = tiw.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                string newClassName = tiw.Result;

                CustomClassSave newClass;

                var response = GlueCommands.Self.GluxCommands.AddNewCustomClass(newClassName, out newClass);

                if (response.OperationResult == Plugins.ExportedInterfaces.CommandInterfaces.OperationResult.Failure)
                {
                    MessageBox.Show(response.Message);
                }
                else
                {
                    UpdateTreeView();
                }
            }
        }
예제 #2
0
        private void NewClassButton_Click(object sender, EventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();
            tiw.DisplayText = "Enter new class name";

            DialogResult result = tiw.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                string newClassName = tiw.Result;

                string whyIsntValid;

                if (!NameVerifier.IsScreenNameValid(tiw.Result, null, out whyIsntValid))
                {
                    MessageBox.Show(whyIsntValid);
                }
                else
                {
                    if (ProjectManager.GlueProjectSave.GetCustomClass(newClassName) == null)
                    {
                        CustomClassSave ccs = new CustomClassSave();
                        ccs.Name = newClassName;
                        ProjectManager.GlueProjectSave.CustomClasses.Add(ccs);

                        UpdateTreeView();
                    }
                }
            }
        }
예제 #3
0
        private void AddResolutionButton_Click(object sender, EventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();

            tiw.DisplayText = "Enter name for the new resolution preset";
            if (tiw.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string whyIsntValid = WhyIsntResolutionPresetNameValid(tiw.Result);

                if (!string.IsNullOrEmpty(whyIsntValid))
                {
                    MessageBox.Show(whyIsntValid);
                }
                else
                {
                    GlueProjectSave glueProject = ObjectFinder.Self.GlueProject;

                    int width = 0;
                    if (int.TryParse(this.tbResWidth.Text, out width) == false)
                    {
                        width = 0;
                    }

                    int height = 0;

                    if (int.TryParse(this.tbResHeight.Text, out height) == false)
                    {
                        height = 0;
                    }

                    ResolutionValues resolutionValues = new ResolutionValues();
                    resolutionValues.Width  = width;
                    resolutionValues.Height = height;
                    resolutionValues.Name   = tiw.Result;

                    glueProject.ResolutionPresets.Add(resolutionValues);

                    GluxCommands.Self.SaveGlux();
                    RefreshPresetTreeView();
                }
            }
        }
예제 #4
0
        static void AddStateCategoryClick(object sender, EventArgs e)
        {
            // add category, addcategory, add state category
            TextInputWindow tiw = new TextInputWindow();
            tiw.DisplayText = "Enter a name for the new category";
            tiw.Text = "New Category";

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

            if (result == DialogResult.OK)
            {
                string whyItIsntValid;

                if(!NameVerifier.IsStateCategoryNameValid(tiw.Result, out whyItIsntValid))
                {
                    GlueGui.ShowMessageBox(whyItIsntValid);
                }
                else
                {
                    IElement element = EditorLogic.CurrentElement;

                    StateSaveCategory newCategory = new StateSaveCategory();
                    newCategory.Name = tiw.Result;
                    newCategory.SharesVariablesWithOtherCategories = false;

                    element.StateCategoryList.Add(newCategory);

                    EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes();
                    ElementViewWindow.GenerateSelectedElementCode();

                    GluxCommands.Self.SaveGlux();
                    ProjectManager.SaveProjects();
                }
            }
        }
예제 #5
0
        static void AddStateClick(object sender, EventArgs e)
        {
            // search: addstate, add new state, addnewstate, add state
            TextInputWindow tiw = new TextInputWindow();
            tiw.DisplayText = "Enter a name for the new state";
            tiw.Text = "New State";


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

            if (result == DialogResult.OK)
            {
                string whyItIsntValid;
                if (!NameVerifier.IsStateNameValid(tiw.Result, EditorLogic.CurrentElement, EditorLogic.CurrentStateSaveCategory, EditorLogic.CurrentStateSave, out whyItIsntValid))
                {
                    GlueGui.ShowMessageBox(whyItIsntValid);
                }
                else
                {

                    StateSave newState = new StateSave();
                    newState.Name = tiw.Result;

                    if (EditorLogic.CurrentStateSaveCategory != null)
                    {
                        EditorLogic.CurrentStateSaveCategory.States.Add(newState);
                    }
                    else
                    {
                        IElement element = EditorLogic.CurrentElement;

                        element.States.Add(newState);
                    }

                    EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes();
                    ElementViewWindow.GenerateSelectedElementCode();

                    GlueCommands.Self.TreeNodeCommands.SelectTreeNode(newState);

                    GluxCommands.Self.SaveGlux();
                    ProjectManager.SaveProjects();
                }
            }
        }
예제 #6
0
        internal static void AddScreenToolStripClick()
        {
            // AddScreen, add screen, addnewscreen, add new screen
            if (ProjectManager.GlueProjectSave == null)
            {
                System.Windows.Forms.MessageBox.Show("You need to load a project first.");
            }
            else
            {
                if (ProjectManager.StatusCheck() == ProjectManager.CheckResult.Passed)
                {
                    TextInputWindow tiw = new TextInputWindow();

                    tiw.DisplayText = "Enter a name for the new Screen";
                    tiw.Text = "New Screen";

                    if (tiw.ShowDialog(MainGlueWindow.Self) == DialogResult.OK)
                    {
                        string whyItIsntValid;

                        if (!NameVerifier.IsScreenNameValid(tiw.Result, null, out whyItIsntValid))
                        {
                            MessageBox.Show(whyItIsntValid);
                        }
                        else
                        {
                            var screen = ProjectManager.AddScreen(tiw.Result);

                            GlueState.Self.CurrentElement = screen;
                        }
                    }
                }
            }
        }
예제 #7
0
        internal static void AddFolderClick()
        {
            // addfolder, add folder, add new folder, addnewfolder
            TextInputWindow tiw = new TextInputWindow();
            tiw.DisplayText = "Enter new folder name";
            tiw.Text = "New Folder";
            DialogResult result = tiw.ShowDialog(MainGlueWindow.Self);

            if (result == DialogResult.OK)
            {
                string folderName = tiw.Result;

                TreeNode treeNodeToAddTo = EditorLogic.CurrentTreeNode;
                GlueCommands.Self.ProjectCommands.AddDirectory(folderName, treeNodeToAddTo);

                treeNodeToAddTo.Nodes.SortByTextConsideringDirectories();
            }
        }
예제 #8
0
        internal static void AddEntityToolStripClick()
        {
            // search:  addentity, add entity
            if (ProjectManager.GlueProjectSave == null)
            {
                System.Windows.Forms.MessageBox.Show("You need to load a project first.");
            }
            else
            {
                if (ProjectManager.StatusCheck() == ProjectManager.CheckResult.Passed)
                {
                    TextInputWindow tiw = new TextInputWindow();
                    tiw.DisplayText = "Enter a name for the new Entity";
                    tiw.Text = "New Entity";

                    CheckBox is2DCheckBox = new CheckBox();
                    is2DCheckBox.Text = "Is 2D";
                    is2DCheckBox.Checked = true;
                    is2DCheckBox.Margin = new Padding(2, 0, 0, 0);

                    tiw.AddControl(is2DCheckBox);

                    if (tiw.ShowDialog(MainGlueWindow.Self) == DialogResult.OK)
                    {

                        string entityName = tiw.Result;

                        string whyIsntValid;
                        string directory = "";

                        if (EditorLogic.CurrentTreeNode.IsDirectoryNode())
                        {
                            directory = EditorLogic.CurrentTreeNode.GetRelativePath();
                            directory = directory.Replace('/', '\\');
                        }

                        if (!NameVerifier.IsEntityNameValid(tiw.Result, null, out whyIsntValid))
                        {
                            MessageBox.Show(whyIsntValid);
                        }
                        else
                        {
                            var newElement = 
                                GlueCommands.Self.GluxCommands.EntityCommands.AddEntity(directory + tiw.Result, is2DCheckBox.Checked);

                            GlueState.Self.CurrentElement = newElement;

                        }
                    }
                }
            }
        }
예제 #9
0
        private void AddResolutionButton_Click(object sender, EventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();
            tiw.DisplayText = "Enter name for the new resolution preset";
            if (tiw.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string whyIsntValid = WhyIsntResolutionPresetNameValid(tiw.Result);

                if (!string.IsNullOrEmpty(whyIsntValid))
                {
                    MessageBox.Show(whyIsntValid);
                }
                else
                {
                    GlueProjectSave glueProject = ObjectFinder.Self.GlueProject;

                    int width = 0;
                    if (int.TryParse(this.tbResWidth.Text, out width) == false)
                    {
                        width = 0;
                    }

                    int height = 0;

                    if (int.TryParse(this.tbResHeight.Text, out height) == false)
                    {
                        height = 0;
                    }

                    ResolutionValues resolutionValues = new ResolutionValues();
                    resolutionValues.Width = width;
                    resolutionValues.Height = height;
                    resolutionValues.Name = tiw.Result;

                    glueProject.ResolutionPresets.Add(resolutionValues);

                    GluxCommands.Self.SaveGlux();
                    RefreshPresetTreeView();
                }
            }
        }
        private static AddObjectViewModel CreateAndShowAddNamedObjectWindow()
        {
            AddObjectViewModel addObjectViewModel = new AddObjectViewModel();

            TextInputWindow tiw = new TextInputWindow();
            tiw.DisplayText = "Enter the new object's name";
            tiw.Text = "New Object";
            bool isTypePredetermined =  EditorLogic.CurrentNamedObject != null && EditorLogic.CurrentNamedObject.IsList;

            NewObjectTypeSelectionControl typeSelectControl = null;
            if (!isTypePredetermined)
            {
                tiw.Width = 400;


                typeSelectControl = new NewObjectTypeSelectionControl();
                typeSelectControl.Width = tiw.Width - 22;

                typeSelectControl.AfterStrongSelect += delegate
                {
                    tiw.ClickOk();
                };

                typeSelectControl.AfterSelect += delegate(object sender, EventArgs args)
                {
                    string result = tiw.Result;

                    bool isDefault = string.IsNullOrEmpty(result);

                    // Victor Chelaru November 3, 2012
                    // I don't know if we want to only re-assign when default.
                    // The downside is that the user may have already entered a
                    // name, an then changed the type.  This would result in the
                    // user-entered name being overwritten.  However, if we don't
                    // change the name, then an old name that the user entered which
                    // is specific to the type may not get reset.  I'm leaning towards
                    // always changing the name to help prevent misnaming, and it's also
                    // less programatically complex.
                    //if (isDefault)
                    {
                        string newName;

                        if(!string.IsNullOrEmpty(typeSelectControl.SourceFile) && !string.IsNullOrEmpty(typeSelectControl.SourceName))
                        {
                            newName = HandleObjectInFileSelected(typeSelectControl);
                        }
                        else if (string.IsNullOrEmpty(typeSelectControl.SourceClassType))
                        {
                            newName = "ObjectInstance";

                        }
                        else
                        {

                            string textToAssign = typeSelectControl.SourceClassType + "Instance";
                            if (textToAssign.Contains("/") || textToAssign.Contains("\\"))
                            {
                                textToAssign = FileManager.RemovePath(textToAssign);
                            }

                            newName = textToAssign.Replace("<T>", "");
                        }

                        // We need to make sure this is a unique name.
                        newName = StringFunctions.MakeStringUnique(newName, EditorLogic.CurrentElement.AllNamedObjects);
                        tiw.Result = newName;
                    }
                };
                tiw.AddControl(typeSelectControl, AboveOrBelow.Above);
            }

            addObjectViewModel.DialogResult = tiw.ShowDialog();

            addObjectViewModel.SourceType = SourceType.FlatRedBallType;
            addObjectViewModel.SourceClassType = null;
            addObjectViewModel.SourceFile = null;
            addObjectViewModel.SourceNameInFile = null;
            addObjectViewModel.SourceClassGenericType = null;
            addObjectViewModel.ObjectName = tiw.Result;

            if(isTypePredetermined)
            {
                var parentList = GlueState.Self.CurrentNamedObjectSave;

                var genericType = parentList.SourceClassGenericType;

                if(!string.IsNullOrEmpty(genericType))
                {
                    addObjectViewModel.SourceClassType = genericType;
                    
                    // the generic type will be fully qualified (like FlatRedBall.Sprite)
                    // but object types for FRB primitives are not qualified, so we need to remove
                    // any dots

                    if(addObjectViewModel.SourceClassType.Contains("."))
                    {
                        int lastDot = addObjectViewModel.SourceClassType.LastIndexOf('.');

                        addObjectViewModel.SourceClassType = addObjectViewModel.SourceClassType.Substring(lastDot + 1);
                    }

                    if(ObjectFinder.Self.GetEntitySave(genericType) != null)
                    {
                        addObjectViewModel.SourceType = SourceType.Entity;
                    }
                    else
                    {
                        addObjectViewModel.SourceType = SourceType.FlatRedBallType;
                    }
                }
            }

            if (typeSelectControl != null)
            {
                if (!string.IsNullOrEmpty(typeSelectControl.SourceClassType) || typeSelectControl.SourceType == SourceType.File)
                {
                    addObjectViewModel.SourceType = typeSelectControl.SourceType;
                }
                addObjectViewModel.SourceFile = typeSelectControl.SourceFile;
                addObjectViewModel.SourceNameInFile = typeSelectControl.SourceName;

                addObjectViewModel.SourceClassType = typeSelectControl.SourceClassType;
                addObjectViewModel.SourceClassGenericType = typeSelectControl.SourceClassGenericType;
            }

            return addObjectViewModel;
        }
예제 #11
0
        private void newContentCSVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();
            tiw.DisplayText = "Enter new CSV name";

            ComboBox comboBox = new ComboBox();

            // project-specific CSVs are always named ProjectSpecificContent.csv
            //const string allProjects = "For all projects";
            //const string thisProjectOnly = "For this project only";

            //comboBox.Items.Add(allProjects);
            //comboBox.Text = allProjects;
            //comboBox.Items.Add(thisProjectOnly);
            //comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            //comboBox.Width = 136;
            //tiw.AddControl(comboBox);

            DialogResult result = tiw.ShowDialog();

            // CSVs can be added to be project-specific or shared across all projects (installed to a centralized location)

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                string textResult = tiw.Result;
                if (textResult.ToLower().EndsWith(".csv"))
                {
                    textResult = FileManager.RemoveExtension(textResult);
                }

                GlobalOrProjectSpecific globalOrProjectSpecific;

                //if (comboBox.SelectedItem == allProjects)
                //{
                    globalOrProjectSpecific = GlobalOrProjectSpecific.Global;
                //}
                //else
                //{
                //    globalOrProjectSpecific = GlobalOrProjectSpecific.ProjectSpecific;
                //}

                AvailableAssetTypes.Self.CreateAdditionalCsvFile(tiw.Result, globalOrProjectSpecific);

                ViewAdditionalContentTypes(globalOrProjectSpecific);
            }
        }
예제 #12
0
        private void customGameClassToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ProjectManager.GlueProjectSave == null)
            {
                MessageBox.Show("There is no loaded Glue project");
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.DisplayText = "Enter the custom class name.  Delete the contents to not use a custom class.";
                tiw.Result = ProjectManager.GlueProjectSave.CustomGameClass;

                DialogResult result = tiw.ShowDialog();


                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    ProjectManager.GlueProjectSave.CustomGameClass = tiw.Result;
                    GluxCommands.Self.SaveGlux();

                    ProjectManager.FindGameClass();

                    if (string.IsNullOrEmpty(ProjectManager.GameClassFileName))
                    {
                        MessageBox.Show("Couldn't find the game class.");
                    }
                    else
                    {
                        MessageBox.Show("Game class found:\n\n" + ProjectManager.GameClassFileName);
                    }
                }
            }

        }
예제 #13
0
        private void findFileReferencesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();

            tiw.DisplayText = "Enter the file name with extension, but no path (for example \"myfile.png\")";

            

            if (tiw.ShowDialog(MainGlueWindow.Self) == DialogResult.OK)
            {
                List<ReferencedFileSave> matchingReferencedFileSaves = new List<ReferencedFileSave>();
                List<string> matchingRegularFiles = new List<string>();

                string result = tiw.Result.ToLower();
                
                List<ReferencedFileSave> allReferencedFiles = ObjectFinder.Self.GetAllReferencedFiles();

                foreach (ReferencedFileSave rfs in allReferencedFiles)
                {
                    if (FileManager.RemovePath(rfs.Name.ToLower()) == result)
                    {
                        matchingReferencedFileSaves.Add(rfs);
                    }
                    
                    string absoluteFileName = ProjectManager.MakeAbsolute(rfs.Name);

                    if (File.Exists(absoluteFileName))
                    {
                        List<string> referencedFiles = null;

                        try
                        {
                            referencedFiles = FileReferenceManager.Self.GetFilesReferencedBy(absoluteFileName, TopLevelOrRecursive.Recursive);
                        }
                        catch (FileNotFoundException fnfe)
                        {
                            ErrorReporter.ReportError(absoluteFileName, "Trying to find file references, but could not find contained file " + fnfe.FileName, true);
                        }

                        if (referencedFiles != null)
                        {
                            foreach (string referencedFile in referencedFiles)
                            {
                                if (result == FileManager.RemovePath(referencedFile).ToLower())
                                {
                                    matchingRegularFiles.Add(referencedFile + " in " + rfs.ToString() + "\n");
                                }
                            }
                        }
                    }
                }

                if (matchingReferencedFileSaves.Count == 0 && matchingRegularFiles.Count == 0)
                {
                    MessageBox.Show("There are no files referencing " + result, "No files found");
                }
                else
                {
                    string message = "Found the following:\n\n";

                    foreach (string s in matchingRegularFiles)
                    {
                        message += s + "\n";
                    }

                    foreach (ReferencedFileSave rfs in matchingReferencedFileSaves)
                    {
                        message += rfs.ToString() + "\n";
                    }
                    MessageBox.Show(message, "Files found");
                }

                

            }

        }
예제 #14
0
        static void HandleRenameFolderClick(object sender, EventArgs e)
        {
            var treeNode = GlueState.Self.CurrentTreeNode;

            var inputWindow = new TextInputWindow();
            inputWindow.Message = "Enter new folder name";
            inputWindow.Result = treeNode.Text;

            var dialogResult = inputWindow.ShowDialog();

            bool shouldPerformMove = false;

            string directoryRenaming = null;
            string newDirectoryNameRelative = null;
            string newDirectoryNameAbsolute = null;

            if (dialogResult == DialogResult.OK)
            {
                // entities use backslash:
                directoryRenaming = treeNode.GetRelativePath().Replace("/", "\\");
                newDirectoryNameRelative = FileManager.GetDirectory(directoryRenaming, RelativeType.Relative) + inputWindow.Result + "\\";
                newDirectoryNameAbsolute = GlueState.Self.CurrentGlueProjectDirectory + newDirectoryNameRelative;

                string whyIsInvalid = null;
                NameVerifier.IsDirectoryNameValid(inputWindow.Result, out whyIsInvalid);

                if (string.IsNullOrEmpty(whyIsInvalid) && Directory.Exists(newDirectoryNameAbsolute))
                {
                    whyIsInvalid = $"The directory {inputWindow.Result} already exists.";
                }

                if (!string.IsNullOrEmpty(whyIsInvalid))
                {
                    MessageBox.Show(whyIsInvalid);
                    shouldPerformMove = false;
                }
                else
                {
                    shouldPerformMove = true;
                }
            }

            if(shouldPerformMove && !Directory.Exists(newDirectoryNameAbsolute))
            {
                try
                {
                    Directory.CreateDirectory(newDirectoryNameAbsolute);
                }
                catch(Exception ex)
                {
                    PluginManager.ReceiveError(ex.ToString());
                    shouldPerformMove = false;
                }
            }

            if(shouldPerformMove)
            {
                var allContainedEntities = GlueState.Self.CurrentGlueProject.Entities
                    .Where(entity => entity.Name.StartsWith(directoryRenaming)).ToList();

                newDirectoryNameRelative = newDirectoryNameRelative.Replace('/', '\\');

                bool didAllSucceed = true;

                foreach(var entity in allContainedEntities)
                {
                    bool succeeded = GlueCommands.Self.GluxCommands.MoveEntityToDirectory(entity, newDirectoryNameRelative);

                    if(!succeeded)
                    {
                        didAllSucceed = false;
                        break;
                    }
                }

                if(didAllSucceed)
                {
                    treeNode.Text = inputWindow.Result;

                    ProjectLoader.Self.MakeGeneratedItemsNested();
                    GlueCommands.Self.GenerateCodeCommands.GenerateAllCode();
                    
                    GluxCommands.Self.SaveGlux();
                    ProjectManager.SaveProjects();

                }
            }
        }
        public void AddChainClick(object sender, EventArgs args)
        {
            if (ProjectManager.Self.AnimationChainListSave == null)
            {
                MessageBox.Show("You must first save a file before working in the Animation Editor");
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.DisplayText = "Enter new AnimationChain name";

                if (tiw.ShowDialog() == DialogResult.OK)
                {
                    string result = tiw.Result;

                    string whyIsntValid = GetWhyNameIsntValid(result);

                    if (!string.IsNullOrEmpty(whyIsntValid))
                    {
                        MessageBox.Show(whyIsntValid);
                    }
                    else
                    {
                        AnimationChainSave acs = new AnimationChainSave();
                        acs.Name = result;

                        ProjectManager.Self.AnimationChainListSave.AnimationChains.Add(acs);


                        TreeViewManager.Self.RefreshTreeView();
                        SelectedState.Self.SelectedChain = acs;


                        CallAnimationChainsChange();
                    }
                }
            }
        }