Exemplo n.º 1
0
        /////////////////////////////////////////

        public static void CheckToRemoveNotExistsFilesFromProject()
        {
            var notExists = new ESet <string>();

            foreach (var path in GetProjectFileCSFiles(false, true))
            {
                if (!File.Exists(path))
                {
                    notExists.AddWithCheckAlreadyContained(path);
                }
            }

            if (notExists.Count != 0)
            {
                var text    = EditorLocalization.Translate("General", "Unable to compile Project.csproj. The project contains files which are not exists. Remove these files from the project?") + "\r\n";
                int counter = 0;
                foreach (var fullPath in notExists)
                {
                    if (counter > 20)
                    {
                        text += "\r\n...";
                        break;
                    }

                    var path = fullPath.Replace(ProjectDir + Path.DirectorySeparatorChar, "");
                    text += "\r\n" + path;
                    counter++;
                }

                if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.YesNo) == EDialogResult.Yes)
                {
                    if (UpdateProjectFile(null, notExists, out var error))
                    {
                        if (notExists.Count > 1)
                        {
                            Log.Info(EditorLocalization.Translate("General", "Items have been removed from the Project.csproj."));
                        }
                        else
                        {
                            Log.Info(EditorLocalization.Translate("General", "The item has been removed from the Project.csproj."));
                        }
                    }
                    else
                    {
                        Log.Warning(error);
                    }
                }
            }
        }
        //

        string Translate(string text)
        {
            return(EditorLocalization.Translate("ParticleSystemInSpace", text));
        }
Exemplo n.º 3
0
            public override bool Creation(NewObjectCell.ObjectCreationContext context)
            {
                if (Window.IsFileCreation())
                {
                    context.disableFileCreation = true;

                    GetCreateCSharpClassInfo(out var csharpRealFileName, out var csharpClassName, out var csharpClassNameWithoutNamespace);

                    try
                    {
                        //main file
                        {
                            string name       = Template.Name + ".scene";
                            var    sourceFile = VirtualPathUtility.GetRealPathByVirtual(@"Base\Tools\NewResourceTemplates\" + name);

                            //copy scene file

                            var text = File.ReadAllText(sourceFile);

                            if (CreateCSharpClass)
                            {
                                text = text.Replace(".component NeoAxis.Component_Scene", ".component " + csharpClassName);
                            }

                            File.WriteAllText(context.fileCreationRealFileName, text);

                            //copy additional folder if exist
                            var sourceFolderPath = sourceFile + "_Files";
                            if (Directory.Exists(sourceFolderPath))
                            {
                                var destFolderPath = context.fileCreationRealFileName + "_Files";
                                IOUtility.CopyDirectory(sourceFolderPath, destFolderPath);
                            }
                        }

                        //cs file
                        if (CreateCSharpClass)
                        {
                            string code = @"using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using NeoAxis;

namespace Project
{
	public class {Name} : {Base}
	{
	}
}";

                            code = code.Replace("{Name}", csharpClassNameWithoutNamespace);
                            code = code.Replace("{Base}", Window.SelectedType.Name);

                            File.WriteAllText(csharpRealFileName, code);
                        }
                    }
                    catch (Exception e)
                    {
                        EditorMessageBox.ShowWarning(e.Message);
                        //Log.Warning( e.Message );
                        return(false);
                    }

                    if (CreateCSharpClass)
                    {
                        //add to Project.csproj
                        {
                            var toAdd = new List <string>();

                            var fileName = Path.Combine("Assets", VirtualPathUtility.GetVirtualPathByReal(csharpRealFileName));
                            toAdd.Add(fileName);

                            if (CSharpProjectFileUtility.UpdateProjectFile(toAdd, null, out var error))
                            {
                                if (toAdd.Count > 1)
                                {
                                    Log.Info(EditorLocalization.Translate("General", "Items have been added to the Project.csproj."));
                                }
                                else
                                {
                                    Log.Info(EditorLocalization.Translate("General", "The item has been added to the Project.csproj."));
                                }
                            }
                            else
                            {
                                EditorMessageBox.ShowWarning(error);
                                //Log.Warning( error );
                                return(false);
                            }
                        }

                        Window.DisableUnableToCreateReason = true;

                        //restart application
                        var text = EditorLocalization.Translate("General", "To apply changes need restart the editor. Restart?\r\n\r\nThe editor must be restarted to compile and enable a new created C# class.");
                        if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.YesNo) == EDialogResult.Yes)
                        {
                            EditorAPI.BeginRestartApplication();
                        }

                        Window.DisableUnableToCreateReason = false;
                    }
                }

                return(true);
            }
Exemplo n.º 4
0
 public void ShowSuccessScreenNotification()
 {
     ScreenNotifications.Show(EditorLocalization.Translate("Backstage", "The product was built successfully."));
 }
Exemplo n.º 5
0
 public static string Translate(string text)
 {
     return(EditorLocalization.Translate("DebugInfoWindow", text));
 }