Example #1
0
 public TerminalModel(string name, Type type, Direction defaultDirection, TerminalKind kind, int index)
 {
     ConnectedWires   = new List <WireModel>();
     PropertyChanged += OnTerminalPropertyChanged;
     TerminalIndex    = index;
     Direction        = defaultDirection;
     Kind             = kind;
     Type             = type;
     Name             = name;
 }
Example #2
0
        private Terminal FindOrCreateTerminalViewModel <T>(string name, Direction direction, TerminalKind kind)
        {
            var terminalViewModel = _nodeViewModel.Terminals.FirstOrDefault(viewModel => viewModel.Model.TerminalIndex == _terminalIndex);

            if (terminalViewModel != null)
            {
                return(terminalViewModel);
            }

            var terminalModel = new TerminalModel(name, typeof(T), direction, kind, _terminalIndex);

            terminalViewModel = Terminal.CreateTerminalViewModel(terminalModel);
            _nodeViewModel.AddTerminalViewModel(terminalViewModel);
            return(terminalViewModel);
        }
Example #3
0
        /// <summary>
        ///     Sets up a terminal on this node of the given kind.
        /// </summary>
        /// <param name="name">The name of the terminal.</param>
        /// <param name="direction">The default side of the node this terminal belongs on.</param>
        /// <param name="kind">The kind of terminal to create.</param>
        /// <remarks>For now, dynamically creating terminals at runtime is not supported</remarks>
        private TypedTerminal <T> CreateClientTerminal <T>(string name, Direction direction, TerminalKind kind)
        {
            var terminalViewModel = FindOrCreateTerminalViewModel <T>(name, direction, kind);

            _terminalIndex++;
            return(new TypedTerminal <T>(terminalViewModel));
        }