// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using System; namespace FlaxEditor.Modules.SourceCodeEditing { /// /// In-build source code editor. /// /// internal class InBuildSourceCodeEditor : ISourceCodeEditor { /// /// The type of the editor. /// public readonly CodeEditorTypes Type; /// /// Initializes a new instance of the class. /// /// The type. public InBuildSourceCodeEditor(CodeEditorTypes type) { Type = type; switch (type) { case CodeEditorTypes.Custom: Name = "Custom"; break; case CodeEditorTypes.SystemDefault: Name = "System Default"; break; case CodeEditorTypes.VS2008: Name = "Visual Studio 2008"; break; case CodeEditorTypes.VS2010: Name = "Visual Studio 2010"; break; case CodeEditorTypes.VS2012: Name = "Visual Studio 2012"; break; case CodeEditorTypes.VS2013: Name = "Visual Studio 2013"; break; case CodeEditorTypes.VS2015: Name = "Visual Studio 2015"; break; case CodeEditorTypes.VS2017: Name = "Visual Studio 2017"; break; case CodeEditorTypes.VS2019: Name = "Visual Studio 2019"; break; case CodeEditorTypes.VS2022: Name = "Visual Studio 2022"; break; case CodeEditorTypes.VSCode: Name = "Visual Studio Code"; break; case CodeEditorTypes.VSCodeInsiders: Name = "Visual Studio Code - Insiders"; break; case CodeEditorTypes.Rider: Name = "Rider"; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } } /// public string Name { get; set; } /// public string GenerateProjectCustomArgs { get { switch (Type) { case CodeEditorTypes.VSCodeInsiders: case CodeEditorTypes.VSCode: return "-vscode -vs2019"; case CodeEditorTypes.Rider: return "-vs2019"; default: return null; } } } /// public void OpenSolution() { CodeEditingManager.OpenSolution(Type); } /// public void OpenFile(string path, int line) { CodeEditingManager.OpenFile(Type, path, line); } /// public void OnFileAdded(string path) { switch (Type) { case CodeEditorTypes.VS2008: case CodeEditorTypes.VS2010: case CodeEditorTypes.VS2012: case CodeEditorTypes.VS2013: case CodeEditorTypes.VS2015: case CodeEditorTypes.VS2017: case CodeEditorTypes.VS2019: case CodeEditorTypes.VS2022: // TODO: finish dynamic files adding to the project //Editor.Instance.ProgressReporting.GenerateScriptsProjectFiles.RunAsync(); break; default: CodeEditingManager.OnFileAdded(Type, path); break; } } /// public void OnSelected(Editor editor) { } /// public void OnDeselected(Editor editor) { } /// public void OnAdded(Editor editor) { } /// public void OnRemoved(Editor editor) { } } }