Exemple #1
0
        /// <summary>
        /// 刷新 树形控件
        /// </summary>
        /// <param name="tree">null:全部刷新,node 刷新改节点下的控件</param>
        /// <param name="node">父节点</param>
        private void SetTree(TreeNode tree, NodeParam node)
        {
            if (tree == null)
            {
                this.programTree.Nodes.Clear();
                this.programTree.Nodes.Add(new TreeNode());
                this.programTree.Nodes[0].ContextMenu = node.Menu(this);
                this.programTree.Nodes[0].Tag         = node;
                this.programTree.Nodes[0].Text        = node.Text();

                foreach (NodeParam param in node.Nodes)
                {
                    SetTree(this.programTree.Nodes[0], param);
                }
            }
            else
            {
                TreeNode tNode = new TreeNode(node.Text());
                tNode.Tag         = node;
                tNode.ContextMenu = node.Menu(this);
                tNode.Text        = node.Text();
                tree.Nodes.Add(tNode);
                foreach (NodeParam param in node.Nodes)
                {
                    SetTree(tNode, param);
                }
            }
        }
Exemple #2
0
 private void programTree_KeyDown(object sender, KeyEventArgs e)
 {
     if (this.programTree.SelectedNode == null)
     {
         return;
     }
     if (e.Control && e.KeyCode == Keys.C)
     {
         var  node = this.programTree.SelectedNode.Tag as NodeParam;
         Type type = node.GetType();
         if (type == typeof(PCSParam) ||
             type == typeof(ReadCodeParam) ||
             type == typeof(BadmarkParam) ||
             type == typeof(PasteParam))
         {
             nodeParamCopy = (this.programTree.SelectedNode.Tag as NodeParam).Clone() as NodeParam;
             Debug.WriteLine("复制");
         }
         else
         {
             nodeParamCopy = null;
         }
     }
     else if (e.Control && e.KeyCode == Keys.V) // 拷贝
     {
         var parent = this.programTree.SelectedNode.Tag as NodeParam;
         if (parent == null || nodeParamCopy == null)
         {
             return;
         }
         Type type  = parent.GetType();
         Type type2 = nodeParamCopy.GetType();
         if (type2 == typeof(PCSParam) && type == typeof(PCBParam))
         {
             this.Flow.PCB.Nodes.Add(nodeParamCopy.Clone() as PCSParam);
             this.RefreshTree();
         }
         else if (type2 == typeof(PasteParam) && type == typeof(PasteListNode))
         {
             parent.Nodes.Add(nodeParamCopy.Clone() as PasteParam);
             this.RefreshTree();
         }
         else if (type2 == typeof(BadmarkParam) && type == typeof(BadmarkListNode))
         {
             parent.Nodes.Add(nodeParamCopy.Clone() as BadmarkParam);
             this.RefreshTree();
         }
         else if (type2 == typeof(MarkParam) && type == typeof(ReadCodeListNode))
         {
             parent.Nodes.Add(nodeParamCopy.Clone() as MarkParam);
             this.RefreshTree();
         }
     }
 }
Exemple #3
0
 public ExcutedResult QueryNodeInfos(NodeParam model)
 {
     try
     {
         if (model == null)
         {
             return(ExcutedResult.FailedResult(BusinessResultCode.ArgumentError, "参数错误或无效"));
         }
         if (String.IsNullOrEmpty(model.SortName))
         {
             model.SortName = "CreateTime";
         }
         var dataInfo = Repository.QueryNode(model);
         if (dataInfo != null)
         {
             return(ExcutedResult.SuccessResult(dataInfo));
         }
         return(ExcutedResult.FailedResult(BusinessResultCode.DataNotExist, "数据不存在,请刷新!"));
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
 }
            public void Draw(int id)
            {
                // Init available params
                AvailableParameters = new Dictionary <Parameter.PARAM_TYPE, List <NodeParam> >();
                foreach (var val in Enum.GetValues(typeof(Parameter.PARAM_TYPE)))
                {
                    AvailableParameters.Add((Parameter.PARAM_TYPE)val, new List <NodeParam>());
                }
                g_ScrollPosition = GUILayout.BeginScrollView(g_ScrollPosition);
                GUILayout.BeginHorizontal("Box");
                GUILayout.Label(new GUIContent("Parameters"));
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(new GUIContent("+")))
                {
                    AddParameter();
                }
                GUILayout.EndHorizontal();
                // Draw Parameters
                if (Parameters.Count > 0)
                {
                    NodeParam toRemove = null;
                    GUILayout.BeginVertical("Box");
                    int index = 1;
                    foreach (NodeParam p in Parameters)
                    {
                        GUILayout.BeginVertical("Box");
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button(new GUIContent("-")))
                        {
                            toRemove = p;
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        string paramName = string.IsNullOrEmpty(p.Name) ? "P" + index : p.Name;
                        GUILayout.Label(new GUIContent("Name"));
                        p.Name = GUILayout.TextField(paramName);
                        // = EditorGUILayout.TextField("Name", paramName);
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Type");
                        GUILayout.FlexibleSpace();
                        p.AssignedType = (Parameter.PARAM_TYPE)EditorGUILayout.EnumPopup(p.AssignedType);
                        AvailableParameters[p.AssignedType].Add(p);
                        GUILayout.EndHorizontal();
                        var val = p.GetValue();
                        switch (p.AssignedType)
                        {
                        case Parameter.PARAM_TYPE.BOOL:
                            if (!(val is Boolean))
                            {
                                val = false;
                            }
                            p.SetValue(GUILayout.Toggle((bool)val, new GUIContent("Value")));
                            break;

                        case Parameter.PARAM_TYPE.AGENT:
                            if (!(val is UnityEngine.Object))
                            {
                                val = null;
                            }
                            UnityEngine.Object a = EditorGUILayout.ObjectField((UnityEngine.Object)val ?? null, typeof(GameObject), true);
                            if (a != null && a is GameObject && ((GameObject)a).GetComponent <NPCController>() != null)
                            {
                                p.SetValue(a, typeof(UnityEngine.Object));
                            }
                            break;

                        case Parameter.PARAM_TYPE.GAMEOBJECT:
                            if (!(val is UnityEngine.Object))
                            {
                                val = null;
                            }
                            UnityEngine.Object o = EditorGUILayout.ObjectField((UnityEngine.Object)val ?? null, typeof(GameObject), true);
                            if (o != null)
                            {
                                p.SetValue(o, typeof(UnityEngine.Object));
                            }
                            break;

                        case Parameter.PARAM_TYPE.NUMERICAL:
                            if (!(val is Single))
                            {
                                val = 0;
                            }
                            p.SetValue(EditorGUILayout.FloatField(Convert.ToSingle(val)));
                            break;

                        case Parameter.PARAM_TYPE.TRANSFORM:
                            if (!(val is Transform))
                            {
                                val = null;
                            }
                            Transform t = (Transform)EditorGUILayout.ObjectField((Transform)val ?? null, typeof(Transform), true);
                            if (t != null)
                            {
                                p.SetValue(t, typeof(Transform));
                            }
                            break;

                        case Parameter.PARAM_TYPE.STRING:
                            if (!(val is string))
                            {
                                val = null;
                            }
                            p.SetValue(EditorGUILayout.TextField(val == null ? "" : val.ToString()));
                            break;
                        }
                        GUILayout.EndVertical();
                        index++;
                    }
                    if (toRemove != null)
                    {
                        RemoveParameter(toRemove);
                    }
                    GUILayout.EndVertical();
                }
                // Draw Children
                GUILayout.BeginHorizontal("Box");
                GUILayout.Label(new GUIContent("Action Nodes"));
                GUILayout.EndHorizontal();
                CollectActionChildren(TreeRoot);
                ActionNodes.Sort((Node n1, Node n2) => { return(n1.NodeID.CompareTo(n2.NodeID)); });
                foreach (Node n in ActionNodes)
                {
                    NodeParam currParam = n.Parameters.SingleOrDefault(param => param.GetValue() is NPCAffordance);
                    if (currParam != null)
                    {
                        GUILayout.BeginVertical("Box");
                        NPCAffordance affordance = (NPCAffordance)currParam.GetValue();
                        GUILayout.Label("Node: " + n.NodeID + " - " + affordance.Name);
                        GUILayout.EndVertical();
                    }
                }
                GUILayout.EndScrollView();
            }
 private void RemoveParameter(NodeParam param)
 {
     Parameters.Remove(param);
 }
            private void AddParameter()
            {
                NodeParam p = new NodeParam();

                Parameters.Add(p);
            }
        /// <summary>
        /// 分页查询节点管理
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public PagedResults <Node> QueryNode(NodeParam model)
        {
            var iQueryable = GetAdvQuery(model);

            return(iQueryable.ToPagedResults <Node, Node>(model));
        }
 public ExcutedResult QueryNodeInfos([FromBody] NodeParam model)
 {
     return(_nodeLogic.QueryNodeInfos(model));
 }