Exemple #1
0
        private void ItemCondition_Click(object sender, EventArgs e)
        {
            SkillInforForm skill_info = new SkillInforForm(false, false);

            if (skill_info.ShowDialog() == DialogResult.OK)
            {
                foreach (string page_title in skill_info.result_text)
                {
                    int     index          = int.Parse(page_title);
                    TabPage item_condition = new TabPage()
                    {
                        Text      = index + 1 + "号物品条件",
                        Tag       = "3",
                        BackColor = Color.FromArgb(50, 50, 50)
                    };
                    skill_tab.TabPages.Add(item_condition);
                    TableLayoutPanel skill_info_table = new TableLayoutPanel()
                    {
                        Name        = "skill_info_table",
                        Dock        = DockStyle.Fill,
                        RowCount    = 2,
                        ColumnCount = 2,
                        AutoScroll  = true,
                        BackColor   = Color.Transparent,
                        ForeColor   = Color.FromArgb(255, 255, 255)
                    };

                    Label para = new Label()
                    {
                        AutoSize  = true,
                        Text      = "参数:",
                        BackColor = Color.Transparent,
                        Anchor    = AnchorStyles.None
                    };

                    #region 执行反射,添加需要的条件参数
                    //获取目标类体的类型
                    Type component_manager = Assembly.Load("cbhk_editor").GetType("cbhk_editor.SkillSpawner.ComponentsManager");
                    //获取目标类体内部的公开方法集合
                    MethodInfo[] ItemMethods = component_manager.GetMethods();
                    //创建目标类体实例
                    var c_m = Activator.CreateInstance(component_manager);
                    //调用目标类体目标方法
                    UserControl target_control = ItemMethods[index].Invoke(c_m, null) as UserControl;
                    #endregion
                    skill_info_table.Controls.Add(para, 0, 0);
                    skill_info_table.Controls.Add(target_control, 1, 0);
                    #region 行列自适应
                    skill_info_table.RowStyles.Add(new RowStyle(SizeType.AutoSize, 1));
                    skill_info_table.RowStyles.Add(new RowStyle(SizeType.AutoSize, 1));
                    skill_info_table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 1));
                    skill_info_table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 1));
                    #endregion

                    #region 开启横向纵向滚动条
                    skill_info_table.HorizontalScroll.Enabled = true;
                    skill_info_table.VerticalScroll.Enabled   = true;
                    #endregion

                    item_condition.Controls.Add(skill_info_table);
                }
            }
        }
Exemple #2
0
        private void AddEvent_Click(object sender, EventArgs e)
        {
            SkillInforForm skill_info = new SkillInforForm(false, true);

            if (skill_info.ShowDialog() == DialogResult.OK)
            {
                if (skill_tab.SelectedTab == null)
                {
                    return;
                }
                foreach (string page_title in skill_info.result_text)
                {
                    int     index   = int.Parse(page_title);
                    TabPage a_event = new TabPage()
                    {
                        Text      = index + 1 + "号事件",
                        Tag       = "9",
                        BackColor = Color.FromArgb(50, 50, 50)
                    };
                    TabControl event_tab = new TabControl()
                    {
                        Name = "event_tab",
                        Dock = DockStyle.Fill
                    };

                    Control[] target_area = skill_tab.SelectedTab.Controls.Find("skill_info_table", true);
                    if (target_area.Length > 0)
                    {
                        //获取当前选中项的表格对象
                        TableLayoutPanel skill_info_table = target_area[0] as TableLayoutPanel;
                        //搜索当前页的事件TabControl控件
                        Control[]  sub_ctls = skill_info_table.Controls.Find("event_tab", true);
                        TabControl EventTab = null;
                        if (sub_ctls.Length > 0)
                        {
                            foreach (Control ctl in sub_ctls)
                            {
                                if (ctl is TabControl)
                                {
                                    EventTab = ctl as TabControl;
                                    break;
                                }
                            }
                        }
                        if (EventTab == null)
                        {
                            event_tab.Controls.Add(a_event);
                        }
                        else
                        {
                            EventTab.Controls.Add(a_event);
                        }
                        Label para = new Label()
                        {
                            Name      = "tip",
                            AutoSize  = true,
                            Text      = "事件:",
                            BackColor = Color.Transparent,
                            Anchor    = AnchorStyles.None
                        };

                        #region 执行反射,添加需要的条件参数
                        //获取目标类体的类型
                        Type component_manager = Assembly.Load("cbhk_editor").GetType("cbhk_editor.SkillSpawner.ComponentsManager");
                        //获取目标类体内部的公开方法集合
                        MethodInfo[] ItemMethods = component_manager.GetMethods();
                        //创建目标类体实例
                        var c_m = Activator.CreateInstance(component_manager);
                        //调用目标类体目标方法
                        UserControl target_control = ItemMethods[index + 10].Invoke(c_m, null) as UserControl;
                        #endregion

                        #region 添加文本提示和事件块
                        //搜索是否存在提示文本
                        Control[] tips = skill_info_table.Controls.Find("tip", true);
                        if (tips.Length == 0)
                        {
                            skill_info_table.Controls.Add(para, 0, 1);
                        }
                        if (target_control != null)
                        {
                            a_event.Controls.Add(target_control);
                            if (EventTab != null)
                            {
                                skill_info_table.Controls.Add(EventTab, 1, 1);
                            }
                            else
                            {
                                skill_info_table.Controls.Add(event_tab, 1, 1);
                            }
                        }
                        #endregion
                    }
                }
            }
        }