Esempio n. 1
0
        private void Menu_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            try
            {
                TreeNode currentNode = e.Node;
                //如果双击的节点的父节点是空
                if (currentNode.Parent == null)
                {
                    return;
                }

                //循环已经打开过的串口
                foreach (var dockContent in DockPanel.Contents)
                {
                    var frm = (DockContent)dockContent;
                    //如果当前窗口已经打开过了
                    if (frm.Text == currentNode.Text)
                    {
                        //激活窗口
                        frm.Activate();
                        return;
                    }
                }
                //不带后缀的文件名
                string tbName = currentNode.Tag.ToString();
                JudgeFile(tbName, currentNode.Parent.Tag.ToString(), currentNode.Text);
                //反射实例化窗体
                DockContent dc = (DockContent)Assembly.Load("xkfy_mod").CreateInstance("xkfy_mod." + tbName);
                //如果对象为空,则代表使用的是公共窗口
                if (dc == null)
                {
                    Almighty a = new Almighty(tbName)
                    {
                        Text = currentNode.Text,
                        Tag  = tbName
                    };
                    a.Show(DockPanel, DockState.Document);
                }
                else
                {
                    //显示窗口
                    dc.Text = currentNode.Text;
                    dc.Tag  = tbName;
                    dc.Show(DockPanel, DockState.Document);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void 重新加载当前文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DockContent d = (DockContent)dockPanel1.ActiveDocument;

            if (d == null || d.Tag == null)
            {
                return;
            }
            string fmName   = d.Text.Replace("*", "");
            string tbName   = d.Tag.ToString();
            string fileName = string.Empty;
            string prefix   = fmName.Substring(0, 3);
            string keyName  = fmName.Substring(3);

            if (prefix == "[M]")
            {
                DataHelper.MapData.Tables.Remove(tbName);
                fileName = "MapInfo";
                //读取MAP文件
                ToolsHelper.ReadMapData(DataHelper.MapFile[keyName], tbName, fileName);
            }
            else if (prefix == "[N]")
            {
                DataHelper.MapData.Tables.Remove(tbName);
                fileName = "NpcProduct";
                //读取NpcConduct
                ToolsHelper.ReadMapData(DataHelper.MapFile[keyName], tbName, fileName);
            }
            else
            {
                if (DataHelper.FormConfig[tbName].DtType == "1")
                {
                    DataHelper.XkfyData.Tables.Remove(DataHelper.FormConfig[tbName].MainDtName);
                    DataHelper.XkfyData.Tables.Remove(DataHelper.FormConfig[tbName].DetailDtName);
                }
                else
                {
                    DataHelper.XkfyData.Tables.Remove(tbName);
                }
                DataHelper.ExistTable(tbName);
            }

            d.Close();



            //反射实例化窗体
            DockContent dc = (DockContent)Assembly.Load("xkfy_mod").CreateInstance("xkfy_mod." + tbName);

            //如果对象为空,则代表使用的是公共窗口
            if (dc == null)
            {
                if (prefix != "[M]" && prefix != "[N]")
                {
                    fileName = "other";
                }

                Almighty a = new Almighty(tbName, fileName);
                a.Text = fmName;
                a.Tag  = tbName;
                a.Show(this.dockPanel1, DockState.Document);
            }
            else
            {
                dc.Text = fmName;
                dc.Tag  = tbName;
                dc.Show(this.dockPanel1, DockState.Document);
            }
        }
Esempio n. 3
0
        private void Menu_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            try
            {
                TreeNode currentNode = e.Node;
                //如果双击的节点的父节点是空
                if (currentNode.Parent == null || currentNode.Parent.Text == "地图信息")
                {
                    return;
                }

                //循环已经打开过的串口
                foreach (DockContent frm in this.DockPanel.Contents)
                {
                    //如果当前窗口已经打开过了
                    if (frm.Text == currentNode.Text)
                    {
                        //激活窗口
                        frm.Activate();
                        return;
                    }
                }
                string tbName = currentNode.Tag.ToString();
                //反射实例化窗体
                DockContent dc = (DockContent)Assembly.Load("xkfy_mod").CreateInstance("xkfy_mod." + tbName);
                //如果对象为空,则代表使用的是公共窗口
                if (dc == null)
                {
                    //如果节点的父节点的tag等于map代表,是地图文件和NPC动作文件
                    if (currentNode.Parent.Tag.ToString() == "map")
                    {
                        string fileName = string.Empty;
                        string preFix   = string.Empty;
                        //如果是第一次打开窗口,读取文件
                        if (!DataHelper.MapData.Tables.Contains(tbName))
                        {
                            string typeName = currentNode.Text.Substring(0, 3);
                            //如果文件名称的前3个字符等于MAP
                            if (typeName.ToUpper() == "MAP")
                            {
                                fileName = "MapInfo";
                                preFix   = "[M]";
                                //读取MAP文件
                                ToolsHelper.ReadMapData(DataHelper.MapFile[currentNode.Text], tbName, fileName);
                            }
                            else
                            {
                                fileName = "NpcProduct";
                                preFix   = "[N]";
                                //读取NpcConduct
                                ToolsHelper.ReadMapData(DataHelper.MapFile[currentNode.Text], tbName, fileName);
                            }
                        }

                        Almighty a = new Almighty(tbName, fileName);
                        a.Text = preFix + currentNode.Text;
                        a.Tag  = tbName;
                        a.Show(this.DockPanel, DockState.Document);
                    }
                    else
                    {
                        DataHelper.ExistTable(tbName);
                        Almighty a = new Almighty(tbName, "other");
                        a.Text = currentNode.Text;
                        a.Tag  = tbName;
                        a.Show(this.DockPanel, DockState.Document);
                    }
                }
                else
                {
                    DataHelper.ExistTable(tbName);
                    //显示窗口
                    dc.Text = currentNode.Text;
                    dc.Tag  = tbName;
                    dc.Show(this.DockPanel, DockState.Document);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }