netpoet coop and 64kode

This commit is contained in:
2026-04-19 00:41:25 +02:00
parent 8d0ab5b7cc
commit 227ea3bf05
367 changed files with 364128 additions and 0 deletions

86
64kode/64kode.sln Normal file
View File

@@ -0,0 +1,86 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "intro", "src\intro\intro.vcxproj", "{3156012A-9165-4DAC-B53B-FEA6EC9A1D32}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NodeSystem", "src\NodeSystem\NodeSystem.vcxproj", "{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "src\Core\Core.vcxproj", "{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Math", "src\Math\Math.vcxproj", "{618E98D1-BDE7-49A2-8CDD-FB2E660CD590}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tool", "src\Tool\Tool.csproj", "{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{E142202B-520D-432C-B26F-F79F910EB90F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Executables", "Executables", "{C0D563AE-148C-489F-8462-83282F7D00BB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToolBridge", "src\ToolBridge\ToolBridge.vcxproj", "{4AC87545-9F48-48A7-A84A-95C84BA97921}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "helloworld", "src\helloworld\helloworld.vcxproj", "{DFADD377-3C32-4920-98A8-79696F83382C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Authoring|x86 = Authoring|x86
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3156012A-9165-4DAC-B53B-FEA6EC9A1D32}.Authoring|x86.ActiveCfg = Authoring|Win32
{3156012A-9165-4DAC-B53B-FEA6EC9A1D32}.Authoring|x86.Build.0 = Authoring|Win32
{3156012A-9165-4DAC-B53B-FEA6EC9A1D32}.Debug|x86.ActiveCfg = Debug|Win32
{3156012A-9165-4DAC-B53B-FEA6EC9A1D32}.Debug|x86.Build.0 = Debug|Win32
{3156012A-9165-4DAC-B53B-FEA6EC9A1D32}.Release|x86.ActiveCfg = Release|Win32
{3156012A-9165-4DAC-B53B-FEA6EC9A1D32}.Release|x86.Build.0 = Release|Win32
{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA}.Authoring|x86.ActiveCfg = Authoring|Win32
{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA}.Authoring|x86.Build.0 = Authoring|Win32
{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA}.Debug|x86.ActiveCfg = Debug|Win32
{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA}.Debug|x86.Build.0 = Debug|Win32
{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA}.Release|x86.ActiveCfg = Release|Win32
{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA}.Release|x86.Build.0 = Release|Win32
{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578}.Authoring|x86.ActiveCfg = Authoring|Win32
{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578}.Authoring|x86.Build.0 = Authoring|Win32
{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578}.Debug|x86.ActiveCfg = Debug|Win32
{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578}.Debug|x86.Build.0 = Debug|Win32
{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578}.Release|x86.ActiveCfg = Release|Win32
{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578}.Release|x86.Build.0 = Release|Win32
{618E98D1-BDE7-49A2-8CDD-FB2E660CD590}.Authoring|x86.ActiveCfg = Authoring|Win32
{618E98D1-BDE7-49A2-8CDD-FB2E660CD590}.Authoring|x86.Build.0 = Authoring|Win32
{618E98D1-BDE7-49A2-8CDD-FB2E660CD590}.Debug|x86.ActiveCfg = Debug|Win32
{618E98D1-BDE7-49A2-8CDD-FB2E660CD590}.Debug|x86.Build.0 = Debug|Win32
{618E98D1-BDE7-49A2-8CDD-FB2E660CD590}.Release|x86.ActiveCfg = Release|Win32
{618E98D1-BDE7-49A2-8CDD-FB2E660CD590}.Release|x86.Build.0 = Release|Win32
{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B}.Authoring|x86.ActiveCfg = Debug|x86
{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B}.Authoring|x86.Build.0 = Debug|x86
{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B}.Debug|x86.ActiveCfg = Debug|x86
{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B}.Debug|x86.Build.0 = Debug|x86
{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B}.Release|x86.ActiveCfg = Release|x86
{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B}.Release|x86.Build.0 = Release|x86
{4AC87545-9F48-48A7-A84A-95C84BA97921}.Authoring|x86.ActiveCfg = Authoring|Win32
{4AC87545-9F48-48A7-A84A-95C84BA97921}.Authoring|x86.Build.0 = Authoring|Win32
{4AC87545-9F48-48A7-A84A-95C84BA97921}.Debug|x86.ActiveCfg = Debug|Win32
{4AC87545-9F48-48A7-A84A-95C84BA97921}.Debug|x86.Build.0 = Debug|Win32
{4AC87545-9F48-48A7-A84A-95C84BA97921}.Release|x86.ActiveCfg = Release|Win32
{4AC87545-9F48-48A7-A84A-95C84BA97921}.Release|x86.Build.0 = Release|Win32
{DFADD377-3C32-4920-98A8-79696F83382C}.Authoring|x86.ActiveCfg = Authoring|Win32
{DFADD377-3C32-4920-98A8-79696F83382C}.Authoring|x86.Build.0 = Authoring|Win32
{DFADD377-3C32-4920-98A8-79696F83382C}.Debug|x86.ActiveCfg = Debug|Win32
{DFADD377-3C32-4920-98A8-79696F83382C}.Debug|x86.Build.0 = Debug|Win32
{DFADD377-3C32-4920-98A8-79696F83382C}.Release|x86.ActiveCfg = Release|Win32
{DFADD377-3C32-4920-98A8-79696F83382C}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3156012A-9165-4DAC-B53B-FEA6EC9A1D32} = {C0D563AE-148C-489F-8462-83282F7D00BB}
{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA} = {E142202B-520D-432C-B26F-F79F910EB90F}
{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578} = {E142202B-520D-432C-B26F-F79F910EB90F}
{618E98D1-BDE7-49A2-8CDD-FB2E660CD590} = {E142202B-520D-432C-B26F-F79F910EB90F}
{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B} = {C0D563AE-148C-489F-8462-83282F7D00BB}
{4AC87545-9F48-48A7-A84A-95C84BA97921} = {E142202B-520D-432C-B26F-F79F910EB90F}
{DFADD377-3C32-4920-98A8-79696F83382C} = {E142202B-520D-432C-B26F-F79F910EB90F}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,17 @@
#pragma once
namespace kode64
{
BEGIN_NODE(Core, Constant)
BEGIN_EXEC
Write(Value, Read(ConstValue));
END_EXEC
PIN_INPUT(ConstValue, 0);
PIN_OUTPUT(Value);
END_NODE
}

1
64kode/src/Core/Core.cpp Normal file
View File

@@ -0,0 +1 @@
#include "Core.h"

7
64kode/src/Core/Core.h Normal file
View File

@@ -0,0 +1,7 @@
#include <NodeSystem/NodeSystem.h>
#include "If.h"
#include "For.h"
#include "While.h"
#include "DoWhile.h"
#include "Variable.h"
#include "Constant.h"

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Authoring|Win32">
<Configuration>Authoring</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{8E06A4A1-40D6-4ACA-BAFB-2B3850CD3578}</ProjectGuid>
<RootNamespace>Core</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>false</CLRSupport>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CLRSupport>false</CLRSupport>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>AUTHORING;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<LanguageStandard>stdcpp17</LanguageStandard>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\NodeSystem\NodeSystem.vcxproj">
<Project>{3f0d4f6b-03be-4d66-a2ef-47ec5d961bca}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Constant.h" />
<ClInclude Include="Core.h" />
<ClInclude Include="DoWhile.h" />
<ClInclude Include="For.h" />
<ClInclude Include="If.h" />
<ClInclude Include="Variable.h" />
<ClInclude Include="While.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Core.cpp" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

18
64kode/src/Core/DoWhile.h Normal file
View File

@@ -0,0 +1,18 @@
#pragma once
namespace kode64
{
BEGIN_NODE(Core, DoWhile)
BEGIN_EXEC
do Run(Body);
while (Read(BoolExpr));
END_EXEC
PIN_EXEC(Body);
PIN_INPUT(BoolExpr, false);
END_NODE
}

19
64kode/src/Core/For.h Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
namespace kode64
{
BEGIN_NODE(Core, For)
BEGIN_EXEC
for (Run(Begin); Read(BoolExpr); Run(Increment)) Run(Body);
END_EXEC
PIN_EXEC(Begin);
PIN_INPUT(BoolExpr, false);
PIN_EXEC(Increment);
PIN_EXEC(Body);
END_NODE
}

25
64kode/src/Core/If.h Normal file
View File

@@ -0,0 +1,25 @@
#pragma once
namespace kode64
{
BEGIN_NODE(Core, If)
BEGIN_EXEC
if (Read<bool>(BoolExpr))
{
Run(True);
}
else
{
Run(False);
};
END_EXEC
PIN_EXEC(True);
PIN_EXEC(False);
PIN_INPUT(BoolExpr, false);
END_NODE
}

View File

@@ -0,0 +1,39 @@
#pragma once
namespace kode64
{
BEGIN_NODE(Core, Get)
BEGIN_EXEC
unsigned int iVariable = Read<unsigned int>(Variable);
unsigned int iFunction = Read<unsigned int>(Function);
auto function = Function::functions[iFunction];
auto value = function->variables[iVariable];
Write(Value, value);
END_EXEC
PIN_INPUT(Function, 4924967295u);
PIN_INPUT(Variable, 4924967295u);
PIN_OUTPUT(Value);
END_NODE
BEGIN_NODE(Core, Set)
BEGIN_EXEC
unsigned int iVariable = Read<unsigned int>(Variable);
unsigned int iFunction = Read<unsigned int>(Function);
auto function = Function::functions[iFunction];
auto value = Read(Value);
function->variables[iVariable] = value;
END_EXEC
PIN_INPUT(Function, 4924967295u);
PIN_INPUT(Variable, 4924967295u);
PIN_INPUT(Value, 0.0);
END_NODE
}

17
64kode/src/Core/While.h Normal file
View File

@@ -0,0 +1,17 @@
#pragma once
namespace kode64
{
BEGIN_NODE(Core, While)
BEGIN_EXEC
while (Read(BoolExpr)) Run(Body);
END_EXEC
PIN_INPUT(BoolExpr, false);
PIN_EXEC(Body);
END_NODE
}

23
64kode/src/Math/Add.h Normal file
View File

@@ -0,0 +1,23 @@
#pragma once
namespace kode64
{
BEGIN_NODE_BASE(Math, Add, MathNode)
double Op(double first) override
{
double result = first;
#ifdef AUTHORING
auto count = inputPins->Count;
for (int i = 1; i < count; ++i) result += Read<double>(inputPins[i]);
#else
auto count = inputPins.size();
for (int i = 1; i < count; ++i) result += Read<double>(i);
#endif
return result;
}
END_NODE
}

78
64kode/src/Math/Bool.h Normal file
View File

@@ -0,0 +1,78 @@
#pragma once
namespace kode64
{
BEGIN_NODE(Math, Less)
BEGIN_EXEC
Write(Result, Read<double>(Left) < Read<double>(Right));
END_EXEC
PIN_INPUT(Left, 0.0);
PIN_INPUT(Right, 0.0);
PIN_OUTPUT(Result);
END_NODE
BEGIN_NODE(Math, LessEquals)
BEGIN_EXEC
Write(Result, Read<double>(Left) <= Read<double>(Right));
END_EXEC
PIN_INPUT(Left, 0.0);
PIN_INPUT(Right, 0.0);
PIN_OUTPUT(Result);
END_NODE
BEGIN_NODE(Math, Greater)
BEGIN_EXEC
Write(Result, Read<double>(Left) > Read<double>(Right));
END_EXEC
PIN_INPUT(Left, 0.0);
PIN_INPUT(Right, 0.0);
PIN_OUTPUT(Result);
END_NODE
BEGIN_NODE(Math, GreaterEquals)
BEGIN_EXEC
Write(Result, Read<double>(Left) >= Read<double>(Right));
END_EXEC
PIN_INPUT(Left, 0.0);
PIN_INPUT(Right, 0.0);
PIN_OUTPUT(Result);
END_NODE
BEGIN_NODE(Math, Equals)
BEGIN_EXEC
Write(Result, Read<double>(Left) == Read<double>(Right));
END_EXEC
PIN_INPUT(Left, 0.0);
PIN_INPUT(Right, 0.0);
PIN_OUTPUT(Result);
END_NODE
BEGIN_NODE(Math, NotEquals)
BEGIN_EXEC
Write(Result, Read<double>(Left) != Read<double>(Right));
END_EXEC
PIN_INPUT(Left, 0.0);
PIN_INPUT(Right, 0.0);
PIN_OUTPUT(Result);
END_NODE
}

1
64kode/src/Math/Math.cpp Normal file
View File

@@ -0,0 +1 @@
#include "Math.h"

6
64kode/src/Math/Math.h Normal file
View File

@@ -0,0 +1,6 @@
#pragma once
#include <NodeSystem/NodeSystem.h>
#include "MathNode.h"
#include "Add.h"
#include "Bool.h"

8
64kode/src/Math/Math.i Normal file
View File

@@ -0,0 +1,8 @@
#line 1 "Math.cpp"
#using <mscorlib.dll>
#line 1 "Math.cpp"
#using <C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll>
#line 1 "Math.cpp"
#line 1 "c:\\code\\64kode\\src\\math\\Math.h"
#pragma once

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Authoring|Win32">
<Configuration>Authoring</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{618E98D1-BDE7-49A2-8CDD-FB2E660CD590}</ProjectGuid>
<RootNamespace>Math</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>AUTHORING;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<LanguageStandard>stdcpp17</LanguageStandard>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<ProjectReference>
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\NodeSystem\NodeSystem.vcxproj">
<Project>{3f0d4f6b-03be-4d66-a2ef-47ec5d961bca}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Math.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Add.h" />
<ClInclude Include="Bool.h" />
<ClInclude Include="Math.h" />
<ClInclude Include="MathNode.h" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@@ -0,0 +1,33 @@
#pragma once
namespace kode64
{
#ifdef AUTHORING
public ref class MathNode abstract : public MultiInputNode
#else
struct MathNode : MultiInputNode
#endif
{
public:
virtual double Op(double first) = 0;
BEGIN_EXEC
#ifdef AUTHORING
if (inputPins->Count > 0)
{
auto first = Read(inputPins[0]);
if (first->GetType() == double::typeid) Write(Result, Op(safe_cast<double>(first)));
}
#else
if (inputPins.size() > 0)
{
auto first = Read(0);
if (first.is<double>()) Write(Result, Op(first.as<double>()));
}
#endif
END_EXEC
PIN_OUTPUT(Result);
};
}

126
64kode/src/NodeSystem/Any.h Normal file
View File

@@ -0,0 +1,126 @@
using namespace std;
template<class T>
using StorageType = typename decay<T>::type;
struct Any
{
bool is_null() const { return !ptr; }
bool not_null() const { return ptr; }
template<typename U> Any(U&& value)
: ptr(new Derived<StorageType<U>>(forward<U>(value)))
{
}
template<class U> bool is() const
{
typedef StorageType<U> T;
auto derived = dynamic_cast<Derived<T>*> (ptr);
return derived;
}
template<class U>
StorageType<U>& as()
{
typedef StorageType<U> T;
auto derived = dynamic_cast<Derived<T>*> (ptr);
if (!derived)
throw bad_cast();
return derived->value;
}
template<class U>
operator U()
{
return as<StorageType<U>>();
}
Any()
: ptr(nullptr)
{
}
Any(Any& that)
: ptr(that.clone())
{
}
Any(Any&& that)
: ptr(that.ptr)
{
that.ptr = nullptr;
}
Any(const Any& that)
: ptr(that.clone())
{
}
Any& operator=(const Any& a)
{
if (ptr == a.ptr)
return *this;
auto old_ptr = ptr;
ptr = a.clone();
if (old_ptr)
delete old_ptr;
return *this;
}
Any& operator=(Any&& a)
{
if (ptr == a.ptr)
return *this;
swap(ptr, a.ptr);
return *this;
}
~Any()
{
delete ptr;
}
private:
struct Base
{
virtual ~Base() {}
virtual Base* clone() const = 0;
};
template<typename T>
struct Derived : Base
{
template<typename U> Derived(U&& value) : value(forward<U>(value)) { }
T value;
Base* clone() const { return new Derived<T>(value); }
};
Base* clone() const
{
if (ptr)
return ptr->clone();
else
return nullptr;
}
Base* ptr;
};

View File

@@ -0,0 +1,73 @@
#pragma once
namespace kode64
{
#ifdef AUTHORING
ref class FunctionCall;
public ref class Function : public MultiNode
{
public:
Function();
void Exec(OutputPin^ outputPin, ExecPin^ execPin) override;
Node^ firstExecNode;
System::Collections::Generic::List<System::Object^>^ variables = gcnew System::Collections::Generic::List<System::Object^>();
System::Collections::Generic::List<FunctionCall^>^ functionCalls = gcnew System::Collections::Generic::List<FunctionCall^>();
static System::Collections::Generic::List<Function^>^ functions = gcnew System::Collections::Generic::List<Function^>();
int index;
};
public ref class FunctionCall : public MultiNode
{
public:
void Exec(OutputPin^ outputPin, ExecPin^ execPin) override;
InputPin^ AddInput(System::Object^ defaultValue) override;
OutputPin^ AddOutput(System::Object^ defaultValue) override;
ExecPin^ AddExec() override;
Function^ function;
};
#else
struct FunctionCall;
struct Function : MultiNode
{
public:
friend FunctionCall;
void Exec(int outputPinIndex, int execPinIndex) override;
Node* firstExecNode;
std::vector<NodeGroup*> functionCalls;
};
struct FunctionCall : MultiNode
{
public:
NodeGroup();
virtual ~NodeGroup();
friend Function;
void Exec(int outputPinIndex, int execPinIndex) override;
virtual void Init() override;
int AddInput(Any&& defaultValue) override;
int AddOutput(Any&& defaultValue) override;
int AddExec() override;
protected:
Function* function;
};
#endif
}

View File

@@ -0,0 +1,117 @@
#ifdef AUTHORING
kode64::Function::Function()
{
index = functions->Count;
functions->Add(this);
}
void kode64::Function::Exec(OutputPin^ outputPin, ExecPin^ execPin)
{
if (functionCalls->Count == 0)
{
throw;
}
auto functionCall = functionCalls[functionCalls->Count - 1];
if (outputPin != nullptr)
{
auto pin = functionCall->inputPins[outputPins->IndexOf(outputPin)];
Write(outputPin, functionCall->Read(pin));
}
else if (execPin != nullptr)
{
auto pin = functionCall->execPins[execPins->IndexOf(execPin)];
functionCall->Run(pin);
}
else
{
NodeRunner::Run(firstExecNode, nullptr, nullptr);
}
}
void kode64::FunctionCall::Exec(OutputPin^ outputPin, ExecPin^ execPin)
{
function->functionCalls->Add(this);
if (outputPin != nullptr)
{
auto pin = function->inputPins[outputPins->IndexOf(outputPin)];
Write(outputPin, function->Read(pin));
}
else if (execPin != nullptr)
{
throw;
}
else
{
NodeRunner::Run(function, nullptr, nullptr);
}
function->functionCalls->Remove(this);
}
kode64::InputPin^ kode64::FunctionCall::AddInput(System::Object^ defaultValue)
{
function->AddOutput(defaultValue);
return MultiNode::AddInput(defaultValue);
}
kode64::OutputPin^ kode64::FunctionCall::AddOutput(System::Object^ defaultValue)
{
function->AddInput(defaultValue);
return MultiNode::AddOutput(defaultValue);
}
kode64::ExecPin^ kode64::FunctionCall::AddExec()
{
function->AddExec();
return MultiNode::AddExec();
}
#else
void kode64::Function::Exec(int outputPinIndex, int execPinIndex)
{
if (outputPinIndex != -1)
{
Write(outputPinIndex, functionCall->Read(outputPinIndex));
}
else if (execPinIndex != -1)
{
NodeRunner::Run(functionCall, -1, execPinIndex);
}
else
{
throw;
}
}
void kode64::FunctionCall::Exec(int outputPinIndex, int execPinIndex)
{
if (outputPinIndex != -1)
{
Write(outputPinIndex, function->Read(outputPinIndex));
}
else if (execPinIndex != -1)
{
auto node = execPins[execPinIndex].node;
NodeRunner::Run(node, -1, -1);
}
else
{
NodeRunner::Run(firstExecNode, -1, i);
}
}
int kode64::FunctionCall::AddInput(Any&& defaultValue)
{
function->RegisterOutputPin();
return MultiInputNode::AddInput(&defaultValue);
}
int kode64::FunctionCall::AddOutput(Any&& defaultValue)
{
function->RegisterInputPin(&defaultValue);
return RegisterOutputPin();
}
#endif

View File

@@ -0,0 +1,357 @@
#pragma once
namespace kode64
{
#ifdef AUTHORING
ref class Node;
ref class InputPin;
ref class OutputPin;
public ref class InputLink
{
public:
InputLink(Node^ _node, InputPin^ _pin)
: node(_node)
, pin(_pin)
{
}
Node^ node = nullptr;
InputPin^ pin;
};
public ref class OutputLink
{
public:
OutputLink(Node^ _node, OutputPin^ _pin)
: node(_node)
, pin(_pin)
{
}
Node^ node = nullptr;
OutputPin^ pin;
};
public ref class InputPin
{
public:
InputPin(System::Object^ _value, OutputLink^ _link)
: value(_value)
, link(_link)
{
}
System::Object^ value;
OutputLink^ link;
};
public ref class OutputPin
{
public:
System::Collections::Generic::List<InputLink^>^ links = gcnew System::Collections::Generic::List<InputLink^>();
};
public ref class ExecPin
{
public:
ExecPin(Node^ _node)
: node(_node)
{
}
Node^ node = nullptr;
};
public ref class Node abstract
{
public:
Node()
{
Init();
}
virtual void Exec(OutputPin^ outputPin, ExecPin^ execPin) = 0;
virtual void Init() {};
virtual void Run(ExecPin^ pin)
{
NodeRunner::Run(pin->node, nullptr, pin);
}
virtual System::Object^ Read(InputPin^ pin)
{
if (pin->link != nullptr)
{
NodeRunner::Run(pin->link->node, (OutputPin^)pin->link->pin, nullptr);
}
return pin->value;
}
template <typename T>
T Read(InputPin^ pin)
{
return safe_cast<T>(Read(pin));
}
virtual void Set(InputPin^ pin, System::Object^ value)
{
pin->value = value;
}
virtual void Write(OutputPin^ pin, System::Object^ value)
{
for (int i = 0; i < pin->links->Count; ++i)
{
auto link = pin->links[i];
link->node->Set((InputPin^)link->pin, value);
}
}
virtual void ConnectInput(InputPin^ pin, Node^ target, OutputPin^ targetPin)
{
pin->link = gcnew OutputLink(target, targetPin);
}
virtual void ConnectOutput(OutputPin^ pin, Node^ source, InputPin^ sourcePin)
{
pin->links->Add(gcnew InputLink(source, sourcePin));
}
virtual void DisconnectInput(InputPin^ pin)
{
pin->link = nullptr;
}
virtual void DisconnectOutput(OutputPin^ pin, Node^ source, InputPin^ sourcePin)
{
for each (auto link in pin->links)
{
if (link->node == source && link->pin == sourcePin)
{
pin->links->Remove(link);
return;
}
}
}
static void Connect(Node^ source, OutputPin^ sourcePin, Node^ target, InputPin^ targetPin)
{
source->ConnectOutput(sourcePin, target, targetPin);
target->ConnectInput(targetPin, source, sourcePin);
}
static void Disconnect(Node^ source, OutputPin^ sourcePin, Node^ target, InputPin^ targetPin)
{
source->DisconnectOutput(sourcePin, target, targetPin);
target->DisconnectInput(targetPin);
}
ExecPin^ nextExec = gcnew ExecPin(nullptr);
};
public ref class MultiInputNode abstract : public Node
{
public:
virtual InputPin^ AddInput(System::Object^ defaultValue)
{
auto result = gcnew InputPin(defaultValue, nullptr);
inputPins->Add(result);
return result;
}
System::Collections::Generic::List<InputPin^>^ inputPins = gcnew System::Collections::Generic::List<InputPin^>();
};
public ref class MultiNode abstract : public MultiInputNode
{
public:
virtual OutputPin^ AddOutput(System::Object^ defaultValue)
{
auto result = gcnew OutputPin();
outputPins->Add(result);
return result;
}
virtual ExecPin^ AddExec()
{
auto result = gcnew ExecPin(nullptr);
execPins->Add(result);
return result;
}
System::Collections::Generic::List<OutputPin^>^ outputPins = gcnew System::Collections::Generic::List<OutputPin^>();
System::Collections::Generic::List<ExecPin^>^ execPins = gcnew System::Collections::Generic::List<ExecPin^>();
};
#define DECLARE_NODE(ns, nodetype, name) ns::nodetype^ name = gcnew ns::nodetype()
#define SET(target, targetPin, value) target->Set(target->targetPin, value)
#define CONNECT(source, sourcePin, target, targetPin) Node::Connect(source, source->sourcePin, target, target->targetPin)
#define CONNECT_EXEC(source, sourcePin, target) source->ConnectExec(source->sourcePin, target)
#define BEGIN_NODE_BASE(ns, nodetype, basetype) namespace ns { public ref class nodetype : public basetype { public:
#define BEGIN_NODE(ns, nodetype) namespace ns { public ref class nodetype : public Node { public:
#define BEGIN_EXEC void Exec(OutputPin^ outputPin, ExecPin^ execPin) override {
#define END_EXEC };
#define PIN_INPUT(name, defvalue) InputPin^ name = gcnew InputPin(nullptr, nullptr)
#define PIN_OUTPUT(name) OutputPin^ name = gcnew OutputPin()
#define PIN_EXEC(name) ExecPin^ name = gcnew ExecPin(nullptr)
#define END_NODE }; }
#else
struct Node;
struct Link
{
Node* node = nullptr;
int pinIndex;
};
struct InputPin
{
Any value;
Link link;
};
struct OutputPin
{
std::vector<Link> links;
};
struct ExecPin
{
Node* node = nullptr;
};
struct Node
{
virtual void Exec(int outputPinIndex, int execPinIndex) = 0;
virtual void Init() {};
virtual void Run(int execPinIndex)
{
NodeRunner::Run(execPins[execPinIndex].node, -1, execPinIndex);
}
virtual Any Read(int pinIndex)
{
auto pin = inputPins[pinIndex];
NodeRunner::Run(pin.link.node, pin.link.pinIndex, -1);
return inputPins[pinIndex].value;
}
template <typename T>
T Read(int pinIndex)
{
return Read(pinIndex).as<T>();
}
virtual void Set(int pinIndex, const Any& value)
{
inputPins[pinIndex].value = value;
}
virtual void Write(int pinIndex, const Any& value)
{
auto pin = outputPins[pinIndex];
for (unsigned int i = 0; i < pin.links.size(); ++i)
{
auto link = pin.links[i];
link.node->Set(link.pinIndex, value);
}
}
virtual void ConnectInput(int pinIndex, Node& target, int targetPinIndex)
{
inputPins[pinIndex].link = { &target, targetPinIndex };
}
virtual void ConnectOutput(int pinIndex, Node& source, int sourcePinIndex)
{
outputPins[pinIndex].links.push_back(Link() = { &source, sourcePinIndex });
}
virtual void ConnectExec(int pinIndex, Node& target)
{
execPins[pinIndex].node = &target;
}
static void Connect(Node& source, int sourcePinIndex, Node& target, int targetPinIndex)
{
source.ConnectOutput(sourcePinIndex, target, targetPinIndex);
target.ConnectInput(targetPinIndex, source, sourcePinIndex);
}
ExecPin nextExec;
protected:
virtual int RegisterInputPin(Any&& defaultValue)
{
int index = inputPins.size();
inputPins.push_back(InputPin() = { defaultValue });
return index;
}
virtual int RegisterOutputPin()
{
int index = outputPins.size();
outputPins.push_back(OutputPin());
return index;
}
virtual int RegisterExecPin()
{
int index = execPins.size();
execPins.push_back(ExecPin());
return index;
}
std::vector<InputPin> inputPins;
std::vector<OutputPin> outputPins;
std::vector<ExecPin> execPins;
};
struct MultiInputNode : Node
{
virtual int AddInput(Any&& defaultValue)
{
return RegisterInputPin(&defaultValue);
}
};
struct MultiNode : MultiInputNode
{
public:
virtual int AddOutput(Any&& defaultValue)
{
return RegisterOutputPin();
}
virtual int AddExec()
{
return RegisterExecPin();
}
};
#define DECLARE_NODE(ns, type, name) ns::type name;
#define SET(target, targetPin, value) target.Set(target.targetPin, value)
#define CONNECT(source, sourcePin, target, targetPin) Node::Connect(source, source.sourcePin, target, target.targetPin);
#define CONNECT_EXEC(source, sourcePin, target) source.ConnectExec(source.sourcePin, target);
#define BEGIN_NODE_BASE(ns, name, base) namespace ns { struct name : base {
#define BEGIN_NODE(ns, name) namespace ns { struct name : Node {
#define BEGIN_EXEC void Exec(int outputPinIndex, int execPinIndex) override {
#define END_EXEC };
#define PIN_INPUT(name, defvalue) int name = RegisterInputPin(defvalue)
#define PIN_OUTPUT(name) int name = RegisterOutputPin()
#define PIN_EXEC(name) int name = RegisterExecPin()
#define END_NODE }; }
#define SET_NEXTEXEC(source, target) source.nextExec = &target
#define ADD_FIRSTEXEC(node) firstExecNodes.push_back(&node)
#define CONNECT_TO_INNER(source, sourcePin, innerPin) ConnectToInner(source, source.sourcePin, innerPin)
#define CONNECT_FROM_INNER(innerPin, target, targetPin) ConnectFromInner(innerPin, target, target.targetPin)
#endif
}

View File

@@ -0,0 +1,34 @@
#pragma once
namespace kode64
{
#ifdef AUTHORING
ref class Node;
ref class OutputPin;
ref class ExecPin;
public ref class NodeRunner
{
public:
static void Run(Node^ node, OutputPin^ outputPin, ExecPin^ execPin);
private:
static System::Collections::Generic::List<Node^>^ stackTrace = gcnew System::Collections::Generic::List<Node^>();
};
#else
struct Node;
struct NodeRunner
{
public:
static void Run(Node* node, int outputPinIndex, int execPinIndex);
private:
static std::vector<Node*> stackTrace;
};
#endif
}

View File

@@ -0,0 +1,64 @@
#ifdef AUTHORING
void kode64::NodeRunner::Run(Node^ node, OutputPin^ outputPin, ExecPin^ execPin)
{
while (node != nullptr)
{
stackTrace->Add(node);
node->Exec(outputPin, execPin);
stackTrace->RemoveAt(stackTrace->Count - 1);
if (outputPin != nullptr)
{
return;
}
if (node->nextExec != nullptr)
{
node = node->nextExec->node;
}
else
{
node = nullptr;
}
execPin = nullptr;
}
}
#else
void kode64::NodeRunner::Run(Node* node, int outputPinIndex, int execPinIndex)
{
while (node != nullptr)
{
stackTrace.push_back(node);
node->Exec(outputPinIndex, execPinIndex);
stackTrace.pop_back();
if (outputPinIndex != -1)
{
return;
}
node = node->nextExec;
execPinIndex = -1;
}
}
unsigned int kode64::NodeRunner::CreateVariable(const Any&& value)
{
unsigned int index = variables.size();
variables.push_back(value);
return index;
}
Any& kode64::NodeRunner::GetVariable(unsigned int variable)
{
return variables[variable];
}
void kode64::NodeRunner::SetVariable(unsigned int variable, const Any& value)
{
variables[variable] = value;
}
#endif

View File

@@ -0,0 +1,4 @@
#include "NodeSystem.h"
#include "NodeRunner.inc"
#include "Functions.inc"

View File

@@ -0,0 +1,14 @@
#pragma once
#include <type_traits>
#include <utility>
#include <typeinfo>
#include <memory>
#include <iostream>
#include <string>
#include <vector>
#include "Any.h"
#include "NodeRunner.h"
#include "NodeRegistry.h"
#include "Functions.h"

View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Authoring|Win32">
<Configuration>Authoring</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{3F0D4F6B-03BE-4D66-A2EF-47EC5D961BCA}</ProjectGuid>
<RootNamespace>NodeSystem</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)src;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>AUTHORING;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<LanguageStandard>stdcpp17</LanguageStandard>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="Functions.inc">
<FileType>CppCode</FileType>
</None>
<None Include="NodeRunner.inc">
<FileType>CppCode</FileType>
</None>
<ClCompile Include="NodeSystem.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Any.h" />
<ClInclude Include="Functions.h" />
<ClInclude Include="NodeRegistry.h" />
<ClInclude Include="NodeRunner.h" />
<ClInclude Include="NodeSystem.h" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.ViewModels;
namespace Tool.Actions
{
public abstract class ActionBase : IUndoItem
{
public ActionBase(string _sDescription)
{
Description = _sDescription;
}
public bool CanRedo
{
get;
protected set;
} = true;
public bool CanUndo
{
get;
protected set;
} = true;
public string Description
{
get;
protected set;
}
public abstract IUndoContext Context
{
get;
}
public bool MarksDirty
{
get;
protected set;
} = true;
public abstract void Redo();
public abstract void Undo();
}
public class NodeActionBase : ActionBase
{
public NodeActionBase(FunctionViewModel _function, string _sDescription)
: base(_sDescription)
{
m_Function = _function;
}
public override void Redo()
{
if (m_Function != null && MarksDirty)
{
m_bWasDirty = m_Function.IsDirty;
m_Function.IsDirty = true;
}
}
public override void Undo()
{
if (!m_bWasDirty && MarksDirty)
{
m_Function.IsDirty = !m_Function.IsDirty;
}
}
public override IUndoContext Context => m_Function;
protected FunctionViewModel m_Function;
private bool m_bWasDirty;
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.ViewModels;
using Tool.Views;
namespace Tool.Actions
{
public class AddNewNodeAction : NodeActionBase
{
public AddNewNodeAction(FunctionViewModel _function, NodeViewModel _node)
: base(_function, $"Create node {_node}")
{
m_Node = _node;
}
public override void Redo()
{
base.Redo();
m_Function.Nodes.Add(m_Node);
LinksView.Instance.InvalidateVisual();
}
public override void Undo()
{
m_Function.Nodes.Remove(m_Node);
LinksView.Instance.InvalidateVisual();
base.Undo();
}
private NodeViewModel m_Node;
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.ViewModels;
using Tool.Views;
namespace Tool.Actions
{
public class AddNewVariableAction : NodeActionBase
{
public AddNewVariableAction(FunctionViewModel _function, VariableViewModel _variable)
: base(_function, $"Create variable {_variable}")
{
m_Variable = _variable;
}
public override void Redo()
{
base.Redo();
m_Function.Variables.Add(m_Variable);
}
public override void Undo()
{
m_Function.Variables.Remove(m_Variable);
base.Undo();
}
private VariableViewModel m_Variable;
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.ViewModels;
namespace Tool.Actions
{
public class ChangePropertyAction<T> : NodeActionBase
{
public ChangePropertyAction(FunctionViewModel _function, string _sDescription, Func<T> _get, Action<T> _set, T _newValue, bool _bMarksDirty = true)
: base(_function, _sDescription)
{
MarksDirty = _bMarksDirty;
m_Get = _get;
m_Set = _set;
m_NewValue = _newValue;
m_OldValue = m_Get();
}
public override void Redo()
{
base.Redo();
m_Set(m_NewValue);
}
public override void Undo()
{
m_Set(m_OldValue);
base.Undo();
}
private Func<T> m_Get;
private Action<T> m_Set;
private T m_OldValue;
private T m_NewValue;
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.ViewModels;
namespace Tool.Actions
{
public class ChangeSelectionAction : NodeActionBase
{
public ChangeSelectionAction(FunctionViewModel _function, List<NodeViewModel> _selection)
: base(_function, "New selection")
{
MarksDirty = false;
m_NewSelection = _selection ?? new List<NodeViewModel>();
m_PreviousSelection = new List<NodeViewModel>();
if (_function.SelectedNodes != null)
{
m_PreviousSelection.AddRange(_function.SelectedNodes);
}
}
public override void Redo()
{
base.Redo();
Select(m_NewSelection);
}
public override void Undo()
{
Select(m_PreviousSelection);
base.Undo();
}
private void Select(List<NodeViewModel> _selection)
{
var newNodes = _selection.Except(m_Function.SelectedNodes).ToList();
var oldNodes = m_Function.SelectedNodes.Except(_selection).ToList();
foreach (var node in oldNodes)
{
m_Function.SelectedNodes.Remove(node);
node.RaisePropertyChanged(nameof(NodeViewModel.IsSelected));
}
foreach (var node in newNodes)
{
m_Function.SelectedNodes.Add(node);
node.RaisePropertyChanged(nameof(NodeViewModel.IsSelected));
}
}
private List<NodeViewModel> m_NewSelection;
private List<NodeViewModel> m_PreviousSelection;
}
}

View File

@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.ViewModels;
using Tool.Views;
namespace Tool.Actions
{
public class DeleteLinkAction : NodeActionBase
{
public DeleteLinkAction(FunctionViewModel _function, PinViewModelBase _pin, int _iIndex = 0)
: base(_function, $"Delete link {_iIndex} at {_pin}")
{
m_Pin = _pin;
m_iIndex = _iIndex;
}
public override void Redo()
{
var execPin = m_Pin as ExecutePinViewModel;
var rootPin = m_Pin as RootPinViewModel;
var inputPin = m_Pin as InputPinViewModel;
var outputPin = m_Pin as OutputPinViewModel;
if (execPin?.m_Connection != null)
{
m_Connection = execPin.m_Connection;
execPin.Disconnect();
}
else if (rootPin?.m_Connection != null)
{
m_Connection = rootPin.m_Connection;
rootPin.m_Connection.Disconnect();
}
else if ((outputPin?.m_lConnections?.Count ?? 0) != 0)
{
m_Connection = outputPin.m_lConnections[m_iIndex];
outputPin.Disconnect(outputPin.m_lConnections[m_iIndex]);
}
else if (inputPin?.m_Connection != null)
{
m_Connection = inputPin.m_Connection;
inputPin.m_Connection.Disconnect(inputPin);
}
LinksView.Instance.InvalidateVisual();
}
public override void Undo()
{
var execPin = m_Pin as ExecutePinViewModel;
var rootPin = m_Pin as RootPinViewModel;
var inputPin = m_Pin as InputPinViewModel;
var outputPin = m_Pin as OutputPinViewModel;
if (execPin != null)
{
execPin?.ConnectTo((RootPinViewModel)m_Connection);
}
else if (rootPin != null)
{
((ExecutePinViewModel)m_Connection).ConnectTo(rootPin);
}
else if (inputPin != null)
{
((OutputPinViewModel)m_Connection).ConnectTo(inputPin);
}
else if (outputPin != null)
{
outputPin.ConnectTo((InputPinViewModel)m_Connection);
}
LinksView.Instance.InvalidateVisual();
}
private PinViewModelBase m_Pin;
private int m_iIndex;
private PinViewModelBase m_Connection;
}
}

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.ViewModels;
namespace Tool.Actions
{
public class DeleteNodeAction : NodeActionBase
{
public DeleteNodeAction(FunctionViewModel _function, NodeViewModel _node)
: base(_function, $"Delete node {_node}")
{
m_iIndex = _function.Nodes.IndexOf(_node);
}
public override void Redo()
{
base.Redo();
m_RemovedNode = m_Function.Nodes[m_iIndex];
var undo = m_Function.Main.Undo;
var links = new List<Tuple<PinViewModelBase, int>>();
links.AddRange(m_RemovedNode.ExecutePins.Where(p => p.m_Connection != null).Select(p => Tuple.Create<PinViewModelBase, int>(p, 0)));
links.AddRange(m_RemovedNode.InputPins.Where(p => p.m_Connection != null).Select(p => Tuple.Create<PinViewModelBase, int>(p, 0)));
links.AddRange(m_RemovedNode.OutputPins.Where(p => (p.m_lConnections?.Count ?? 0) != 0).SelectMany(p => p.m_lConnections.Select((c, i) => Tuple.Create<PinViewModelBase, int>(p, i))));
if (m_RemovedNode.RootPin.m_Connection != null)
{
links.Add(Tuple.Create<PinViewModelBase, int>(m_RemovedNode.RootPin, 0));
}
if (m_RemovedNode.NextExecPin.m_Connection != null)
{
links.Add(Tuple.Create<PinViewModelBase, int>(m_RemovedNode.NextExecPin, 0));
}
m_lActions = links.Select(l => new DeleteLinkAction(m_Function, l.Item1, l.Item2)).ToList();
foreach (var action in m_lActions)
{
action.Redo();
}
m_Function.Nodes.RemoveAt(m_iIndex);
}
public override void Undo()
{
m_Function.Nodes.Insert(m_iIndex, m_RemovedNode);
foreach (var action in m_lActions)
{
action.Undo();
}
base.Undo();
}
private int m_iIndex;
private NodeViewModel m_RemovedNode;
private List<DeleteLinkAction> m_lActions;
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Tool.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<Tool.Properties.Settings>
<setting name="LastLayout" serializeAs="String">
<value />
</setting>
</Tool.Properties.Settings>
</userSettings>
</configuration>

14
64kode/src/Tool/App.xaml Normal file
View File

@@ -0,0 +1,14 @@
<Application x:Class="Tool.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Shared/Controls.xaml" />
<ResourceDictionary Source="/Themes/Dark/Theme.xaml" />
<ResourceDictionary Source="/Layout/Views/Resources.xaml" />
<ResourceDictionary Source="/Resources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

113
64kode/src/Tool/App.xaml.cs Normal file
View File

@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Navigation;
using System.Xml.Serialization;
using Tool.Layout.Services;
using Tool.Layout.ViewModels;
using Tool.Properties;
using Tool.ViewModels;
namespace Tool
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
this.Startup += App_Startup;
}
private void App_Startup(object sender, StartupEventArgs e)
{
LayoutViewRegistry.RegisterAssembly(Assembly.GetExecutingAssembly());
Layouts = new ObservableCollection<LayoutViewModel>();
var serializer = new XmlSerializer(typeof(LayoutViewModel));
if (Settings.Default.Layouts != null)
{
foreach (var layout in Settings.Default.Layouts)
{
Layouts.Add(serializer.Deserialize(new StringReader(layout)) as LayoutViewModel);
}
}
if (!string.IsNullOrEmpty(Settings.Default.LastLayout))
{
var layoutVm = serializer.Deserialize(new StringReader(Settings.Default.LastLayout)) as LayoutViewModel;
if (layoutVm.Windows.Count == 0)
{
WindowViewModel.CreateNewWindow();
}
else
{
LoadLayout(layoutVm);
}
}
else
{
WindowViewModel.CreateNewWindow();
}
}
public void LoadLayout(LayoutViewModel layoutViewModel)
{
RootViewModel.Instance.Windows.Replace(layoutViewModel.Windows, true);
m_sCurrentLayout = layoutViewModel.DisplayName;
}
public void SaveLayoutAs()
{
var layout = new LayoutViewModel();
layout.DisplayName = MessageBoxService.Input("Enter the layout name:", m_sCurrentLayout);
layout.Windows = RootViewModel.Instance.Windows.ToList();
var existingLayout = Layouts.FirstOrDefault(l => l.DisplayName == layout.DisplayName);
if (existingLayout != null)
{
Layouts.Remove(existingLayout);
}
Layouts.Add(layout);
m_sCurrentLayout = layout.DisplayName;
var serializer = new XmlSerializer(typeof(LayoutViewModel));
var sb = new StringBuilder();
serializer.Serialize(new StringWriter(sb), layout);
if (Settings.Default.Layouts == null)
{
Settings.Default.Layouts = new System.Collections.Specialized.StringCollection();
}
Settings.Default.Layouts.Add(sb.ToString());
Settings.Default.Save();
}
public void SaveLastLayout()
{
var layout = new LayoutViewModel();
layout.DisplayName = "Least recently used";
layout.Windows = RootViewModel.Instance.Windows.ToList();
var serializer = new XmlSerializer(typeof(LayoutViewModel));
var sb = new StringBuilder();
serializer.Serialize(new StringWriter(sb), layout);
Settings.Default.LastLayout = sb.ToString();
Settings.Default.Save();
}
public ObservableCollection<LayoutViewModel> Layouts
{
get;
private set;
}
private string m_sCurrentLayout;
}
}

View File

@@ -0,0 +1,28 @@
<Window x:Class="Tool.Dialogs.MessageBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Title="Alcatraz 64kode" SizeToContent="WidthAndHeight"
Background="{DynamicResource GeneralBackground}"
d:DesignWidth="500" d:DesignHeight="200" MinWidth="400" WindowStartupLocation="CenterOwner">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image x:Name="ErrorIcon" Source="/Tool;component/Images/bigerror.png" Grid.Row="1" Stretch="Uniform" Width="32" Height="32" Margin="5" VerticalAlignment="Top" />
<Image x:Name="InfoIcon" Source="/Tool;component/Images/biginfo.png" Grid.Row="1" Stretch="Uniform" Width="32" Height="32" Margin="5" VerticalAlignment="Top" />
<TextBlock Grid.Column="1" x:Name="Message" Margin="5,10" FontWeight="Bold" />
<TextBox Grid.Row="1" Grid.Column="1" x:Name="Details" TextWrapping="Wrap" IsReadOnly="True" Height="Auto" Margin="5" MaxWidth="800" MaxHeight="700" VerticalAlignment="Top" VerticalScrollBarVisibility="Auto" />
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Right">
<Button Content="Close" Margin="5,10" HorizontalAlignment="Right" Padding="5,3" Click="Button_Click" />
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Tool.Dialogs
{
/// <summary>
/// Interaction logic for MessageBox.xaml
/// </summary>
public partial class MessageBox : Window
{
public MessageBox()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@@ -0,0 +1,29 @@
<Window x:Class="Tool.Dialogs.QueryChooseBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Tool.Dialogs"
Background="{DynamicResource GeneralBackground}"
mc:Ignorable="d" SizeToContent="WidthAndHeight" Title="Alcatraz 64kode"
d:DesignHeight="300" d:DesignWidth="300" WindowStartupLocation="CenterOwner">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock x:Name="Message" Margin="5,10" FontWeight="Bold" TextWrapping="Wrap" Height="Auto" VerticalAlignment="Top" />
<ItemsControl ItemsSource="{Binding Options, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:QueryChooseBox}}}" Grid.Row="1" HorizontalAlignment="Right">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding}" Margin="5,10" HorizontalAlignment="Right" Padding="5,3" Click="Button_Click" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Window>

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Tool.Dialogs
{
/// <summary>
/// Interaction logic for QueryChooseBox.xaml
/// </summary>
public partial class QueryChooseBox : Window
{
public QueryChooseBox()
{
Result = null;
InitializeComponent();
}
public string Result { get; private set; }
private void Button_Click(object sender, RoutedEventArgs e)
{
Result = (sender as Button).DataContext as string;
this.Close();
}
public List<string> Options { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
<Window x:Class="Tool.Dialogs.UserInputBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Background="{DynamicResource GeneralBackground}"
mc:Ignorable="d" SizeToContent="WidthAndHeight" Title="Alcatraz 64kode"
d:DesignWidth="500" d:DesignHeight="200" MaxWidth="500" WindowStartupLocation="CenterOwner">
<Grid Margin="10,5">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock x:Name="Message" Margin="5" FontWeight="Bold" TextWrapping="Wrap" Height="Auto" VerticalAlignment="Top" />
<TextBox Grid.Row="1" x:Name="UserInput" AcceptsReturn="False" MaxLines="1" Margin="5" Height="23" />
<StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Right">
<Button Content="OK" Margin="5" IsDefault="True" HorizontalAlignment="Right" Padding="5,3" Click="OkButton_Click" />
<Button Content="Cancel" Margin="5" HorizontalAlignment="Right" Padding="5,3" Click="CancelButton_Click" />
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Tool.Dialogs
{
/// <summary>
/// Interaction logic for UserInputBox.xaml
/// </summary>
public partial class UserInputBox : Window
{
public UserInputBox()
{
InitializeComponent();
}
private void OkButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
UserInput.Text = null;
this.Close();
}
}
}

View File

@@ -0,0 +1,20 @@
<Window x:Class="Tool.Dialogs.YesNoBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Background="{DynamicResource GeneralBackground}"
mc:Ignorable="d" SizeToContent="WidthAndHeight" Title="Alcatraz 64kode"
d:DesignHeight="300" d:DesignWidth="300" WindowStartupLocation="CenterOwner">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock x:Name="Message" Margin="5,10" FontWeight="Bold" TextWrapping="Wrap" Height="Auto" VerticalAlignment="Top" />
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
<Button Content="Yes" Margin="5,10" HorizontalAlignment="Right" Padding="5,3" Click="YesButton_Click" />
<Button Content="No" Margin="5,10" HorizontalAlignment="Right" Padding="5,3" Click="NoButton_Click" />
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Tool.Dialogs
{
/// <summary>
/// Interaction logic for YesNoBox.xaml
/// </summary>
public partial class YesNoBox : Window
{
public YesNoBox()
{
Result = false;
InitializeComponent();
}
public bool Result { get; private set; }
private void YesButton_Click(object sender, RoutedEventArgs e)
{
Result = true;
this.Close();
}
private void NoButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool
{
public interface IUndoContext
{
bool IsDirty { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tool
{
public interface IUndoItem
{
IUndoContext Context { get; }
string Description { get; }
bool CanUndo { get; }
bool CanRedo { get; }
bool MarksDirty { get; }
void Redo();
void Undo();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool.Layout.Attributes
{
public class LayoutViewAttribute : Attribute
{
public LayoutViewAttribute(string _sViewName, string _sViewIconPath)
{
ViewName = _sViewName;
ViewIconPath = _sViewIconPath;
}
public string ViewName { get; private set; }
public string ViewIconPath { get; private set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool.Layout.Attributes
{
public class LayoutWindowAttribute : Attribute
{
public LayoutWindowAttribute(bool _bMainWindow)
{
MainWindow = _bMainWindow;
}
public bool MainWindow { get; private set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool.Layout.Attributes
{
public class MainLayoutViewAttribute : Attribute
{
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.Layout.ViewModels;
namespace Tool.Layout.Interfaces
{
public interface ILayoutWindow
{
WindowViewModel WindowViewModel { get; set; }
}
}

View File

@@ -0,0 +1,183 @@
using Tool.Layout.Attributes;
using Tool.Layout.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows;
using Tool.Layout.Interfaces;
namespace Tool.Layout.Services
{
public static class LayoutViewRegistry
{
public static ViewViewModel RegisterView<T>() where T : FrameworkElement
{
return RegisterView(typeof(T));
}
public static void RegisterWindow<T>() where T : Window, ILayoutWindow
{
RegisterWindow(typeof(T));
}
private static ViewViewModel RegisterView(Type _type)
{
if (!typeof(FrameworkElement).IsAssignableFrom(_type))
throw new ArgumentException("Only FrameworkElements can be registered for layout views.");
if (!m_RegisteredViews.Any(v => v.ViewType == _type))
{
var vm = new ViewViewModel() { ViewType = _type, ViewName = GetViewName(_type) };
m_RegisteredViews.Add(vm);
return vm;
}
else
{
return m_RegisteredViews.FirstOrDefault(v => v.ViewType == _type);
}
}
public static void RegisterWindow(Type _type)
{
if (!typeof(Window).IsAssignableFrom(_type) || !typeof(ILayoutWindow).IsAssignableFrom(_type))
throw new ArgumentException("Only Windows implementing ILayoutWindow can be registered.");
var layoutWindowAttribute = _type.GetCustomAttributes(typeof(LayoutWindowAttribute), true).FirstOrDefault() as LayoutWindowAttribute;
if (layoutWindowAttribute == null)
{
throw new NotSupportedException("Types implementing ILayoutWindow must be decorated with a [LayoutWindow] attribute.");
}
if (layoutWindowAttribute.MainWindow)
{
if (m_RegisteredMainWindow == null)
{
m_RegisteredMainWindow = _type;
}
else
{
throw new NotSupportedException("Only one main window may ever implement ILayoutWindow. Multiple main window types are not supported.");
}
}
else
{
if (m_RegisteredSecondaryWindow == null)
{
m_RegisteredSecondaryWindow = _type;
}
else
{
throw new NotSupportedException("Only one secondary window may ever implement ILayoutWindow. Multiple secondary window types are not supported.");
}
}
}
public static IEnumerable<ViewViewModel> RegisteredViews
{
get
{
return m_RegisteredViews;
}
}
public static Type RegisteredMainWindow
{
get
{
return m_RegisteredMainWindow;
}
}
public static Type RegisteredSecondaryWindow
{
get
{
return m_RegisteredSecondaryWindow;
}
}
public static ViewViewModel MainView
{
get;
private set;
}
public static void SetMainView(ViewViewModel _mainView)
{
if (!m_RegisteredViews.Contains(_mainView))
{
throw new ArgumentException("The specified view was not registered in the LayoutViewRegistry.");
}
MainView = _mainView;
}
public static void RegisterAssembly(System.Reflection.Assembly _assembly)
{
foreach (var type in _assembly.GetTypes())
{
var layoutViewAttribute = type.GetCustomAttributes(typeof(LayoutViewAttribute), true).FirstOrDefault();
if (layoutViewAttribute != null)
{
var view = LayoutViewRegistry.RegisterView(type);
var mainLayoutViewAttribute = type.GetCustomAttributes(typeof(MainLayoutViewAttribute), true).FirstOrDefault();
if (mainLayoutViewAttribute != null)
{
LayoutViewRegistry.SetMainView(view);
}
}
if (typeof(ILayoutWindow).IsAssignableFrom(type) && type != typeof(ILayoutWindow))
{
var layoutWindowAttribute = type.GetCustomAttributes(typeof(LayoutWindowAttribute), true).FirstOrDefault() as LayoutWindowAttribute;
if (layoutWindowAttribute == null)
{
throw new NotSupportedException("Types implementing ILayoutWindow must be decorated with a [LayoutWindow] attribute.");
}
if (layoutWindowAttribute.MainWindow)
{
if (m_RegisteredMainWindow == null)
{
m_RegisteredMainWindow = type;
}
else
{
throw new NotSupportedException("Only one main window may ever implement ILayoutWindow. Multiple main window types are not supported.");
}
}
else
{
if (m_RegisteredSecondaryWindow == null)
{
m_RegisteredSecondaryWindow = type;
}
else
{
throw new NotSupportedException("Only one secondary window may ever implement ILayoutWindow. Multiple secondary window types are not supported.");
}
}
}
}
}
private static string GetViewName(Type _type)
{
var attribute = _type.GetCustomAttributes(typeof(LayoutViewAttribute), true).FirstOrDefault() as LayoutViewAttribute;
if (attribute != null)
{
return attribute.ViewName;
}
return _type.ToString();
}
private static List<ViewViewModel> m_RegisteredViews = new List<ViewViewModel>();
private static Type m_RegisteredMainWindow;
private static Type m_RegisteredSecondaryWindow;
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Tool.ViewModels;
namespace Tool.Layout.ViewModels
{
public abstract class InheritedViewModel : NodeViewModelBase
{
[XmlIgnore]
public NodeViewModelBase Parent
{
get
{
return m_Parent;
}
set
{
if (m_Parent == value)
return;
m_Parent = value;
RaisePropertyChanged("Parent");
}
}
private NodeViewModelBase m_Parent;
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Tool.ViewModels;
namespace Tool.Layout.ViewModels
{
[XmlInclude(typeof(NodeViewModel))]
[XmlInclude(typeof(LeafViewModel))]
[XmlInclude(typeof(InheritedViewModel))]
[XmlInclude(typeof(ViewViewModel))]
[XmlInclude(typeof(NodeViewModelBase))]
[XmlInclude(typeof(WindowViewModel))]
public class LayoutViewModel : ViewModelBase
{
public string DisplayName { get; set; }
public List<WindowViewModel> Windows { get; set; }
}
}

View File

@@ -0,0 +1,331 @@
using Tool.Layout.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Tool.Layout.Services;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
namespace Tool.Layout.ViewModels
{
public class LeafViewModel : InheritedViewModel
{
public enum Arrow
{
None,
Left,
Top,
Right,
Bottom
}
public LeafViewModel(LeafViewModel _leafViewModel)
: this()
{
CurrentView = _leafViewModel.CurrentView;
ToolbarGridRow = _leafViewModel.ToolbarGridRow;
}
public LeafViewModel()
{
SideSize = 0;
ArrowDirection = Arrow.None;
CurrentView = LayoutViewRegistry.MainView;
}
public void Split(Orientation _orientation, bool _bPreserveFirst, double _dFirstWeight, double _dSecondWeight)
{
var nvm = new NodeViewModel();
nvm.Orientation = _orientation;
nvm.FirstWeight = new GridLength(_dFirstWeight, GridUnitType.Star);
nvm.SecondWeight = new GridLength(_dSecondWeight, GridUnitType.Star);
var cloneVm = new LeafViewModel(this);
Parent.Replace(this, nvm);
if (_bPreserveFirst)
{
nvm.FirstChild = this;
nvm.SecondChild = cloneVm;
}
else
{
nvm.SecondChild = this;
nvm.FirstChild = cloneVm;
}
}
public double ToolbarGridRow
{
get
{
return m_ToolbarGridRow;
}
set
{
if (m_ToolbarGridRow == value)
return;
m_ToolbarGridRow = value;
RaisePropertyChanged("ToolbarGridRow");
}
}
[XmlIgnore]
public double SideSize
{
get
{
return m_SideSize;
}
set
{
if (m_SideSize == value)
return;
m_SideSize = value;
RaisePropertyChanged("SideSize");
}
}
[XmlIgnore]
public Arrow ArrowDirection
{
get
{
return m_ArrowDirection;
}
set
{
if (m_ArrowDirection == value)
return;
m_ArrowDirection = value;
RaisePropertyChanged("ArrowDirection");
UpdateArrow();
}
}
[XmlIgnore]
public Visibility LeftSideVisibility
{
get
{
return m_LeftSideVisibility;
}
set
{
if (m_LeftSideVisibility == value)
return;
m_LeftSideVisibility = value;
RaisePropertyChanged("LeftSideVisibility");
}
}
[XmlIgnore]
public Visibility RightSideVisibility
{
get
{
return m_RightSideVisibility;
}
set
{
if (m_RightSideVisibility == value)
return;
m_RightSideVisibility = value;
RaisePropertyChanged("RightSideVisibility");
}
}
[XmlIgnore]
public Visibility TopSideVisibility
{
get
{
return m_TopSideVisibility;
}
set
{
if (m_TopSideVisibility == value)
return;
m_TopSideVisibility = value;
RaisePropertyChanged("TopSideVisibility");
}
}
[XmlIgnore]
public Visibility BottomSideVisibility
{
get
{
return m_BottomSideVisibility;
}
set
{
if (m_BottomSideVisibility == value)
return;
m_BottomSideVisibility = value;
RaisePropertyChanged("BottomSideVisibility");
}
}
[XmlIgnore]
public Visibility LeftArrowVisibility
{
get
{
return m_LeftArrowVisibility;
}
set
{
if (m_LeftArrowVisibility == value)
return;
m_LeftArrowVisibility = value;
RaisePropertyChanged("LeftArrowVisibility");
}
}
[XmlIgnore]
public Visibility RightArrowVisibility
{
get
{
return m_RightArrowVisibility;
}
set
{
if (m_RightArrowVisibility == value)
return;
m_RightArrowVisibility = value;
RaisePropertyChanged("RightArrowVisibility");
}
}
[XmlIgnore]
public Visibility TopArrowVisibility
{
get
{
return m_TopArrowVisibility;
}
set
{
if (m_TopArrowVisibility == value)
return;
m_TopArrowVisibility = value;
RaisePropertyChanged("TopArrowVisibility");
}
}
[XmlIgnore]
public Visibility BottomArrowVisibility
{
get
{
return m_BottomArrowVisibility;
}
set
{
if (m_BottomArrowVisibility == value)
return;
m_BottomArrowVisibility = value;
RaisePropertyChanged("BottomArrowVisibility");
}
}
[XmlIgnore]
public ViewViewModel CurrentView
{
get
{
return m_CurrentView;
}
set
{
if (m_CurrentView == value)
return;
m_CurrentView = value;
RaisePropertyChanged("CurrentView");
UpdateView();
}
}
public string CurrentViewName
{
get
{
return m_CurrentView.ViewName;
}
set
{
var newView = LayoutViewRegistry.RegisteredViews.FirstOrDefault(v => v.ViewName == value);
if (newView != null)
{
CurrentView = newView;
}
}
}
[XmlIgnore]
public FrameworkElement View
{
get
{
return m_View;
}
private set
{
if (m_View == value)
return;
m_View = value;
RaisePropertyChanged("View");
}
}
public void UpdateArrow()
{
LeftArrowVisibility = ArrowDirection == Arrow.Left ? Visibility.Visible : Visibility.Collapsed;
RightArrowVisibility = ArrowDirection == Arrow.Right ? Visibility.Visible : Visibility.Collapsed;
TopArrowVisibility = ArrowDirection == Arrow.Top ? Visibility.Visible : Visibility.Collapsed;
BottomArrowVisibility = ArrowDirection == Arrow.Bottom ? Visibility.Visible : Visibility.Collapsed;
}
public void UpdateView()
{
View = Activator.CreateInstance(CurrentView.ViewType) as FrameworkElement;
}
public override void Replace(InheritedViewModel _from, InheritedViewModel _to)
{
throw new InvalidOperationException();
}
private double m_ToolbarGridRow;
private double m_SideSize;
private Arrow m_ArrowDirection;
private Visibility m_LeftSideVisibility = Visibility.Collapsed;
private Visibility m_RightSideVisibility = Visibility.Collapsed;
private Visibility m_TopSideVisibility = Visibility.Collapsed;
private Visibility m_BottomSideVisibility = Visibility.Collapsed;
private Visibility m_LeftArrowVisibility = Visibility.Collapsed;
private Visibility m_RightArrowVisibility = Visibility.Collapsed;
private Visibility m_TopArrowVisibility = Visibility.Collapsed;
private Visibility m_BottomArrowVisibility = Visibility.Collapsed;
private ViewViewModel m_CurrentView;
private FrameworkElement m_View;
}
}

View File

@@ -0,0 +1,170 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Xml.Serialization;
namespace Tool.Layout.ViewModels
{
public class NodeViewModel : InheritedViewModel
{
public NodeViewModel()
{
FirstWeight = new GridLength(1, GridUnitType.Star);
SecondWeight = new GridLength(1, GridUnitType.Star);
}
public Orientation Orientation
{
get
{
return m_Orientation;
}
set
{
if (m_Orientation == value)
return;
m_Orientation = value;
RaisePropertyChanged("Orientation");
}
}
public InheritedViewModel FirstChild
{
get
{
return m_FirstChild;
}
set
{
if (m_FirstChild == value)
return;
m_FirstChild = value;
RaisePropertyChanged("FirstChild");
UpdateChildren();
}
}
public InheritedViewModel SecondChild
{
get
{
return m_SecondChild;
}
set
{
if (m_SecondChild == value)
return;
m_SecondChild = value;
RaisePropertyChanged("SecondChild");
UpdateChildren();
}
}
[XmlIgnore]
public GridLength FirstWeight
{
get
{
return m_FirstWeight;
}
set
{
if (m_FirstWeight == value)
return;
m_FirstWeight = value;
RaisePropertyChanged("FirstWeight");
}
}
[XmlIgnore]
public GridLength SecondWeight
{
get
{
return m_SecondWeight;
}
set
{
if (m_SecondWeight == value)
return;
m_SecondWeight = value;
RaisePropertyChanged("SecondWeight");
}
}
public string FirstWeightString
{
get
{
return FirstWeight.Value + " " + (int)FirstWeight.GridUnitType;
}
set
{
var tokens = value.Split(' ');
FirstWeight = new GridLength(double.Parse(tokens[0]), (GridUnitType)int.Parse(tokens[1]));
}
}
public string SecondWeightString
{
get
{
return SecondWeight.Value + " " + (int)SecondWeight.GridUnitType;
}
set
{
var tokens = value.Split(' ');
SecondWeight = new GridLength(double.Parse(tokens[0]), (GridUnitType)int.Parse(tokens[1]));
}
}
public void UpdateChildren()
{
if (FirstChild != null)
{
FirstChild.Parent = this;
}
if (SecondChild != null)
{
SecondChild.Parent = this;
}
}
public override void Replace(InheritedViewModel _from, InheritedViewModel _to)
{
if (_from == FirstChild)
{
FirstChild = _to;
}
else if (_from == SecondChild)
{
SecondChild = _to;
}
}
public void MergeSecondToFirst()
{
Parent.Replace(this, SecondChild);
}
public void MergeFirstToSecond()
{
Parent.Replace(this, FirstChild);
}
private Orientation m_Orientation;
private InheritedViewModel m_FirstChild;
private InheritedViewModel m_SecondChild;
private GridLength m_FirstWeight;
private GridLength m_SecondWeight;
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.ViewModels;
namespace Tool.Layout.ViewModels
{
public abstract class NodeViewModelBase : ViewModelBase
{
public abstract void Replace(InheritedViewModel _from, InheritedViewModel _to);
}
}

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Tool.Layout.Interfaces;
using Tool.Layout.Services;
using Tool.ViewModels;
namespace Tool.Layout.ViewModels
{
public class RootViewModel : ViewModelBase
{
public static RootViewModel Instance
{
get
{
if (s_Instance == null)
{
s_Instance = new RootViewModel();
}
return s_Instance;
}
}
private RootViewModel()
{
Windows = new ObservableCollectionEx<WindowViewModel>();
Windows.CollectionChanged += Windows_CollectionChanged;
}
void Windows_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
for (int i = 0; i < Math.Min(m_LayoutWindows.Count, Windows.Count); ++i)
{
m_LayoutWindows[i].WindowViewModel = Windows[i];
}
while (m_LayoutWindows.Count < Windows.Count)
{
var windowType = m_LayoutWindows.Count == 0 ? LayoutViewRegistry.RegisteredMainWindow : LayoutViewRegistry.RegisteredSecondaryWindow;
var window = Activator.CreateInstance(windowType) as ILayoutWindow;
m_LayoutWindows.Add(window);
window.WindowViewModel = Windows[m_LayoutWindows.IndexOf(window)];
(window as Window).Show();
}
while (Windows.Count < m_LayoutWindows.Count)
{
var window = m_LayoutWindows.Last();
m_LayoutWindows.Remove(window);
window.WindowViewModel = null;
(window as Window).Close();
}
}
public ObservableCollectionEx<WindowViewModel> Windows
{
get;
private set;
}
private List<ILayoutWindow> m_LayoutWindows = new List<ILayoutWindow>();
private static RootViewModel s_Instance;
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Xml.Serialization;
using Tool.Layout.Attributes;
using Tool.ViewModels;
namespace Tool.Layout.ViewModels
{
public class ViewViewModel : ViewModelBase
{
[XmlIgnore]
public Type ViewType
{
get
{
return Type.GetType(ViewTypeName);
}
set
{
ViewTypeName = value.AssemblyQualifiedName;
}
}
public string ViewTypeName { get; set; }
public string ViewName { get; set; }
[XmlIgnore]
public System.Windows.Media.ImageSource ViewIcon
{
get
{
var isc = new ImageSourceConverter();
var attribute = ViewType.GetCustomAttributes(typeof(LayoutViewAttribute), true).FirstOrDefault() as LayoutViewAttribute;
if (attribute != null)
{
return isc.ConvertFromInvariantString(attribute.ViewIconPath) as ImageSource;
}
return isc.ConvertFromInvariantString("pack://application:,,,/Tool;component/Images/error.png") as ImageSource;
}
}
}
}

View File

@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Tool.Layout.Services;
namespace Tool.Layout.ViewModels
{
public class WindowViewModel : InheritedViewModel
{
public WindowViewModel()
{
Child = new LeafViewModel();
WindowState = System.Windows.WindowState.Normal;
Width = 1280;
Height = 720;
Left = SystemParameters.PrimaryScreenWidth / 2 - 640;
Top = SystemParameters.PrimaryScreenHeight / 2 - 360;
}
public InheritedViewModel Child
{
get
{
return m_Child;
}
set
{
if (m_Child == value)
return;
m_Child = value;
RaisePropertyChanged("Child");
Child.Parent = this;
}
}
public override void Replace(InheritedViewModel _from, InheritedViewModel _to)
{
if (_from == Child)
{
Child = _to;
}
}
public static WindowViewModel CreateNewWindow()
{
var windowVm = new WindowViewModel();
windowVm.Child = new LeafViewModel() { CurrentView = LayoutViewRegistry.MainView };
RootViewModel.Instance.Windows.Add(windowVm);
return windowVm;
}
public void RegisterWindow(Window _window)
{
_window.StateChanged += Window_StateChanged;
_window.LocationChanged += Window_LocationChanged;
_window.SizeChanged += Wwindow_SizeChanged;
_window.Width = Width;
_window.Height = Height;
_window.Left = Left;
_window.Top = Top;
if (_window.IsLoaded)
{
_window.WindowState = WindowState;
}
else
{
_window.Loaded += _window_Loaded;
}
}
void _window_Loaded(object sender, RoutedEventArgs e)
{
(sender as Window).Loaded -= _window_Loaded;
(sender as Window).WindowState = WindowState;
}
public void UnregisterWindow(Window _window)
{
_window.StateChanged -= Window_StateChanged;
_window.LocationChanged -= Window_LocationChanged;
_window.SizeChanged -= Wwindow_SizeChanged;
}
void Wwindow_SizeChanged(object sender, SizeChangedEventArgs e)
{
Width = (sender as Window).Width;
Height = (sender as Window).Height;
}
void Window_LocationChanged(object sender, EventArgs e)
{
Left = (sender as Window).Left;
Top = (sender as Window).Top;
}
void Window_StateChanged(object sender, EventArgs e)
{
WindowState = (sender as Window).WindowState;
}
public WindowState WindowState { get; set; }
public double Left { get; set; }
public double Top { get; set; }
public double Width { get; set; }
public double Height { get; set; }
private InheritedViewModel m_Child;
}
}

View File

@@ -0,0 +1,132 @@
<UserControl x:Class="Tool.Layout.Views.LeafView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:v="clr-namespace:Tool.Layout.Views"
xmlns:ls="clr-namespace:Tool.Layout.Services"
mc:Ignorable="d" Background="{DynamicResource DarkBackground}"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Background="{DynamicResource GeneralBackground}" Grid.Column="0" Grid.Row="1" Margin="0,0,5,0" Width="{Binding SideSize}" Visibility="{Binding LeftSideVisibility}" />
<Grid Background="{DynamicResource GeneralBackground}" Grid.Column="2" Grid.Row="1" Margin="5,0,0,0" Width="{Binding SideSize}" Visibility="{Binding RightSideVisibility}" />
<Grid Background="{DynamicResource GeneralBackground}" Grid.Column="1" Grid.Row="0" Margin="0,0,0,5" Height="{Binding SideSize}" Visibility="{Binding TopSideVisibility}" />
<Grid Background="{DynamicResource GeneralBackground}" Grid.Column="1" Grid.Row="2" Margin="0,5,0,0" Height="{Binding SideSize}" Visibility="{Binding BottomSideVisibility}" />
<Grid Grid.Column="1" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ContentControl x:Name="cntView" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="{Binding View}">
<ContentControl.Resources>
<Style TargetType="v:ViewBase">
<Setter Property="Leaf" Value="{Binding Leaf, RelativeSource={RelativeSource AncestorType=v:LeafView}}" />
</Style>
</ContentControl.Resources>
</ContentControl>
<ToolBarTray Grid.Row="{Binding ToolbarGridRow}">
<ToolBar Margin="10,0,0,0">
<Grid HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Button x:Name="btnUp" Grid.Column="1" Grid.Row="0" Margin="-3,0,0,-1" Click="btnUp_Click">
<Path Data="M0,4 L4,0 L8,4" Stroke="{DynamicResource Foreground}" StrokeThickness="2" Margin="5,1,2,0" />
</Button>
<Button x:Name="btnDown" Grid.Column="1" Grid.Row="1" Margin="-3,0,0,-1" Click="btnDown_Click">
<Path Data="M0,0 L4,4 L8,0" Stroke="{DynamicResource Foreground}" StrokeThickness="2" Margin="5,0,2,0" />
</Button>
<ComboBox Grid.RowSpan="2" Padding="5,0" SelectedItem="{Binding CurrentView, Mode=TwoWay}" ItemsSource="{x:Static ls:LayoutViewRegistry.RegisteredViews}">
<ComboBox.Template>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid>
<ToggleButton Name="ToggleButton" Margin="0,0,0,-1" Template="{DynamicResource ComboBoxToggleButtonNoArrow}" Grid.Column="2" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
<ContentPresenter Name="ContentSite" IsHitTestVisible="False" TextBlock.Foreground="{DynamicResource Foreground}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Margin="3,2,15,3" VerticalAlignment="Center" HorizontalAlignment="Left" />
<Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide">
<Grid Name="DropDown" MinWidth="{TemplateBinding ActualWidth}" MaxWidth="{TemplateBinding MaxDropDownHeight}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border x:Name="DropDownBorder" CornerRadius="0,0,4,4" Margin="0,-2,0,0" Background="{DynamicResource NormalGradient}" BorderThickness="1" BorderBrush="{DynamicResource DimSeparatingBorder}"/>
<ScrollViewer Margin="2,0,1,1" VerticalScrollBarVisibility="Auto">
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
</ControlTemplate>
</ComboBox.Template>
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" Background="{DynamicResource PseudoTransparent}">
<Image Source="{Binding ViewIcon}" Width="16" Height="16" Stretch="Uniform" />
<TextBlock Text="{Binding ViewName}" Margin="5,0,0,0" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</ToolBar>
<ToolBar Template="{Binding View.ToolBarTemplate}" />
</ToolBarTray>
</Grid>
<Thumb Grid.Column="1" Grid.Row="1" x:Name="tmbBottomLeft" VerticalAlignment="Bottom" HorizontalAlignment="Left" Height="16" Width="16" Cursor="SizeNESW" DragStarted="tmbBottomLeft_DragStarted" DragDelta="tmbBottomLeft_DragDelta" DragCompleted="tmbBottomLeft_DragCompleted">
<Thumb.Template>
<ControlTemplate>
<Canvas Background="{DynamicResource PseudoTransparent}">
<Path Fill="{DynamicResource DarkBackground}" Data="M0,0 L16,16 0,16 Z" />
<Path Stroke="{DynamicResource BrightGradient}">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="1,12" EndPoint="4,15" />
<LineGeometry StartPoint="1,9" EndPoint="7,15" />
<LineGeometry StartPoint="1,6" EndPoint="10,15" />
<LineGeometry StartPoint="1,3" EndPoint="13,15" />
<LineGeometry StartPoint="1,0" EndPoint="16,15" />
</GeometryGroup>
</Path.Data>
</Path>
</Canvas>
</ControlTemplate>
</Thumb.Template>
</Thumb>
<Thumb Grid.Column="1" Grid.Row="1" x:Name="tmbTopRight" VerticalAlignment="Top" HorizontalAlignment="Right" Height="16" Width="16" Cursor="SizeNESW" DragStarted="tmbTopRight_DragStarted" DragDelta="tmbTopRight_DragDelta" DragCompleted="tmbTopRight_DragCompleted">
<Thumb.Template>
<ControlTemplate>
<Canvas Background="{DynamicResource PseudoTransparent}">
<Path Fill="{DynamicResource DarkBackground}" Data="M0,0 L16,0 16,16 Z" />
<Path Stroke="{DynamicResource BrightGradient}">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="13,0" EndPoint="16,3" />
<LineGeometry StartPoint="10,0" EndPoint="16,6" />
<LineGeometry StartPoint="7,0" EndPoint="16,9" />
<LineGeometry StartPoint="4,0" EndPoint="16,12" />
<LineGeometry StartPoint="1,0" EndPoint="16,15" />
</GeometryGroup>
</Path.Data>
</Path>
</Canvas>
</ControlTemplate>
</Thumb.Template>
</Thumb>
<Path Data="M 0,2 L 2,2 2,1 4,3 2,5 2,4 0,4 Z M 6,6 M 0,0" Grid.Column="1" Grid.Row="1" Stretch="Fill" Width="100" Height="100" HorizontalAlignment="Left" Stroke="{DynamicResource DarkBackground}" Fill="{DynamicResource ForegroundGradient}" Visibility="{Binding RightArrowVisibility}" />
<Path Data="M 6,4 L 4,4 4,5 2,3 4,1 4,2 6,2 Z M 6,6 M 0,0" Grid.Column="1" Grid.Row="1" Stretch="Fill" Width="100" Height="100" HorizontalAlignment="Right" Stroke="{DynamicResource DarkBackground}" Fill="{DynamicResource ForegroundGradient}" Visibility="{Binding LeftArrowVisibility}" />
<Path Data="M 4,6 L 4,4 5,4 3,2 1,4 2,4 2,6 Z M 6,6 M 0,0" Grid.Column="1" Grid.Row="1" Stretch="Fill" Width="100" Height="100" VerticalAlignment="Bottom" Stroke="{DynamicResource DarkBackground}" Fill="{DynamicResource ForegroundGradient}" Visibility="{Binding TopArrowVisibility}" />
<Path Data="M 2,0 L 2,2 1,2 3,4 5,2 4,2 4,0 Z M 6,6 M 0,0" Grid.Column="1" Grid.Row="1" Stretch="Fill" Width="100" Height="100" VerticalAlignment="Top" Stroke="{DynamicResource DarkBackground}" Fill="{DynamicResource ForegroundGradient}" Visibility="{Binding BottomArrowVisibility}" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,396 @@
using Tool.Layout.ViewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
namespace Tool.Layout.Views
{
/// <summary>
/// Interaction logic for LeafView.xaml
/// </summary>
public partial class LeafView : UserControl
{
private enum DragMode
{
None,
MergeToLeft,
MergeToTop,
MergeToRight,
MergeToBottom,
SplitToLeft,
SplitToTop,
SplitToRight,
SplitToBottom
}
public LeafView()
{
InitializeComponent();
}
private void tmbBottomLeft_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
{
StartDrag();
}
private void tmbTopRight_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
{
StartDrag();
}
private void tmbBottomLeft_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
BeginDragDelta(e);
if (m_eDragMode == DragMode.None)
{
if (Math.Abs(m_CurrentX) > Math.Abs(m_CurrentY) && Math.Abs(m_CurrentX) > s_DragThreshold) // Start horizontal drag
{
if (m_CurrentX < 0 && CanMergeLeft)
{
m_eDragMode = DragMode.MergeToLeft;
}
else if (m_CurrentX > 0)
{
m_eDragMode = DragMode.SplitToRight;
}
}
else if (Math.Abs(m_CurrentY) > Math.Abs(m_CurrentX) && Math.Abs(m_CurrentY) > s_DragThreshold) // Start vertical drag
{
if (m_CurrentY > 0 && CanMergeBottom)
{
m_eDragMode = DragMode.MergeToBottom;
}
else if (m_CurrentY < 0)
{
m_eDragMode = DragMode.SplitToTop;
}
}
}
HandleDragDelta(e);
}
private void tmbTopRight_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
BeginDragDelta(e);
if (m_eDragMode == DragMode.None)
{
if (Math.Abs(m_CurrentX) > Math.Abs(m_CurrentY) && Math.Abs(m_CurrentX) > s_DragThreshold) // Start horizontal drag
{
if (m_CurrentX > 0 && CanMergeRight)
{
m_eDragMode = DragMode.MergeToRight;
}
else if (m_CurrentX < 0)
{
m_eDragMode = DragMode.SplitToLeft;
}
}
else if (Math.Abs(m_CurrentY) > Math.Abs(m_CurrentX) && Math.Abs(m_CurrentY) > s_DragThreshold) // Start vertical drag
{
if (m_CurrentY < 0 && CanMergeTop)
{
m_eDragMode = DragMode.MergeToTop;
}
else if (m_CurrentY > 0)
{
m_eDragMode = DragMode.SplitToBottom;
}
}
}
HandleDragDelta(e);
}
private void tmbBottomLeft_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
{
HandleDragEnd();
}
private void tmbTopRight_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
{
HandleDragEnd();
}
private void StartDrag()
{
m_eDragMode = DragMode.None;
m_CurrentX = 0;
m_CurrentY = 0;
}
private void BeginDragDelta(System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
if (m_eDragMode == DragMode.MergeToBottom || m_eDragMode == DragMode.MergeToTop || m_eDragMode == DragMode.MergeToLeft || m_eDragMode == DragMode.MergeToRight)
{
m_CurrentX = e.HorizontalChange;
m_CurrentY = e.VerticalChange;
}
else
{
m_CurrentX += e.HorizontalChange;
m_CurrentY += e.VerticalChange;
}
}
private void HandleDragDelta(System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
switch (m_eDragMode)
{
case DragMode.MergeToLeft:
{
if (m_CurrentX > 0)
{
m_eDragMode = DragMode.MergeToRight;
}
UpdateMergeArrows();
break;
}
case DragMode.MergeToTop:
{
if (m_CurrentY > 0)
{
m_eDragMode = DragMode.MergeToBottom;
}
UpdateMergeArrows();
break;
}
case DragMode.MergeToRight:
{
if (m_CurrentX < 0)
{
m_eDragMode = DragMode.MergeToLeft;
}
UpdateMergeArrows();
break;
}
case DragMode.MergeToBottom:
{
if (m_CurrentY < 0)
{
m_eDragMode = DragMode.MergeToTop;
}
UpdateMergeArrows();
break;
}
case DragMode.SplitToLeft:
{
Leaf.RightSideVisibility = m_CurrentX < 0 ? Visibility.Visible : Visibility.Collapsed;
Leaf.SideSize = Math.Max(0, -m_CurrentX);
break;
}
case DragMode.SplitToTop:
{
Leaf.BottomSideVisibility = m_CurrentY < 0 ? Visibility.Visible : Visibility.Collapsed;
Leaf.SideSize = Math.Max(0, -m_CurrentY);
break;
}
case DragMode.SplitToRight:
{
Leaf.LeftSideVisibility = m_CurrentX > 0 ? Visibility.Visible : Visibility.Collapsed;
Leaf.SideSize = Math.Max(0, m_CurrentX);
break;
}
case DragMode.SplitToBottom:
{
Leaf.TopSideVisibility = m_CurrentY > 0 ? Visibility.Visible : Visibility.Collapsed;
Leaf.SideSize = Math.Max(0, m_CurrentY);
break;
}
}
}
private void UpdateMergeArrows()
{
switch (m_eDragMode)
{
case DragMode.MergeToLeft:
{
((Leaf.Parent as NodeViewModel).FirstChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.Left;
((Leaf.Parent as NodeViewModel).SecondChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.None;
break;
}
case DragMode.MergeToTop:
{
((Leaf.Parent as NodeViewModel).FirstChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.Top;
((Leaf.Parent as NodeViewModel).SecondChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.None;
break;
}
case DragMode.MergeToRight:
{
((Leaf.Parent as NodeViewModel).FirstChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.None;
((Leaf.Parent as NodeViewModel).SecondChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.Right;
break;
}
case DragMode.MergeToBottom:
{
((Leaf.Parent as NodeViewModel).FirstChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.None;
((Leaf.Parent as NodeViewModel).SecondChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.Bottom;
break;
}
}
}
private void HandleDragEnd()
{
var dSideSize = Leaf.SideSize;
Leaf.TopSideVisibility = Visibility.Collapsed;
Leaf.BottomSideVisibility = Visibility.Collapsed;
Leaf.LeftSideVisibility = Visibility.Collapsed;
Leaf.RightSideVisibility = Visibility.Collapsed;
Leaf.SideSize = 0;
if (Leaf.Parent is NodeViewModel)
{
var node = Leaf.Parent as NodeViewModel;
if (node.FirstChild is LeafViewModel)
{
(node.FirstChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.None;
}
if (node.SecondChild is LeafViewModel)
{
(node.SecondChild as LeafViewModel).ArrowDirection = LeafViewModel.Arrow.None;
}
}
switch (m_eDragMode)
{
case DragMode.MergeToLeft:
{
ParentNode.MergeSecondToFirst();
break;
}
case DragMode.MergeToTop:
{
ParentNode.MergeSecondToFirst();
break;
}
case DragMode.MergeToRight:
{
ParentNode.MergeFirstToSecond();
break;
}
case DragMode.MergeToBottom:
{
ParentNode.MergeFirstToSecond();
break;
}
case DragMode.SplitToLeft:
{
if (dSideSize > 0)
{
var dWeight = dSideSize / this.ActualWidth;
Leaf.Split(Orientation.Horizontal, true, 1.0 - dWeight, dWeight);
}
break;
}
case DragMode.SplitToTop:
{
if (dSideSize > 0)
{
var dWeight = dSideSize / this.ActualHeight;
Leaf.Split(Orientation.Vertical, true, 1.0 - dWeight, dWeight);
}
break;
}
case DragMode.SplitToRight:
{
if (dSideSize > 0)
{
var dWeight = dSideSize / this.ActualWidth;
Leaf.Split(Orientation.Horizontal, false, dWeight, 1.0 - dWeight);
}
break;
}
case DragMode.SplitToBottom:
{
if (dSideSize > 0)
{
var dWeight = dSideSize / this.ActualHeight;
Leaf.Split(Orientation.Vertical, false, dWeight, 1.0 - dWeight);
}
break;
}
}
}
private bool CanMergeLeft
{
get
{
return Leaf != null && ParentNode != null && ParentNode.Orientation == Orientation.Horizontal && ParentNode.FirstChild is LeafViewModel && ParentNode.SecondChild == Leaf;
}
}
private bool CanMergeTop
{
get
{
return Leaf != null && ParentNode != null && ParentNode.Orientation == Orientation.Vertical && ParentNode.FirstChild is LeafViewModel && ParentNode.SecondChild == Leaf;
}
}
private bool CanMergeRight
{
get
{
return Leaf != null && ParentNode != null && ParentNode.Orientation == Orientation.Horizontal && ParentNode.SecondChild is LeafViewModel && ParentNode.FirstChild == Leaf;
}
}
private bool CanMergeBottom
{
get
{
return Leaf != null && ParentNode != null && ParentNode.Orientation == Orientation.Vertical && ParentNode.SecondChild is LeafViewModel && ParentNode.FirstChild == Leaf;
}
}
private LeafViewModel Leaf
{
get
{
return this.DataContext as LeafViewModel;
}
}
private NodeViewModel ParentNode
{
get
{
return Leaf.Parent as NodeViewModel;
}
}
private void btnUp_Click(object sender, RoutedEventArgs e)
{
Leaf.ToolbarGridRow = 0;
}
private void btnDown_Click(object sender, RoutedEventArgs e)
{
Leaf.ToolbarGridRow = 2;
}
private DragMode m_eDragMode;
private double m_CurrentX;
private double m_CurrentY;
private static readonly double s_DragThreshold = 10;
}
}

View File

@@ -0,0 +1,30 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="HorizontalNodeView">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding FirstWeight, Mode=TwoWay}" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="{Binding SecondWeight, Mode=TwoWay}" />
</Grid.ColumnDefinitions>
<ContentPresenter Grid.Column="0" Content="{Binding FirstChild}" />
<GridSplitter Grid.Column="1" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" Width="5" VerticalAlignment="Stretch" Background="{DynamicResource GeneralBackground}" />
<ContentPresenter Grid.Column="2" Content="{Binding SecondChild}" />
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="VerticalNodeView">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="{Binding FirstWeight, Mode=TwoWay}" />
<RowDefinition Height="5" />
<RowDefinition Height="{Binding SecondWeight, Mode=TwoWay}" />
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="0" Content="{Binding FirstChild}" />
<GridSplitter Grid.Row="1" ResizeBehavior="PreviousAndNext" ResizeDirection="Rows" Height="5" HorizontalAlignment="Stretch" Background="{DynamicResource GeneralBackground}" />
<ContentPresenter Grid.Row="2" Content="{Binding SecondChild}" />
</Grid>
</ControlTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,167 @@
using Tool.Layout.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tool.ViewModels;
using System.Collections.ObjectModel;
namespace Tool.Layout.Views
{
public class ViewBase : UserControl
{
public ViewBase()
{
this.Loaded += ViewBase_Loaded;
this.Unloaded += ViewBase_Unloaded;
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
void Dispatcher_ShutdownStarted(object sender, EventArgs e)
{
if (ViewModel != null)
{
ViewModel.RemoveView(this);
}
}
protected virtual void ViewBase_Unloaded(object sender, RoutedEventArgs e)
{
if (ViewModel != null)
{
ViewModel.RemoveView(this);
}
}
protected virtual void ViewBase_Loaded(object sender, RoutedEventArgs e)
{
if (ViewModel != null)
{
ViewModel.AddView(this);
}
}
public static DependencyProperty LeafProperty = DependencyProperty.Register("Leaf", typeof(LeafViewModel), typeof(ViewBase), new FrameworkPropertyMetadata());
public LeafViewModel Leaf
{
get
{
return GetValue(LeafProperty) as LeafViewModel;
}
set
{
SetValue(LeafProperty, value);
}
}
public static readonly DependencyProperty ToolBarTemplateProperty = DependencyProperty.Register("ToolBarTemplate", typeof(ControlTemplate), typeof(LeafView), new FrameworkPropertyMetadata());
public ControlTemplate ToolBarTemplate
{
get
{
return GetValue(ToolBarTemplateProperty) as ControlTemplate;
}
set
{
SetValue(ToolBarTemplateProperty, value);
}
}
public ViewModelBase ViewModel
{
get
{
return this.DataContext as ViewModelBase;
}
}
public static void DrawText(DrawingContext _context, Brush _brush, Point _point, string _sText, Brush _backgroundBrush = null, HorizontalAlignment _eHAlignment = HorizontalAlignment.Left, VerticalAlignment _eVAlignment = VerticalAlignment.Top)
{
var rect = new Rect(_point, new Size());
DrawText(_context, _brush, ref rect, _sText, _backgroundBrush, _eHAlignment, _eVAlignment);
}
public static void DrawText(DrawingContext _context, Brush _brush, ref Rect _rect, string _sText, Brush _backgroundBrush = null, HorizontalAlignment _eHAlignment = HorizontalAlignment.Left, VerticalAlignment _eVAlignment = VerticalAlignment.Top)
{
if (string.IsNullOrWhiteSpace(_sText))
{
return;
}
var geo = CreateTextGeometry(_sText, 12.0, _rect.Location, _eHAlignment, _eVAlignment);
if (_backgroundBrush != null)
{
_rect = new Rect(_rect.Location, new Size(Math.Max(_rect.Width, geo.Item2), Math.Max(_rect.Height, geo.Item3)));
_context.DrawRectangle(_backgroundBrush, null, _rect);
}
_context.DrawGlyphRun(_brush, geo.Item1);
}
public static Tuple<GlyphRun, double, double> CreateTextGeometry(string _sText, double _fSize, Point _position, HorizontalAlignment _eHAlignment = HorizontalAlignment.Left, VerticalAlignment _eVAlignment = VerticalAlignment.Top)
{
if (s_GlyphTypeface == null)
{
Typeface typeface = new Typeface("Consolas");
if (!typeface.TryGetGlyphTypeface(out s_GlyphTypeface))
{
throw new InvalidOperationException("No glyphtypeface found");
}
}
var key = Tuple.Create(_sText, _fSize);
Tuple<double, ushort[], double[]> cache;
if (!s_dGlyphCache.TryGetValue(key, out cache))
{
var totalWidth = 0d;
int n = 0;
var aGlyphIndices = new ushort[_sText.Length];
var aAdvanceWidths = new double[_sText.Length];
for (; n < _sText.Length; n++)
{
ushort glyphIndex = s_GlyphTypeface.CharacterToGlyphMap[_sText[n]];
var glyphWidth = s_aGlyphWidths[glyphIndex];
if (glyphWidth == 0.0)
{
glyphWidth = s_GlyphTypeface.AdvanceWidths[glyphIndex] * _fSize;
s_aGlyphWidths[glyphIndex] = glyphWidth;
}
aGlyphIndices[n] = glyphIndex;
aAdvanceWidths[n] = glyphWidth;
totalWidth += glyphWidth;
}
s_dGlyphCache[key] = cache = Tuple.Create(totalWidth, aGlyphIndices, aAdvanceWidths);
}
var offsetPosition = new Point(Math.Floor(_position.X), Math.Floor(_position.Y + _fSize));
switch (_eHAlignment)
{
case HorizontalAlignment.Center: offsetPosition.X -= cache.Item1 * 0.5; break;
case HorizontalAlignment.Right: offsetPosition.X -= cache.Item1; break;
}
switch (_eVAlignment)
{
case VerticalAlignment.Center: offsetPosition.Y -= _fSize * 0.5; break;
case VerticalAlignment.Bottom: offsetPosition.Y -= _fSize; break;
}
var gr = new GlyphRun(s_GlyphTypeface, 0, false, _fSize, cache.Item2, offsetPosition, cache.Item3, null, null, null, null, null, null);
return Tuple.Create(gr, cache.Item1, _fSize);
}
private static GlyphTypeface s_GlyphTypeface;
private static Dictionary<Tuple<string, double>, Tuple<double, ushort[], double[]>> s_dGlyphCache = new Dictionary<Tuple<string, double>, Tuple<double, ushort[], double[]>>();
private static double[] s_aGlyphWidths = new double[1024];
}
}

View File

@@ -0,0 +1,31 @@
<UserControl x:Class="Tool.Layout.Views.WindowView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:Tool.Layout.ViewModels"
xmlns:v="clr-namespace:Tool.Layout.Views"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<DataTemplate DataType="{x:Type vm:NodeViewModel}">
<ContentControl x:Name="NodeViewContent" />
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Orientation}" Value="Horizontal">
<Setter TargetName="NodeViewContent" Property="Template" Value="{DynamicResource HorizontalNodeView}" />
</DataTrigger>
<DataTrigger Binding="{Binding Orientation}" Value="Vertical">
<Setter TargetName="NodeViewContent" Property="Template" Value="{DynamicResource VerticalNodeView}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:LeafViewModel}">
<v:LeafView />
</DataTemplate>
</UserControl.Resources>
<Grid>
<ContentPresenter Content="{Binding Child}" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,29 @@
using Tool.Layout.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Tool.Layout.Views
{
/// <summary>
/// Interaction logic for RootNodeView.xaml
/// </summary>
public partial class WindowView : UserControl
{
public WindowView()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,59 @@
<Window x:Class="Tool.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:Tool.Layout.Views"
xmlns:vm="clr-namespace:Tool.Layout.ViewModels"
xmlns:v="clr-namespace:Tool.Layout.Views"
xmlns:views="clr-namespace:Tool.Views"
xmlns:core="clr-namespace:Tool.Views.Core"
Background="{DynamicResource GeneralBackground}"
Title="Alcatraz 64kode (main window)" Height="800" Width="1440">
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+Z" Command="{Binding Undo.UndoCommand}" />
<KeyBinding Gesture="Ctrl+Y" Command="{Binding Undo.RedoCommand}" />
<KeyBinding Gesture="Del" Command="{Binding CurrentFunction.DeleteSelectionCommand}" />
</Window.InputBindings>
<Window.Resources>
<DataTemplate x:Key="DefaultNodeTemplate">
<views:DefaultNodeView />
</DataTemplate>
<DataTemplate x:Key="IfNodeTemplate">
<core:IfView />
</DataTemplate>
<DataTemplate x:Key="ForNodeTemplate">
<core:ForView />
</DataTemplate>
<DataTemplate x:Key="WhileNodeTemplate">
<core:WhileView />
</DataTemplate>
<DataTemplate x:Key="GetNodeTemplate">
<core:GetView />
</DataTemplate>
<DataTemplate x:Key="SetNodeTemplate">
<core:SetView />
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Menu>
<MenuItem Header="_File">
<MenuItem x:Name="mnuNewWindow" Header="_New window" Click="mnuNewWindow_Click" />
<MenuItem x:Name="mnuExit" Header="_Exit" Click="mnuExit_Click" />
</MenuItem>
<MenuItem Header="_Layout">
<MenuItem Header="_Save" x:Name="mnuSaveLayout" Click="mnuSaveLayout_Click" />
<MenuItem Header="Load" ItemsSource="{Binding Layouts, RelativeSource={RelativeSource AncestorType=Window}}">
<MenuItem.ItemTemplate>
<DataTemplate>
<MenuItem Header="{Binding DisplayName}" x:Name="mnuLayout" Click="mnuLayout_Click" />
</DataTemplate>
</MenuItem.ItemTemplate>
</MenuItem>
</MenuItem>
</Menu>
<v:WindowView Grid.Row="1" DataContext="{Binding WindowViewModel, RelativeSource={RelativeSource AncestorType=Window}}" />
</Grid>
</Window>

View File

@@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Tool.Layout.Attributes;
using Tool.Layout.Interfaces;
using Tool.Layout.ViewModels;
using Tool.ViewModels;
using Tool.Views;
namespace Tool
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
[LayoutWindow(true)]
public partial class MainWindow : Window, ILayoutWindow, INotifyPropertyChanged
{
public MainWindow()
{
DataContext = MainViewModel.Instance;
InitializeComponent();
Instance = this;
this.Loaded += MainWindow_Loaded;
this.Closed += MainWindow_Closed;
}
void MainWindow_Closed(object sender, EventArgs e)
{
Content = null;
MainViewModel.Instance.RemoveView(this);
(Application.Current as App).SaveLastLayout();
Application.Current.Shutdown();
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
MainViewModel.Instance.AddView(this);
}
private void mnuLayout_Click(object sender, RoutedEventArgs e)
{
(App.Current as App).LoadLayout((sender as MenuItem).DataContext as LayoutViewModel);
}
private void mnuSaveLayout_Click(object sender, RoutedEventArgs e)
{
(App.Current as App).SaveLayoutAs();
}
public static Window Instance { get; private set; }
public WindowViewModel WindowViewModel
{
get
{
return m_WindowViewModel;
}
set
{
if (m_WindowViewModel == value)
return;
if (m_WindowViewModel != null)
{
m_WindowViewModel.UnregisterWindow(this);
m_WindowViewModel = null;
}
m_WindowViewModel = value;
if (m_WindowViewModel != null)
{
m_WindowViewModel.RegisterWindow(this);
}
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("WindowViewModel"));
}
}
public ObservableCollection<LayoutViewModel> Layouts
{
get
{
return (App.Current as App).Layouts;
}
}
private void mnuNewWindow_Click(object sender, RoutedEventArgs e)
{
WindowViewModel.CreateNewWindow();
}
private void mnuExit_Click(object sender, RoutedEventArgs e)
{
App.Current.Shutdown();
}
private WindowViewModel m_WindowViewModel;
public event PropertyChangedEventHandler PropertyChanged;
}
}

View File

@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tool.Dialogs;
namespace Tool
{
public static class MessageBoxService
{
private static bool showingDialog = false;
public static MessageBox ShowDialog(string _sMessage, string _sDetails, bool _bIsError)
{
if (showingDialog)
{
return null;
}
var dialog = new MessageBox();
if (_bIsError)
{
dialog.InfoIcon.Visibility = System.Windows.Visibility.Collapsed;
}
else
{
dialog.ErrorIcon.Visibility = System.Windows.Visibility.Collapsed;
}
dialog.Message.Text = _sMessage;
dialog.Details.Text = _sDetails;
dialog.Owner = MainWindow.Instance;
showingDialog = true;
dialog.ShowDialog();
showingDialog = false;
return dialog;
}
public static string Input(string message, string defaultValue = null)
{
if (showingDialog)
{
return null;
}
var dialog = new UserInputBox();
dialog.Message.Text = message;
dialog.Owner = MainWindow.Instance;
if (!string.IsNullOrEmpty(defaultValue))
{
dialog.UserInput.Text = defaultValue;
dialog.UserInput.SelectAll();
}
showingDialog = true;
dialog.ShowDialog();
showingDialog = false;
return dialog.UserInput.Text;
}
public static bool Ask(string message)
{
if (showingDialog)
{
return false;
}
var dialog = new YesNoBox();
dialog.Message.Text = message;
dialog.Owner = MainWindow.Instance;
showingDialog = true;
dialog.ShowDialog();
showingDialog = false;
return dialog.Result;
}
public static string Choose(string query, IEnumerable<string> options)
{
if (showingDialog)
{
return null;
}
var dialog = new QueryChooseBox();
dialog.Message.Text = query;
dialog.Options = options.ToList();
dialog.Owner = MainWindow.Instance;
showingDialog = true;
dialog.ShowDialog();
showingDialog = false;
return dialog.Result;
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Tool.ViewModels;
namespace Tool
{
public class NodeTemplateSelector : DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
var vm = item as NodeViewModel;
var element = container as FrameworkElement;
if (element != null && vm != null)
{
if (vm.Model is kode64.Core.If)
{
return element.FindResource("IfNodeTemplate") as DataTemplate;
}
else if (vm.Model is kode64.Core.For)
{
return element.FindResource("ForNodeTemplate") as DataTemplate;
}
else if (vm.Model is kode64.Core.While || vm.Model is kode64.Core.DoWhile)
{
return element.FindResource("WhileNodeTemplate") as DataTemplate;
}
else if (vm.Model is kode64.Core.Get)
{
return element.FindResource("GetNodeTemplate") as DataTemplate;
}
else if (vm.Model is kode64.Core.Set)
{
return element.FindResource("SetNodeTemplate") as DataTemplate;
}
return element.FindResource("DefaultNodeTemplate") as DataTemplate;
}
return null;
}
}
}

View File

@@ -0,0 +1,79 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
namespace Tool
{
public class ObservableCollectionEx<T> : ObservableCollection<T>
{
public virtual void NotifyCollectionChanged()
{
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (!m_bPreventCollectionChangedEvents)
{
base.OnCollectionChanged(e);
}
}
public void AddRange(IEnumerable<T> _range)
{
foreach (var item in _range)
{
Add(item);
}
}
public void Replace(IEnumerable<T> _range, bool _bUseResetEvent = true)
{
m_bPreventCollectionChangedEvents = true;
List<T> oldItems = null;
List<T> newItems = null;
if (!_bUseResetEvent)
{
oldItems = this.Except(_range).ToList();
newItems = _range.Except(this).ToList();
}
Clear();
foreach (var item in _range)
{
Add(item);
}
m_bPreventCollectionChangedEvents = false;
if (_bUseResetEvent)
{
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
else
{
foreach (var oldItem in oldItems)
{
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, oldItem));
}
foreach (var newItem in newItems)
{
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newItem));
}
}
}
public void RemoveAll(IEnumerable<T> range)
{
foreach (var item in range)
{
Remove(item);
}
}
protected bool m_bPreventCollectionChangedEvents = false;
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Tool.ViewModels;
namespace Tool
{
public class PinConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var sPinPath = parameter as string;
if (string.IsNullOrEmpty(sPinPath))
{
return null;
}
var node = value as NodeViewModel;
if (node == null)
{
return null;
}
var tokens = sPinPath.Split('.');
switch (tokens[0])
{
case "Input":
return node.InputPins.FirstOrDefault(p => p.Name == tokens[1]);
case "Output":
return node.OutputPins.FirstOrDefault(p => p.Name == tokens[1]);
case "Exec":
return node.ExecutePins.FirstOrDefault(p => p.Name == tokens[1]);
default:
return null;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tool")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tool.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tool.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,49 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tool.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Specialized.StringCollection Layouts {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["Layouts"]));
}
set {
this["Layouts"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string LastLayout {
get {
return ((string)(this["LastLayout"]));
}
set {
this["LastLayout"] = value;
}
}
}
}

View File

@@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Tool.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="Layouts" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="LastLayout" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Media.Imaging;
using Tool.ViewModels;
namespace Tool
{
public class RelayCommand : ViewModelBase, ICommand
{
public RelayCommand(string _sDisplayName, Action<object> _execute, Predicate<object> _canExecute, string _sIconUri, int _iSortIndex = 0)
{
if (_execute == null)
throw new ArgumentNullException("execute");
m_Execute = _execute;
m_CanExecute = _canExecute;
DisplayName = _sDisplayName;
m_sIconUri = _sIconUri;
SortIndex = _iSortIndex;
}
public int SortIndex
{
get;
private set;
}
public string DisplayName
{
get;
private set;
}
public Image Icon
{
get
{
if (m_sIconUri == null)
return null;
var image = new Image();
image.Source = new BitmapImage(new Uri(m_sIconUri));
image.Width = 16;
image.Height = 16;
image.Stretch = Stretch.UniformToFill;
image.VerticalAlignment = VerticalAlignment.Center;
image.HorizontalAlignment = HorizontalAlignment.Center;
return image;
}
}
public bool CanExecute(object parameter)
{
return m_CanExecute == null ? true : m_CanExecute(parameter);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter)
{
m_Execute(parameter);
}
private readonly string m_sIconUri;
private readonly Action<object> m_Execute;
private readonly Predicate<object> m_CanExecute;
}
}

View File

@@ -0,0 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Tool">
<local:NodeTemplateSelector x:Key="NodeTemplateSelector" />
<local:PinConverter x:Key="PinConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</ResourceDictionary>

View File

@@ -0,0 +1,96 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Color x:Key="TextShadowColor">Black</Color>
<Color x:Key="DarkBackgroundColor">#1B1B1B</Color>
<Color x:Key="LightBackgroundColor">#333333</Color>
<Color x:Key="GeneralBackgroundColor">#202020</Color>
<Color x:Key="ForegroundColor">#D8D8D8</Color>
<Color x:Key="DimForegroundColor">#909090</Color>
<SolidColorBrush x:Key="GroupBackground" Color="#3A3A3A" />
<SolidColorBrush x:Key="LightBackground" Color="{StaticResource LightBackgroundColor}" />
<SolidColorBrush x:Key="GeneralBackground" Color="{StaticResource GeneralBackgroundColor}" />
<SolidColorBrush x:Key="DarkBackground" Color="{StaticResource DarkBackgroundColor}" />
<SolidColorBrush x:Key="Highlight" Color="#B8B8B8" />
<SolidColorBrush x:Key="Foreground" Color="{StaticResource ForegroundColor}" />
<SolidColorBrush x:Key="GroupText" Color="#C8C8C8" />
<SolidColorBrush x:Key="DimForeground" Color="{StaticResource DimForegroundColor}" />
<SolidColorBrush x:Key="LightSeparatingBorder" Color="#505050" />
<SolidColorBrush x:Key="SeparatingBorder" Color="#3A3A3A" />
<SolidColorBrush x:Key="DimSeparatingBorder" Color="#2D2D2D" />
<SolidColorBrush x:Key="DarkSeparatingBorder" Color="#111111" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#2D2D2D" />
<SolidColorBrush x:Key="SnapGuide" Color="#80A0A0A0" />
<SolidColorBrush x:Key="TimeMarker" Color="DarkGray" Opacity="0.4" />
<SolidColorBrush x:Key="TimeMarkerQuarterSecond" Color="OrangeRed" Opacity="0.4" />
<SolidColorBrush x:Key="TimeMarkerHalfSecond" Color="Orange" Opacity="0.4" />
<SolidColorBrush x:Key="TimeMarkerSecond" Color="Gold" Opacity="0.4" />
<SolidColorBrush x:Key="PlayPositionGuide" Color="Red" />
<SolidColorBrush x:Key="MenuBorder" Color="#707070" />
<SolidColorBrush x:Key="MenuBackground" Color="#505050" />
<SolidColorBrush x:Key="SeparatorHighlight" Color="#707070" />
<SolidColorBrush x:Key="SeparatorShadow" Color="#505050" />
<SolidColorBrush x:Key="LongOperationBackground" Color="#A0000000" />
<LinearGradientBrush x:Key="HighlightGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#D8D8D8" Offset="0" />
<GradientStop Color="#C8C8C8" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ForegroundGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#B5B5B5" Offset="0" />
<GradientStop Color="#949494" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="BrightGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#606060" Offset="0" />
<GradientStop Color="#505050" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="LightGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#505050" Offset="0" />
<GradientStop Color="#404040" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#404040" Offset="0" />
<GradientStop Color="#383838" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="BarGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#2B2B2B" Offset="0" />
<GradientStop Color="#1C1C1C" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="SunkenGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#2C2C2C" Offset="0" />
<GradientStop Color="#3B3B3B" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="SunkenBorder" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#2D2D2D" Offset="0" />
<GradientStop Color="#606060" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ScrollbarGradient" EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#252525" Offset="0" />
<GradientStop Color="#2B2B2B" Offset="0.135" />
<GradientStop Color="#2B2B2B" Offset="0.865" />
<GradientStop Color="#252525" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="PseudoTransparent" Color="#01808080" />
<SolidColorBrush x:Key="TimelineItemForeground" Color="White" />
<LinearGradientBrush x:Key="TimelineItemGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#40000000" Offset="0" />
<GradientStop Color="#80000000" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="ToggleHBackgroundBright" Color="#E8E8E8" />
<SolidColorBrush x:Key="ToggleHForegroundBright" Color="#000000" />
<SolidColorBrush x:Key="ToggleHBackgroundDark" Color="#808080" />
<SolidColorBrush x:Key="ToggleHForegroundDark" Color="#606060" />
</ResourceDictionary>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,101 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Color x:Key="TextShadowColor">White</Color>
<Color x:Key="DarkBackgroundColor">#F0F0F0</Color>
<Color x:Key="GeneralBackgroundColor">#F4F4F4</Color>
<Color x:Key="LightBackgroundColor">#FAFAFA</Color>
<Color x:Key="ForegroundColor">#404040</Color>
<Color x:Key="DimForegroundColor">#606060</Color>
<SolidColorBrush x:Key="GroupBackground" Color="#FFFFFF" />
<SolidColorBrush x:Key="LightBackground" Color="{StaticResource LightBackgroundColor}" />
<SolidColorBrush x:Key="GeneralBackground" Color="{StaticResource GeneralBackgroundColor}" />
<SolidColorBrush x:Key="DarkBackground" Color="{StaticResource DarkBackgroundColor}" />
<SolidColorBrush x:Key="Highlight" Color="#383838" />
<SolidColorBrush x:Key="Foreground" Color="{StaticResource ForegroundColor}" />
<SolidColorBrush x:Key="GroupText" Color="#505050" />
<SolidColorBrush x:Key="DimForeground" Color="{StaticResource DimForegroundColor}" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#8D8D8D" />
<LinearGradientBrush x:Key="HighlightGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#787878" Offset="0" />
<GradientStop Color="#585858" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ForegroundGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#555555" Offset="0" />
<GradientStop Color="#333333" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="LightSeparatingBorder" Color="#D0D0D0" />
<SolidColorBrush x:Key="SeparatingBorder" Color="#CACACA" />
<SolidColorBrush x:Key="DimSeparatingBorder" Color="#C0C0C0" />
<SolidColorBrush x:Key="DarkSeparatingBorder" Color="#A8A8A8" />
<SolidColorBrush x:Key="SnapGuide" Color="#80404040" />
<SolidColorBrush x:Key="PlayPositionGuide" Color="Red" />
<SolidColorBrush x:Key="TimeMarker" Color="DarkGray" Opacity="0.6" />
<SolidColorBrush x:Key="TimeMarkerQuarterSecond" Color="OrangeRed" Opacity="0.4" />
<SolidColorBrush x:Key="TimeMarkerHalfSecond" Color="Orange" Opacity="0.4" />
<SolidColorBrush x:Key="TimeMarkerSecond" Color="Gold" Opacity="0.4" />
<SolidColorBrush x:Key="MenuBorder" Color="#F0F0F0" />
<SolidColorBrush x:Key="MenuBackground" Color="#E0E0E0" />
<SolidColorBrush x:Key="SeparatorHighlight" Color="#F0F0F0" />
<SolidColorBrush x:Key="SeparatorShadow" Color="#D0D0D0" />
<SolidColorBrush x:Key="LongOperationBackground" Color="#A0FFFFFF" />
<LinearGradientBrush x:Key="BrightGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFFFF" Offset="0" />
<GradientStop Color="#F0F0F0" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="LightGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#F0F0F0" Offset="0" />
<GradientStop Color="#E0E0E0" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#E0E0E0" Offset="0" />
<GradientStop Color="#D8D8D8" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="BarGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFFFF" Offset="0" />
<GradientStop Color="#D0D0D0" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="SunkenGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#CCCCCC" Offset="0" />
<GradientStop Color="#DBDBDB" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="SunkenBorder" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#9D9D9D" Offset="0" />
<GradientStop Color="#E0E0E0" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="ScrollbarGradient" EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#C5C5C5" Offset="0" />
<GradientStop Color="#CBCBCB" Offset="0.135" />
<GradientStop Color="#CBCBCB" Offset="0.865" />
<GradientStop Color="#C5C5C5" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="PseudoTransparent" Color="#01808080" />
<SolidColorBrush x:Key="TimelineItemForeground" Color="White" />
<LinearGradientBrush x:Key="TimelineItemGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#40FFFFFF" Offset="0" />
<GradientStop Color="#40000000" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush x:Key="ToggleHBackgroundBright" Color="#FFFFFF" />
<SolidColorBrush x:Key="ToggleHForegroundBright" Color="#000000" />
<SolidColorBrush x:Key="ToggleHBackgroundDark" Color="#C0C0C0" />
<SolidColorBrush x:Key="ToggleHForegroundDark" Color="#808080" />
</ResourceDictionary>

321
64kode/src/Tool/Tool.csproj Normal file
View File

@@ -0,0 +1,321 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8F47CC11-D2A1-4C38-8ECF-30BCEDA2208B}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Tool</RootNamespace>
<AssemblyName>Tool</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Actions\ActionBase.cs" />
<Compile Include="Actions\AddNewNodeAction.cs" />
<Compile Include="Actions\ChangePropertyAction.cs" />
<Compile Include="Actions\ChangeSelectionAction.cs" />
<Compile Include="Actions\DeleteLinkAction.cs" />
<Compile Include="Actions\DeleteNodeAction.cs" />
<Compile Include="Dialogs\MessageBox.xaml.cs">
<DependentUpon>MessageBox.xaml</DependentUpon>
</Compile>
<Compile Include="Dialogs\QueryChooseBox.xaml.cs">
<DependentUpon>QueryChooseBox.xaml</DependentUpon>
</Compile>
<Compile Include="Dialogs\UserInputBox.xaml.cs">
<DependentUpon>UserInputBox.xaml</DependentUpon>
</Compile>
<Compile Include="Dialogs\YesNoBox.xaml.cs">
<DependentUpon>YesNoBox.xaml</DependentUpon>
</Compile>
<Compile Include="IUndoContext.cs" />
<Compile Include="IUndoItem.cs" />
<Compile Include="Layout\Attributes\LayoutViewAttribute.cs" />
<Compile Include="Layout\Attributes\LayoutWindowAttribute.cs" />
<Compile Include="Layout\Attributes\MainLayoutViewAttribute.cs" />
<Compile Include="Layout\Interfaces\ILayoutWindow.cs" />
<Compile Include="Layout\Services\LayoutViewRegistry.cs" />
<Compile Include="Layout\ViewModels\InheritedViewModel.cs" />
<Compile Include="Layout\ViewModels\LayoutViewModel.cs" />
<Compile Include="Layout\ViewModels\LeafViewModel.cs" />
<Compile Include="Layout\ViewModels\NodeViewModel.cs" />
<Compile Include="Layout\ViewModels\NodeViewModelBase.cs" />
<Compile Include="Layout\ViewModels\RootViewModel.cs" />
<Compile Include="Layout\ViewModels\ViewViewModel.cs" />
<Compile Include="Layout\ViewModels\WindowViewModel.cs" />
<Compile Include="Layout\Views\LeafView.xaml.cs">
<DependentUpon>LeafView.xaml</DependentUpon>
</Compile>
<Compile Include="Layout\Views\ViewBase.cs" />
<Compile Include="Layout\Views\WindowView.xaml.cs">
<DependentUpon>WindowView.xaml</DependentUpon>
</Compile>
<Compile Include="MessageBoxService.cs" />
<Compile Include="Views\NodeGraphView.xaml.cs">
<DependentUpon>NodeGraphView.xaml</DependentUpon>
</Compile>
<Compile Include="NodeTemplateSelector.cs" />
<Compile Include="ObservableCollectionEx.cs" />
<Compile Include="PinConverter.cs" />
<Compile Include="RelayCommand.cs" />
<Compile Include="ViewModels\ExecutePinViewModel.cs" />
<Compile Include="ViewModels\FunctionCallViewModel.cs" />
<Compile Include="ViewModels\FunctionViewModel.cs" />
<Compile Include="ViewModels\InputPinViewModel.cs" />
<Compile Include="ViewModels\LinkViewModel.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="ViewModels\NodeViewModel.cs" />
<Compile Include="ViewModels\OutputPinViewModel.cs" />
<Compile Include="ViewModels\PinViewModelBase.cs" />
<Compile Include="ViewModels\RootPinViewModel.cs" />
<Compile Include="ViewModels\UndoRedoViewModel.cs" />
<Compile Include="ViewModels\VariableNodeViewModel.cs" />
<Compile Include="ViewModels\VariableViewModel.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="Views\Core\ForView.xaml.cs">
<DependentUpon>ForView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\GetView.xaml.cs">
<DependentUpon>GetView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\IfView.xaml.cs">
<DependentUpon>IfView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\SetView.xaml.cs">
<DependentUpon>SetView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\WhileView.xaml.cs">
<DependentUpon>WhileView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DefaultNodeView.xaml.cs">
<DependentUpon>DefaultNodeView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ExecutePinView.xaml.cs">
<DependentUpon>ExecutePinView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\InputPinView.xaml.cs">
<DependentUpon>InputPinView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Link.cs" />
<Compile Include="Views\LinksView.xaml.cs">
<DependentUpon>LinksView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\NodeViewBase.cs" />
<Compile Include="Views\OutputPinView.xaml.cs">
<DependentUpon>OutputPinView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PinViewBase.cs" />
<Compile Include="Views\RootPinView.xaml.cs">
<DependentUpon>RootPinView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\VariablesView.xaml.cs">
<DependentUpon>VariablesView.xaml</DependentUpon>
</Compile>
<Page Include="Dialogs\MessageBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Dialogs\QueryChooseBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Dialogs\UserInputBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Dialogs\YesNoBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Layout\Views\LeafView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Layout\Views\Resources.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Layout\Views\WindowView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Views\NodeGraphView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resources.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Dark\Theme.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Shared\Controls.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\White\Theme.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Core\ForView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Core\GetView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Core\IfView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Core\SetView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Core\WhileView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\DefaultNodeView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ExecutePinView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\InputPinView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\LinksView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\OutputPinView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\RootPinView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\VariablesView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ToolBridge\ToolBridge.vcxproj">
<Project>{4ac87545-9f48-48a7-a84a-95c84ba97921}</Project>
<Name>ToolBridge</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\audio.png" />
<Resource Include="Images\bigerror.png" />
<Resource Include="Images\biginfo.png" />
<Resource Include="Images\error.png" />
<Resource Include="Images\explorer.png" />
<Resource Include="Images\histogram.png" />
<Resource Include="Images\intro.png" />
<Resource Include="Images\notepad++.png" />
<Resource Include="Images\parade.png" />
<Resource Include="Images\sync.png" />
<Resource Include="Images\thumb.png" />
<Resource Include="Images\vectorscope.png" />
<Resource Include="Images\warning.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="Actions\AddNewVariableAction.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using kode64;
using Tool.Views;
namespace Tool.ViewModels
{
public class ExecutePinViewModel : PinViewModelBase
{
public ExecutePinViewModel(NodeViewModel _ownerNode, ExecPin _pin, string _sName)
: base(_ownerNode, _sName)
{
m_Pin = _pin;
}
internal void ConnectTo(RootPinViewModel _target)
{
m_Pin.node = _target.OwnerNode.Model;
m_lLinks.Clear();
m_lLinks.Add(new Link());
m_Connection = _target;
_target.m_Connection = this;
UpdateLinks();
}
internal void Disconnect()
{
m_Connection.m_Connection = null;
m_lLinks.Clear();
m_Pin.node = null;
m_Connection = null;
}
public override void UpdateLinks()
{
if (m_Connection == null)
{
return;
}
var main = OwnerNode.Main;
m_lLinks[0].Update(Offset.X, Offset.Y, m_Connection.Offset.X, m_Connection.Offset.Y, false, true);
}
public ExecPin m_Pin;
public RootPinViewModel m_Connection;
}
}

Some files were not shown because too many files have changed in this diff Show More