示例#1
0
 private ViewModelConnect AddConnect(ViewModelConnect parameter, ViewModelConnect result)
 {
     if (result == null)
     {
         return(parameter);
     }
     result.FromConnector.CommandAdd.Execute();
     Connects.Add(result);
     return(result);
 }
示例#2
0
        public static ViewModelConnect FromXElement(ViewModelNodesCanvas nodesCanvas, XElement node, out string errorMessage, Func <string, bool> actionForCheck)
        {
            ViewModelConnect viewModelConnect = null;

            errorMessage = null;
            string name = node.Attribute("Name")?.Value;
            string from = node.Attribute("From")?.Value;
            string to   = node.Attribute("To")?.Value;

            if (string.IsNullOrEmpty(name))
            {
                errorMessage = "Connect without name";
                return(viewModelConnect);
            }
            if (string.IsNullOrEmpty(from))
            {
                errorMessage = "Connect without from point";
                return(viewModelConnect);
            }
            if (string.IsNullOrEmpty(to))
            {
                errorMessage = "Connect without to point";
                return(viewModelConnect);
            }
            if (actionForCheck(name))
            {
                errorMessage = String.Format("Contains more than one connect with name \"{0}\"", name);
                return(viewModelConnect);
            }

            ViewModelNode nodeFrom = nodesCanvas.Nodes.Single(x => x.Name == from);
            ViewModelNode nodeTo   = nodesCanvas.Nodes.Single(x => x.Name == to);

            nodeFrom.CurrentConnector.Name = name;


            if (nodeFrom == nodeTo)
            {
                nodeFrom.CurrentConnector.CommandSetAsLoop.ExecuteWithSubscribe();
            }
            else
            {
                viewModelConnect             = new ViewModelConnect(nodeFrom.NodesCanvas, nodeFrom.CurrentConnector);
                viewModelConnect.ToConnector = nodeTo.Input;
                nodeFrom.CommandAddEmptyConnector.ExecuteWithSubscribe();
            }

            return(viewModelConnect);
        }
示例#3
0
 private ViewModelConnect DeleteConnect(ViewModelConnect parameter, ViewModelConnect result)
 {
     Connects.Remove(parameter);
     parameter.FromConnector.CommandDelete.Execute();
     return(parameter);
 }
示例#4
0
 private void AddFreeConnect(ViewModelConnector fromConnector)
 {
     DraggedConnect = new ViewModelConnect(fromConnector);
     Connects.Add(DraggedConnect);
 }