示例#1
0
        /// <summary>
        /// Create new connection
        /// </summary>
        /// <returns>Connection was created or not</returns>
        public bool CreateConnection(PortViewModel first, PortViewModel second)
        {
            try
            {
                Scheme.Connect(first.Port, second.Port);
                ConnectionViewModel conn = new ConnectionViewModel();

                Binding bind = new Binding("Hotspot");
                bind.Source = first;
                BindingOperations.SetBinding(conn, ConnectionViewModel.Hotspot1Property, bind);

                bind        = new Binding("Hotspot");
                bind.Source = second;
                BindingOperations.SetBinding(conn, ConnectionViewModel.Hotspot2Property, bind);

                Connections.Add(conn);
                ConsViewModel.Print(string.Format("Connection created beetwen {0} and {1}", first.Port, second.Port));
            }
            catch (Exception e)
            {
                ConsViewModel.PrintError(e.Message);
                return(false);
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// Create new node
        /// </summary>
        /// <param name="debug">Print result in console</param>
        NodeViewModel CreateNode(Main.Nodes.NodeType type, double left, double right, bool debug, string name = null)
        {
            NodeViewModel inst = new NodeViewModel(Scheme.CreateNode(type, name), left, right, this);

            Nodes.Add(inst);

            if (debug)
            {
                ConsViewModel.Print(string.Format("Node ({0}) added", inst.NodeModel));
            }
            return(inst);
        }