diff --git a/src/Core/Furesoft.LowCode.Desktop/Furesoft.LowCode.Desktop.csproj b/src/Core/Furesoft.LowCode.Desktop/Furesoft.LowCode.Desktop.csproj index f666533..69ef164 100644 --- a/src/Core/Furesoft.LowCode.Desktop/Furesoft.LowCode.Desktop.csproj +++ b/src/Core/Furesoft.LowCode.Desktop/Furesoft.LowCode.Desktop.csproj @@ -40,10 +40,4 @@ - - - Always - - - diff --git a/src/Core/Furesoft.LowCode/Designer/ViewModels/MainViewViewModel.cs b/src/Core/Furesoft.LowCode/Designer/ViewModels/MainViewViewModel.cs index 27a941d..fbe757e 100644 --- a/src/Core/Furesoft.LowCode/Designer/ViewModels/MainViewViewModel.cs +++ b/src/Core/Furesoft.LowCode/Designer/ViewModels/MainViewViewModel.cs @@ -1,4 +1,5 @@ -using Avalonia.Controls.ApplicationLifetimes; +using System.Reflection; +using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Platform.Storage; using Avalonia.PropertyGrid.Services; using CommunityToolkit.Mvvm.Input; @@ -43,7 +44,7 @@ public MainViewViewModel() root.Navigate.Execute("Home"); } - OpenedProject = new Project();//Project.Load("test.zip"); + OpenedProject = Project.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("Furesoft.LowCode.test.zip")); OpenDocument(OpenedProject.Items[1]); SetInitialSelectedDocument(); @@ -343,7 +344,7 @@ private async Task Open() { await using var stream = await file.OpenReadAsync(); - OpenedProject = Project.Load(file.Path.ToString()); + OpenedProject = Project.Load(stream); } } diff --git a/src/Core/Furesoft.LowCode/Furesoft.LowCode.csproj b/src/Core/Furesoft.LowCode/Furesoft.LowCode.csproj index 00a1afc..858e39d 100644 --- a/src/Core/Furesoft.LowCode/Furesoft.LowCode.csproj +++ b/src/Core/Furesoft.LowCode/Furesoft.LowCode.csproj @@ -101,4 +101,12 @@ + + + + + Always + + + diff --git a/src/Core/Furesoft.LowCode/ProjectSystem/Project.cs b/src/Core/Furesoft.LowCode/ProjectSystem/Project.cs index af4ef60..98b3a6f 100644 --- a/src/Core/Furesoft.LowCode/ProjectSystem/Project.cs +++ b/src/Core/Furesoft.LowCode/ProjectSystem/Project.cs @@ -22,14 +22,32 @@ public Project() [JsonIgnore] public string Path { get; set; } - public static Project Load(string path) + public static Project Create() { - using var zip = ZipFile.OpenRead(path); + var project = new Project(); + + project.Name = "New Project"; + project.Version = "1.0.0.0"; + project.MainGraph = "Main Graph"; + + var factory = new DrawingNodeFactory(); + //var drawing = factory. + /* project.Items = new ObservableCollection() + { + new GraphItem("Main Graph", drawing, new GraphProps()) + }; +*/ + return project; + } + + public static Project Load(Stream path) + { + using var zip = new ZipArchive(path); using var jsonStream = zip.GetEntry("meta.json")!.Open(); var optionsEntry = zip.GetEntry("options.json"); var proj = JsonConvert.DeserializeObject(new StreamReader(jsonStream).ReadToEnd()); - proj.Path = path; + // proj.Path = path; if (optionsEntry != null) { diff --git a/src/Core/Furesoft.LowCode.Desktop/test.zip b/src/Core/Furesoft.LowCode/test.zip similarity index 100% rename from src/Core/Furesoft.LowCode.Desktop/test.zip rename to src/Core/Furesoft.LowCode/test.zip