示例#1
0
        /// <summary>
        /// 重命名自定义事件
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void buttonX5_Click(object sender, EventArgs e)
        {
            Node eventNode = allEventTree.SelectedNode;

            if (eventNode != null)
            {
                string eventName = textBoxX1.Text;

                if (eventName != "")
                {
                    AI_Event aiEvent = eventNode.Tag as AI_Event;

                    if (aiEvent != null && int.Parse(aiEvent.eventid) > 2000)
                    {
                        aiEvent.Name   = eventName;
                        eventNode.Text = aiEvent.ToString();
                    }
                    else
                    {
                        MessageBox.Show("只能重命名本图内创建的自定义事件!", "重命名自定义事件", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("请先输入自定义事件的名称!", "重命名自定义事件", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("请先选择要重命名的自定义事件!", "重命名自定义事件", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#2
0
        /// <summary>
        /// 新建自定义事件
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void buttonX3_Click(object sender, EventArgs e)
        {
            string eventName = textBoxX1.Text;

            if (eventName != "")
            {
                List <AI_Event> customEventList = flowChartInteractor.CustomTable["CustomEventList"] as List <AI_Event>;

                if (customEventList == null)
                {
                    customEventList = new List <AI_Event>();
                }

                bool nameExist = false;

                foreach (AI_Event aiEvent in customEventList)
                {
                    if (aiEvent.Name == eventName)
                    {
                        nameExist = true;
                        break;
                    }
                }

                if (nameExist) // 事件名已经存在
                {
                    MessageBox.Show("该名称的事件已经存在!", "新建自定义事件", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    string customEventIndexString = flowChartInteractor.CustomTable["CustomEventIndex"] as string;
                    int    customEventIndex       = 1;
                    if (customEventIndexString != null)
                    {
                        customEventIndex = int.Parse(customEventIndexString);
                    }
                    int eventID = customEventIndex + 2000; // ID2000以上的为脚本内自定义事件

                    AI_Event aiEvent = new AI_Event();
                    aiEvent.Name    = eventName;
                    aiEvent.Ename   = "CustomEvent";
                    aiEvent.DBID    = "0";
                    aiEvent.eventid = eventID.ToString();
                    customEventList.Add(aiEvent);
                    customEventIndex++;

                    Node node = new Node();
                    node.Text  = aiEvent.ToString();
                    node.Tag   = aiEvent;
                    node.Image = imageList1.Images[0];
                    allEventTree.Nodes.Add(node);
                    allEventTree.SelectedNode = node;

                    flowChartInteractor.CustomTable["CustomEventList"]  = customEventList;
                    flowChartInteractor.CustomTable["CustomEventIndex"] = customEventIndex.ToString();
                }
            }
            else
            {
                MessageBox.Show("请先输入自定义事件的名称!", "新建自定义事件", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#3
0
        /// <summary>
        /// 新建自定义事件
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void buttonX3_Click(object sender, EventArgs e)
        {
            string eventName = textBoxX1.Text;

            if (eventName != "")
            {
                List<AI_Event> customEventList = flowChartInteractor.CustomTable["CustomEventList"] as List<AI_Event>;

                if (customEventList == null)
                {
                    customEventList = new List<AI_Event>();
                }

                bool nameExist = false;

                foreach (AI_Event aiEvent in customEventList)
                {
                    if (aiEvent.Name == eventName)
                    {
                        nameExist = true;
                        break;
                    }
                }

                if (nameExist) // 事件名已经存在
                {
                    MessageBox.Show("该名称的事件已经存在!", "新建自定义事件", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    string customEventIndexString = flowChartInteractor.CustomTable["CustomEventIndex"] as string;
                    int customEventIndex = 1;
                    if(customEventIndexString != null)
                    {
                        customEventIndex = int.Parse(customEventIndexString);
                    }
                    int eventID = customEventIndex + 2000; // ID2000以上的为脚本内自定义事件

                    AI_Event aiEvent = new AI_Event();
                    aiEvent.Name = eventName;
                    aiEvent.Ename = "CustomEvent";
                    aiEvent.DBID = "0";
                    aiEvent.eventid = eventID.ToString();
                    customEventList.Add(aiEvent);
                    customEventIndex++;

                    Node node = new Node();
                    node.Text = aiEvent.ToString();
                    node.Tag = aiEvent;
                    node.Image = imageList1.Images[0];
                    allEventTree.Nodes.Add(node);
                    allEventTree.SelectedNode = node;

                    flowChartInteractor.CustomTable["CustomEventList"] = customEventList;
                    flowChartInteractor.CustomTable["CustomEventIndex"] = customEventIndex.ToString(); 
                }
            }
            else
            {
                MessageBox.Show("请先输入自定义事件的名称!", "新建自定义事件", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }