Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
0
        public MainWindowViewModel()
        {
            List <Assembly> _assemblys = new List <Assembly>();

            _assemblys.Add(Assembly.LoadFrom(@"StandartNodes.dll"));
            _nodeTypes = new Main.Nodes.NodeTypesManager(_assemblys);

            WorkArea = new WorkAreaViewModel(_nodeTypes);

            NodeTypes = new NodeTypesListViewModel(_nodeTypes);

            MyConsole = new ConsViewModel();

            CalculateSchemeCommand = new SimpleCommand(CalculateSchemeExcecuted);
            ClearSchemeCommand     = new SimpleCommand(ClearSchemeExcecuted);
            SaveSchemeCommand      = new SimpleCommand(SaveSchemeExcecuted);
            LoadSchemeCommand      = new SimpleCommand(LoadSchemeExcecuted);
        }