├── .gitattributes ├── Resources ├── MM.gif ├── demo.png ├── for.png ├── GoNode.gif ├── Search.png ├── code1.png ├── code2.png ├── delete.gif ├── nodes.png ├── splash.gif ├── Conn_full.gif ├── comment1.png ├── v_formula.png ├── for_console.png ├── Gauge_Perform.gif ├── ob_link_poss.gif ├── ob_link_simple.gif ├── v_form_graph.png ├── var_drag_drop.gif ├── connectors_diag.png └── Tree_Nodes_Altered.gif ├── Nodes ├── Nodes │ ├── Resources │ │ └── Array.png │ ├── Nodes │ │ ├── Math │ │ │ ├── Tan.cs │ │ │ ├── Abs.cs │ │ │ ├── exp.cs │ │ │ ├── log.cs │ │ │ ├── Cos.cs │ │ │ ├── Floor.cs │ │ │ ├── Log10.cs │ │ │ ├── Trunc.cs │ │ │ ├── Ceiling.cs │ │ │ ├── Sin.cs │ │ │ ├── Divide.cs │ │ │ ├── Sum.cs │ │ │ ├── Multiply.cs │ │ │ └── Subtract.cs │ │ ├── Logic │ │ │ ├── LogicalNode.cs │ │ │ ├── Equal.cs │ │ │ ├── Greater.cs │ │ │ ├── NotEqual.cs │ │ │ ├── LesserEqual.cs │ │ │ ├── GreaterEqual.cs │ │ │ ├── Lesser.cs │ │ │ └── IfElse.cs │ │ ├── Characters │ │ │ ├── Tolower.cs │ │ │ ├── Toupper.cs │ │ │ ├── Substr.cs │ │ │ └── Grep.cs │ │ ├── R │ │ │ ├── Basics │ │ │ │ ├── Vector1D.cs │ │ │ │ ├── Cat.cs │ │ │ │ ├── Print.cs │ │ │ │ ├── GenericRArray.cs │ │ │ │ ├── NumericRArray.cs │ │ │ │ └── CharacterRArray.cs │ │ │ ├── RCore │ │ │ │ ├── Library.cs │ │ │ │ └── Install.cs │ │ │ ├── Plotting │ │ │ │ └── Plot.cs │ │ │ └── CSV │ │ │ │ └── ReadCSV.cs │ │ └── Loops │ │ │ ├── While.cs │ │ │ └── For.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Nodes.csproj └── Nodes.sln ├── VisualSR ├── MediaResources │ ├── Cross.png │ ├── info.png │ ├── tick.png │ ├── Package.png │ ├── Search.png │ ├── Warning.png │ ├── Operations │ │ └── Run.png │ ├── handle_resize.png │ ├── VariablesListIcons │ │ ├── Object.png │ │ ├── Plus.png │ │ ├── Details.png │ │ ├── PlusHover.png │ │ └── Types │ │ │ ├── Generic.png │ │ │ ├── Logical.png │ │ │ ├── Numeric.png │ │ │ ├── Character.png │ │ │ ├── DataFrame.png │ │ │ └── List_Matrix_etc.png │ └── ContentsBrowser │ │ └── Icons │ │ └── file-icon-md.png ├── BasicNodes │ ├── FileMirrorNode.cs │ ├── ReturnNode.cs │ ├── StartNode.cs │ ├── ReadFile.cs │ ├── Get.cs │ ├── Set.cs │ └── SpaghettiDivider.cs ├── packages.config ├── App.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Themes │ └── Icons.xaml ├── App.xaml.cs ├── Tools │ ├── CollectionsCleaner.cs │ ├── UnitsCalculator.cs │ ├── PointsCalculator.cs │ ├── Cipher.cs │ ├── PluginsManager.cs │ ├── ListUtilities.cs │ └── Hub.cs ├── App.xaml ├── VisualSR.sln ├── Compiler │ ├── GenerateCode.cs │ └── Builder.cs ├── Controls │ ├── PortControlsCollection.cs │ ├── Notification.cs │ ├── InnerMessageBox.cs │ └── Search.cs └── Core │ ├── RVariable.cs │ ├── Wire.cs │ └── Brain.cs ├── demo ├── demo │ ├── App.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── App.xaml.cs │ ├── Basic.xaml │ ├── Performance.xaml.cs │ ├── VariablesList.xaml.cs │ ├── Basic.xaml.cs │ ├── App.xaml │ ├── VariablesList.xaml │ ├── Performance.xaml │ ├── SaveLoad.xaml │ ├── SaveLoad.xaml.cs │ ├── Standard.xaml │ ├── Standard.xaml.cs │ ├── Advanced.xaml.cs │ ├── Advanced.xaml │ ├── MainWindow.xaml.cs │ └── MainWindow.xaml └── demo.sln ├── LICENSE └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Resources/MM.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/MM.gif -------------------------------------------------------------------------------- /Resources/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/demo.png -------------------------------------------------------------------------------- /Resources/for.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/for.png -------------------------------------------------------------------------------- /Resources/GoNode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/GoNode.gif -------------------------------------------------------------------------------- /Resources/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/Search.png -------------------------------------------------------------------------------- /Resources/code1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/code1.png -------------------------------------------------------------------------------- /Resources/code2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/code2.png -------------------------------------------------------------------------------- /Resources/delete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/delete.gif -------------------------------------------------------------------------------- /Resources/nodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/nodes.png -------------------------------------------------------------------------------- /Resources/splash.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/splash.gif -------------------------------------------------------------------------------- /Resources/Conn_full.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/Conn_full.gif -------------------------------------------------------------------------------- /Resources/comment1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/comment1.png -------------------------------------------------------------------------------- /Resources/v_formula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/v_formula.png -------------------------------------------------------------------------------- /Resources/for_console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/for_console.png -------------------------------------------------------------------------------- /Resources/Gauge_Perform.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/Gauge_Perform.gif -------------------------------------------------------------------------------- /Resources/ob_link_poss.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/ob_link_poss.gif -------------------------------------------------------------------------------- /Resources/ob_link_simple.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/ob_link_simple.gif -------------------------------------------------------------------------------- /Resources/v_form_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/v_form_graph.png -------------------------------------------------------------------------------- /Resources/var_drag_drop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/var_drag_drop.gif -------------------------------------------------------------------------------- /Resources/connectors_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/connectors_diag.png -------------------------------------------------------------------------------- /Nodes/Nodes/Resources/Array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Nodes/Nodes/Resources/Array.png -------------------------------------------------------------------------------- /Resources/Tree_Nodes_Altered.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/Resources/Tree_Nodes_Altered.gif -------------------------------------------------------------------------------- /VisualSR/MediaResources/Cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/Cross.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/info.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/tick.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/Package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/Package.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/Search.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/Warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/Warning.png -------------------------------------------------------------------------------- /VisualSR/BasicNodes/FileMirrorNode.cs: -------------------------------------------------------------------------------- 1 | namespace VisualSR.BasicNodes 2 | { 3 | public class FileMirrorNode 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /VisualSR/MediaResources/Operations/Run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/Operations/Run.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/handle_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/handle_resize.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Object.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Plus.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Details.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/PlusHover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/PlusHover.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Types/Generic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Types/Generic.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Types/Logical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Types/Logical.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Types/Numeric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Types/Numeric.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/ContentsBrowser/Icons/file-icon-md.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/ContentsBrowser/Icons/file-icon-md.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Types/Character.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Types/Character.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Types/DataFrame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Types/DataFrame.png -------------------------------------------------------------------------------- /VisualSR/MediaResources/VariablesListIcons/Types/List_Matrix_etc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alaabenfatma/VisualSR/HEAD/VisualSR/MediaResources/VariablesListIcons/Types/List_Matrix_etc.png -------------------------------------------------------------------------------- /VisualSR/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /VisualSR/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /demo/demo/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /VisualSR/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /VisualSR/Themes/Icons.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | -------------------------------------------------------------------------------- /VisualSR/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace VisualSR 4 | { 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | public App() 11 | { 12 | ShutdownMode = ShutdownMode.OnLastWindowClose; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /VisualSR/Tools/CollectionsCleaner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace UnrealData.Tools 8 | { 9 | public class CollectionsCleaner 10 | { 11 | public void ClearDuplications() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/demo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace demo 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /VisualSR/Tools/UnitsCalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace VisualSR.Tools 4 | { 5 | public static class UnitsCalculator 6 | { 7 | public static string SizeCalc(long byteCount) 8 | { 9 | string[] suf = {"B", "KB", "MB", "GB", "TB", "PB", "EB"}; 10 | if (byteCount == 0) 11 | return "0" + suf[0]; 12 | var bytes = Math.Abs(byteCount); 13 | var place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024))); 14 | var num = Math.Round(bytes / Math.Pow(1024, place), 1); 15 | return Math.Sign(byteCount) * num + suf[place]; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /demo/demo/Basic.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /VisualSR/BasicNodes/ReturnNode.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media; 2 | using VisualSR.Core; 3 | 4 | namespace VisualSR.BasicNodes 5 | { 6 | public class ReturnNode : Node 7 | { 8 | public ReturnNode(VirtualControl host, bool spontaneousAddition = true) : base(host, NodeTypes.Return, 9 | spontaneousAddition) 10 | { 11 | Background = Brushes.WhiteSmoke; 12 | Title = "Return"; 13 | Description = "This value will reflect the passed value as a return value."; 14 | AddExecPort(this, "", PortTypes.Input, ""); 15 | AddObjectPort(this, "return value", PortTypes.Input, RTypes.Generic, false); 16 | } 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /demo/demo/Performance.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Shapes; 14 | 15 | namespace demo 16 | { 17 | /// 18 | /// Interaction logic for Performance.xaml 19 | /// 20 | public partial class Performance : Window 21 | { 22 | public Performance() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /VisualSR/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /demo/demo/VariablesList.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Shapes; 14 | 15 | namespace demo 16 | { 17 | /// 18 | /// Interaction logic for VariablesList.xaml 19 | /// 20 | public partial class VariablesList : Window 21 | { 22 | public VariablesList() 23 | { 24 | InitializeComponent(); 25 | Loaded += (s, e) => { vars.Host = MagicBox; }; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /demo/demo/Basic.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Shapes; 14 | 15 | namespace demo 16 | { 17 | /// 18 | /// Interaction logic for Basic.xaml 19 | /// 20 | public partial class Basic : Window 21 | { 22 | public Basic() 23 | { 24 | Loaded += MyWindow_Loaded; 25 | 26 | } 27 | private void MyWindow_Loaded(object sender, RoutedEventArgs e) 28 | { 29 | InitializeComponent(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /demo/demo/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /VisualSR/BasicNodes/StartNode.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media; 2 | using VisualSR.Core; 3 | using VisualSR.Tools; 4 | 5 | namespace VisualSR.BasicNodes 6 | { 7 | public class StartNode : Node 8 | { 9 | public StartNode(VirtualControl host, bool addDirectly = false) : base(host, NodeTypes.Root) 10 | { 11 | Background = Brushes.WhiteSmoke; 12 | Title = "Start"; 13 | AddExecPort(this, "", PortTypes.Output, "Execute first node"); 14 | Description = "The root node."; 15 | } 16 | 17 | public override string GenerateCode() 18 | { 19 | var path = Hub.WorkSpace.Replace(@"\", @"\\"); 20 | return @"#Artificial code. Generated using VisualSR. 21 | setwd(""" + path + @""")"; 22 | } 23 | 24 | public override void Delete(bool deletedByBrain = false) 25 | { 26 | //Not a chance :-) 27 | } 28 | 29 | public override Node Clone() 30 | { 31 | return null; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /VisualSR/VisualSR.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualSR", "VisualSR.csproj", "{AA62D03A-7724-4035-AD2C-28BF357CADBA}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {AA62D03A-7724-4035-AD2C-28BF357CADBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {AA62D03A-7724-4035-AD2C-28BF357CADBA}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {AA62D03A-7724-4035-AD2C-28BF357CADBA}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {AA62D03A-7724-4035-AD2C-28BF357CADBA}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /demo/demo/VariablesList.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /demo/demo/Performance.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alaa Ben Fatma 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /demo/demo/SaveLoad.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /demo/demo.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30128.74 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "demo", "demo\demo.csproj", "{DFAA96DD-772F-459B-A793-6CE13EB0BEF9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {DFAA96DD-772F-459B-A793-6CE13EB0BEF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {DFAA96DD-772F-459B-A793-6CE13EB0BEF9}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {DFAA96DD-772F-459B-A793-6CE13EB0BEF9}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {DFAA96DD-772F-459B-A793-6CE13EB0BEF9}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {126AE4CD-FCCF-4DD9-A5DD-1F51F0F8ADE6} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Nodes/Nodes.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30128.74 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nodes", "Nodes\Nodes.csproj", "{B4DCEC74-E9BA-4D95-928F-3B81F8BF3275}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B4DCEC74-E9BA-4D95-928F-3B81F8BF3275}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {B4DCEC74-E9BA-4D95-928F-3B81F8BF3275}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {B4DCEC74-E9BA-4D95-928F-3B81F8BF3275}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {B4DCEC74-E9BA-4D95-928F-3B81F8BF3275}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {8968B877-A1F1-401C-8851-77DE5C455F8D} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /VisualSR/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace VisualSR.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /demo/demo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace demo.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /demo/demo/SaveLoad.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Windows; 3 | using VisualSR.Tools; 4 | using Microsoft.Win32; 5 | 6 | namespace demo 7 | { 8 | /// 9 | /// Interaction logic for SaveLoad.xaml 10 | /// 11 | public partial class SaveLoad : Window 12 | { 13 | public SaveLoad() 14 | { 15 | InitializeComponent(); 16 | save.Click += (s, e) => Save(); 17 | load.Click += (s, e) => Load(); 18 | } 19 | 20 | private void Save() 21 | { 22 | var sfd = new SaveFileDialog(); 23 | sfd.Filter = "CDE file (*.cde)|*.cde"; 24 | sfd.FileName = "ProjectName"; 25 | var save = sfd.ShowDialog(); 26 | if (save == true) 27 | File.WriteAllText(sfd.FileName, vControl.SerializeAll()); 28 | } 29 | 30 | private void Load() 31 | { 32 | var ofd = new OpenFileDialog(); 33 | ofd.Filter = "CDE file (*.cde)|*.cde"; 34 | var save = ofd.ShowDialog(); 35 | if (save == true) 36 | Hub.LoadVirtualData(vControl, File.ReadAllText(ofd.FileName)); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /demo/demo/Standard.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Tan.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Core; 3 | 4 | namespace Nodes.Nodes.Math 5 | { 6 | [Export(typeof(Node))] 7 | public class Tan : Node 8 | { 9 | private readonly VirtualControl Host; 10 | 11 | [ImportingConstructor] 12 | public Tan([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base(host, 13 | NodeTypes.Basic, 14 | spontaneousAddition) 15 | { 16 | Host = host; 17 | Title = "Tan"; 18 | Category = "Math nodes"; 19 | Description = "Calculates tan(x)."; 20 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 21 | AddObjectPort(this, "return tan(value)", PortTypes.Output, RTypes.Numeric, true); 22 | InputPorts[0].DataChanged += (s, e) => 23 | { 24 | OutputPorts[0].Data.Value = "tan(" + InputPorts[0].Data.Value + ")"; 25 | }; 26 | } 27 | 28 | public override string GenerateCode() 29 | { 30 | return null; 31 | } 32 | 33 | public override Node Clone() 34 | { 35 | var node = new Tan(Host); 36 | 37 | return node; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Abs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Abs : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Abs([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base(host, 15 | NodeTypes.Basic, 16 | spontaneousAddition) 17 | { 18 | Host = host; 19 | Title = "Abs"; 20 | Category = "Math nodes"; 21 | Description = "Calculates abs(x)."; 22 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 23 | AddObjectPort(this, "return abs(value)", PortTypes.Output, RTypes.Numeric, true); 24 | InputPorts[0].DataChanged += (s, e) => 25 | { 26 | OutputPorts[0].Data.Value = "abs(" + InputPorts[0].Data.Value + ")"; 27 | }; 28 | } 29 | 30 | public override string GenerateCode() 31 | { 32 | return null; 33 | } 34 | 35 | public override Node Clone() 36 | { 37 | var node = new Abs(Host); 38 | 39 | return node; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/exp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Exp : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Exp([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base(host, 15 | NodeTypes.Basic, 16 | spontaneousAddition) 17 | { 18 | Host = host; 19 | Title = "Exp"; 20 | Category = "Math nodes"; 21 | Description = "Calculates exp(x)."; 22 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 23 | AddObjectPort(this, "return exp(value)", PortTypes.Output, RTypes.Numeric, true); 24 | InputPorts[0].DataChanged += (s, e) => 25 | { 26 | OutputPorts[0].Data.Value = "exp(" + InputPorts[0].Data.Value + ")"; 27 | }; 28 | } 29 | 30 | public override string GenerateCode() 31 | { 32 | return null; 33 | } 34 | 35 | public override Node Clone() 36 | { 37 | var node = new Exp(Host); 38 | 39 | return node; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/log.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Log : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Log([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base(host, 15 | NodeTypes.Basic, 16 | spontaneousAddition) 17 | { 18 | Host = host; 19 | Title = "Log"; 20 | Category = "Math nodes"; 21 | Description = "Calculates log(x)."; 22 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 23 | AddObjectPort(this, "return log(value)", PortTypes.Output, RTypes.Numeric, true); 24 | InputPorts[0].DataChanged += (s, e) => 25 | { 26 | OutputPorts[0].Data.Value = "log(" + InputPorts[0].Data.Value + ")"; 27 | }; 28 | } 29 | 30 | public override string GenerateCode() 31 | { 32 | return null; 33 | } 34 | 35 | public override Node Clone() 36 | { 37 | var node = new Log(Host); 38 | 39 | return node; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Cos.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Cos : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Cos([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base(host, 15 | NodeTypes.Basic, 16 | spontaneousAddition) 17 | { 18 | Host = host; 19 | Title = "Cos"; 20 | Category = "Math nodes"; 21 | Description = "Calculates cos(x)."; 22 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 23 | AddObjectPort(this, "return cos(value)", PortTypes.Output, RTypes.Numeric, true); 24 | InputPorts[0].DataChanged += (s, e) => 25 | { 26 | OutputPorts[0].Data.Value = "cos(" + InputPorts[0].Data.Value + ")"; 27 | }; 28 | } 29 | 30 | public override string GenerateCode() 31 | { 32 | return null; 33 | } 34 | 35 | public override Node Clone() 36 | { 37 | var node = new Cos(Host, false); 38 | 39 | return node; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Floor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Floor : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Floor([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, 16 | NodeTypes.Basic, 17 | spontaneousAddition) 18 | { 19 | Host = host; 20 | Title = "Floor"; 21 | Category = "Math nodes"; 22 | Description = "Calculates floor(x)."; 23 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 24 | AddObjectPort(this, "return floor(value)", PortTypes.Output, RTypes.Numeric, true); 25 | InputPorts[0].DataChanged += (s, e) => 26 | { 27 | OutputPorts[0].Data.Value = "floor(" + InputPorts[0].Data.Value + ")"; 28 | }; 29 | } 30 | 31 | public override string GenerateCode() 32 | { 33 | return null; 34 | } 35 | 36 | public override Node Clone() 37 | { 38 | var node = new Floor(Host); 39 | 40 | return node; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Log10.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Log10 : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Log10([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, 16 | NodeTypes.Basic, 17 | spontaneousAddition) 18 | { 19 | Host = host; 20 | Title = "Log10"; 21 | Category = "Math nodes"; 22 | Description = "Calculates log10(x)."; 23 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 24 | AddObjectPort(this, "return log10(value)", PortTypes.Output, RTypes.Numeric, true); 25 | InputPorts[0].DataChanged += (s, e) => 26 | { 27 | OutputPorts[0].Data.Value = "log10(" + InputPorts[0].Data.Value + ")"; 28 | }; 29 | } 30 | 31 | public override string GenerateCode() 32 | { 33 | return null; 34 | } 35 | 36 | public override Node Clone() 37 | { 38 | var node = new Log10(Host); 39 | 40 | return node; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Trunc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Trunc : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Trunc([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, 16 | NodeTypes.Basic, 17 | spontaneousAddition) 18 | { 19 | Host = host; 20 | Title = "Trunc"; 21 | Category = "Math nodes"; 22 | Description = "Calculates trunc(x)."; 23 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 24 | AddObjectPort(this, "return trunc(value)", PortTypes.Output, RTypes.Numeric, true); 25 | InputPorts[0].DataChanged += (s, e) => 26 | { 27 | OutputPorts[0].Data.Value = "trunc(" + InputPorts[0].Data.Value + ")"; 28 | }; 29 | } 30 | 31 | public override string GenerateCode() 32 | { 33 | return null; 34 | } 35 | 36 | public override Node Clone() 37 | { 38 | var node = new Trunc(Host); 39 | 40 | return node; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Logic/LogicalNode.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Logic 6 | { 7 | [Export(typeof(Node))] 8 | public class LogicalNode : Node 9 | { 10 | private readonly UnrealControlsCollection.CheckBox _cb = new UnrealControlsCollection.CheckBox(); 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public LogicalNode([Import("host")] VirtualControl host, 15 | [Import("bool")] bool spontaneousAddition = false) : base(host, NodeTypes.Basic, 16 | spontaneousAddition) 17 | { 18 | Title = "Bool"; 19 | Host = host; 20 | 21 | Category = "Logic nodes"; 22 | AddObjectPort(this, "return value", PortTypes.Output, RTypes.Logical, true, _cb); 23 | _cb.GotFocus += (sender, args) => 24 | { 25 | _cb.IsChecked = !_cb.IsChecked; 26 | OutputPorts[0].Data.Value = _cb.IsChecked.Value.ToString(); 27 | }; 28 | } 29 | 30 | public override string GenerateCode() 31 | { 32 | return null; 33 | } 34 | 35 | public override Node Clone() 36 | { 37 | var node = new LogicalNode(Host, false); 38 | 39 | return node; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Ceiling.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Ceiling : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Ceiling([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, 16 | NodeTypes.Basic, 17 | spontaneousAddition) 18 | { 19 | Host = host; 20 | Title = "Ceiling"; 21 | Category = "Math nodes"; 22 | Description = "Calculates ceiling(x)."; 23 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, false); 24 | AddObjectPort(this, "return ceiling(value)", PortTypes.Output, RTypes.Numeric, true); 25 | InputPorts[0].DataChanged += (s, e) => 26 | { 27 | OutputPorts[0].Data.Value = "ceiling(" + InputPorts[0].Data.Value + ")"; 28 | }; 29 | } 30 | 31 | public override string GenerateCode() 32 | { 33 | return null; 34 | } 35 | 36 | public override Node Clone() 37 | { 38 | var node = new Ceiling(Host); 39 | 40 | return node; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Characters/Tolower.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class Tolower : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Tolower([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, 16 | NodeTypes.Basic, 17 | spontaneousAddition) 18 | { 19 | Host = host; 20 | Title = "Text to lower"; 21 | Category = "Characters"; 22 | Description = "Converts a set of characters to lowercased characters."; 23 | AddObjectPort(this, "Text", PortTypes.Input, RTypes.Character, false); 24 | AddObjectPort(this, "return ", PortTypes.Output, RTypes.Character, true); 25 | InputPorts[0].DataChanged += (s, e) => 26 | { 27 | OutputPorts[0].Data.Value = "tolower(" + InputPorts[0].Data.Value + ")"; 28 | }; 29 | } 30 | 31 | public override string GenerateCode() 32 | { 33 | return null; 34 | } 35 | 36 | public override Node Clone() 37 | { 38 | var node = new Tolower(Host); 39 | 40 | return node; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Characters/Toupper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Serializable] 8 | [Export(typeof(Node))] 9 | public class ToUpper : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public ToUpper([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, 16 | NodeTypes.Basic, 17 | spontaneousAddition) 18 | { 19 | Host = host; 20 | Title = "Text to upper"; 21 | Category = "Characters"; 22 | Description = "Converts a set of characters to uppercased characters."; 23 | AddObjectPort(this, "Text", PortTypes.Input, RTypes.Character, false); 24 | AddObjectPort(this, "return ", PortTypes.Output, RTypes.Character, true); 25 | InputPorts[0].DataChanged += (s, e) => 26 | { 27 | OutputPorts[0].Data.Value = "toupper(" + InputPorts[0].Data.Value + ")"; 28 | }; 29 | } 30 | 31 | public override string GenerateCode() 32 | { 33 | return null; 34 | } 35 | 36 | public override Node Clone() 37 | { 38 | var node = new ToUpper(Host); 39 | 40 | return node; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Sin.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Math 6 | { 7 | [Export(typeof(Node))] 8 | public class Sin : Node 9 | { 10 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox(); 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Sin([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base(host, 15 | NodeTypes.Basic, 16 | spontaneousAddition) 17 | { 18 | Host = host; 19 | Title = "Sin"; 20 | 21 | Category = "Math nodes"; 22 | Description = "Calculates sin(value)."; 23 | AddObjectPort(this, "value", PortTypes.Input, RTypes.Numeric, true); 24 | AddObjectPort(this, "return sin(value)", PortTypes.Output, RTypes.Numeric, true); 25 | InputPorts[0].DataChanged += (s, e) => 26 | { 27 | OutputPorts[0].Data.Value = "sin(" + InputPorts[0].Data.Value + ")"; 28 | }; 29 | } 30 | 31 | public override string GenerateCode() 32 | { 33 | return null; 34 | } 35 | 36 | public override Node Clone() 37 | { 38 | var node = new Sin(Host, false); 39 | 40 | return node; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Nodes")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Nodes")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b4dcec74-e9ba-4d95-928f-3b81f8bf3275")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /VisualSR/BasicNodes/ReadFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | using VisualSR.Tools; 5 | 6 | namespace VisualSR.BasicNodes 7 | { 8 | public class ReadFile : Node 9 | { 10 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox {MaxWidth = 150}; 11 | private readonly VirtualControl Host; 12 | 13 | public ReadFile(VirtualControl host, bool spontaneousAddition = false) : base( 14 | host, NodeTypes.Basic, 15 | spontaneousAddition) 16 | { 17 | Host = host; 18 | Title = "String"; 19 | Description = "This node contains a list of charaters."; 20 | Category = "Basic"; 21 | AddObjectPort(this, "return ", PortTypes.Output, RTypes.Character, true, _tb); 22 | OutputPorts[0].DataChanged += ReadFile_DataChanged; 23 | _tb.TextChanged += (sender, args) => OutputPorts[0].Data.Value = _tb.Text; 24 | } 25 | 26 | private void ReadFile_DataChanged(object sender, EventArgs e) 27 | { 28 | if (OutputPorts[0].Data.Value != _tb.Text) 29 | _tb.Text = MagicLaboratory.CorrectWindowsPath(OutputPorts[0].Data.Value); 30 | } 31 | 32 | public override string GenerateCode() 33 | { 34 | return null; 35 | } 36 | 37 | public override Node Clone() 38 | { 39 | var node = new ReadFile(Host, false); 40 | 41 | return node; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/Basics/Vector1D.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using VisualSR.Controls; 5 | using VisualSR.Core; 6 | 7 | namespace Nodes.Nodes.Math 8 | { 9 | [Serializable] 10 | [Export(typeof(Node))] 11 | public class Vector1D : Node 12 | { 13 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox(); 14 | private readonly VirtualControl Host; 15 | 16 | [ImportingConstructor] 17 | public Vector1D([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 18 | host, NodeTypes.Basic, 19 | spontaneousAddition) 20 | { 21 | Host = host; 22 | Title = "Vector 1D"; 23 | Category = "Vectors"; 24 | Description = "Contains a one-dimensional vector"; 25 | AddObjectPort(this, "return value", PortTypes.Output, RTypes.Generic, true, _tb); 26 | _tb.TextChanged += (sender, args) => OutputPorts[0].Data.Value = _tb.Text; 27 | } 28 | 29 | public override string GenerateCode() 30 | { 31 | return null; 32 | } 33 | 34 | public override Node Clone() 35 | { 36 | var node = new Vector1D(Host, false); 37 | 38 | return node; 39 | } 40 | 41 | public override void DeSerializeData(List input, List output) 42 | { 43 | _tb.Text = output[0]; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /demo/demo/Standard.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Windows; 5 | using System.Windows.Forms; 6 | using VisualSR.Compiler; 7 | using VisualSR.Tools; 8 | 9 | namespace demo 10 | { 11 | /// 12 | /// Interaction logic for SaveLoad.xaml 13 | /// 14 | public partial class Standard : Window 15 | { 16 | public Standard() 17 | { 18 | Closing += Standard_Closing; 19 | 20 | InitializeComponent(); 21 | var browser = new FolderBrowserDialog(); 22 | var path = ""; 23 | if (browser.ShowDialog() == System.Windows.Forms.DialogResult.OK) 24 | path = browser.SelectedPath + @"\"; 25 | else 26 | Close(); 27 | Hub.WorkSpace = path; 28 | vars.Host = vc; 29 | compile.Click += (s, e) => Compile(); 30 | } 31 | 32 | private void Standard_Closing(object sender, CancelEventArgs e) 33 | { 34 | e.Cancel = true; 35 | Visibility = Visibility.Hidden; 36 | } 37 | 38 | private void Compile() 39 | { 40 | File.WriteAllText(Hub.WorkSpace + "code.r", CodeMiner.Code(vc.RootNode)); 41 | var path = Hub.WorkSpace + "virtualConsole.bat"; 42 | var cmd = @"@echo off 43 | title Console 44 | rscript """ + Hub.WorkSpace + @"code.r""" + @" 45 | 46 | pause"; 47 | 48 | File.WriteAllText(path, cmd); 49 | Process.Start(path); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /demo/demo/Advanced.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Windows; 5 | using System.Windows.Forms; 6 | using VisualSR.Compiler; 7 | using VisualSR.Tools; 8 | 9 | 10 | namespace demo 11 | { 12 | /// 13 | /// Interaction logic for Advanced.xaml 14 | /// 15 | public partial class Advanced : Window 16 | { 17 | public Advanced() 18 | { 19 | Closing += Advanced_Closing; 20 | InitializeComponent(); 21 | vars.Host = vc; 22 | var browser = new FolderBrowserDialog(); 23 | var path = ""; 24 | if (browser.ShowDialog() == System.Windows.Forms.DialogResult.OK) 25 | path = browser.SelectedPath + @"\"; 26 | else 27 | Close(); 28 | Hub.WorkSpace = path; 29 | 30 | compile.Click += (s, e) => Compile(); 31 | } 32 | 33 | private void Advanced_Closing(object sender, CancelEventArgs e) 34 | { 35 | e.Cancel = true; 36 | Visibility = Visibility.Hidden; 37 | } 38 | 39 | private void Compile() 40 | { 41 | File.WriteAllText(Hub.WorkSpace + "code.r", CodeMiner.Code(vc.RootNode)); 42 | var path = Hub.WorkSpace + "virtualConsole.bat"; 43 | var cmd = @"@echo off 44 | title Console 45 | rscript """ + Hub.WorkSpace + @"code.r""" + @" 46 | 47 | pause"; 48 | 49 | File.WriteAllText(path, cmd); 50 | Process.Start(path); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /demo/demo/Advanced.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /VisualSR/BasicNodes/Get.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | using VisualSR.Tools; 5 | 6 | namespace VisualSR.BasicNodes 7 | { 8 | public class Get : Node 9 | { 10 | private readonly VariableItem _item; 11 | private readonly VirtualControl Host; 12 | 13 | public Get(VirtualControl host, VariableItem variable, bool spontaneousAddition) : base(host, 14 | NodeTypes.VariableGet, 15 | spontaneousAddition) 16 | { 17 | Host = host; 18 | Title = string.Empty; 19 | AddObjectPort(this, "Return " + variable.Name, PortTypes.Output, RTypes.Generic, true); 20 | Description = @"Gets the value of " + variable.Name + "."; 21 | OutputPorts[0].Data.Value = variable.Name; 22 | if (variable.Type != null) 23 | NodesManager.ChangeColorOfVariableNode(OutputPorts[0], variable.Type); 24 | _item = variable; 25 | _item.Gets++; 26 | _item.DsOfNodes.Add(Id); 27 | } 28 | 29 | public void Update(string name) 30 | { 31 | OutputPorts[0].Data.Value = name; 32 | } 33 | public override string GenerateCode() 34 | { 35 | throw new NotImplementedException(); 36 | } 37 | 38 | public override void Delete(bool deletedByBrain) 39 | { 40 | if (_item.Gets > 0) _item.Gets--; 41 | base.Delete(); 42 | } 43 | 44 | public override Node Clone() 45 | { 46 | var node = new Get(Host, _item, false); 47 | return node; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Loops/While.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using System.Text; 3 | using VisualSR.Compiler; 4 | using VisualSR.Core; 5 | 6 | namespace Nodes.Nodes.R.Loops 7 | { 8 | [Export(typeof(Node))] 9 | public class While : Node 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public While([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, NodeTypes.Method, 16 | spontaneousAddition) 17 | { 18 | Title = "While"; 19 | Host = host; 20 | Category = "Loops"; 21 | AddExecPort(this, "", PortTypes.Input, ""); 22 | AddExecPort(this, "", PortTypes.Output, "Reset"); 23 | AddExecPort(this, "Instructions", PortTypes.Output, "Instructions"); 24 | AddObjectPort(this, "Condition", PortTypes.Input, RTypes.Logical, false); 25 | Description = "While loop."; 26 | } 27 | 28 | 29 | public override string GenerateCode() 30 | { 31 | var sb = new StringBuilder(); 32 | sb.Append($"while({InputPorts?[0].Data.Value})" + "{"); 33 | sb.AppendLine(); 34 | if (OutExecPorts[1].ConnectedConnectors.Count > 0) 35 | sb.AppendLine(CodeMiner.Code(OutExecPorts[1].ConnectedConnectors[0].EndPort.ParentNode)); 36 | sb.AppendLine(); 37 | sb.Append("}"); 38 | return sb.ToString(); 39 | } 40 | 41 | 42 | public override Node Clone() 43 | { 44 | var node = new While(Host, false); 45 | return node; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /VisualSR/BasicNodes/Set.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | using VisualSR.Tools; 5 | 6 | namespace VisualSR.BasicNodes 7 | { 8 | public class Set : Node 9 | { 10 | private readonly VariableItem _item; 11 | private readonly VirtualControl Host; 12 | 13 | public Set(VirtualControl host, VariableItem variable, bool spontaneousAddition) : base(host, 14 | NodeTypes.VariableSet, 15 | spontaneousAddition) 16 | { 17 | Title = "Set"; 18 | Host = host; 19 | 20 | AddExecPort(this, "", PortTypes.Input, ""); 21 | AddExecPort(this, "", PortTypes.Output, ""); 22 | AddObjectPort(this, variable.Name, PortTypes.Input, RTypes.Generic, false); 23 | Description = @"Sets the value of " + variable.Name + "."; 24 | if (variable.Type != null) 25 | NodesManager.ChangeColorOfVariableNode(InputPorts[0], variable.Type); 26 | variable.Sets++; 27 | _item = variable; 28 | _item.DsOfNodes.Add(Id); 29 | Console.WriteLine("Sets: " + variable.Gets); 30 | } 31 | 32 | public override string GenerateCode() 33 | { 34 | var variableName = _item.Name; 35 | 36 | return variableName + " <- " + InputPorts[0].Data.Value; 37 | } 38 | 39 | public override void Delete(bool deletedByBrain = false) 40 | { 41 | if (_item.Sets > 0) _item.Sets--; 42 | base.Delete(); 43 | } 44 | 45 | public override Node Clone() 46 | { 47 | var node = new Set(Host, _item, false); 48 | return node; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/RCore/Library.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.R.RCore 6 | { 7 | [Export(typeof(Node))] 8 | public class Library : Node 9 | { 10 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox(); 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Library([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, NodeTypes.Method, 16 | spontaneousAddition) 17 | { 18 | Title = "Load a library"; 19 | Description = "Loads a library from the installed packages."; 20 | Host = host; 21 | 22 | Category = "Core"; 23 | AddExecPort(this, "", PortTypes.Input, ""); 24 | AddExecPort(this, "", PortTypes.Output, ""); 25 | AddObjectPort(this, "Library name", PortTypes.Input, RTypes.Character, false, _tb); 26 | _tb.TextChanged += (s, e) => { InputPorts[0].Data.Value = _tb.Text; }; 27 | InputPorts[0].DataChanged += (s, e) => 28 | { 29 | if (_tb.Text != InputPorts[0].Data.Value) 30 | _tb.Text = InputPorts[0].Data.Value; 31 | }; 32 | } 33 | 34 | public override string GenerateCode() 35 | { 36 | var value = InputPorts?[0].Data.Value; 37 | return "Library('" + value + "')"; 38 | } 39 | 40 | 41 | public override Node Clone() 42 | { 43 | var node = new Library(Host); 44 | 45 | return node; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/RCore/Install.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.R.RCore 6 | { 7 | [Export(typeof(Node))] 8 | public class Install : Node 9 | { 10 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox(); 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Install([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, NodeTypes.Method, 16 | spontaneousAddition) 17 | { 18 | Title = "Install Package"; 19 | Description = "Installs packages from CRAN."; 20 | Host = host; 21 | 22 | Category = "Core"; 23 | AddExecPort(this, "", PortTypes.Input, ""); 24 | AddExecPort(this, "", PortTypes.Output, ""); 25 | AddObjectPort(this, "Package name", PortTypes.Input, RTypes.Character, false, _tb); 26 | _tb.TextChanged += (s, e) => { InputPorts[0].Data.Value = _tb.Text; }; 27 | InputPorts[0].DataChanged += (s, e) => 28 | { 29 | if (_tb.Text != InputPorts[0].Data.Value) 30 | _tb.Text = InputPorts[0].Data.Value; 31 | }; 32 | } 33 | 34 | public override string GenerateCode() 35 | { 36 | var value = InputPorts?[0].Data.Value; 37 | 38 | return "install.packages('" + value + "'," + @"repos = 'http://cran.rstudio.com/')"; 39 | } 40 | 41 | 42 | public override Node Clone() 43 | { 44 | var node = new Install(Host); 45 | 46 | return node; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /VisualSR/Tools/PointsCalculator.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using VisualSR.Core; 3 | 4 | namespace VisualSR.Tools 5 | { 6 | /// 7 | /// A class to determine the EXACT coordinates of a point 8 | /// 9 | public static class PointsCalculator 10 | { 11 | public static Point PortOrigin(Port port) 12 | { 13 | port.CalcOrigin(); 14 | var p = new Point(); 15 | //In case we've got an ObjectPort 16 | if (port is ObjectPort) 17 | if (port.PortTypes == PortTypes.Input) 18 | { 19 | var x = port.Origin.X; 20 | var y = port.Origin.Y + port.ActualHeight / 2; 21 | p = new Point(x + 5, y + 5); 22 | } 23 | else 24 | { 25 | var x = port.Origin.X + port.ActualWidth; 26 | var y = port.Origin.Y + port.ActualHeight / 2; 27 | p = new Point(x - 5, y + 5); 28 | } 29 | //In case we've got an execution port 30 | else if (port is ExecPort) 31 | if (port.PortTypes == PortTypes.Input) 32 | { 33 | port.CalcOrigin(); 34 | var x = port.Origin.X; 35 | var y = port.Origin.Y + port.ActualHeight / 2; 36 | p = new Point(x + 5, y); 37 | } 38 | else 39 | { 40 | port.CalcOrigin(); 41 | var x = port.Origin.X + port.ActualWidth; 42 | var y = port.Origin.Y + port.ActualHeight / 2; 43 | p = new Point(x - 5, y + 1); 44 | } 45 | return p; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/Basics/Cat.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.R.Basics 6 | { 7 | [Export(typeof(Node))] 8 | public class Cat : Node 9 | { 10 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox(); 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Cat([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, NodeTypes.Method, 16 | spontaneousAddition) 17 | { 18 | Title = "Cat"; 19 | Host = host; 20 | 21 | Category = "Console"; 22 | AddExecPort(this, "", PortTypes.Input, ""); 23 | 24 | AddExecPort(this, "", PortTypes.Output, ""); 25 | AddObjectPort(this, "", PortTypes.Input, RTypes.Character, false, _tb); 26 | 27 | Description = "Prints out the input on the sceen."; 28 | _tb.TextChanged += (s, e) => { InputPorts[0].Data.Value = _tb.Text; }; 29 | InputPorts[0].DataChanged += (s, e) => 30 | { 31 | if (_tb.Text != InputPorts[0].Data.Value) 32 | _tb.Text = InputPorts[0].Data.Value; 33 | }; 34 | } 35 | 36 | public override string GenerateCode() 37 | { 38 | var value = InputPorts?[0].Data.Value; 39 | 40 | if (InputPorts != null && !InputPorts[0].Linked) 41 | return "cat('" + value + "')"; 42 | return "cat(" + value + ")"; 43 | } 44 | 45 | 46 | public override Node Clone() 47 | { 48 | var node = new Cat(Host, false); 49 | 50 | return node; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/Plotting/Plot.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.R.Plotting 6 | { 7 | [Export(typeof(Node))] 8 | public class Plot : Node 9 | { 10 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox(); 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Plot([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, NodeTypes.Method, 16 | spontaneousAddition) 17 | { 18 | Title = "Plot"; 19 | Host = host; 20 | 21 | Category = "Plotting"; 22 | AddExecPort(this, "", PortTypes.Input, ""); 23 | 24 | AddExecPort(this, "", PortTypes.Output, ""); 25 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false, _tb); 26 | 27 | Description = "Uses R's built-in plotting function to generate a plot out of the entered data."; 28 | _tb.TextChanged += (s, e) => { InputPorts[0].Data.Value = _tb.Text; }; 29 | InputPorts[0].DataChanged += (s, e) => 30 | { 31 | if (_tb.Text != InputPorts[0].Data.Value) 32 | _tb.Text = InputPorts[0].Data.Value; 33 | }; 34 | } 35 | 36 | public override string GenerateCode() 37 | { 38 | var value = InputPorts?[0].Data.Value; 39 | 40 | if (InputPorts != null && !InputPorts[0].Linked) 41 | return "plot('" + value + "')"; 42 | return "plot(" + value + ")"; 43 | } 44 | 45 | 46 | public override Node Clone() 47 | { 48 | var node = new Plot(Host, false); 49 | 50 | return node; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/Basics/Print.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using System.Windows.Controls; 3 | using VisualSR.Controls; 4 | using VisualSR.Core; 5 | 6 | namespace Nodes.Nodes.R.Basics 7 | { 8 | [Export(typeof(Node))] 9 | public class Print : Node 10 | { 11 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox(); 12 | private readonly VirtualControl Host; 13 | 14 | [ImportingConstructor] 15 | public Print([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 16 | host, NodeTypes.Method, 17 | spontaneousAddition) 18 | { 19 | Title = "Print"; 20 | Host = host; 21 | 22 | Category = "Console"; 23 | AddExecPort(this, "", PortTypes.Input, ""); 24 | 25 | AddExecPort(this, "", PortTypes.Output, ""); 26 | AddObjectPort(this, "", PortTypes.Input, RTypes.Character, false, _tb); 27 | 28 | Description = "Prints out the input on the sceen."; 29 | _tb.TextChanged += (s, e) => { InputPorts[0].Data.Value = _tb.Text; }; 30 | InputPorts[0].DataChanged += (s, e) => 31 | { 32 | if (_tb.Text != InputPorts[0].Data.Value) 33 | _tb.Text = InputPorts[0].Data.Value; 34 | }; 35 | } 36 | 37 | 38 | public override string GenerateCode() 39 | { 40 | var value = InputPorts?[0].Data.Value; 41 | 42 | if (InputPorts != null && !InputPorts[0].Linked) 43 | return "print('" + value + "')"; 44 | return "print(" + value + ")"; 45 | } 46 | 47 | 48 | public override Node Clone() 49 | { 50 | var node = new Print(Host, false); 51 | 52 | return node; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /demo/demo/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace demo 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | Closed += (s, e) => { Application.Current.Shutdown(); }; 27 | } 28 | 29 | private void Button_Click(object sender, RoutedEventArgs e) 30 | { 31 | var basic = new Basic(); 32 | basic.ShowDialog(); 33 | } 34 | 35 | private void Button_Click_1(object sender, RoutedEventArgs e) 36 | { 37 | var vars = new VariablesList(); 38 | vars.ShowDialog(); 39 | } 40 | 41 | private void Button_Click_2(object sender, RoutedEventArgs e) 42 | { 43 | var saveload = new SaveLoad(); 44 | saveload.ShowDialog(); 45 | } 46 | 47 | private void Button_Click_3(object sender, RoutedEventArgs e) 48 | { 49 | var stan = new Standard(); 50 | stan.ShowDialog(); 51 | } 52 | 53 | private void Button_Click_4(object sender, RoutedEventArgs e) 54 | { 55 | var perf = new Performance(); 56 | perf.ShowDialog(); 57 | } 58 | 59 | private void Button_Click_5(object sender, RoutedEventArgs e) 60 | { 61 | var advanced = new Advanced(); 62 | advanced.ShowDialog(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /VisualSR/Tools/Cipher.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Web.Script.Serialization; 3 | using System.Xml.Serialization; 4 | 5 | namespace VisualSR.Tools 6 | { 7 | public class Cipher 8 | { 9 | public static void SerializeToFile(string filePath, T objectToWrite, bool append = false, bool JSON = true) 10 | where T : new() 11 | { 12 | if (!JSON) 13 | { 14 | TextWriter writer = null; 15 | try 16 | { 17 | var serializer = new XmlSerializer(typeof(T)); 18 | writer = new StreamWriter(filePath, append); 19 | serializer.Serialize(writer, objectToWrite); 20 | } 21 | finally 22 | { 23 | if (writer != null) 24 | writer.Close(); 25 | } 26 | return; 27 | } 28 | File.WriteAllText(filePath, SerializeToString(objectToWrite)); 29 | } 30 | 31 | public static string SerializeToString(T toSerialize) 32 | { 33 | return new JavaScriptSerializer().Serialize(toSerialize); 34 | } 35 | 36 | public static T DeSerializeFromString(string data) where T : new() 37 | { 38 | return new JavaScriptSerializer().Deserialize(data); 39 | } 40 | 41 | public static T DeSerializeFromFile(string filePath, bool JSON = true) where T : new() 42 | { 43 | if (JSON) 44 | { 45 | var data = File.ReadAllText(filePath); 46 | return new JavaScriptSerializer().Deserialize(data); 47 | } 48 | TextReader reader = null; 49 | try 50 | { 51 | var serializer = new XmlSerializer(typeof(T)); 52 | reader = new StreamReader(filePath); 53 | return (T) serializer.Deserialize(reader); 54 | } 55 | finally 56 | { 57 | if (reader != null) 58 | reader.Close(); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /VisualSR/Compiler/GenerateCode.cs: -------------------------------------------------------------------------------- 1 | /*Copyright 2018 ALAA BEN FATMA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ 8 | using System.Text; 9 | using VisualSR.Core; 10 | 11 | namespace VisualSR.Compiler 12 | { 13 | public static class CodeMiner 14 | { 15 | public static string Code(Node root) 16 | { 17 | var codeBuilder = new StringBuilder(); 18 | codeBuilder.Append(root.GenerateCode()); 19 | codeBuilder.AppendLine(); 20 | if (root.OutExecPorts.Count <= 0) return codeBuilder.ToString(); 21 | if (root.OutExecPorts[0].ConnectedConnectors.Count <= 0) return codeBuilder.ToString(); 22 | var nextNode = root.OutExecPorts[0].ConnectedConnectors[0].EndPort.ParentNode; 23 | var stillHasMoreNodes = true; 24 | while (stillHasMoreNodes) 25 | { 26 | codeBuilder.Append(nextNode.GenerateCode()); 27 | codeBuilder.AppendLine(); 28 | if (nextNode.OutExecPorts[0].ConnectedConnectors.Count > 0) 29 | nextNode = nextNode.OutExecPorts[0].ConnectedConnectors[0].EndPort.ParentNode; 30 | else 31 | stillHasMoreNodes = false; 32 | } 33 | return codeBuilder.ToString(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /VisualSR/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("VisualSR")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("VisualSR")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | //In order to begin building localizable applications, set 21 | //CultureYouAreCodingWith in your .csproj file 22 | //inside a . For example, if you are using US english 23 | //in your source files, set the to en-US. Then uncomment 24 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 25 | //the line below to match the UICulture setting in the project file. 26 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 27 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 28 | //(used if a resource is not found in the page, 29 | // or application resource dictionaries) 30 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 31 | //(used if a resource is not found in the page, 32 | // app, or any theme specific resource dictionaries) 33 | )] 34 | // Version information for an assembly consists of the following four values: 35 | // 36 | // Major Version 37 | // Minor Version 38 | // Build Number 39 | // Revision 40 | // 41 | // You can specify all the values or you can default the Build and Revision Numbers 42 | // by using the '*' as shown below: 43 | // [assembly: AssemblyVersion("1.0.*")] 44 | [assembly: AssemblyVersion("1.0.0.0")] 45 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /VisualSR/Compiler/Builder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * This class has been written with the intention to write a nodes parser 3 | * May be supported in the new versions 4 | */ 5 | //using System; 6 | //using System.Windows; 7 | //using VisualSR.Core; 8 | 9 | //namespace VisualSR.Compiler 10 | //{ 11 | // public class Builder 12 | // { 13 | // public static int Errors(VirtualControl host) 14 | // { 15 | // var collection = host.Nodes; 16 | // var errors = 0; 17 | // Node nodeToPoke = null; 18 | // foreach (var node in collection) 19 | // if (HasAnError(node)) 20 | // { 21 | // errors++; 22 | // if (nodeToPoke == null) 23 | // nodeToPoke = node; 24 | // } 25 | // if (nodeToPoke != null) MessageBox.Show(nodeToPoke.Title); 26 | // return errors; 27 | // } 28 | 29 | // private static bool HasAnError(Node node) 30 | // { 31 | // switch (node.Types) 32 | // { 33 | // case NodeTypes.Method: 34 | // var portCollection = node.InputPorts; 35 | 36 | // foreach (var port in portCollection) 37 | // if (port.Linked) 38 | // return false; 39 | // break; 40 | // case NodeTypes.VariableSet: 41 | // { 42 | // var port = node.InputPorts[0]; 43 | 44 | // if (port.Data.Value != "") 45 | // return false; 46 | // break; 47 | // } 48 | // case NodeTypes.Function: 49 | // { 50 | // var port = node.OutputPorts[0]; 51 | 52 | // Console.WriteLine("Error has been detected:\nNode:{0}\nID:{1}\nValue:{2}", node, node.Id, 53 | // port.Data.Value); 54 | // if (port.Data.Value != "") 55 | // return false; 56 | // break; 57 | // } 58 | // case NodeTypes.Root: 59 | // { 60 | // return false; 61 | // } 62 | // } 63 | // return true; 64 | // } 65 | // } 66 | //} 67 | 68 | -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Logic/Equal.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Core; 3 | using VisualSR.Tools; 4 | 5 | namespace Nodes.Nodes.Logic 6 | { 7 | [Export(typeof(Node))] 8 | public class Equal : Node 9 | 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Equal([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, NodeTypes.Basic, spontaneousAddition) 16 | { 17 | Title = "=="; 18 | Category = "Logic nodes"; 19 | Host = host; 20 | 21 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 22 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 23 | AddObjectPort(this, "==", PortTypes.Output, RTypes.Logical, true); 24 | MouseRightButtonDown += (sender, args) => GenerateCode(); 25 | foreach (var port in InputPorts) 26 | port.DataChanged += (sender, args) => { GenerateCode(); }; 27 | InputPorts[1].LinkChanged += (sender, args) => 28 | { 29 | if (!InputPorts[1].Linked) 30 | InputPorts[1].Data.Value = ""; 31 | }; 32 | InputPorts[0].LinkChanged += (sender, args) => 33 | { 34 | if (!InputPorts[0].Linked) 35 | InputPorts[0].Data.Value = ""; 36 | }; 37 | } 38 | 39 | public Equal() 40 | { 41 | } 42 | 43 | 44 | public override string GenerateCode() 45 | { 46 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")==(" + InputPorts[1].Data.Value + "))"; 47 | return OutputPorts[0].Data.Value; 48 | } 49 | 50 | public override Node Clone() 51 | { 52 | var node = new Equal(Host, false); 53 | 54 | return node; 55 | } 56 | 57 | public override string Serialize() 58 | { 59 | NodeProperties = new NodeProperties(this); 60 | Cipher.SerializeToFile(@"sum.txt", NodeProperties, true); 61 | return null; 62 | } 63 | 64 | public override string DeSerialize() 65 | { 66 | return null; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Logic/Greater.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Core; 3 | using VisualSR.Tools; 4 | 5 | namespace Nodes.Nodes.Logic 6 | { 7 | [Export(typeof(Node))] 8 | public class Greater : Node 9 | 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public Greater([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, NodeTypes.Basic, spontaneousAddition) 16 | { 17 | Title = ">"; 18 | 19 | Category = "Logic nodes"; 20 | Host = host; 21 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 22 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 23 | AddObjectPort(this, ">", PortTypes.Output, RTypes.Logical, true); 24 | MouseRightButtonDown += (sender, args) => GenerateCode(); 25 | foreach (var port in InputPorts) 26 | port.DataChanged += (sender, args) => { GenerateCode(); }; 27 | InputPorts[1].LinkChanged += (sender, args) => 28 | { 29 | if (!InputPorts[1].Linked) 30 | InputPorts[1].Data.Value = ""; 31 | }; 32 | InputPorts[0].LinkChanged += (sender, args) => 33 | { 34 | if (!InputPorts[0].Linked) 35 | InputPorts[0].Data.Value = ""; 36 | }; 37 | } 38 | 39 | public Greater() 40 | { 41 | } 42 | 43 | 44 | public override string GenerateCode() 45 | { 46 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")>(" + InputPorts[1].Data.Value + "))"; 47 | return OutputPorts[0].Data.Value; 48 | } 49 | 50 | public override Node Clone() 51 | { 52 | var node = new Greater(Host, false); 53 | 54 | return node; 55 | } 56 | 57 | public override string Serialize() 58 | { 59 | NodeProperties = new NodeProperties(this); 60 | Cipher.SerializeToFile(@"sum.txt", NodeProperties, true); 61 | return null; 62 | } 63 | 64 | public override string DeSerialize() 65 | { 66 | return null; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Logic/NotEqual.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Core; 3 | using VisualSR.Tools; 4 | 5 | namespace Nodes.Nodes.Logic 6 | { 7 | [Export(typeof(Node))] 8 | public class NotEqual : Node 9 | 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public NotEqual([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 15 | host, NodeTypes.Basic, spontaneousAddition) 16 | { 17 | Title = "!="; 18 | Host = host; 19 | 20 | Category = "Logic nodes"; 21 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 22 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 23 | AddObjectPort(this, "!= ", PortTypes.Output, RTypes.Logical, true); 24 | MouseRightButtonDown += (sender, args) => GenerateCode(); 25 | foreach (var port in InputPorts) 26 | port.DataChanged += (sender, args) => { GenerateCode(); }; 27 | InputPorts[1].LinkChanged += (sender, args) => 28 | { 29 | if (!InputPorts[1].Linked) 30 | InputPorts[1].Data.Value = ""; 31 | }; 32 | InputPorts[0].LinkChanged += (sender, args) => 33 | { 34 | if (!InputPorts[0].Linked) 35 | InputPorts[0].Data.Value = ""; 36 | }; 37 | } 38 | 39 | public NotEqual() 40 | { 41 | } 42 | 43 | 44 | public override string GenerateCode() 45 | { 46 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")!=(" + InputPorts[1].Data.Value + "))"; 47 | return OutputPorts[0].Data.Value; 48 | } 49 | 50 | public override Node Clone() 51 | { 52 | var node = new NotEqual(Host, false); 53 | 54 | return node; 55 | } 56 | 57 | public override string Serialize() 58 | { 59 | NodeProperties = new NodeProperties(this); 60 | Cipher.SerializeToFile(@"sum.txt", NodeProperties, true); 61 | return null; 62 | } 63 | 64 | public override string DeSerialize() 65 | { 66 | return null; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Logic/LesserEqual.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Core; 3 | using VisualSR.Tools; 4 | 5 | namespace Nodes.Nodes.Logic 6 | { 7 | [Export(typeof(Node))] 8 | public class LesserEqual : Node 9 | 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public LesserEqual([Import("host")] VirtualControl host, 15 | [Import("bool")] bool spontaneousAddition = false) : base(host, NodeTypes.Basic, spontaneousAddition) 16 | { 17 | Title = "<="; 18 | 19 | Category = "Logic nodes"; 20 | Host = host; 21 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 22 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 23 | AddObjectPort(this, "<=", PortTypes.Output, RTypes.Logical, true); 24 | MouseRightButtonDown += (sender, args) => GenerateCode(); 25 | foreach (var port in InputPorts) 26 | port.DataChanged += (sender, args) => { GenerateCode(); }; 27 | InputPorts[1].LinkChanged += (sender, args) => 28 | { 29 | if (!InputPorts[1].Linked) 30 | InputPorts[1].Data.Value = ""; 31 | }; 32 | InputPorts[0].LinkChanged += (sender, args) => 33 | { 34 | if (!InputPorts[0].Linked) 35 | InputPorts[0].Data.Value = ""; 36 | }; 37 | } 38 | 39 | public LesserEqual() 40 | { 41 | } 42 | 43 | 44 | public override string GenerateCode() 45 | { 46 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")<=(" + InputPorts[1].Data.Value + "))"; 47 | return OutputPorts[0].Data.Value; 48 | } 49 | 50 | public override Node Clone() 51 | { 52 | var node = new LesserEqual(Host, false); 53 | 54 | return node; 55 | } 56 | 57 | public override string Serialize() 58 | { 59 | NodeProperties = new NodeProperties(this); 60 | Cipher.SerializeToFile(@"sum.txt", NodeProperties, true); 61 | return null; 62 | } 63 | 64 | public override string DeSerialize() 65 | { 66 | return null; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Logic/GreaterEqual.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Core; 3 | using VisualSR.Tools; 4 | 5 | namespace Nodes.Nodes.Logic 6 | { 7 | [Export(typeof(Node))] 8 | public class GreaterEqual : Node 9 | 10 | { 11 | private readonly VirtualControl Host; 12 | 13 | [ImportingConstructor] 14 | public GreaterEqual([Import("host")] VirtualControl host, 15 | [Import("bool")] bool spontaneousAddition = false) : base(host, NodeTypes.Basic, spontaneousAddition) 16 | { 17 | Title = ">="; 18 | 19 | Category = "Logic nodes"; 20 | Host = host; 21 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 22 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 23 | AddObjectPort(this, ">=", PortTypes.Output, RTypes.Logical, true); 24 | MouseRightButtonDown += (sender, args) => GenerateCode(); 25 | foreach (var port in InputPorts) 26 | port.DataChanged += (sender, args) => { GenerateCode(); }; 27 | InputPorts[1].LinkChanged += (sender, args) => 28 | { 29 | if (!InputPorts[1].Linked) 30 | InputPorts[1].Data.Value = ""; 31 | }; 32 | InputPorts[0].LinkChanged += (sender, args) => 33 | { 34 | if (!InputPorts[0].Linked) 35 | InputPorts[0].Data.Value = ""; 36 | }; 37 | } 38 | 39 | public GreaterEqual() 40 | { 41 | } 42 | 43 | 44 | public override string GenerateCode() 45 | { 46 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")>=(" + InputPorts[1].Data.Value + "))"; 47 | return OutputPorts[0].Data.Value; 48 | } 49 | 50 | public override Node Clone() 51 | { 52 | var node = new GreaterEqual(Host, false); 53 | 54 | return node; 55 | } 56 | 57 | public override string Serialize() 58 | { 59 | NodeProperties = new NodeProperties(this); 60 | Cipher.SerializeToFile(@"sum.txt", NodeProperties, true); 61 | return null; 62 | } 63 | 64 | public override string DeSerialize() 65 | { 66 | return null; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /VisualSR/Controls/PortControlsCollection.cs: -------------------------------------------------------------------------------- 1 | /*Copyright 2018 ALAA BEN FATMA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Media; 11 | 12 | namespace VisualSR.Controls 13 | { 14 | public class UnrealControlsCollection 15 | { 16 | public class TextBox : System.Windows.Controls.TextBox 17 | { 18 | public TextBox() 19 | { 20 | Background = Brushes.Transparent; 21 | Foreground = Brushes.WhiteSmoke; 22 | MaxWidth = 350; 23 | MinWidth = 20; 24 | Height = 20; 25 | } 26 | } 27 | 28 | public sealed class AddPin : Button 29 | { 30 | public AddPin() 31 | { 32 | Style = FindResource("AddPin") as Style; 33 | OnApplyTemplate(); 34 | } 35 | } 36 | 37 | public class CheckBox : System.Windows.Controls.CheckBox 38 | { 39 | public CheckBox() 40 | { 41 | Style = FindResource("CheckBoxStyle") as Style; 42 | MouseLeftButtonDown += (sender, args) => 43 | { 44 | IsChecked = !IsChecked; 45 | MessageBox.Show(IsChecked.ToString()); 46 | }; 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Loops/For.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using VisualSR.Compiler; 8 | using VisualSR.Controls; 9 | using VisualSR.Core; 10 | 11 | namespace Nodes.Nodes.R.Loops 12 | { 13 | [Export(typeof(Node))] 14 | public class For : Node 15 | { 16 | private readonly UnrealControlsCollection.TextBox _rang = new UnrealControlsCollection.TextBox(); 17 | private readonly VirtualControl Host; 18 | 19 | [ImportingConstructor] 20 | public For([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 21 | host, NodeTypes.Method, 22 | spontaneousAddition) 23 | { 24 | Title = "For"; 25 | Host = host; 26 | 27 | Category = "Loops"; 28 | AddExecPort(this, "", PortTypes.Input, ""); 29 | 30 | AddExecPort(this, "", PortTypes.Output, "Idle"); 31 | AddExecPort(this, "Instructions", PortTypes.Output, "Instructions"); 32 | AddObjectPort(this, "Element", PortTypes.Input, RTypes.Generic, false); 33 | AddObjectPort(this, "Range", PortTypes.Input, RTypes.Generic, false, _rang); 34 | Description = "For loop."; 35 | _rang.TextChanged += (s, e) => { InputPorts[1].Data.Value = _rang.Text; }; 36 | InputPorts[1].DataChanged += (s, e) => 37 | { 38 | if (_rang.Text != InputPorts[1].Data.Value) 39 | _rang.Text = InputPorts[1].Data.Value; 40 | }; 41 | } 42 | 43 | 44 | public override string GenerateCode() 45 | { 46 | var sb = new StringBuilder(); 47 | sb.Append($"for({InputPorts?[0].Data.Value} in {InputPorts?[1].Data.Value})"+"{"); 48 | sb.AppendLine(); 49 | if (OutExecPorts[1].ConnectedConnectors.Count > 0) 50 | sb.AppendLine(CodeMiner.Code(OutExecPorts[1].ConnectedConnectors[0].EndPort.ParentNode)); 51 | sb.AppendLine(); 52 | sb.Append("}"); 53 | return sb.ToString(); 54 | } 55 | 56 | 57 | public override Node Clone() 58 | { 59 | var node = new For(Host, false); 60 | 61 | return node; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Logic/Lesser.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using System.Windows.Media; 3 | using VisualSR.Core; 4 | using VisualSR.Tools; 5 | 6 | namespace Nodes.Nodes.Logic 7 | { 8 | [Export(typeof(Node))] 9 | public class Lesser : Node 10 | 11 | { 12 | private readonly VirtualControl Host; 13 | 14 | [ImportingConstructor] 15 | public Lesser([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 16 | host, NodeTypes.Basic, spontaneousAddition) 17 | { 18 | Background = Brushes.LawnGreen; 19 | Title = "<"; 20 | 21 | Category = "Logic nodes"; 22 | Host = host; 23 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 24 | AddObjectPort(this, "", PortTypes.Input, RTypes.Generic, false); 25 | AddObjectPort(this, ">", PortTypes.Output, RTypes.Logical, true); 26 | MouseRightButtonDown += (sender, args) => GenerateCode(); 27 | foreach (var port in InputPorts) 28 | port.DataChanged += (sender, args) => { GenerateCode(); }; 29 | InputPorts[1].LinkChanged += (sender, args) => 30 | { 31 | if (!InputPorts[1].Linked) 32 | InputPorts[1].Data.Value = ""; 33 | }; 34 | InputPorts[0].LinkChanged += (sender, args) => 35 | { 36 | if (!InputPorts[0].Linked) 37 | InputPorts[0].Data.Value = ""; 38 | }; 39 | } 40 | 41 | public Lesser() 42 | { 43 | } 44 | 45 | 46 | public override string GenerateCode() 47 | { 48 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")<(" + InputPorts[1].Data.Value + "))"; 49 | return OutputPorts[0].Data.Value; 50 | } 51 | 52 | public override Node Clone() 53 | { 54 | var node = new Lesser(Host, false); 55 | 56 | return node; 57 | } 58 | 59 | public override string Serialize() 60 | { 61 | NodeProperties = new NodeProperties(this); 62 | Cipher.SerializeToFile(@"sum.txt", NodeProperties, true); 63 | return null; 64 | } 65 | 66 | public override string DeSerialize() 67 | { 68 | return null; 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /VisualSR/Tools/PluginsManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.ComponentModel.Composition.Hosting; 5 | using System.IO; 6 | using VisualSR.Core; 7 | 8 | namespace VisualSR.Tools 9 | { 10 | public class PluginsManager 11 | { 12 | private readonly VirtualControl _host; 13 | private CompositionContainer _container; 14 | private IList _plugins = new List(); 15 | 16 | public PluginsManager(VirtualControl host) 17 | { 18 | _host = host; 19 | try 20 | { 21 | _plugins = new List(Directory.GetFiles(@"./Plugins/", "*.dll")); 22 | } 23 | catch (Exception){ 24 | Console.WriteLine("Could not find the plugins folder. The application will create one."); 25 | Directory.CreateDirectory(@"./Plugins/"); 26 | _plugins = new List(Directory.GetFiles(@"./Plugins/", "*.dll")); 27 | } 28 | } 29 | 30 | [ImportMany(typeof(Node))] 31 | public List LoadedNodes { get; set; } 32 | 33 | public bool LoadPlugins() 34 | { 35 | var newFilesList = new List(Directory.GetFiles(@"./Plugins/", "*.dll")); 36 | 37 | var same = true; 38 | if (newFilesList.Count != _plugins.Count) 39 | { 40 | _plugins = new List(newFilesList.GetRange(0, newFilesList.Count)); 41 | same = false; 42 | } 43 | if (same && _container != null) return false; 44 | 45 | var catalog = new AggregateCatalog(); 46 | catalog.Catalogs.Add(new AssemblyCatalog(typeof(Node).Assembly)); 47 | catalog.Catalogs.Add(new DirectoryCatalog(@"./")); 48 | _container = new CompositionContainer(catalog); 49 | try 50 | { 51 | _container.ComposeExportedValue("host", _host); 52 | _container.ComposeExportedValue("bool", false); 53 | _container.ComposeParts(this); 54 | } 55 | catch (CompositionException compositionException) 56 | { 57 | Console.WriteLine(compositionException.ToString()); 58 | } 59 | Hub.LoadedExternalNodes = LoadedNodes; 60 | return true; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /demo/demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("demo")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("demo")] 15 | [assembly: AssemblyCopyright("Copyright © 2020")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Logic/IfElse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using System.Text; 4 | using VisualSR.Compiler; 5 | using VisualSR.Core; 6 | 7 | namespace Nodes.Nodes.Logic 8 | { 9 | [Export(typeof(Node))] 10 | public class IfElse : Node 11 | 12 | { 13 | private readonly VirtualControl Host; 14 | 15 | [ImportingConstructor] 16 | public IfElse([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 17 | host, NodeTypes.Method, 18 | spontaneousAddition) 19 | { 20 | Types = NodeTypes.Event; 21 | Host = host; 22 | Title = "IfElse"; 23 | Category = "Logic nodes"; 24 | AddExecPort(this, "", PortTypes.Input, ""); 25 | AddObjectPort(this, "Condition", PortTypes.Input, RTypes.Logical, false); 26 | AddExecPort(this, "", PortTypes.Output, "True"); 27 | AddExecPort(this, "", PortTypes.Output, "False"); 28 | AddExecPort(this, "", PortTypes.Output, "Default"); 29 | re_Arrange(); 30 | } 31 | 32 | private void re_Arrange() 33 | { 34 | var aux = OutExecPorts[0]; 35 | OutExecPorts[0] = OutExecPorts[2]; 36 | OutExecPorts[2] = aux; 37 | aux = OutExecPorts[1]; 38 | OutExecPorts[1] = OutExecPorts[2]; 39 | OutExecPorts[2] = aux; 40 | } 41 | 42 | public override string GenerateCode() 43 | { 44 | var sb = new StringBuilder(); 45 | sb.AppendLine(); 46 | sb.Append("if(" + InputPorts[0].Data.Value + "){"); 47 | try 48 | { 49 | if (OutExecPorts[1] != null) 50 | sb.Append(CodeMiner.Code(OutExecPorts[1].ConnectedConnectors[0].EndPort.ParentNode)); 51 | } 52 | catch (Exception) 53 | { 54 | //Ignored 55 | } 56 | sb.Append("}"); 57 | sb.Append("else{"); 58 | try 59 | { 60 | if (OutExecPorts[1] != null) 61 | sb.Append(CodeMiner.Code(OutExecPorts[2].ConnectedConnectors[0].EndPort.ParentNode)); 62 | } 63 | catch (Exception) 64 | { 65 | //Ignored 66 | } 67 | sb.Append("}"); 68 | sb.AppendLine(); 69 | return sb.ToString(); 70 | } 71 | 72 | public override Node Clone() 73 | { 74 | var node = new IfElse(Host, false); 75 | 76 | return node; 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/CSV/ReadCSV.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.R.CSV 6 | { 7 | [Export(typeof(Node))] 8 | public class ReadCSV : Node 9 | { 10 | private readonly UnrealControlsCollection.CheckBox _cb = new UnrealControlsCollection.CheckBox(); 11 | private readonly UnrealControlsCollection.TextBox _tb = new UnrealControlsCollection.TextBox(); 12 | private readonly UnrealControlsCollection.TextBox _tc = new UnrealControlsCollection.TextBox {MaxLength = 1}; 13 | private readonly VirtualControl Host; 14 | 15 | [ImportingConstructor] 16 | public ReadCSV([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 17 | host, NodeTypes.Basic, 18 | spontaneousAddition) 19 | { 20 | Title = "Read CSV"; 21 | Description = "Reads a CSV file and return a data frame."; 22 | Host = host; 23 | 24 | Category = "CSV"; 25 | 26 | AddObjectPort(this, "File Path", PortTypes.Input, RTypes.Character, false, _tb); 27 | AddObjectPort(this, "Headers", PortTypes.Input, RTypes.Logical, false, _cb); 28 | AddObjectPort(this, "Character of separation", PortTypes.Input, RTypes.Character, false, _tc); 29 | AddObjectPort(this, "return", PortTypes.Output, RTypes.DataFrame, false); 30 | 31 | _tb.TextChanged += (s, e) => { InputPorts[0].Data.Value = _tb.Text; }; 32 | InputPorts[0].DataChanged += (s, e) => 33 | { 34 | if (_tb.Text != InputPorts[0].Data.Value) 35 | _tb.Text = InputPorts[0].Data.Value; 36 | GenerateCode(); 37 | }; 38 | InputPorts[2].DataChanged += (s, e) => 39 | { 40 | if (_tc.Text != InputPorts[2].Data.Value) 41 | _tc.Text = InputPorts[2].Data.Value; 42 | GenerateCode(); 43 | }; 44 | _cb.Checked += (s, e) => 45 | GenerateCode(); 46 | } 47 | 48 | public override string GenerateCode() 49 | { 50 | var value = InputPorts?[0].Data.Value; 51 | OutputPorts[0].Data.Value = "read.csv(file='" + value + "',header=" + _cb.IsChecked.ToString().ToUpper() + 52 | ",sep='" + _tc.Text + "')"; 53 | return "# read CSV from" + value; 54 | } 55 | 56 | 57 | public override Node Clone() 58 | { 59 | var node = new ReadCSV(Host); 60 | 61 | return node; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/Basics/GenericRArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Windows; 5 | using VisualSR.Controls; 6 | using VisualSR.Core; 7 | 8 | namespace Nodes.Nodes.R.Basics 9 | { 10 | [Export(typeof(Node))] 11 | public class GenericRArray : Node 12 | { 13 | private readonly List _dataToCombine = new List(); 14 | private readonly VirtualControl Host; 15 | private int numOfElements = 2; 16 | 17 | [ImportingConstructor] 18 | public GenericRArray([Import("host")] VirtualControl host, 19 | [Import("bool")] bool spontaneousAddition = false) : base( 20 | host, NodeTypes.Method, 21 | spontaneousAddition) 22 | { 23 | Title = "Generic array"; 24 | Host = host; 25 | Category = "Arrays"; 26 | AddExecPort(this, "", PortTypes.Input, ""); 27 | AddExecPort(this, "", PortTypes.Output, ""); 28 | AddObjectPort(this, "[1]", PortTypes.Input, RTypes.Generic, true); 29 | AddObjectPort(this, "return value", PortTypes.Output, RTypes.ArrayOrFactorOrListOrMatrix, true); 30 | Loaded += RArray_Loaded; 31 | } 32 | 33 | private void RArray_Loaded(object sender, RoutedEventArgs e) 34 | { 35 | if (InputPortsControls.Children.Count != 0) return; 36 | 37 | var addpin = new UnrealControlsCollection.AddPin(); 38 | Height += 25; 39 | addpin.Click += (s, p) => 40 | { 41 | AddObjectPort(this, "[" + (numOfElements++) + "]", PortTypes.Input, 42 | RTypes.Generic, false); 43 | }; 44 | 45 | InputPortsControls.Children.Add(addpin); 46 | } 47 | 48 | public override void DynamicPortsGeneration(int n) 49 | { 50 | for (var i = 0; i < n - 1; i++) 51 | AddObjectPort(this, "[" + InputPorts.Count + 1 + "]", PortTypes.Input, 52 | RTypes.Generic, false); 53 | } 54 | 55 | private void OnDataChanged(object sender, EventArgs eventArgs) 56 | { 57 | _dataToCombine.Clear(); 58 | var s = ""; 59 | foreach (ObjectsConnector conn in InputPorts[0].ConnectedConnectors) 60 | { 61 | _dataToCombine.Add(((ObjectPort) conn.StartPort).Data.Value); 62 | s += "\n" + ((ObjectPort) conn.StartPort).Data.Value; 63 | } 64 | } 65 | 66 | public override string GenerateCode() 67 | { 68 | throw new NotImplementedException(); 69 | } 70 | 71 | public override Node Clone() 72 | { 73 | var node = new GenericRArray(Host, false); 74 | 75 | return node; 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /demo/demo/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /VisualSR/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace VisualSR.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | public class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | public static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VisualSR.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | public static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /demo/demo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace demo.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("demo.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /VisualSR/Controls/Notification.cs: -------------------------------------------------------------------------------- 1 | /*Copyright 2018 ALAA BEN FATMA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ 8 | //Did not include it in the demos. 9 | using System; 10 | using System.ComponentModel; 11 | using System.Runtime.CompilerServices; 12 | using System.Windows; 13 | using System.Windows.Controls; 14 | using System.Windows.Media; 15 | using System.Windows.Threading; 16 | using VisualSR.Core; 17 | using VisualSR.Properties; 18 | 19 | namespace VisualSR.Controls 20 | { 21 | public class Notification : Button, INotifyPropertyChanged 22 | { 23 | private readonly VirtualControl host; 24 | 25 | public Notification(VirtualControl parent) 26 | { 27 | Background = Brushes.Cyan; 28 | Style = FindResource("Notification") as Style; 29 | host = parent; 30 | } 31 | 32 | public event PropertyChangedEventHandler PropertyChanged; 33 | 34 | public void Show(string msg) 35 | { 36 | Loaded += (s, e) => 37 | { 38 | var b = Template.FindName("b", this) as Border; 39 | var m = Template.FindName("Message", this) as TextBlock; 40 | m.Text = msg; 41 | b.SizeChanged += (ss, ee) => 42 | { 43 | Width = b.ActualWidth; 44 | Height = b.ActualHeight; 45 | }; 46 | 47 | VerticalContentAlignment = VerticalAlignment.Bottom; 48 | HorizontalAlignment = HorizontalAlignment.Right; 49 | 50 | Visibility = Visibility.Visible; 51 | var timer = new DispatcherTimer {Interval = new TimeSpan(0, 0, 3), IsEnabled = true}; 52 | timer.Tick += (ts, te) => 53 | { 54 | host.Children.Remove(this); 55 | timer.Stop(); 56 | }; 57 | host.Children.Add(this); 58 | }; 59 | } 60 | 61 | [NotifyPropertyChangedInvocator] 62 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) 63 | { 64 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Divide.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Controls; 4 | using VisualSR.Core; 5 | 6 | namespace Nodes.Nodes.Math 7 | { 8 | [Export(typeof(Node))] 9 | public class Divide : Node 10 | 11 | { 12 | private readonly UnrealControlsCollection.TextBox _a = new UnrealControlsCollection.TextBox(); 13 | private readonly UnrealControlsCollection.TextBox _b = new UnrealControlsCollection.TextBox(); 14 | private readonly VirtualControl Host; 15 | 16 | [ImportingConstructor] 17 | public Divide([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 18 | host, NodeTypes.Basic, spontaneousAddition) 19 | { 20 | Title = "Divide"; 21 | Host = host; 22 | 23 | Category = "Math nodes"; 24 | AddObjectPort(this, "A", PortTypes.Input, RTypes.Numeric, false, _a); 25 | AddObjectPort(this, "B", PortTypes.Input, RTypes.Numeric, false, _b); 26 | AddObjectPort(this, "A / B", PortTypes.Output, RTypes.Numeric, true); 27 | MouseRightButtonDown += (sender, args) => GenerateCode(); 28 | _a.TextChanged += (sender, args) => 29 | { 30 | InputPorts[0].Data.Value = _a.Text; 31 | GenerateCode(); 32 | }; 33 | _b.TextChanged += (sender, args) => 34 | { 35 | InputPorts[1].Data.Value = _b.Text; 36 | GenerateCode(); 37 | }; 38 | foreach (var port in InputPorts) 39 | port.DataChanged += (sender, args) => { GenerateCode(); }; 40 | InputPorts[1].LinkChanged += (sender, args) => 41 | { 42 | if (!InputPorts[1].Linked) 43 | InputPorts[1].Data.Value = _b.Text; 44 | }; 45 | InputPorts[0].LinkChanged += (sender, args) => 46 | { 47 | if (!InputPorts[0].Linked) 48 | InputPorts[0].Data.Value = _a.Text; 49 | }; 50 | InputPorts[0].DataChanged += (s, e) => 51 | { 52 | if (_a.Text != InputPorts[0].Data.Value) 53 | _a.Text = InputPorts[0].Data.Value; 54 | }; 55 | InputPorts[1].DataChanged += (s, e) => 56 | { 57 | if (_b.Text != InputPorts[1].Data.Value) 58 | _b.Text = InputPorts[1].Data.Value; 59 | }; 60 | } 61 | 62 | public Divide() 63 | { 64 | } 65 | 66 | 67 | public override string GenerateCode() 68 | { 69 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")/(" + InputPorts[1].Data.Value + "))"; 70 | return OutputPorts[0].Data.Value; 71 | } 72 | 73 | public override Node Clone() 74 | { 75 | var node = new Divide(Host, false); 76 | 77 | return node; 78 | } 79 | 80 | 81 | public override void DeSerializeData(List input, List output) 82 | { 83 | base.DeSerializeData(input, output); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/Basics/NumericRArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Text; 5 | using System.Windows; 6 | using VisualSR.Controls; 7 | using VisualSR.Core; 8 | 9 | namespace Nodes.Nodes.R.Basics 10 | { 11 | [Export(typeof(Node))] 12 | public class NumericRVector : Node 13 | { 14 | private readonly List _dataToCombine = new List(); 15 | private readonly VirtualControl Host; 16 | 17 | [ImportingConstructor] 18 | public NumericRVector([Import("host")] VirtualControl host, 19 | [Import("bool")] bool spontaneousAddition = false) : base( 20 | host, NodeTypes.Method, 21 | spontaneousAddition) 22 | { 23 | Title = "Numeric Vector"; 24 | Host = host; 25 | Category = "Vectors"; 26 | AddExecPort(this, "", PortTypes.Input, ""); 27 | AddExecPort(this, "", PortTypes.Output, ""); 28 | AddObjP(); 29 | AddObjectPort(this, "return value", PortTypes.Output, RTypes.ArrayOrFactorOrListOrMatrix, true); 30 | Loaded += RArray_Loaded; 31 | } 32 | 33 | public override void DynamicPortsGeneration(int n) 34 | { 35 | for (var i = 0; i < n - 1; i++) 36 | AddObjP(); 37 | } 38 | 39 | private void AddObjP() 40 | { 41 | var newtb = new UnrealControlsCollection.TextBox(); 42 | AddObjectPort(this, "[" + (InputPorts.Count + 1) + "]", PortTypes.Input, 43 | RTypes.Numeric, false); 44 | var x = InputPorts.Count - 1; 45 | 46 | newtb.TextChanged += (ss, ee) => { InputPorts[x].Data.Value = newtb.Text; }; 47 | InputPorts[x].Control = newtb; 48 | } 49 | 50 | private void RArray_Loaded(object sender, RoutedEventArgs e) 51 | { 52 | if (InputPortsControls.Children.Count != 0) return; 53 | 54 | var addpin = new UnrealControlsCollection.AddPin(); 55 | Height += 25; 56 | addpin.Click += (s, p) => { AddObjP(); }; 57 | InputPortsControls.Children.Add(addpin); 58 | } 59 | 60 | private void OnDataChanged(object sender, EventArgs eventArgs) 61 | { 62 | _dataToCombine.Clear(); 63 | var s = ""; 64 | foreach (ObjectsConnector conn in InputPorts[0].ConnectedConnectors) 65 | { 66 | _dataToCombine.Add(((ObjectPort) conn.StartPort).Data.Value); 67 | s += "\n" + ((ObjectPort) conn.StartPort).Data.Value; 68 | } 69 | } 70 | 71 | public override string GenerateCode() 72 | { 73 | var sb = new StringBuilder(); 74 | sb.Append("c("); 75 | foreach (var ip in InputPorts) 76 | sb.Append($"{ip.Data.Value},"); 77 | sb.Append(')'); 78 | var code = sb.ToString().Replace(",)", ")"); 79 | OutputPorts[0].Data.Value = code; 80 | return "#Generated a vector of characters : " + code; 81 | } 82 | 83 | public override Node Clone() 84 | { 85 | var node = new NumericRVector(Host, false); 86 | 87 | return node; 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Sum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Controls; 4 | using VisualSR.Core; 5 | 6 | namespace Nodes.Nodes.Math 7 | { 8 | [Export(typeof(Node))] 9 | public class Sum : Node 10 | 11 | { 12 | private readonly UnrealControlsCollection.TextBox _a = new UnrealControlsCollection.TextBox(); 13 | private readonly UnrealControlsCollection.TextBox _b = new UnrealControlsCollection.TextBox(); 14 | private readonly VirtualControl Host; 15 | 16 | [ImportingConstructor] 17 | public Sum([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base(host, 18 | NodeTypes.Basic, spontaneousAddition) 19 | { 20 | Title = "Sum"; 21 | Host = host; 22 | 23 | Category = "Math nodes"; 24 | AddObjectPort(this, "A", PortTypes.Input, RTypes.Numeric, false, _a); 25 | AddObjectPort(this, "B", PortTypes.Input, RTypes.Numeric, false, _b); 26 | AddObjectPort(this, "A + B", PortTypes.Output, RTypes.Numeric, true); 27 | MouseRightButtonDown += (sender, args) => GenerateCode(); 28 | _a.TextChanged += (sender, args) => 29 | { 30 | InputPorts[0].Data.Value = _a.Text; 31 | GenerateCode(); 32 | }; 33 | _b.TextChanged += (sender, args) => 34 | { 35 | InputPorts[1].Data.Value = _b.Text; 36 | GenerateCode(); 37 | }; 38 | foreach (var port in InputPorts) 39 | port.DataChanged += (sender, args) => { GenerateCode(); }; 40 | InputPorts[1].LinkChanged += (sender, args) => 41 | { 42 | if (!InputPorts[1].Linked) 43 | InputPorts[1].Data.Value = _b.Text; 44 | }; 45 | InputPorts[0].LinkChanged += (sender, args) => 46 | { 47 | if (!InputPorts[0].Linked) 48 | InputPorts[0].Data.Value = _a.Text; 49 | }; 50 | InputPorts[0].DataChanged += (s, e) => 51 | { 52 | if (_a.Text != InputPorts[0].Data.Value) 53 | _a.Text = InputPorts[0].Data.Value; 54 | }; 55 | InputPorts[1].DataChanged += (s, e) => 56 | { 57 | if (_b.Text != InputPorts[1].Data.Value) 58 | _b.Text = InputPorts[1].Data.Value; 59 | }; 60 | } 61 | 62 | public Sum() 63 | { 64 | } 65 | 66 | 67 | public override string GenerateCode() 68 | { 69 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")+(" + InputPorts[1].Data.Value + "))"; 70 | return OutputPorts[0].Data.Value; 71 | } 72 | 73 | public override Node Clone() 74 | { 75 | var node = new Sum(Host, false); 76 | 77 | return node; 78 | } 79 | 80 | 81 | public override string DeSerialize() 82 | { 83 | return null; 84 | } 85 | 86 | public object GetInstance(string fullyQualifiedNameOfClass) 87 | { 88 | var t = Type.GetType(fullyQualifiedNameOfClass); 89 | return Activator.CreateInstance(t); 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /VisualSR/Tools/ListUtilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using System.Collections.Specialized; 4 | using System.Linq; 5 | using System.Windows; 6 | using VisualSR.Core; 7 | 8 | namespace VisualSR.Tools 9 | { 10 | /// 11 | /// A list that contains Connectors 12 | /// 13 | public sealed class ConnectorsList : ObservableCollection 14 | { 15 | public ConnectorsList() 16 | { 17 | CollectionChanged += ConnectorsList_CollectionChanged; 18 | } 19 | 20 | public void RemoveConnector(int index) 21 | { 22 | this[index].Delete(); 23 | } 24 | 25 | public void ClearConnectors() 26 | { 27 | for (var i = Count - 1; i >= 0; i--) 28 | if (Count > i) 29 | switch (this[i].Type) 30 | { 31 | case ConnectorTypes.Execution: 32 | this[i].Delete(); 33 | break; 34 | case ConnectorTypes.Object: 35 | var objectsConnector = this[i] as ObjectsConnector; 36 | objectsConnector?.Delete(); 37 | break; 38 | } 39 | 40 | Clear(); 41 | } 42 | 43 | private void ConnectorsList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) 44 | { 45 | //Validations 46 | if (Count <= 0) return; 47 | if (Count == 1) 48 | for (var index = 0; index < Count; index++) 49 | try 50 | { 51 | var c = this[index]; 52 | if (c.EndPort.ParentNode 53 | .IsCollapsed) 54 | { 55 | c.StartPort.Linked = false; 56 | c.Wire.Visibility = Visibility.Collapsed; 57 | c.EndPort.Linked = false; 58 | ClearConnectors(); 59 | break; 60 | } 61 | if (!c.StartPort.ParentNode 62 | .IsCollapsed) continue; 63 | c.StartPort.Linked = false; 64 | c.EndPort.Linked = false; 65 | c.Wire.Visibility = Visibility.Collapsed; 66 | ClearConnectors(); 67 | break; 68 | } 69 | catch (Exception exception) 70 | { 71 | Console.WriteLine(exception); 72 | } 73 | foreach (var c in this) 74 | if (Equals(c.EndPort.ParentNode, c.StartPort.ParentNode)) 75 | c.Wire.Visibility = Visibility.Collapsed; 76 | } 77 | } 78 | 79 | public static class NodesTreeUtilities 80 | { 81 | public static void Sort(this ObservableCollection collection) where T : IComparable 82 | { 83 | var sorted = collection.OrderBy(x => x).ToList(); 84 | for (var i = 0; i < sorted.Count(); i++) 85 | if (sorted.Count > i) collection.Move(collection.IndexOf(sorted[i]), i); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /VisualSR/Controls/InnerMessageBox.cs: -------------------------------------------------------------------------------- 1 | /*Copyright 2018 ALAA BEN FATMA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ 8 | using System.ComponentModel; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using VisualSR.Properties; 12 | 13 | namespace VisualSR.Controls 14 | { 15 | public class InnerLinkingMessageBox : Control, INotifyPropertyChanged 16 | { 17 | public enum InnerMessageIcon 18 | { 19 | Correct, 20 | Warning, 21 | False 22 | } 23 | 24 | public const string BaseUri = @"VisualSR;component/MediaResources/"; 25 | private string _text; 26 | private string _uri; 27 | public InnerMessageIcon MessageIcon = InnerMessageIcon.Correct; 28 | 29 | public InnerLinkingMessageBox() 30 | { 31 | Style = FindResource("InnerMessageBox") as Style; 32 | Height = 25; 33 | Visibility = Visibility.Collapsed; 34 | } 35 | 36 | public string Text 37 | { 38 | get { return _text; } 39 | set 40 | { 41 | _text = value; 42 | OnPropertyChanged("Text"); 43 | OnPropertyChanged("Uri"); 44 | 45 | Loaded += (s, e) => 46 | { 47 | (Template.FindName("BorderIcon", this) as Border).Style = FindResource("TickBorder") as Style; 48 | }; 49 | BringIntoView(); 50 | } 51 | } 52 | 53 | public string Uri 54 | { 55 | get 56 | { 57 | if (MessageIcon == InnerMessageIcon.Correct) 58 | _uri = BaseUri + "tick.png"; 59 | else if (MessageIcon == InnerMessageIcon.False) 60 | _uri = BaseUri + "Cross.png"; 61 | else 62 | _uri = BaseUri + "Warning.png"; 63 | 64 | return _uri; 65 | } 66 | set 67 | { 68 | _uri = value; 69 | 70 | OnPropertyChanged("Uri"); 71 | } 72 | } 73 | 74 | public event PropertyChangedEventHandler PropertyChanged; 75 | 76 | [NotifyPropertyChangedInvocator] 77 | protected virtual void OnPropertyChanged(string propertyName = null) 78 | { 79 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Multiply.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | using VisualSR.Tools; 5 | 6 | namespace Nodes.Nodes.Math 7 | { 8 | [Export(typeof(Node))] 9 | public class Multiply : Node 10 | 11 | { 12 | private readonly UnrealControlsCollection.TextBox _a = new UnrealControlsCollection.TextBox(); 13 | private readonly UnrealControlsCollection.TextBox _b = new UnrealControlsCollection.TextBox(); 14 | private readonly VirtualControl Host; 15 | 16 | [ImportingConstructor] 17 | public Multiply([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 18 | host, NodeTypes.Basic, spontaneousAddition) 19 | { 20 | Title = "Multiply"; 21 | Description = "Multiplies A and B."; 22 | 23 | Category = "Math nodes"; 24 | Host = host; 25 | AddObjectPort(this, "A", PortTypes.Input, RTypes.Numeric, false, _a); 26 | AddObjectPort(this, "B", PortTypes.Input, RTypes.Numeric, false, _b); 27 | AddObjectPort(this, "A * B", PortTypes.Output, RTypes.Numeric, true); 28 | MouseRightButtonDown += (sender, args) => GenerateCode(); 29 | _a.TextChanged += (sender, args) => 30 | { 31 | InputPorts[0].Data.Value = _a.Text; 32 | GenerateCode(); 33 | }; 34 | _b.TextChanged += (sender, args) => 35 | { 36 | InputPorts[1].Data.Value = _b.Text; 37 | GenerateCode(); 38 | }; 39 | foreach (var port in InputPorts) 40 | port.DataChanged += (sender, args) => { GenerateCode(); }; 41 | InputPorts[1].LinkChanged += (sender, args) => 42 | { 43 | if (!InputPorts[1].Linked) 44 | InputPorts[1].Data.Value = _b.Text; 45 | }; 46 | InputPorts[0].LinkChanged += (sender, args) => 47 | { 48 | if (!InputPorts[0].Linked) 49 | InputPorts[0].Data.Value = _a.Text; 50 | }; 51 | InputPorts[0].DataChanged += (s, e) => 52 | { 53 | if (_a.Text != InputPorts[0].Data.Value) 54 | _a.Text = InputPorts[0].Data.Value; 55 | }; 56 | InputPorts[1].DataChanged += (s, e) => 57 | { 58 | if (_b.Text != InputPorts[1].Data.Value) 59 | _b.Text = InputPorts[1].Data.Value; 60 | }; 61 | } 62 | 63 | public Multiply() 64 | { 65 | } 66 | 67 | 68 | public override string GenerateCode() 69 | { 70 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")*(" + InputPorts[1].Data.Value + "))"; 71 | return OutputPorts[0].Data.Value; 72 | } 73 | 74 | public override Node Clone() 75 | { 76 | var node = new Multiply(Host, false); 77 | 78 | return node; 79 | } 80 | 81 | public override string Serialize() 82 | { 83 | NodeProperties = new NodeProperties(this); 84 | Cipher.SerializeToFile(@"multiply.txt", NodeProperties, true); 85 | return null; 86 | } 87 | 88 | public override string DeSerialize() 89 | { 90 | return null; 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/R/Basics/CharacterRArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Text; 5 | using System.Windows; 6 | using VisualSR.Controls; 7 | using VisualSR.Core; 8 | 9 | namespace Nodes.Nodes.R.Basics 10 | { 11 | [Export(typeof(Node))] 12 | public class CharacterRVector : Node 13 | { 14 | private readonly List _dataToCombine = new List(); 15 | private readonly VirtualControl Host; 16 | 17 | [ImportingConstructor] 18 | public CharacterRVector([Import("host")] VirtualControl host, 19 | [Import("bool")] bool spontaneousAddition = false) : base( 20 | host, NodeTypes.Method, 21 | spontaneousAddition) 22 | { 23 | Title = "Characters Vector"; 24 | Host = host; 25 | Category = "Vectors"; 26 | AddExecPort(this, "", PortTypes.Input, ""); 27 | AddExecPort(this, "", PortTypes.Output, ""); 28 | AddObjP(); 29 | AddObjectPort(this, "return value", PortTypes.Output, RTypes.ArrayOrFactorOrListOrMatrix, true); 30 | Loaded += RArray_Loaded; 31 | } 32 | 33 | private void AddObjP() 34 | { 35 | var newtb = new UnrealControlsCollection.TextBox(); 36 | AddObjectPort(this, "[" + (InputPorts.Count + 1) + "]", PortTypes.Input, 37 | RTypes.Character, false); 38 | var x = InputPorts.Count - 1; 39 | 40 | newtb.TextChanged += (ss, ee) => { InputPorts[x].Data.Value = newtb.Text; }; 41 | InputPorts[x].Control = newtb; 42 | InputPorts[x].DataChanged += (s, e) => 43 | { 44 | if (newtb.Text != InputPorts[x].Data.Value) 45 | newtb.Text = InputPorts[x].Data.Value; 46 | }; 47 | } 48 | 49 | public override void DynamicPortsGeneration(int n) 50 | { 51 | for (var i = 0; i < n - 1; i++) 52 | AddObjP(); 53 | } 54 | 55 | private void RArray_Loaded(object sender, RoutedEventArgs e) 56 | { 57 | if (InputPortsControls.Children.Count != 0) return; 58 | 59 | var addpin = new UnrealControlsCollection.AddPin(); 60 | Height += 25; 61 | addpin.Click += (s, p) => { AddObjP(); }; 62 | InputPortsControls.Children.Add(addpin); 63 | } 64 | 65 | private void OnDataChanged(object sender, EventArgs eventArgs) 66 | { 67 | _dataToCombine.Clear(); 68 | var s = ""; 69 | foreach (ObjectsConnector conn in InputPorts[0].ConnectedConnectors) 70 | { 71 | _dataToCombine.Add(((ObjectPort) conn.StartPort).Data.Value); 72 | s += "\n" + ((ObjectPort) conn.StartPort).Data.Value; 73 | } 74 | } 75 | 76 | public override string GenerateCode() 77 | { 78 | var sb = new StringBuilder(); 79 | sb.Append("c("); 80 | foreach (var ip in InputPorts) 81 | sb.Append($"'{ip.Data.Value}',"); 82 | sb.Append(')'); 83 | var code = sb.ToString().Replace(",)", ")"); 84 | OutputPorts[0].Data.Value = code; 85 | return "#Generated a vector of characters : " + code; 86 | } 87 | 88 | public override Node Clone() 89 | { 90 | var node = new CharacterRVector(Host, false); 91 | 92 | return node; 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Math/Subtract.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using VisualSR.Controls; 4 | using VisualSR.Core; 5 | using VisualSR.Tools; 6 | 7 | namespace Nodes.Nodes.Math 8 | { 9 | [Export(typeof(Node))] 10 | public class Subtract : Node 11 | 12 | { 13 | private readonly UnrealControlsCollection.TextBox _a = new UnrealControlsCollection.TextBox(); 14 | private readonly UnrealControlsCollection.TextBox _b = new UnrealControlsCollection.TextBox(); 15 | private readonly VirtualControl Host; 16 | 17 | [ImportingConstructor] 18 | public Subtract([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 19 | host, NodeTypes.Basic, spontaneousAddition) 20 | { 21 | Title = "Subtract"; 22 | Host = host; 23 | 24 | Category = "Math nodes"; 25 | AddObjectPort(this, "A", PortTypes.Input, RTypes.Numeric, false, _a); 26 | AddObjectPort(this, "B", PortTypes.Input, RTypes.Numeric, false, _b); 27 | AddObjectPort(this, "A - B", PortTypes.Output, RTypes.Numeric, true); 28 | MouseRightButtonDown += (sender, args) => GenerateCode(); 29 | _a.TextChanged += (sender, args) => 30 | { 31 | InputPorts[0].Data.Value = _a.Text; 32 | GenerateCode(); 33 | }; 34 | _b.TextChanged += (sender, args) => 35 | { 36 | InputPorts[1].Data.Value = _b.Text; 37 | GenerateCode(); 38 | }; 39 | foreach (var port in InputPorts) 40 | port.DataChanged += (sender, args) => { GenerateCode(); }; 41 | InputPorts[1].LinkChanged += (sender, args) => 42 | { 43 | if (!InputPorts[1].Linked) 44 | InputPorts[1].Data.Value = _b.Text; 45 | }; 46 | InputPorts[0].LinkChanged += (sender, args) => 47 | { 48 | if (!InputPorts[0].Linked) 49 | InputPorts[0].Data.Value = _a.Text; 50 | }; 51 | InputPorts[0].DataChanged += (s, e) => 52 | { 53 | if (_a.Text != InputPorts[0].Data.Value) 54 | _a.Text = InputPorts[0].Data.Value; 55 | }; 56 | InputPorts[1].DataChanged += (s, e) => 57 | { 58 | if (_b.Text != InputPorts[1].Data.Value) 59 | _b.Text = InputPorts[1].Data.Value; 60 | }; 61 | } 62 | 63 | public Subtract() 64 | { 65 | } 66 | 67 | 68 | public override string GenerateCode() 69 | { 70 | OutputPorts[0].Data.Value = "((" + InputPorts[0].Data.Value + ")-(" + InputPorts[1].Data.Value + "))"; 71 | return OutputPorts[0].Data.Value; 72 | } 73 | 74 | public override Node Clone() 75 | { 76 | var node = new Subtract(Host, false); 77 | 78 | return node; 79 | } 80 | 81 | public override string Serialize() 82 | { 83 | NodeProperties = new NodeProperties(this); 84 | Cipher.SerializeToFile(@"sum.txt", NodeProperties, true); 85 | return null; 86 | } 87 | 88 | public override string DeSerialize() 89 | { 90 | return null; 91 | } 92 | 93 | public object GetInstance(string fullyQualifiedNameOfClass) 94 | { 95 | var t = Type.GetType(fullyQualifiedNameOfClass); 96 | return Activator.CreateInstance(t); 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Characters/Substr.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | 5 | namespace Nodes.Nodes.Characters 6 | { 7 | [Export(typeof(Node))] 8 | public class Substr : Node 9 | 10 | { 11 | private readonly UnrealControlsCollection.TextBox _start = new UnrealControlsCollection.TextBox(); 12 | private readonly UnrealControlsCollection.TextBox _stop = new UnrealControlsCollection.TextBox(); 13 | private readonly UnrealControlsCollection.TextBox _t = new UnrealControlsCollection.TextBox(); 14 | private readonly VirtualControl Host; 15 | 16 | [ImportingConstructor] 17 | public Substr([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 18 | host, NodeTypes.Basic, spontaneousAddition) 19 | { 20 | Title = "Sub Text"; 21 | Host = host; 22 | 23 | Category = "Characters"; 24 | AddObjectPort(this, "Text", PortTypes.Input, RTypes.Character, false, _t); 25 | AddObjectPort(this, "Start Index", PortTypes.Input, RTypes.Numeric, false, _start); 26 | AddObjectPort(this, "Stop Index", PortTypes.Input, RTypes.Numeric, false, _stop); 27 | AddObjectPort(this, "Extracted value", PortTypes.Output, RTypes.Character, true); 28 | MouseRightButtonDown += (sender, args) => GenerateCode(); 29 | _t.TextChanged += (sender, args) => 30 | { 31 | InputPorts[0].Data.Value = _t.Text; 32 | GenerateCode(); 33 | }; 34 | _start.TextChanged += (sender, args) => 35 | { 36 | InputPorts[1].Data.Value = _start.Text; 37 | GenerateCode(); 38 | }; 39 | _stop.TextChanged += (sender, args) => 40 | { 41 | InputPorts[2].Data.Value = _stop.Text; 42 | GenerateCode(); 43 | }; 44 | foreach (var port in InputPorts) 45 | port.DataChanged += (sender, args) => { GenerateCode(); }; 46 | InputPorts[1].LinkChanged += (sender, args) => 47 | { 48 | if (!InputPorts[1].Linked) 49 | InputPorts[1].Data.Value = _start.Text; 50 | }; 51 | InputPorts[0].LinkChanged += (sender, args) => 52 | { 53 | if (!InputPorts[0].Linked) 54 | InputPorts[0].Data.Value = _t.Text; 55 | }; 56 | InputPorts[2].LinkChanged += (sender, args) => 57 | { 58 | if (!InputPorts[2].Linked) 59 | InputPorts[2].Data.Value = _stop.Text; 60 | }; 61 | InputPorts[0].DataChanged += (s, e) => 62 | { 63 | if (_t.Text != InputPorts[0].Data.Value) 64 | _t.Text = InputPorts[0].Data.Value; 65 | }; 66 | InputPorts[1].DataChanged += (s, e) => 67 | { 68 | if (_start.Text != InputPorts[1].Data.Value) 69 | _start.Text = InputPorts[1].Data.Value; 70 | }; 71 | InputPorts[2].DataChanged += (s, e) => 72 | { 73 | if (_stop.Text != InputPorts[2].Data.Value) 74 | _stop.Text = InputPorts[2].Data.Value; 75 | }; 76 | } 77 | 78 | public Substr() 79 | { 80 | } 81 | 82 | 83 | public override string GenerateCode() 84 | { 85 | OutputPorts[0].Data.Value = "substr('" + _t.Text + "',start=" + _start.Text + ",stop=" + _stop.Text + ")"; 86 | return OutputPorts[0].Data.Value; 87 | } 88 | 89 | public override Node Clone() 90 | { 91 | var node = new Substr(Host); 92 | 93 | return node; 94 | } 95 | } 96 | } -------------------------------------------------------------------------------- /VisualSR/BasicNodes/SpaghettiDivider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Shapes; 5 | using System.Windows.Threading; 6 | using VisualSR.Core; 7 | using VisualSR.Tools; 8 | 9 | namespace VisualSR.BasicNodes 10 | { 11 | public class SpaghettiDivider : Node 12 | { 13 | private readonly VirtualControl Host; 14 | 15 | public SpaghettiDivider(VirtualControl host, Connector connector, bool spontaneousAddition = true) : base(host, 16 | NodeTypes.SpaghettiDivider, spontaneousAddition) 17 | { 18 | ObjectConnector = connector as ObjectsConnector; 19 | Host = host; 20 | Connector = connector; 21 | Start = connector.StartPort as ObjectPort; 22 | End = connector.EndPort as ObjectPort; 23 | connector.Delete(); 24 | Title = ""; 25 | var inPort = Connector.EndPort as ObjectPort; 26 | var outPort = Connector.StartPort as ObjectPort; 27 | if (outPort != null) 28 | AddObjectPort(this, "", PortTypes.Input, outPort.Data.Type, true); 29 | Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => 30 | { 31 | NodesManager.CreateObjectConnector(host, InputPorts[0], outPort); 32 | NodesManager.CreateObjectConnector(host, inPort, InputPorts[0]); 33 | if (Host.NodesTree.IsVisible) 34 | Host.NodesTree.Remove(); 35 | InputPorts[0].IsEnabled = false; 36 | if (InputPorts.Count > 0) 37 | if (InputPorts[0].ConnectedConnectors.Count > 0) 38 | Connector.StartPort = InputPorts[0].ConnectedConnectors[0].StartPort; 39 | InputPorts[0].DataChanged += (ss, ee) => 40 | { 41 | End.Data.Value = InputPorts[0].Data.Value; 42 | foreach (var c in InputPorts[0].ConnectedConnectors) 43 | c.Wire.HeartBeatsAnimation(false); 44 | }; 45 | InputPorts[0].ConnectedConnectors.CollectionChanged += (ss, ee) => { }; 46 | var hint = Template.FindName("NodeHint", this) as Path; 47 | if (hint != null) hint.Visibility = Visibility.Collapsed; 48 | Height -= 33; 49 | Width -= 13; 50 | Canvas.SetTop(InputPortsPanel, -8); 51 | Canvas.SetLeft(InputPortsPanel, 3); 52 | })); 53 | } 54 | 55 | public ObjectsConnector ObjectConnector { get; set; } 56 | 57 | private Connector Connector { get; } 58 | private ObjectPort Start { get; } 59 | private ObjectPort End { get; } 60 | 61 | public override void Delete(bool deletedByBrain = false) 62 | { 63 | try 64 | { 65 | Types = NodeTypes.Basic; 66 | if (InputPorts[0].ConnectedConnectors.Count > 0) 67 | InputPorts[0].ConnectedConnectors[0].Wire.Visibility = Visibility.Collapsed; 68 | if (InputPorts[0].ConnectedConnectors.Count > 0) 69 | InputPorts[0].ConnectedConnectors[0].Wire.Visibility = Visibility.Collapsed; 70 | InputPorts[0].ConnectedConnectors.Remove(Connector); 71 | InputPorts[0].ConnectedConnectors.ClearConnectors(); 72 | if (Host.Children.Contains(Start.ParentNode)) 73 | if (Host.Children.Contains(End.ParentNode)) 74 | if (End.ConnectedConnectors.Count == 0) 75 | NodesManager.CreateObjectConnector(Host, Start, End); 76 | Host.Children.Remove(this); 77 | Host.Nodes.Remove(this); 78 | } 79 | catch (Exception ex) 80 | { 81 | MessageBox.Show(ex.ToString()); 82 | } 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /VisualSR/Tools/Hub.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using VisualSR.BasicNodes; 4 | using VisualSR.Controls; 5 | using VisualSR.Core; 6 | 7 | namespace VisualSR.Tools 8 | { 9 | public static class Hub 10 | { 11 | public static string WorkSpace; 12 | public static VirtualControl VirtualScriptsHost { get; set; } 13 | public static VariablesList VarialbesHost { get; set; } 14 | public static List LoadedExternalNodes { get; set; } 15 | public static VirtualControl CurrentHost { get; set; } 16 | 17 | public static bool LoadVirtualData(VirtualControl vc, string str) 18 | { 19 | try 20 | { 21 | for (var index = 0; index < vc.Nodes.Count; index++) 22 | { 23 | var node = vc.Nodes[index]; 24 | node.Delete(); 25 | } 26 | var data = Cipher.DeSerializeFromString(str); 27 | for (var index = data.Nodes.Count - 1; index >= 0; index--) 28 | { 29 | var copiednode = data.Nodes[index]; 30 | var typename = copiednode.Name; 31 | Node newNode = null; 32 | foreach (var node in LoadedExternalNodes) 33 | { 34 | if (node.ToString() != typename) continue; 35 | newNode = node.Clone(); 36 | vc.AddNode(newNode, copiednode.X, copiednode.Y); 37 | newNode.DeSerializeData(copiednode.InputData, copiednode.OutputData); 38 | newNode.Id = copiednode.Id; 39 | break; 40 | } 41 | if (newNode != null) continue; 42 | var type = Type.GetType(typename); 43 | if (type != null) 44 | { 45 | var instance = Activator.CreateInstance(type, vc, false); 46 | vc.AddNode(instance as Node, copiednode.X, copiednode.Y); 47 | var node = instance as Node; 48 | if (node != null) node.Id = copiednode.Id; 49 | } 50 | } 51 | foreach (var eConn in data.ExecutionConnectors) 52 | { 53 | var start = vc.GetNode(eConn.StartNode_ID); 54 | var end = vc.GetNode(eConn.EndNode_ID); 55 | NodesManager.CreateExecutionConnector(vc, start.OutExecPorts[eConn.StartPort_Index], 56 | end.InExecPorts[eConn.EndPort_Index]); 57 | } 58 | foreach (var oConn in data.ObjectConnectors) 59 | { 60 | var start = vc.GetNode(oConn.StartNode_ID); 61 | var end = vc.GetNode(oConn.EndNode_ID); 62 | NodesManager.CreateObjectConnector(vc, start.OutputPorts[oConn.StartPort_Index], 63 | end.InputPorts[oConn.EndPort_Index]); 64 | } 65 | foreach (var divider in data.SpaghettiDividers) 66 | { 67 | var node = vc.GetNode(divider.EndNode_ID); 68 | var port = node.InputPorts[divider.Port_Index]; 69 | var conn = port.ConnectedConnectors[0]; 70 | var spaghettiDivider = new SpaghettiDivider(vc, conn, false) 71 | { 72 | X = divider.X, 73 | Y = divider.Y 74 | }; 75 | vc.AddNode(spaghettiDivider, spaghettiDivider.X, spaghettiDivider.Y); 76 | } 77 | } 78 | catch (Exception) 79 | { 80 | return false; 81 | } 82 | foreach (var node in vc.Nodes) 83 | node.Refresh(); 84 | vc.NeedsRefresh = true; 85 | 86 | return true; 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B4DCEC74-E9BA-4D95-928F-3B81F8BF3275} 8 | Library 9 | Properties 10 | Nodes 11 | Nodes 12 | v4.5 13 | 512 14 | true 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | ..\..\VisualSR\bin\Debug\VisualSR.dll 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /VisualSR/Core/RVariable.cs: -------------------------------------------------------------------------------- 1 | /*Copyright 2018 ALAA BEN FATMA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ 8 | using System.ComponentModel; 9 | using System.Windows.Media; 10 | using VisualSR.Properties; 11 | 12 | namespace VisualSR.Core 13 | { 14 | public enum RTypes 15 | { 16 | //Character refers to strings too, will be using the same properties. 17 | Character, 18 | 19 | //Numeric refers to Doubles,Integers,Decimals,Bytes and even complex values. 20 | Numeric, 21 | 22 | //Logical refers to either TRUE or FALSE values. With that being said, you can call it a boolean type. 23 | Logical, 24 | 25 | /*While matrices are confined to two dimensions, arrays can be of any number of dimensions. 26 | *Factors are the r-objects which are created using a vector. It stores the vector along with the distinct values of the elements in the vector as labels. 27 | *A list is an R-object which can contain many different types of elements inside it like vectors, functions and even another list inside it. 28 | *A matrix is a two-dimensional rectangular data set. It can be created using a vector input to the matrix function. 29 | */ 30 | ArrayOrFactorOrListOrMatrix, 31 | 32 | 33 | //Data frames are tabular data objects. Unlike a matrix in data frame each column can contain different modes of data. 34 | DataFrame, 35 | 36 | 37 | //This one can contain any value you put into it. 38 | Generic 39 | } 40 | 41 | public class RVariable : INotifyPropertyChanged 42 | { 43 | private ObjectPort _pp; 44 | private string _value; 45 | 46 | public RTypes Type; 47 | 48 | /// 49 | /// Virtual type that works as a data container for R-data-like types. 50 | /// 51 | /// 52 | public RVariable(RTypes type) 53 | { 54 | Type = type; 55 | } 56 | 57 | public ObjectPort ParentPort 58 | { 59 | get { return _pp; } 60 | set 61 | { 62 | _pp = value; 63 | switch (Type) 64 | { 65 | case RTypes.ArrayOrFactorOrListOrMatrix: 66 | ParentPort.StrokeBrush = Brushes.DodgerBlue; 67 | break; 68 | case RTypes.Character: 69 | ParentPort.StrokeBrush = Brushes.Magenta; 70 | 71 | break; 72 | case RTypes.Logical: 73 | ParentPort.StrokeBrush = Brushes.Red; 74 | 75 | break; 76 | case RTypes.Numeric: 77 | ParentPort.StrokeBrush = Brushes.LawnGreen; 78 | break; 79 | case RTypes.DataFrame: 80 | ParentPort.StrokeBrush = Brushes.Orange; 81 | break; 82 | default: 83 | ParentPort.StrokeBrush = Brushes.LightGray; 84 | break; 85 | } 86 | } 87 | } 88 | 89 | /// 90 | /// Contains the data that will be parsed. 91 | /// 92 | public string Value 93 | { 94 | get { return _value; } 95 | set 96 | { 97 | _value = value; 98 | OnPropertyChanged("Value"); 99 | ParentPort.OnDataChanged(); 100 | } 101 | } 102 | 103 | public event PropertyChangedEventHandler PropertyChanged; 104 | 105 | [NotifyPropertyChangedInvocator] 106 | protected virtual void OnPropertyChanged(string propertyName = null) 107 | { 108 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 109 | } 110 | } 111 | } -------------------------------------------------------------------------------- /Nodes/Nodes/Nodes/Characters/Grep.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using VisualSR.Controls; 3 | using VisualSR.Core; 4 | using VisualSR.Tools; 5 | 6 | namespace Nodes.Nodes.Characters 7 | { 8 | [Export(typeof(Node))] 9 | public class Grep : Node 10 | 11 | { 12 | private readonly UnrealControlsCollection.CheckBox _cb = 13 | new UnrealControlsCollection.CheckBox {IsChecked = true}; 14 | 15 | private readonly UnrealControlsCollection.CheckBox _cbc = 16 | new UnrealControlsCollection.CheckBox {IsChecked = false}; 17 | 18 | private readonly UnrealControlsCollection.TextBox _p = new UnrealControlsCollection.TextBox(); 19 | private readonly UnrealControlsCollection.TextBox _t = new UnrealControlsCollection.TextBox(); 20 | private readonly VirtualControl Host; 21 | 22 | [ImportingConstructor] 23 | public Grep([Import("host")] VirtualControl host, [Import("bool")] bool spontaneousAddition = false) : base( 24 | host, NodeTypes.Basic, spontaneousAddition) 25 | { 26 | Title = "Grep"; 27 | Host = host; 28 | 29 | Category = "Characters"; 30 | AddObjectPort(this, "Text", PortTypes.Input, RTypes.Character, false, _t); 31 | AddObjectPort(this, "Pattern", PortTypes.Input, RTypes.Generic, false, _p); 32 | AddObjectPort(this, "Case sensitive", PortTypes.Input, RTypes.Logical, false, _cbc); 33 | AddObjectPort(this, "Normal Text", PortTypes.Input, RTypes.Logical, false, _cb); 34 | AddObjectPort(this, "Extracted value", PortTypes.Output, RTypes.Character, true); 35 | MouseRightButtonDown += (sender, args) => GenerateCode(); 36 | _t.TextChanged += (sender, args) => 37 | { 38 | InputPorts[0].Data.Value = _t.Text; 39 | GenerateCode(); 40 | }; 41 | _p.TextChanged += (sender, args) => 42 | { 43 | InputPorts[1].Data.Value = _p.Text; 44 | GenerateCode(); 45 | }; 46 | _cbc.Checked += (sender, args) => 47 | { 48 | InputPorts[2].Data.Value = _cbc.IsChecked.ToString().ToUpper(); 49 | GenerateCode(); 50 | }; 51 | _cb.Checked += (sender, args) => 52 | { 53 | InputPorts[3].Data.Value = _cb.IsChecked.ToString().ToUpper(); 54 | GenerateCode(); 55 | }; 56 | foreach (var port in InputPorts) 57 | port.DataChanged += (sender, args) => { GenerateCode(); }; 58 | InputPorts[1].LinkChanged += (sender, args) => 59 | { 60 | if (!InputPorts[1].Linked) 61 | InputPorts[1].Data.Value = _p.Text; 62 | }; 63 | InputPorts[0].LinkChanged += (sender, args) => 64 | { 65 | if (!InputPorts[0].Linked) 66 | InputPorts[0].Data.Value = _t.Text; 67 | }; 68 | InputPorts[3].LinkChanged += (sender, args) => 69 | { 70 | if (!InputPorts[3].Linked) 71 | InputPorts[3].Data.Value = _cb.IsChecked.ToString().ToUpper(); 72 | }; 73 | InputPorts[2].LinkChanged += (sender, args) => 74 | { 75 | if (!InputPorts[2].Linked) 76 | InputPorts[2].Data.Value = _cbc.IsChecked.ToString().ToUpper(); 77 | }; 78 | InputPorts[0].DataChanged += (s, e) => 79 | { 80 | if (_t.Text != InputPorts[0].Data.Value) 81 | _t.Text = InputPorts[0].Data.Value; 82 | }; 83 | InputPorts[1].DataChanged += (s, e) => 84 | { 85 | if (_p.Text != InputPorts[1].Data.Value) 86 | _p.Text = InputPorts[1].Data.Value; 87 | }; 88 | InputPorts[3].DataChanged += (s, e) => 89 | { 90 | if (_cb.IsChecked.ToString().ToUpper() != InputPorts[3].Data.Value) 91 | _cb.IsChecked = MagicLaboratory.ConvertFromString(InputPorts[3].Data.Value); 92 | }; 93 | InputPorts[2].DataChanged += (s, e) => 94 | { 95 | if (_cb.IsChecked.ToString().ToUpper() != InputPorts[2].Data.Value) 96 | _cbc.IsChecked = MagicLaboratory.ConvertFromString(InputPorts[2].Data.Value); 97 | }; 98 | } 99 | 100 | 101 | public override string GenerateCode() 102 | { 103 | OutputPorts[0].Data.Value = 104 | $"grep({_t},{_p},ignore.case={_cbc.IsChecked.ToString().ToUpper()},fixed={_cb.IsChecked.ToString().ToUpper()})"; 105 | return OutputPorts[0].Data.Value; 106 | } 107 | 108 | public override Node Clone() 109 | { 110 | var node = new Substr(Host); 111 | 112 | return node; 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Visual Scripting Environment for R and Data Science 2 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/splash.gif "SPLASH") 3 | 4 | ### Technical article -> https://www.codeproject.com/Articles/1239656/VisualSR 5 | 6 | ### 📉 Status 7 | ![AppVeyor](https://img.shields.io/appveyor/build/alaabenfatma/visualsr?style=plastic) 8 | ![GitHub issues](https://img.shields.io/github/issues/alaabenfatma/visualsr) 9 | ![GitHub](https://img.shields.io/github/license/alaabenfatma/visualsr) 10 | 11 | ### 🔧 Pre-requirments 12 |
    13 |
  • .NET Framework 4.5
  • 14 |
  • rscript has to be reachable from the command-line : https://www.r-project.org/ 15 |
16 | 17 | ### 🏗️ Build 18 | 19 | Each project in this repo (VisualSR, Nodes and demo) can be built using one of these two different approaches. 20 |
    21 |
  • Automatically : Using an IDE, such as Visual Studio or SharpDevelop.
  • 22 |
  • Semi-manually : You can use MSBuild
  • 23 | 24 |
     25 |   MSBuild.exe VisualSR\VisualSR.sln
     26 |   MSBuild.exe Nodes\Nodes.sln
     27 |   MSBuild.exe demo\demo.sln
     28 | 
    29 | 30 |
31 | 32 | ### 📚 Usage 33 | This repo contains 3 different projects. Each one of them contains a .csproj file that can load the whole project. 34 |
    35 |
  • VisualSR : This is the core of the project. It contains all the tools, custom controls and utilities. A class library (.dll) will be generated once the project is built.
  • 36 |
  • Nodes : This is a project within which I have created many samples of how to create custom nodes. A class library (.dll) will be generated once the project is built.
  • 37 |
  • DEMO : This GUI will provide the user with a UX which can help demonstrate the capabilities of this project.
  • 38 |
39 | 40 | ### 💕 Contributions 41 | The project is far from being perfect. Please do not hesitate to open issues, debug the code if needed or make pull requests! 42 | 43 | #### Please note that the rest is not a documentation, it is nothing but an *eye-catcher*. Refer to this article [CODEPROJECT](https://www.codeproject.com/Articles/1239656/VisualSR) for more details. 44 | 45 | 46 | 47 | 48 | ### NODES 49 | 50 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/nodes.png "SPLASH") 51 |
52 | 53 | ### CONNECTORS 54 | 55 | #### Diagram 56 | 57 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/connectors_diag.png "SPLASH") 58 |
59 | 60 | ### Applications 61 | 62 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/Conn_full.gif "SPLASH") 63 |
64 | 65 | ### Making connections 66 | 67 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/ob_link_simple.gif "SPLASH") 68 | 69 | ### Possibilities 70 | 71 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/ob_link_poss.gif "SPLASH") 72 |
73 | 74 | ### Deleting connections 75 | 76 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/delete.gif "SPLASH") 77 | 78 |
79 | 80 | ### Middle Man Algorithm 81 | 82 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/MM.gif "SPLASH") 83 |
84 | 85 | 86 | ### SAMPLES 87 | 88 | #### Math 89 | 90 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/v_formula.png "SPLASH") 91 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/v_form_graph.png "SPLASH") 92 |
93 | 94 | 95 | #### For loop 96 | 97 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/for.png "SPLASH") 98 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/for_console.png "SPLASH") 99 |
100 | 101 | #### Graph 102 | 103 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/code1.png "SPLASH") 104 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/code2.png "SPLASH") 105 |
106 | 107 | ## More stuff you will find 108 | 109 | #### A performance gauge 110 | 111 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/Gauge_Perform.gif "SPLASH") 112 |
113 | 114 | #### Commenting zones 115 | 116 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/comment1.png "SPLASH") 117 |
118 | 119 | #### Variables list 120 | 121 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/var_drag_drop.gif "SPLASH") 122 |
123 | 124 | #### Altered Nodes Tree 125 | 126 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/Tree_Nodes_Altered.gif "SPLASH") 127 |
128 | 129 | 130 | #### Search for nodes 131 | 132 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/GoNode.gif "SPLASH") 133 |
134 |
135 | 136 | # DEMO 137 | ![alt text](https://github.com/alaabenfatma/VisualSR/blob/master/Resources/demo.png "SPLASH") 138 |
139 | -------------------------------------------------------------------------------- /VisualSR/Controls/Search.cs: -------------------------------------------------------------------------------- 1 | /*Copyright 2018 ALAA BEN FATMA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ 8 | using System.ComponentModel; 9 | using System.Runtime.CompilerServices; 10 | using System.Windows; 11 | using System.Windows.Controls; 12 | using System.Windows.Input; 13 | using System.Windows.Media; 14 | using System.Windows.Shapes; 15 | using VisualSR.Core; 16 | using VisualSR.Properties; 17 | using VisualSR.Tools; 18 | 19 | namespace VisualSR.Controls 20 | { 21 | public class Search : Window, INotifyPropertyChanged 22 | { 23 | private readonly VirtualControl _host; 24 | private TextBlock clear; 25 | private TextBlock go; 26 | private ListView lv; 27 | 28 | private TextBox tb; 29 | 30 | public Search(VirtualControl host) 31 | { 32 | WindowStyle = WindowStyle.ToolWindow; 33 | _host = host; 34 | Style = FindResource("Search") as Style; 35 | Loaded += (s, e) => 36 | { 37 | clear = Template.FindName("Clear", this) as TextBlock; 38 | go = Template.FindName("FindButton", this) as TextBlock; 39 | tb = Template.FindName("NodeName", this) as TextBox; 40 | lv = Template.FindName("FoundNodes", this) as ListView; 41 | clear.MouseLeftButtonUp += (ss, ee) => tb.Clear(); 42 | go.MouseLeftButtonUp += Go_MouseLeftButtonUp; 43 | Topmost = true; 44 | }; 45 | } 46 | 47 | public event PropertyChangedEventHandler PropertyChanged; 48 | 49 | private void Go_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) 50 | { 51 | lv.Items.Clear(); 52 | foreach (var node in _host.Nodes) 53 | if (node.Search(tb.Text) != null) 54 | { 55 | var tv = new TreeView {Background = new SolidColorBrush(Color.FromArgb(35, 35, 35, 35))}; 56 | tv.Items.Add(node.Search(tb.Text)); 57 | lv.Items.Add(tv); 58 | } 59 | } 60 | 61 | [NotifyPropertyChangedInvocator] 62 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) 63 | { 64 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 65 | } 66 | } 67 | 68 | public class FoundItem : TreeViewItem 69 | { 70 | private readonly Path ctrl = new Path {Width = 15, Height = 15, Margin = new Thickness(0, -2, 0, 0)}; 71 | 72 | private readonly TextBlock hint = 73 | new TextBlock {Foreground = Brushes.WhiteSmoke, Background = Brushes.Transparent}; 74 | 75 | private string _hint; 76 | 77 | private Brush brush; 78 | 79 | public ItemTypes Type; 80 | 81 | public FoundItem(Brush b = null) 82 | { 83 | IsExpanded = true; 84 | Loaded += (s, e) => 85 | { 86 | MouseDoubleClick += FoundItem_MouseDoubleClick; 87 | 88 | 89 | var sp = new StackPanel {Orientation = Orientation.Horizontal, MaxHeight = 20}; 90 | sp.Children.Add(ctrl); 91 | sp.Children.Add(hint); 92 | Header = sp; 93 | if (Type == ItemTypes.Port) 94 | { 95 | ctrl.Style = FindResource("ObjectPin") as Style; 96 | ctrl.Stroke = b; 97 | } 98 | else 99 | { 100 | ctrl.Style = FindResource("ExecPin") as Style; 101 | } 102 | }; 103 | } 104 | 105 | public string Hint 106 | { 107 | get { return _hint; } 108 | set 109 | { 110 | _hint = value; 111 | if (hint != null) hint.Text = value; 112 | } 113 | } 114 | 115 | public Brush Brush 116 | { 117 | get { return brush; } 118 | set 119 | { 120 | brush = value; 121 | ctrl.Stroke = value; 122 | ctrl.Fill = value; 123 | } 124 | } 125 | 126 | public Node foundNode { get; set; } 127 | 128 | private void FoundItem_MouseDoubleClick(object sender, MouseButtonEventArgs e) 129 | { 130 | foundNode.Host.GoForNode(foundNode); 131 | } 132 | } 133 | } -------------------------------------------------------------------------------- /VisualSR/Core/Wire.cs: -------------------------------------------------------------------------------- 1 | /*Copyright 2018 ALAA BEN FATMA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ 8 | using System; 9 | using System.ComponentModel; 10 | using System.Windows; 11 | using System.Windows.Controls; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Animation; 14 | using System.Windows.Shapes; 15 | using VisualSR.Properties; 16 | using VisualSR.Tools; 17 | 18 | namespace VisualSR.Core 19 | { 20 | public class Wire : Control, INotifyPropertyChanged 21 | { 22 | private readonly PointAnimationUsingPath beatsAnimation = new PointAnimationUsingPath(); 23 | 24 | private readonly Storyboard heart = new Storyboard(); 25 | private Point _epoint; 26 | private Point _mpoint1; 27 | private Point _mpoint2; 28 | private Point _spoint; 29 | 30 | public Wire() 31 | { 32 | Style = (Style) FindResource("VirtualWire"); 33 | Background = Brushes.WhiteSmoke; 34 | Focusable = false; 35 | Loaded += (s, e) => 36 | { 37 | IsVisibleChanged += (ss, ee) => 38 | { 39 | if (Visibility != Visibility.Visible) 40 | stopAnimation(); 41 | }; 42 | }; 43 | 44 | 45 | beatsAnimation.Completed += BeatsAnimation_Completed; 46 | heart.Children.Add(beatsAnimation); 47 | } 48 | 49 | public Connector ParentConnector { get; set; } 50 | 51 | public Point StartPoint 52 | { 53 | get { return _spoint; } 54 | set 55 | { 56 | _spoint = value; 57 | OnPropertyChanged("StartPoint"); 58 | MiddlePoint1 = _spoint; 59 | } 60 | } 61 | 62 | public Point MiddlePoint1 63 | { 64 | get { return _mpoint1; } 65 | set 66 | { 67 | _mpoint1 = new Point(value.X + 70, value.Y); 68 | OnPropertyChanged("MiddlePoint1"); 69 | } 70 | } 71 | 72 | public Point MiddlePoint2 73 | { 74 | get { return _mpoint2; } 75 | set 76 | { 77 | OnPropertyChanged("MiddlePoint2"); 78 | _mpoint2 = new Point(value.X - 70, value.Y); 79 | } 80 | } 81 | 82 | public Point EndPoint 83 | { 84 | get { return _epoint; } 85 | set 86 | { 87 | _epoint = value; 88 | 89 | MiddlePoint2 = _epoint; 90 | OnPropertyChanged("EndPoint"); 91 | } 92 | } 93 | 94 | 95 | public event PropertyChangedEventHandler PropertyChanged; 96 | 97 | public void HeartBeatsAnimation(bool forever = true) 98 | { 99 | try 100 | { 101 | var path = Template.FindName("Wire", this) as Path; 102 | beatsAnimation.PathGeometry = path.Data.GetFlattenedPathGeometry(); 103 | beatsAnimation.Duration = TimeSpan.FromSeconds(1); 104 | (Template.FindName("BeatContainer", this) as Path).Visibility = Visibility.Visible; 105 | beatsAnimation.RepeatBehavior = forever ? RepeatBehavior.Forever : new RepeatBehavior(1); 106 | (Template.FindName("Beat", this) as EllipseGeometry).BeginAnimation(EllipseGeometry.CenterProperty, 107 | beatsAnimation); 108 | } 109 | catch (Exception) 110 | { 111 | //Ignored 112 | } 113 | } 114 | 115 | private void BeatsAnimation_Completed(object sender, EventArgs e) 116 | { 117 | stopAnimation(); 118 | } 119 | 120 | private void stopAnimation() 121 | { 122 | (Template.FindName("Beat", this) as EllipseGeometry).BeginAnimation(EllipseGeometry.CenterProperty, null); 123 | (Template.FindName("BeatContainer", this) as Path).Visibility = Visibility.Collapsed; 124 | } 125 | 126 | public void ParentNodeOnPropertyChanged(Port s, Port e) 127 | { 128 | var sp = PointsCalculator.PortOrigin(s); 129 | var ep = PointsCalculator.PortOrigin(e); 130 | StartPoint = sp; 131 | EndPoint = ep; 132 | } 133 | 134 | [NotifyPropertyChangedInvocator] 135 | protected virtual void OnPropertyChanged(string propertyName = null) 136 | { 137 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 138 | } 139 | } 140 | } -------------------------------------------------------------------------------- /demo/demo/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /VisualSR/Core/Brain.cs: -------------------------------------------------------------------------------- 1 | /*Copyright 2018 ALAA BEN FATMA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ 8 | /* 9 | * Brain is an UNDO/REDO framework 10 | * It is still under exp 11 | */ 12 | //using System; 13 | //using System.Collections.Generic; 14 | //using System.Windows.Forms; 15 | //using VisualSR.Tools; 16 | 17 | //namespace VisualSR.Core 18 | //{ 19 | 20 | // public class VirtualStack : Stack 21 | // { 22 | // public Stack RedoList = new Stack(); 23 | // public event EventHandler CollectionChanged; 24 | // public new Record Pop() 25 | // { 26 | // if (Count == 0) return null; 27 | // var x = base.Pop(); 28 | // RedoList.Push(x); 29 | // OnCollectionChanged(); 30 | // return x as Record; 31 | // } 32 | 33 | // public void Push(T item, bool redoing) 34 | // { 35 | // Push(item); 36 | // if (!redoing) 37 | // RedoList.Clear(); 38 | // OnCollectionChanged(); 39 | // } 40 | 41 | // protected virtual void OnCollectionChanged() 42 | // { 43 | // CollectionChanged?.Invoke(this, EventArgs.Empty); 44 | // } 45 | // } 46 | 47 | // public enum PossibleEvents 48 | // { 49 | // //VirtualControl related events 50 | // MoveNodes, 51 | // DeleteNode, 52 | // AddNode, 53 | // MakeAConnection, 54 | // DeleteAConnection, 55 | // AddAPin, 56 | // //VariablesList 57 | // AddAVariable, 58 | // DeleteAVarible, 59 | // RenameAVarible, 60 | // ChangeTypeOfAVariable, 61 | // //ContentsBrowser 62 | // MakeNewItem, 63 | // RenameItem, 64 | // DeleteItem, 65 | // //FunctionsList : not supported yet 66 | // } 67 | 68 | // public class UndoAddNode : Record 69 | // { 70 | 71 | // public UndoAddNode(VirtualControl host,Node Node) : base(() => 72 | // { 73 | // Node.Delete(true); 74 | // }, () => 75 | // { 76 | // var props = new NodeProperties(Node); 77 | // var capture = new CaptureData {Data = props}; 78 | // var data = capture.Data as NodeProperties; 79 | // var typename = data.Name; 80 | // Node newNode = null; 81 | // foreach (var node in Hub.LoadedExternalNodes) 82 | // { 83 | // if (node.ToString() != typename) continue; 84 | // newNode = node.Clone(); 85 | // host.AddNode(newNode, data.X, data.Y,true); 86 | // newNode.DeSerializeData(data.InputData, data.OutputData); 87 | // newNode.Id = data.Id; 88 | // break; 89 | // } 90 | // if (newNode != null) return; 91 | // var type = Type.GetType(typename); 92 | // if (type != null) 93 | // { 94 | // var instance = Activator.CreateInstance(type, host, false); 95 | // host.AddNode(instance as Node, data.X, data.Y,true); 96 | // var node = instance as Node; 97 | // if (node != null) node.Id = data.Id; 98 | // } 99 | // }, "Add Node") 100 | // { 101 | // } 102 | // } 103 | // public class CaptureData 104 | // { 105 | // public object Data; 106 | // } 107 | // public class Record 108 | // { 109 | 110 | // public Action Command; 111 | // public Action Opposite; 112 | // public string Description; 113 | // public Record(Action command,Action opposite, string description) 114 | // { 115 | // Command = command; 116 | // Opposite = opposite; 117 | // Description = description; 118 | // Opposite(); 119 | // } 120 | 121 | 122 | // public void Undo() 123 | // { 124 | 125 | // Command(); 126 | // } 127 | // } 128 | 129 | // public class Brain 130 | // { 131 | // /// 132 | // /// This stack will contain all the previous states of a specific 133 | // /// control based on some serialized data. 134 | // /// 135 | // public VirtualStack UndoList = new VirtualStack(); 136 | 137 | // public void AddToUndo(Record item, bool redoing=false) 138 | // { 139 | // UndoList.Push(item, redoing); 140 | // } 141 | 142 | // public void Undo() 143 | // { 144 | // if (UndoList.Count == 0) return; 145 | // var x = UndoList.Pop(); 146 | 147 | // x.Undo(); 148 | // } 149 | 150 | // public void Redo() 151 | // { 152 | // if (UndoList.RedoList.Count == 0) 153 | // { 154 | // MessageBox.Show("redo empty."); 155 | // return; 156 | // } 157 | // AddToUndo(UndoList.RedoList.Peek() as Record, true); 158 | // UndoList.RedoList.Pop().Opposite(); 159 | // } 160 | // } 161 | //} 162 | 163 | -------------------------------------------------------------------------------- /VisualSR/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | --------------------------------------------------------------------------------