Esempio n. 1
0
        /// <summary>
        /// 添加动作
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // 初始化自动重命名种子
            InitActionIndex(null);

            AI_SingleAction  singleAction     = new AI_SingleAction();
            SingleActionForm singleActionForm = new SingleActionForm();

            singleActionForm.GraphElementID = graphElementID;
            singleActionForm.InActionGroup  = true;
            singleActionForm.GroupIndex     = groupIndex;
            singleActionForm.Reload(singleAction);
            singleActionForm.ShowDialog();

            if (singleActionForm.EditSuccess)
            {
                listBox1.Items.Add(singleAction);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 编辑动作
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            AI_SingleAction singleAction = this.listBox1.SelectedItem as AI_SingleAction;

            if (singleAction != null)
            {
                // 初始化自动重命名种子
                InitActionIndex(singleAction);

                SingleActionForm saForm = new SingleActionForm();
                saForm.GraphElementID = graphElementID;
                saForm.InActionGroup  = true;
                saForm.GroupIndex     = groupIndex;
                saForm.Reload(singleAction);
                saForm.ShowDialog();

                if (saForm.EditSuccess)
                {
                    int ind = listBox1.SelectedIndex;
                    listBox1.Items.RemoveAt(ind);
                    listBox1.Items.Insert(ind, singleAction);
                }
            }
        }
Esempio n. 3
0
        private static StateNodeForm stateForm = new StateNodeForm(); // 状态结点编辑窗体

        // [NonSerialized]
        // private static SingleActionForm singleActionForm = new SingleActionForm(); // 单动作结点编辑窗体

        /// <summary>
        /// 编辑数据
        /// </summary>
        /// <param name="table">数据哈希表</param>
        /// <returns>是否编辑成功</returns>
        public override bool EditData(System.Collections.Hashtable table)
        {
            switch (this.DataType)
            {
            case "AIStateNode":     // 状态结点
            {
                AI_State state = table["data"] as AI_State;

                if (state == null)
                {
                    state = new AI_State();
                }

                // 优化窗体显示
                stateForm.GraphElementID = id;
                stateForm.Reload(state);
                stateForm.ShowDialog();

                if (stateForm.EditSuccess)         // 编辑成功
                {
                    this.Data = state;

                    // 清空连接线
                    List <AI_Event> elist       = state.EventList;
                    Hashtable       outlineList = (table["next_data"] as Hashtable);
                    foreach (DataElement de in outlineList.Values)
                    {
                        if (!elist.Contains(de.Data as AI_Event))
                        {
                            de.Data        = null;
                            de.Text        = "";
                            de.TooltipText = "";
                        }
                    }
                    this.Text        = state.ToString();
                    this.TooltipText = state.ToFullText();
                }
                else
                {
                    return(false);
                }

                break;
            }

            case "AIActionNode":     // 动作结点
            {
                AI_SingleAction action = table["data"] as AI_SingleAction;

                if (action == null)
                {
                    action = new AI_SingleAction();
                }

                // 优化窗体显示
                SingleActionForm singleActionForm = new SingleActionForm();
                singleActionForm.GraphElementID = id;
                singleActionForm.InActionGroup  = false;
                singleActionForm.Reload(action);
                singleActionForm.ShowDialog();

                if (singleActionForm.EditSuccess)         // 编辑成功
                {
                    this.Data = action;

                    // 清空连接线
                    List <string> eventList   = action.Action.RetList;
                    Hashtable     outLineList = (table["next_data"] as Hashtable);

                    foreach (DataElement dataElement in outLineList.Values)
                    {
                        if (!eventList.Contains(dataElement.Data as string))
                        {
                            dataElement.Data        = null;
                            dataElement.Text        = "";
                            dataElement.TooltipText = "";
                        }
                    }

                    this.Text        = action.ToString();
                    this.TooltipText = action.ToFullText();
                }
                else
                {
                    return(false);
                }

                break;
            }

            case "AIActionsNode":     // 动作组结点
            {
                AI_MultiAction multiAction = table["data"] as AI_MultiAction;

                if (multiAction == null)
                {
                    multiAction = new AI_MultiAction();
                }

                MultiActionForm multiActionForm = new MultiActionForm(multiAction);
                multiActionForm.GraphElementID = id;

                if (multiActionForm.ShowDialog() == DialogResult.OK)
                {
                    this.Data = multiAction;

                    //清空连接线
                    Hashtable outlineList = (table["next_data"] as Hashtable);
                    if (multiAction.ActionList.Count == 0)
                    {
                        foreach (DataElement dataElement in outlineList.Values)
                        {
                            dataElement.Data        = null;
                            dataElement.Text        = "";
                            dataElement.TooltipText = "";
                        }
                    }
                    else
                    {
                        List <string> elist = multiAction.ActionList[multiAction.ActionList.Count - 1].Action.RetList;
                        foreach (DataElement dataElement in outlineList.Values)
                        {
                            if (!elist.Contains(dataElement.Data as string))
                            {
                                dataElement.Data        = null;
                                dataElement.Text        = "";
                                dataElement.TooltipText = "";
                            }
                        }
                    }
                    this.Text        = multiAction.ToString();
                    this.TooltipText = multiAction.ToFullText();
                }
                else
                {
                    return(false);
                }

                break;
            }

            case "AILine":     // 连接线
            {
                Hashtable ht_prev_data      = table["prev_data"] as Hashtable;
                Hashtable ht_neightbor_data = table["neighbor_data"] as Hashtable;

                if (ht_prev_data.Count == 0)
                {
                    return(false);
                }

                object      prev_data           = null;
                DataElement previousDataElement = null;

                foreach (object o in ht_prev_data.Values)
                {
                    DataElement dataElement = o as DataElement;

                    if (dataElement.Data != null)
                    {
                        previousDataElement = dataElement;
                        prev_data           = dataElement.Data;
                        break;
                    }
                }

                if (previousDataElement == null || prev_data == null)
                {
                    return(false);
                }

                switch (previousDataElement.DataType)
                {
                case "AIStateNode":             // 状态结点连出的线
                {
                    AI_State        state         = prev_data as AI_State;
                    List <AI_Event> selectionList = new List <AI_Event>(state.EventList);

                    foreach (DataElement de in ht_neightbor_data.Values)                 // 剔除已经选择过了的事件
                    {
                        if ((de.Data as AI_Event) != null)
                        {
                            selectionList.Remove(de.Data as AI_Event);
                        }
                    }

                    this.data = LineForm <AI_Event> .ShowSelect(table["data"] as AI_Event, selectionList);

                    if (this.data == null)
                    {
                        this.Text = "";
                    }
                    else
                    {
                        this.Text = this.Data.ToString();
                    }

                    break;
                }

                case "AIActionNode":
                {
                    AI_Action action = (prev_data as AI_SingleAction).Action;

                    if (action == null)
                    {
                        return(false);
                    }

                    List <string> selectionList = new List <string>(action.RetList);
                    EditLine(selectionList, ht_neightbor_data);

                    break;
                }

                case "AIActionsNode":
                {
                    List <AI_SingleAction> actionList = (prev_data as AI_MultiAction).ActionList;

                    if (actionList.Count == 0)
                    {
                        return(false);
                    }

                    AI_Action action = actionList[actionList.Count - 1].Action;

                    if (action == null)
                    {
                        return(false);
                    }

                    List <string> selectionList = new List <string>(action.RetList);
                    EditLine(selectionList, ht_neightbor_data);

                    break;
                }

                case "InnerChart":
                {
                    Hashtable infoTable   = prev_data as Hashtable;
                    Hashtable outSlotInfo = infoTable["outSlotInfo"] as Hashtable;

                    List <string> selectionList = new List <string>();

                    foreach (string id in outSlotInfo.Keys)
                    {
                        string interfaceName = outSlotInfo[id] as string;

                        if (interfaceName == null)
                        {
                            interfaceName = "未命名";
                        }

                        selectionList.Add(string.Format("{0}:{1}", id, interfaceName));
                    }

                    EditLine(selectionList, ht_neightbor_data);

                    break;
                }

                case "InterfaceNode":
                {
                    this.data = "1:下一步";
                    this.text = "";

                    break;
                }
                }

                break;
            }
            }

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// 编辑动作
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            AI_SingleAction singleAction = this.listBox1.SelectedItem as AI_SingleAction;

            if (singleAction != null)
            {
                // 初始化自动重命名种子
                InitActionIndex(singleAction);

                SingleActionForm saForm = new SingleActionForm();
                saForm.GraphElementID = graphElementID;
                saForm.InActionGroup = true;
                saForm.GroupIndex = groupIndex;
                saForm.Reload(singleAction);
                saForm.ShowDialog();

                if (saForm.EditSuccess)
                {
                    int ind = listBox1.SelectedIndex;
                    listBox1.Items.RemoveAt(ind);
                    listBox1.Items.Insert(ind, singleAction);
                }
            }                
        }
Esempio n. 5
0
        /// <summary>
        /// 添加动作
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // 初始化自动重命名种子
            InitActionIndex(null);

            AI_SingleAction singleAction = new AI_SingleAction();
            SingleActionForm singleActionForm = new SingleActionForm();

            singleActionForm.GraphElementID = graphElementID;
            singleActionForm.InActionGroup = true;
            singleActionForm.GroupIndex = groupIndex;
            singleActionForm.Reload(singleAction);
            singleActionForm.ShowDialog();

            if (singleActionForm.EditSuccess)
            {
                listBox1.Items.Add(singleAction);
            }         
        }