Added different startup screen and ability to open and save project into files

This commit is contained in:
Ankitkumar Satapara
2026-04-18 18:42:52 +05:30
parent 5c838908eb
commit 161370e4ce
10 changed files with 234 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:nodify="https://miroiu.github.io/nodify" xmlns:nodify="https://miroiu.github.io/nodify"
StartupUri="MainWindow.xaml"> StartupUri="StartupWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>

View File

@@ -6,17 +6,16 @@ using System.Linq.Expressions;
public class LiteDbHelper<T> : IDisposable where T : class public class LiteDbHelper<T> : IDisposable where T : class
{ {
private string dbPath = @"MyData.db";
private readonly LiteDatabase _database; private readonly LiteDatabase _database;
private readonly ILiteCollection<T> _collection; private readonly ILiteCollection<T> _collection;
/// <summary> /// <summary>
/// Initializes a new instance of the LiteDbHelper class. /// Initializes a new instance of the LiteDbHelper class.
/// </summary> /// </summary>
/// <param name="databasePath">The path to the LiteDB database file.</param>
/// <param name="collectionName">The name of the collection to work with.</param> /// <param name="collectionName">The name of the collection to work with.</param>
public LiteDbHelper(string collectionName) public LiteDbHelper(string collectionName)
{ {
var dbPath = Nodify.Calculator.ProjectManager.DatabasePath;
_database = new LiteDatabase(dbPath); _database = new LiteDatabase(dbPath);
_collection = _database.GetCollection<T>(collectionName); _collection = _database.GetCollection<T>(collectionName);
} }

View File

@@ -71,7 +71,7 @@
</shared:TabControlEx> </shared:TabControlEx>
<Expander Header="Click to hide/show" <Expander Header="Click to hide/show"
IsExpanded="True" IsExpanded="False"
Margin="10" Margin="10"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">

View File

@@ -0,0 +1,48 @@
<Window x:Class="Nodify.Calculator.NewProjectDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="New Project"
Width="450"
Height="250"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Background="#2D2D30"
Foreground="White">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="Project Name:" Grid.Row="0" Margin="0 0 0 4" />
<TextBox x:Name="ProjectNameBox" Grid.Row="1" Margin="0 0 0 14"
Background="#3E3E42" Foreground="White" Padding="6" FontSize="14" />
<TextBlock Text="Location:" Grid.Row="2" Margin="0 0 0 4" />
<Grid Grid.Row="3" Margin="0 0 0 14">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox x:Name="LocationBox" Grid.Column="0"
Background="#3E3E42" Foreground="White" Padding="6" FontSize="14"
IsReadOnly="True" />
<Button Content="Browse..." Grid.Column="1" Margin="8 0 0 0"
Padding="12 4" Click="Browse_Click"
Background="#3E3E42" Foreground="White" Cursor="Hand" />
</Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="5">
<Button Content="Create" Width="90" Margin="0 0 10 0" Padding="6"
Click="Create_Click" IsDefault="True"
Background="#6366f1" Foreground="White" Cursor="Hand" />
<Button Content="Cancel" Width="90" Padding="6"
Click="Cancel_Click" IsCancel="True"
Background="#3E3E42" Foreground="White" Cursor="Hand" />
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,56 @@
using System.IO;
using System.Windows;
using System.Windows.Forms;
using MessageBox = System.Windows.MessageBox;
namespace Nodify.Calculator
{
public partial class NewProjectDialog : Window
{
public string ProjectName { get; private set; } = string.Empty;
public string ProjectDirectory { get; private set; } = string.Empty;
public NewProjectDialog()
{
InitializeComponent();
}
private void Browse_Click(object sender, RoutedEventArgs e)
{
using var dialog = new FolderBrowserDialog
{
Description = "Select project location",
UseDescriptionForTitle = true
};
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
LocationBox.Text = dialog.SelectedPath;
}
}
private void Create_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrWhiteSpace(ProjectNameBox.Text))
{
MessageBox.Show("Please enter a project name.", "Validation", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (string.IsNullOrWhiteSpace(LocationBox.Text))
{
MessageBox.Show("Please select a project location.", "Validation", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
ProjectName = ProjectNameBox.Text.Trim();
ProjectDirectory = Path.Combine(LocationBox.Text, ProjectName);
DialogResult = true;
}
private void Cancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
}
}
}

View File

@@ -4,6 +4,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFrameworks>net9-windows;</TargetFrameworks> <TargetFrameworks>net9-windows;</TargetFrameworks>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -148,7 +148,7 @@ namespace Nodify.Calculator
} }
operations.AddRange(OperationFactory.GetSystemNodes()); operations.AddRange(OperationFactory.GetSystemNodes());
operations.AddRange(OperationFactory.GetOperationsInfo(typeof(OperationsContainer))); //operations.AddRange(OperationFactory.GetOperationsInfo(typeof(OperationsContainer)));
SwaggerOperations = new NodifyObservableCollection<OperationInfoViewModel>(); SwaggerOperations = new NodifyObservableCollection<OperationInfoViewModel>();
LoadSwaggerNodesFromDb(); LoadSwaggerNodesFromDb();

View File

@@ -0,0 +1,36 @@
using System.IO;
namespace Nodify.Calculator
{
public static class ProjectManager
{
public const string ProjectExtension = ".avep";
public const string ProjectFilter = "API Visual Executor Project (*.avep)|*.avep";
public static string ProjectName { get; private set; } = string.Empty;
public static string ProjectDirectory { get; private set; } = string.Empty;
public static string ProjectFilePath { get; private set; } = string.Empty;
public static string DatabasePath { get; private set; } = "MyData.db";
public static void CreateProject(string name, string directory)
{
ProjectName = name;
ProjectDirectory = directory;
ProjectFilePath = Path.Combine(directory, name + ProjectExtension);
DatabasePath = Path.Combine(directory, name + ".db");
Directory.CreateDirectory(directory);
// Write a simple project file
File.WriteAllText(ProjectFilePath, $"{{\"name\":\"{name}\"}}");
}
public static void OpenProject(string projectFilePath)
{
ProjectFilePath = projectFilePath;
ProjectDirectory = Path.GetDirectoryName(projectFilePath)!;
ProjectName = Path.GetFileNameWithoutExtension(projectFilePath);
DatabasePath = Path.Combine(ProjectDirectory, ProjectName + ".db");
}
}
}

View File

@@ -0,0 +1,39 @@
<Window x:Class="Nodify.Calculator.StartupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="API Visual Executor"
Width="500"
Height="380"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize"
Background="#1E1E1E"
Foreground="White">
<Grid>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Width="360">
<TextBlock Text="API Visual Executor"
FontSize="26" FontWeight="Bold"
Foreground="#6366f1"
HorizontalAlignment="Center"
Margin="0 0 0 8" />
<TextBlock Text="Create or open a project to get started"
FontSize="13" Foreground="Gray"
HorizontalAlignment="Center"
Margin="0 0 0 30" />
<Button Content=" New Project"
Height="48" FontSize="16"
Margin="0 0 0 14"
Background="#6366f1" Foreground="White"
BorderThickness="0" Cursor="Hand"
Click="NewProject_Click" />
<Button Content="📂 Open Project"
Height="48" FontSize="16"
Margin="0 0 0 14"
Background="#3E3E42" Foreground="White"
BorderThickness="1" BorderBrush="#555"
Cursor="Hand"
Click="OpenProject_Click" />
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,50 @@
using Microsoft.Win32;
using System.IO;
using System.Windows;
namespace Nodify.Calculator
{
public partial class StartupWindow : Window
{
public StartupWindow()
{
InitializeComponent();
}
private void NewProject_Click(object sender, RoutedEventArgs e)
{
var dialog = new NewProjectDialog();
dialog.Owner = this;
if (dialog.ShowDialog() != true)
return;
ProjectManager.CreateProject(dialog.ProjectName, dialog.ProjectDirectory);
OpenMainWindow();
}
private void OpenProject_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog
{
Title = "Open Project",
Filter = ProjectManager.ProjectFilter,
DefaultExt = ProjectManager.ProjectExtension
};
if (ofd.ShowDialog() != true)
return;
ProjectManager.OpenProject(ofd.FileName);
OpenMainWindow();
}
private void OpenMainWindow()
{
var mainWindow = new MainWindow();
mainWindow.Title = $"API Visual Executor — {ProjectManager.ProjectName}";
Application.Current.MainWindow = mainWindow;
mainWindow.Show();
Close();
}
}
}