Esempio n. 1
0
        public void ShowAddNewEntityDialog()
        {
            // search:  addentity, add entity
            if (ProjectManager.GlueProjectSave == null)
            {
                System.Windows.Forms.MessageBox.Show("You need to create or load a project first.");
            }
            else
            {
                if (ProjectManager.StatusCheck() == ProjectManager.CheckResult.Passed)
                {
                    AddEntityWindow window = new Controls.AddEntityWindow();
                    window.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;

                    double width = window.Width;
                    if (double.IsNaN(width))
                    {
                        width = 0;
                    }
                    double height = window.Height;
                    if (double.IsNaN(height))
                    {
                        height = 0;
                    }

                    window.Left = MainGlueWindow.MousePosition.X - width / 2;
                    window.Top  = MainGlueWindow.MousePosition.Y - height / 2;

                    PluginManager.ModifyAddEntityWindow(window);

                    var result = window.ShowDialog();

                    if (result == true)
                    {
                        string entityName = window.EnteredText;

                        string whyIsntValid;

                        if (!NameVerifier.IsEntityNameValid(entityName, null, out whyIsntValid))
                        {
                            MessageBox.Show(whyIsntValid);
                        }
                        else
                        {
                            string directory = "";

                            if (EditorLogic.CurrentTreeNode.IsDirectoryNode())
                            {
                                directory = EditorLogic.CurrentTreeNode.GetRelativePath();
                                directory = directory.Replace('/', '\\');
                            }
                            var entity = CreateEntityAndObjects(window, entityName, directory);

                            PluginManager.ReactToNewEntityCreated(entity, window);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void ShowAddNewEntityDialog()
        {
            // search:  addentity, add entity
            if (ProjectManager.GlueProjectSave == null)
            {
                System.Windows.Forms.MessageBox.Show("You need to create or load a project first.");
            }
            else
            {
                if (ProjectManager.StatusCheck() == ProjectManager.CheckResult.Passed)
                {
                    AddEntityWindow window = new Controls.AddEntityWindow();

                    PluginManager.ModifyAddEntityWindow(window);

                    var result = window.ShowDialog();

                    if (result == true)
                    {
                        string entityName = window.EnteredText;

                        string whyIsntValid;

                        if (!NameVerifier.IsEntityNameValid(entityName, null, out whyIsntValid))
                        {
                            MessageBox.Show(whyIsntValid);
                        }
                        else
                        {
                            string directory = "";

                            if (EditorLogic.CurrentTreeNode.IsDirectoryNode())
                            {
                                directory = EditorLogic.CurrentTreeNode.GetRelativePath();
                                directory = directory.Replace('/', '\\');
                            }
                            var entity = CreateEntityAndObjects(window, entityName, directory);

                            PluginManager.ReactToNewEntityCreated(entity, window);
                        }
                    }
                }
            }
        }