private void kryptonButtonDarkTheme_Click(object sender, EventArgs e) { if (EditorMessageBox.ShowQuestion("Set the dark theme and restart the editor to apply changes?", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } ProjectSettings.Get.Theme = Component_ProjectSettings.ThemeEnum.Dark; ProjectSettings.SaveToFileAndUpdate(); EditorAPI.BeginRestartApplication(); }
private void kryptonButtonInstall_Click(object sender, EventArgs e) { var info = PackageManager.ReadPackageArchiveInfo(selectedPackage.FullFilePath, out var error); if (info == null) { return; } var filesToCopy = new List <string>(); foreach (var file in info.Files) { var fullName = Path.Combine(VirtualFileSystem.Directories.Project, file); filesToCopy.Add(fullName); } var text = string.Format(Translate("Install {0}?\n\n{1} files will created."), selectedPackage.GetDisplayName(), filesToCopy.Count); //var text = string.Format( Translate( "Install {0}?\r\n\r\n{1} files will created." ), selectedPackage.Name, filesToCopy.Count ); //var text = $"Install {selectedPackage.Name}?\r\n\r\n{filesToCopy.Count} files will created."; if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.YesNo) != EDialogResult.Yes) { return; } var notification = ScreenNotifications.ShowSticky("Installing the package..."); try { using (var archive = ZipFile.OpenRead(selectedPackage.FullFilePath)) { foreach (var entry in archive.Entries) { var fileName = entry.FullName; bool directory = fileName[fileName.Length - 1] == '/'; if (fileName != "Package.info" && !directory) { var fullPath = Path.Combine(VirtualFileSystem.Directories.Project, fileName); var directoryName = Path.GetDirectoryName(fullPath); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } entry.ExtractToFile(fullPath, true); } } } PackageManager.ChangeInstalledState(selectedPackage.Name, true); } catch (Exception e2) { EditorMessageBox.ShowWarning(e2.Message); return; } finally { notification.Close(); } if (!string.IsNullOrEmpty(info.AddCSharpFilesToProject)) { var toAdd = new ESet <string>(); var path = Path.Combine(VirtualFileSystem.Directories.Assets, info.AddCSharpFilesToProject); if (Directory.Exists(path)) { var fullPaths = CSharpProjectFileUtility.GetProjectFileCSFiles(false, true); var files = Directory.GetFiles(path, "*.cs", SearchOption.AllDirectories); foreach (var file in files) { if (!fullPaths.Contains(file)) { toAdd.AddWithCheckAlreadyContained(file); } } } // if( !fileItem.IsDirectory && Path.GetExtension( fileItem.FullPath ).ToLower() == ".cs" ) // { // bool added = CSharpProjectFileUtility.GetProjectFileCSFiles( false, true ).Contains( fileItem.FullPath ); // if( !added ) // toAdd.Add( fileItem.FullPath ); // } if (toAdd.Count != 0) { if (CSharpProjectFileUtility.UpdateProjectFile(toAdd, null, out var error2)) { 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 { Log.Warning(error2); } } } needUpdateList = true; if (info.MustRestart) { ShowRestartLabel(); } if (!string.IsNullOrEmpty(info.OpenAfterInstall)) { var realFileName = VirtualPathUtility.GetRealPathByVirtual(info.OpenAfterInstall); if (info.MustRestart) { EditorSettingsSerialization.OpenFileAtStartup = realFileName; } else { EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow(new string[] { realFileName }, Directory.Exists(realFileName)); EditorAPI.OpenFileAsDocument(realFileName, true, true); } } ScreenNotifications.Show(EditorLocalization.Translate("General", "The package has been successfully installed.")); //restart application if (info.MustRestart) { var text2 = EditorLocalization.Translate("General", "To apply changes need restart the editor. Restart?"); if (EditorMessageBox.ShowQuestion(text2, EMessageBoxButtons.YesNo) == EDialogResult.Yes) { EditorAPI.BeginRestartApplication(); } } }
public virtual bool Creation(NewObjectCell.ObjectCreationContext context) { if (Window.IsFileCreation() && CreateCSharpClass) { context.disableFileCreation = true; GetCreateCSharpClassInfo(out var csharpRealFileName, out var csharpClassName, out var csharpClassNameWithoutNamespace); try { //main file { string className = csharpClassName; //string className = CreateCSharpClass ? csharpClassName : Window.SelectedType.Name; var text = ".component " + className + "\r\n{\r\n}"; File.WriteAllText(context.fileCreationRealFileName, text); } //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); }