Changed connection string format in ProjectRepository.cs and updated application data path retrieval. Added project reference to Ghost.Engine in Ghost.Database.csproj. Added new property Packages in TemplateInfo.cs. Changed XamlControlsResources source in App.xaml for clarity. Changed App.xaml.cs to include new Host property and updated OnLaunched method. Removed unused image files related to branding. Updated Ghost.Editor.csproj to change target framework and organize content files. Changed display name in Package.appxmanifest from "Ghost.Editor" to "GhostEngine". Enhanced UI layout and data binding in CreateProjectPage.xaml and its code-behind. Changed LandingWindow to use WindowEx for improved functionality. Updated CreateProjectViewModel to implement INavigationAware for better navigation handling. Updated AssemblyInfo.cs for internal visibility to Ghost.Database. Added new files for activation handling and game object management in Ghost.Core and Ghost.Engine. Introduced SystemUtilities for folder picker dialog functionality. Created PropertyField control with corresponding XAML for UI consistency. Added TemplateInfoWarper for managing template information. Introduced HostHelper class to set up application services. Overall, these changes reflect a significant restructuring of the project, enhancing architecture, improving UI components, and establishing clearer separation of concerns.
64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using Ghost.Database.Models.Projects;
|
|
using Ghost.Engine.Constants;
|
|
using System.Data.SQLite;
|
|
|
|
namespace Ghost.Database.DataContext;
|
|
|
|
public class ProjectRepository
|
|
{
|
|
private const string _CONNECTION_STRING = "Data Source={0}\\projects.db;Version=3;";
|
|
private const string _CREATE_PROJECT_TABLE_STRING = "CREATE TABLE IF NOT EXISTS Projects (ID INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Path TEXT, EngineVersion TEXT, LastOpened DATETIME);";
|
|
private const string _SELECT_PROJECT_STRING = "SELECT * FROM Projects";
|
|
private const string _INSERT_PROJECT_STRING = "INSERT INTO Projects (Name, Path, EngineVersion, LastOpened) VALUES (@Name, @Path, @EngineVersion, @LastOpened);";
|
|
|
|
private static string GetConnectionString() => string.Format(_CONNECTION_STRING, EngineDataPath.ApplicationDataFolder);
|
|
|
|
private static void EnsureTableCreated(SQLiteConnection connection)
|
|
{
|
|
using var createCommand = connection.CreateCommand();
|
|
createCommand.CommandText = _CREATE_PROJECT_TABLE_STRING;
|
|
createCommand.ExecuteNonQuery();
|
|
}
|
|
|
|
public static IEnumerable<ProjectInfo> LoadProjects()
|
|
{
|
|
using var connection = new SQLiteConnection(GetConnectionString());
|
|
connection.Open();
|
|
|
|
EnsureTableCreated(connection);
|
|
|
|
using var command = connection.CreateCommand();
|
|
command.CommandText = _SELECT_PROJECT_STRING;
|
|
|
|
using var reader = command.ExecuteReader();
|
|
while (reader.Read())
|
|
{
|
|
var project = new ProjectInfo
|
|
{
|
|
Name = reader.GetString(0),
|
|
Path = reader.GetString(1),
|
|
EngineVersion = new Version(reader.GetString(2)),
|
|
LastOpened = reader.GetDateTime(3)
|
|
};
|
|
|
|
yield return project;
|
|
}
|
|
}
|
|
|
|
public static void AddProject(ProjectInfo project)
|
|
{
|
|
using var connection = new SQLiteConnection(GetConnectionString());
|
|
connection.Open();
|
|
|
|
EnsureTableCreated(connection);
|
|
|
|
using var command = connection.CreateCommand();
|
|
command.CommandText = _INSERT_PROJECT_STRING;
|
|
|
|
command.Parameters.AddWithValue("@Name", project.Name);
|
|
command.Parameters.AddWithValue("@Path", project.Path);
|
|
command.Parameters.AddWithValue("@EngineVersion", project.EngineVersion.ToString());
|
|
command.Parameters.AddWithValue("@LastOpened", project.LastOpened);
|
|
command.ExecuteNonQuery();
|
|
}
|
|
} |