Compare commits
2 Commits
e698f18ad9
...
9908fd097c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9908fd097c | ||
|
|
07c27e0c48 |
@@ -35,6 +35,15 @@
|
|||||||
Background="#3E3E42" Foreground="White" RowBackground="#3E3E42"
|
Background="#3E3E42" Foreground="White" RowBackground="#3E3E42"
|
||||||
AlternatingRowBackground="#333337" GridLinesVisibility="None"
|
AlternatingRowBackground="#333337" GridLinesVisibility="None"
|
||||||
HeadersVisibility="Column" BorderBrush="#555">
|
HeadersVisibility="Column" BorderBrush="#555">
|
||||||
|
<DataGrid.ColumnHeaderStyle>
|
||||||
|
<Style TargetType="DataGridColumnHeader">
|
||||||
|
<Setter Property="Background" Value="#2D2D30" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
<Setter Property="Padding" Value="6 4" />
|
||||||
|
<Setter Property="BorderBrush" Value="#555" />
|
||||||
|
<Setter Property="BorderThickness" Value="0 0 1 1" />
|
||||||
|
</Style>
|
||||||
|
</DataGrid.ColumnHeaderStyle>
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*">
|
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*">
|
||||||
<DataGridTextColumn.ElementStyle>
|
<DataGridTextColumn.ElementStyle>
|
||||||
@@ -49,33 +58,22 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</DataGridTextColumn.EditingElementStyle>
|
</DataGridTextColumn.EditingElementStyle>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridComboBoxColumn Header="Type" SelectedItemBinding="{Binding Type}" Width="120">
|
<DataGridTemplateColumn Header="Type" Width="180">
|
||||||
<DataGridComboBoxColumn.ElementStyle>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<Style TargetType="ComboBox">
|
<DataTemplate>
|
||||||
<Setter Property="Foreground" Value="White" />
|
<TextBlock Text="{Binding Type}" Foreground="White" Padding="4 2" />
|
||||||
<Setter Property="Background" Value="#3E3E42" />
|
</DataTemplate>
|
||||||
</Style>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridComboBoxColumn.ElementStyle>
|
<DataGridTemplateColumn.CellEditingTemplate>
|
||||||
<DataGridComboBoxColumn.EditingElementStyle>
|
<DataTemplate>
|
||||||
<Style TargetType="ComboBox">
|
<ComboBox ItemsSource="{Binding AvailableTypes, RelativeSource={RelativeSource AncestorType=Window}}"
|
||||||
<Setter Property="Foreground" Value="Black" />
|
SelectedItem="{Binding Type, UpdateSourceTrigger=PropertyChanged}"
|
||||||
<Setter Property="Background" Value="White" />
|
IsEditable="True"
|
||||||
</Style>
|
Text="{Binding Type, UpdateSourceTrigger=LostFocus}"
|
||||||
</DataGridComboBoxColumn.EditingElementStyle>
|
Foreground="Black" Background="White" />
|
||||||
<DataGridComboBoxColumn.ItemsSource>
|
</DataTemplate>
|
||||||
<x:Array Type="sys:String" xmlns:sys="clr-namespace:System;assembly=System.Runtime">
|
</DataGridTemplateColumn.CellEditingTemplate>
|
||||||
<sys:String>string</sys:String>
|
</DataGridTemplateColumn>
|
||||||
<sys:String>int</sys:String>
|
|
||||||
<sys:String>double</sys:String>
|
|
||||||
<sys:String>bool</sys:String>
|
|
||||||
<sys:String>float</sys:String>
|
|
||||||
<sys:String>decimal</sys:String>
|
|
||||||
<sys:String>long</sys:String>
|
|
||||||
<sys:String>DateTime</sys:String>
|
|
||||||
<sys:String>object</sys:String>
|
|
||||||
</x:Array>
|
|
||||||
</DataGridComboBoxColumn.ItemsSource>
|
|
||||||
</DataGridComboBoxColumn>
|
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
@@ -90,6 +88,15 @@
|
|||||||
Background="#3E3E42" Foreground="White" RowBackground="#3E3E42"
|
Background="#3E3E42" Foreground="White" RowBackground="#3E3E42"
|
||||||
AlternatingRowBackground="#333337" GridLinesVisibility="None"
|
AlternatingRowBackground="#333337" GridLinesVisibility="None"
|
||||||
HeadersVisibility="Column" BorderBrush="#555">
|
HeadersVisibility="Column" BorderBrush="#555">
|
||||||
|
<DataGrid.ColumnHeaderStyle>
|
||||||
|
<Style TargetType="DataGridColumnHeader">
|
||||||
|
<Setter Property="Background" Value="#2D2D30" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
<Setter Property="Padding" Value="6 4" />
|
||||||
|
<Setter Property="BorderBrush" Value="#555" />
|
||||||
|
<Setter Property="BorderThickness" Value="0 0 1 1" />
|
||||||
|
</Style>
|
||||||
|
</DataGrid.ColumnHeaderStyle>
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*">
|
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*">
|
||||||
<DataGridTextColumn.ElementStyle>
|
<DataGridTextColumn.ElementStyle>
|
||||||
@@ -104,33 +111,22 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</DataGridTextColumn.EditingElementStyle>
|
</DataGridTextColumn.EditingElementStyle>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridComboBoxColumn Header="Type" SelectedItemBinding="{Binding Type}" Width="120">
|
<DataGridTemplateColumn Header="Type" Width="180">
|
||||||
<DataGridComboBoxColumn.ElementStyle>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<Style TargetType="ComboBox">
|
<DataTemplate>
|
||||||
<Setter Property="Foreground" Value="White" />
|
<TextBlock Text="{Binding Type}" Foreground="White" Padding="4 2" />
|
||||||
<Setter Property="Background" Value="#3E3E42" />
|
</DataTemplate>
|
||||||
</Style>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridComboBoxColumn.ElementStyle>
|
<DataGridTemplateColumn.CellEditingTemplate>
|
||||||
<DataGridComboBoxColumn.EditingElementStyle>
|
<DataTemplate>
|
||||||
<Style TargetType="ComboBox">
|
<ComboBox ItemsSource="{Binding AvailableTypes, RelativeSource={RelativeSource AncestorType=Window}}"
|
||||||
<Setter Property="Foreground" Value="Black" />
|
SelectedItem="{Binding Type, UpdateSourceTrigger=PropertyChanged}"
|
||||||
<Setter Property="Background" Value="White" />
|
IsEditable="True"
|
||||||
</Style>
|
Text="{Binding Type, UpdateSourceTrigger=LostFocus}"
|
||||||
</DataGridComboBoxColumn.EditingElementStyle>
|
Foreground="Black" Background="White" />
|
||||||
<DataGridComboBoxColumn.ItemsSource>
|
</DataTemplate>
|
||||||
<x:Array Type="sys:String" xmlns:sys="clr-namespace:System;assembly=System.Runtime">
|
</DataGridTemplateColumn.CellEditingTemplate>
|
||||||
<sys:String>string</sys:String>
|
</DataGridTemplateColumn>
|
||||||
<sys:String>int</sys:String>
|
|
||||||
<sys:String>double</sys:String>
|
|
||||||
<sys:String>bool</sys:String>
|
|
||||||
<sys:String>float</sys:String>
|
|
||||||
<sys:String>decimal</sys:String>
|
|
||||||
<sys:String>long</sys:String>
|
|
||||||
<sys:String>DateTime</sys:String>
|
|
||||||
<sys:String>object</sys:String>
|
|
||||||
</x:Array>
|
|
||||||
</DataGridComboBoxColumn.ItemsSource>
|
|
||||||
</DataGridComboBoxColumn>
|
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Nodify.Calculator
|
namespace Nodify.Calculator
|
||||||
@@ -17,9 +19,12 @@ namespace Nodify.Calculator
|
|||||||
|
|
||||||
public string DialogTitle => IsEditMode ? "Edit Function" : "Create New Function";
|
public string DialogTitle => IsEditMode ? "Edit Function" : "Create New Function";
|
||||||
|
|
||||||
|
/// <summary>All available types for parameter dropdowns (system + custom models + List variants).</summary>
|
||||||
|
public List<string> AvailableTypes { get; } = new List<string>();
|
||||||
|
|
||||||
public CreateFunctionDialog()
|
public CreateFunctionDialog()
|
||||||
{
|
{
|
||||||
|
BuildAvailableTypes();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
InputParamsGrid.ItemsSource = _inputs;
|
InputParamsGrid.ItemsSource = _inputs;
|
||||||
OutputParamsGrid.ItemsSource = _outputs;
|
OutputParamsGrid.ItemsSource = _outputs;
|
||||||
@@ -38,6 +43,46 @@ namespace Nodify.Calculator
|
|||||||
_outputs.Add(new FunctionParameterInfo { Name = p.Name, Type = p.Type });
|
_outputs.Add(new FunctionParameterInfo { Name = p.Name, Type = p.Type });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BuildAvailableTypes()
|
||||||
|
{
|
||||||
|
// System / primitive types
|
||||||
|
var systemTypes = new[]
|
||||||
|
{
|
||||||
|
"string", "int", "double", "bool", "float",
|
||||||
|
"decimal", "long", "DateTime", "object"
|
||||||
|
};
|
||||||
|
|
||||||
|
AvailableTypes.AddRange(systemTypes);
|
||||||
|
|
||||||
|
// List<> wrappers for system types
|
||||||
|
foreach (var t in systemTypes)
|
||||||
|
AvailableTypes.Add($"List<{t}>");
|
||||||
|
|
||||||
|
// Custom model types from the project's CustomModels folder
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var customModelDir = Path.Combine(ProjectManager.ProjectDirectory, "CustomModels");
|
||||||
|
if (Directory.Exists(customModelDir))
|
||||||
|
{
|
||||||
|
var modelNames = Directory.GetFiles(customModelDir, "*.cs")
|
||||||
|
.Select(f => Path.GetFileNameWithoutExtension(f))
|
||||||
|
.Where(n => !string.IsNullOrEmpty(n))
|
||||||
|
.OrderBy(n => n)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var model in modelNames)
|
||||||
|
{
|
||||||
|
AvailableTypes.Add(model);
|
||||||
|
AvailableTypes.Add($"List<{model}>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// If project directory is not set yet, just use system types
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void AddInput_Click(object sender, RoutedEventArgs e)
|
private void AddInput_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_inputs.Add(new FunctionParameterInfo { Name = $"param{_inputs.Count + 1}", Type = "string" });
|
_inputs.Add(new FunctionParameterInfo { Name = $"param{_inputs.Count + 1}", Type = "string" });
|
||||||
|
|||||||
@@ -33,9 +33,42 @@
|
|||||||
Background="#3E3E42" Foreground="White" RowBackground="#3E3E42"
|
Background="#3E3E42" Foreground="White" RowBackground="#3E3E42"
|
||||||
AlternatingRowBackground="#333337" GridLinesVisibility="None"
|
AlternatingRowBackground="#333337" GridLinesVisibility="None"
|
||||||
HeadersVisibility="Column" BorderBrush="#555">
|
HeadersVisibility="Column" BorderBrush="#555">
|
||||||
|
<DataGrid.ColumnHeaderStyle>
|
||||||
|
<Style TargetType="DataGridColumnHeader">
|
||||||
|
<Setter Property="Background" Value="#2D2D30" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
<Setter Property="Padding" Value="6 4" />
|
||||||
|
<Setter Property="BorderBrush" Value="#555" />
|
||||||
|
<Setter Property="BorderThickness" Value="0 0 1 1" />
|
||||||
|
</Style>
|
||||||
|
</DataGrid.ColumnHeaderStyle>
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*" />
|
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
<DataGridTextColumn.EditingElementStyle>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="Foreground" Value="Black" />
|
||||||
|
<Setter Property="Background" Value="White" />
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.EditingElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
<DataGridComboBoxColumn Header="Type" SelectedItemBinding="{Binding Type}" Width="120">
|
<DataGridComboBoxColumn Header="Type" SelectedItemBinding="{Binding Type}" Width="120">
|
||||||
|
<DataGridComboBoxColumn.ElementStyle>
|
||||||
|
<Style TargetType="ComboBox">
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
<Setter Property="Background" Value="#3E3E42" />
|
||||||
|
</Style>
|
||||||
|
</DataGridComboBoxColumn.ElementStyle>
|
||||||
|
<DataGridComboBoxColumn.EditingElementStyle>
|
||||||
|
<Style TargetType="ComboBox">
|
||||||
|
<Setter Property="Foreground" Value="Black" />
|
||||||
|
<Setter Property="Background" Value="White" />
|
||||||
|
</Style>
|
||||||
|
</DataGridComboBoxColumn.EditingElementStyle>
|
||||||
<DataGridComboBoxColumn.ItemsSource>
|
<DataGridComboBoxColumn.ItemsSource>
|
||||||
<x:Array Type="sys:String" xmlns:sys="clr-namespace:System;assembly=System.Runtime">
|
<x:Array Type="sys:String" xmlns:sys="clr-namespace:System;assembly=System.Runtime">
|
||||||
<sys:String>string</sys:String>
|
<sys:String>string</sys:String>
|
||||||
|
|||||||
@@ -71,30 +71,40 @@ namespace Nodify.Calculator
|
|||||||
// Add data output connectors to InnerBegin (these feed the inner flow with input values)
|
// Add data output connectors to InnerBegin (these feed the inner flow with input values)
|
||||||
foreach (var inp in inputs)
|
foreach (var inp in inputs)
|
||||||
{
|
{
|
||||||
|
var shape = GetShapeForType(inp.Type);
|
||||||
|
var color = ConnectorViewModel.GetColorForType(inp.Type);
|
||||||
|
|
||||||
InnerBegin.Output.Add(new ConnectorViewModel
|
InnerBegin.Output.Add(new ConnectorViewModel
|
||||||
{
|
{
|
||||||
Title = $"{inp.Name} ({inp.Type})",
|
Title = $"{inp.Name} ({inp.Type})",
|
||||||
Shape = ConnectorShape.Circle,
|
Shape = shape,
|
||||||
IsInput = false,
|
IsInput = false,
|
||||||
ConnectorColor = System.Drawing.Color.Gold
|
ConnectorColor = color,
|
||||||
|
DataType = inp.Type
|
||||||
});
|
});
|
||||||
|
|
||||||
// Also add an outer input connector on the function node
|
// Also add an outer input connector on the function node
|
||||||
Input.Add(new ConnectorViewModel
|
Input.Add(new ConnectorViewModel
|
||||||
{
|
{
|
||||||
Title = $"{inp.Name} ({inp.Type})",
|
Title = $"{inp.Name} ({inp.Type})",
|
||||||
ConnectorColor = System.Drawing.Color.Gold
|
Shape = shape,
|
||||||
|
ConnectorColor = color,
|
||||||
|
DataType = inp.Type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add data input connectors to InnerEnd (these collect inner flow results)
|
// Add data input connectors to InnerEnd (these collect inner flow results)
|
||||||
foreach (var outp in outputs)
|
foreach (var outp in outputs)
|
||||||
{
|
{
|
||||||
|
var shape = GetShapeForType(outp.Type);
|
||||||
|
var color = ConnectorViewModel.GetColorForType(outp.Type);
|
||||||
|
|
||||||
InnerEnd.Input.Add(new ConnectorViewModel
|
InnerEnd.Input.Add(new ConnectorViewModel
|
||||||
{
|
{
|
||||||
Title = $"{outp.Name} ({outp.Type})",
|
Title = $"{outp.Name} ({outp.Type})",
|
||||||
Shape = ConnectorShape.Circle,
|
Shape = shape,
|
||||||
ConnectorColor = System.Drawing.Color.Gold
|
ConnectorColor = color,
|
||||||
|
DataType = outp.Type
|
||||||
});
|
});
|
||||||
|
|
||||||
// Also add an outer output connector on the function node
|
// Also add an outer output connector on the function node
|
||||||
@@ -102,11 +112,29 @@ namespace Nodify.Calculator
|
|||||||
{
|
{
|
||||||
Title = $"{outp.Name} ({outp.Type})",
|
Title = $"{outp.Name} ({outp.Type})",
|
||||||
IsInput = false,
|
IsInput = false,
|
||||||
ConnectorColor = System.Drawing.Color.Gold
|
Shape = shape,
|
||||||
|
ConnectorColor = color,
|
||||||
|
DataType = outp.Type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the appropriate connector shape based on the type name.
|
||||||
|
/// List/array types use Grid, custom model types use Square, primitives use Circle.
|
||||||
|
/// </summary>
|
||||||
|
private static ConnectorShape GetShapeForType(string typeName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(typeName)) return ConnectorShape.Circle;
|
||||||
|
if (typeName.StartsWith("List<") && typeName.EndsWith(">"))
|
||||||
|
return ConnectorShape.Grid;
|
||||||
|
var primitives = new[] { "string", "int", "double", "bool", "float", "decimal", "long", "datetime", "object" };
|
||||||
|
if (primitives.Contains(typeName.ToLower()))
|
||||||
|
return ConnectorShape.Circle;
|
||||||
|
// Assume it's a custom model type
|
||||||
|
return ConnectorShape.Square;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnInputValueChanged()
|
protected override void OnInputValueChanged()
|
||||||
{
|
{
|
||||||
PropagateInputsToInner();
|
PropagateInputsToInner();
|
||||||
|
|||||||
Reference in New Issue
Block a user