public bool ParseCommand(string command, Main.Nodes.NodeTypesManager nodeTypes, Main.Sceme.Scheme scheme, EndPoint _remote) { Regex reg = new Regex(@"^create ([^ ]+)(?: -([^ ]+)){0,1}$"); Match match = reg.Match(command); bool flag = false; if (match.Success) { flag = true; try { string nodeName; if (match.Groups[3].Value != "") { nodeName = match.Groups[3].Value; } else { nodeName = null; } var newNode = scheme.CreateNode(nodeTypes.GetNodeType(match.Groups[1].ToString()), nodeName); PrintSuccess(string.Format("Node '{0}' created", newNode.Name), _remote); } catch (Exception e) { PrintError(e.Message, _remote); } } reg = new Regex(@"^print(?: -([^ ]+)){0,1}$"); match = reg.Match(command); if (match.Success) { flag = true; try { var nodes = scheme.Nodes; foreach (Main.Nodes.Node node in nodes) { if (match.Groups[1].Value != "") { if (node.Name != match.Groups[1].Value) { continue; } } Print(string.Format(">>'{0}' of type '{1}'", node.Name, node.NodeType.Name), _remote); Print("inputs:", _remote); var ports = node.PortManager.GetPorts(Main.Ports.PortType.Input); foreach (Main.Ports.Port port in ports) { if (Main.Connections.ConnectionManager.Connected(port)) { Main.Ports.Port _conenctedTo = Main.Connections.ConnectionManager.GetAllConnections(port)[0]; Print(string.Format(" {0} : connected to '{1}.{2}'", port.Name, _conenctedTo.Parent.Name, _conenctedTo.Name), _remote); } else { Print(string.Format(" {0} : value = {1}", port.Name, Main.Values.ValueManager.GetVal(port)), _remote); } } Print("outputs:", _remote); var outputs = node.PortManager.GetPorts(Main.Ports.PortType.Output); foreach (Main.Ports.Port port in outputs) { Print(string.Format(" {0} : value(calculated) = {1}", port.Name, Main.Values.ValueManager.GetVal(port)), _remote); } } } catch (Exception e) { PrintError(e.Message, _remote); } } reg = new Regex(@"^connect ([^ .]+).([^ .]+) ([^ .]+).([^ .]+)$"); match = reg.Match(command); if (match.Success) { flag = true; try { Main.Nodes.Node node1 = scheme.Nodes.Find((x) => x.Name == match.Groups[1].Value); Main.Ports.Port port1 = node1.PortManager.GetPort(match.Groups[2].Value); Main.Nodes.Node node2 = scheme.Nodes.Find((x) => x.Name == match.Groups[3].Value); Main.Ports.Port port2 = node2.PortManager.GetPort(match.Groups[4].Value); scheme.Connect(port1, port2); PrintSuccess(string.Format("Conenction between '{0}.{1}' and '{2}.{3}' created", node1.Name, port1.Name, node2.Name, port2.Name), _remote); } catch (Exception e) { PrintError(e.Message, _remote); } } reg = new Regex(@"^set ([^ .]+).([^ .]+) (True|False|true|false)$"); match = reg.Match(command); if (match.Success) { flag = true; try { Main.Nodes.Node node1 = scheme.Nodes.Find((x) => x.Name == match.Groups[1].Value); Main.Ports.Port port1 = node1.PortManager.GetPort(match.Groups[2].Value); Main.Values.ValueManager.SetValue(port1, Convert.ToBoolean(match.Groups[3].Value)); PrintSuccess("Value changed", _remote); } catch (Exception e) { PrintError(e.Message, _remote); } } reg = new Regex(@"^help$"); match = reg.Match(command); if (match.Success) { flag = true; PrintHelp(nodeTypes, _remote); } if (!flag) { PrintError("No such command", _remote); } return(true); }