Added different startup screen and ability to open and save project into files
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:nodify="https://miroiu.github.io/nodify"
|
||||
StartupUri="MainWindow.xaml">
|
||||
StartupUri="StartupWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
@@ -6,17 +6,16 @@ using System.Linq.Expressions;
|
||||
|
||||
public class LiteDbHelper<T> : IDisposable where T : class
|
||||
{
|
||||
private string dbPath = @"MyData.db";
|
||||
private readonly LiteDatabase _database;
|
||||
private readonly ILiteCollection<T> _collection;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the LiteDbHelper class.
|
||||
/// </summary>
|
||||
/// <param name="databasePath">The path to the LiteDB database file.</param>
|
||||
/// <param name="collectionName">The name of the collection to work with.</param>
|
||||
public LiteDbHelper(string collectionName)
|
||||
{
|
||||
var dbPath = Nodify.Calculator.ProjectManager.DatabasePath;
|
||||
_database = new LiteDatabase(dbPath);
|
||||
_collection = _database.GetCollection<T>(collectionName);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
</shared:TabControlEx>
|
||||
|
||||
<Expander Header="Click to hide/show"
|
||||
IsExpanded="True"
|
||||
IsExpanded="False"
|
||||
Margin="10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Bottom">
|
||||
|
||||
48
Examples/Nodify.Calculator/NewProjectDialog.xaml
Normal file
48
Examples/Nodify.Calculator/NewProjectDialog.xaml
Normal 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>
|
||||
56
Examples/Nodify.Calculator/NewProjectDialog.xaml.cs
Normal file
56
Examples/Nodify.Calculator/NewProjectDialog.xaml.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFrameworks>net9-windows;</TargetFrameworks>
|
||||
<UseWPF>true</UseWPF>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Nodify.Calculator
|
||||
}
|
||||
|
||||
operations.AddRange(OperationFactory.GetSystemNodes());
|
||||
operations.AddRange(OperationFactory.GetOperationsInfo(typeof(OperationsContainer)));
|
||||
//operations.AddRange(OperationFactory.GetOperationsInfo(typeof(OperationsContainer)));
|
||||
|
||||
SwaggerOperations = new NodifyObservableCollection<OperationInfoViewModel>();
|
||||
LoadSwaggerNodesFromDb();
|
||||
|
||||
36
Examples/Nodify.Calculator/ProjectManager.cs
Normal file
36
Examples/Nodify.Calculator/ProjectManager.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Examples/Nodify.Calculator/StartupWindow.xaml
Normal file
39
Examples/Nodify.Calculator/StartupWindow.xaml
Normal 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>
|
||||
50
Examples/Nodify.Calculator/StartupWindow.xaml.cs
Normal file
50
Examples/Nodify.Calculator/StartupWindow.xaml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user