⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmainframe.cs

📁 三国群英传7场景修改器 源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.IO;
using System.Xml;

namespace San7GeneralScreen
{
    /// <summary>
    /// 框架窗体
    /// </summary>
    public partial class FrmMainFrame:Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public FrmMainFrame()
        {
            InitializeComponent();
        }
        
        /// <summary>
        /// 当前的程序集对象
        /// </summary>
        private Assembly curApplication;
        
        /// <summary>
        /// 窗体加载时发生的事件
        /// </summary>
        /// <param name="sender">事件对象</param>
        /// <param name="e">附加参数</param>
        private void FrmMainFrame_Load(object sender, EventArgs e)
        {
            try
            {                
                InitEnvrionment();               
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }      
        
        /// <summary>
        /// 初始化系统环境
        /// </summary>
        private void InitEnvrionment()
        {
            try
            {
                tvWindows.Nodes.Clear();
                Assembly[] asms = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies();
                Assembly[] curAssemblyArray = AppDomain.CurrentDomain.GetAssemblies();
                foreach (Assembly asm in curAssemblyArray)
                {
                    if (asm.Location.ToUpper() == Application.ExecutablePath.ToUpper())
                    {
                        curApplication = asm;
                        Type[] curAsmTypes = asm.GetTypes();
                        foreach (Type t in curAsmTypes)
                        {
                            if (t.BaseType.FullName == "San7GeneralScreen.FrmINIBase" && t.FullName != this.GetType().FullName)
                            {
                                Form win = (Form)t.Assembly.CreateInstance(t.FullName);
                                TreeNode tn = new TreeNode();
                                tn.Text = win.Text;
                                tn.Tag = t.FullName;
                                tvWindows.Nodes.Add(tn);
                            }
                        }
                        break;
                    }
                }
                this.tsSystemStatus.Text = "就绪";

                //初始化系统菜单
                XmlDocument xmlDoc = CommonDefine.LoadXmlFromFile(Application.StartupPath + "\\SystemConfigure.xml");
                if (xmlDoc != null)
                {
                    XmlNodeList xnl=  xmlDoc.LastChild.SelectSingleNode("ColumnSettings").SelectNodes("Column");
                    foreach (XmlNode xn in xnl)
                    {
                        if (xn is XmlElement)
                        {
                            XmlElement xe = (XmlElement)xn;
                            CommonDefine.SanGuoColumns.Add(new INIValue(xe.GetAttribute("key"), xe.GetAttribute("value")));
                        }
                    }                   
                }

                tsmiOri = big5ToolStripMenuItem;
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
       
        /// <summary>
        /// 树结构结点的单击事件
        /// </summary>
        /// <param name="sender">事件对象</param>
        /// <param name="e">附加参数</param>
        private void tvWindows_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            try
            {
                if (e.Node.Tag != null)
                {
                    Form win = (Form)curApplication.CreateInstance(e.Node.Tag.ToString());               
                    win.MdiParent = this;
                    win.WindowState = FormWindowState.Maximized;
                    win.Show();                 
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
         
        }

        private string _EncodingName = "big5";

        private void tsbOpen_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild is FrmINIBase)
            {
                ((FrmINIBase)ActiveMdiChild).EncodingName = _EncodingName;
                ((FrmINIBase)ActiveMdiChild).OpenFile();
            }
        }

        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild is FrmINIBase)
            {
                ((FrmINIBase)ActiveMdiChild).EncodingName = _EncodingName;
                ((FrmINIBase)ActiveMdiChild).SaveFile();
            }
        } 

        private void tsbAction_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild is FrmINIBase)
            {
                ((FrmINIBase)ActiveMdiChild).EncodingName = _EncodingName;
                ((FrmINIBase)ActiveMdiChild).ExecAction();
            }
        }

        private void tsbRefurbish_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild is FrmINIBase)
            {
                ((FrmINIBase)ActiveMdiChild).EncodingName = _EncodingName;
                ((FrmINIBase)ActiveMdiChild).RefurbishEntironment();
            }
        }

        ToolStripMenuItem tsmiOri = null;
        private void EncodingChange_Envent(object sender, EventArgs e)
        {
            tsmiOri.Checked = false;
            tsmiOri = (ToolStripMenuItem)sender;
            _EncodingName = tsmiOri.Text;
            tsmiOri.Checked = true;
            ((ToolStripMenuItem)sender).Checked = true;
            if (ActiveMdiChild is FrmINIBase)
            {
                ((FrmINIBase)ActiveMdiChild).EncodingName = _EncodingName;
                ((FrmINIBase)ActiveMdiChild).RefurbishEntironment();
            }
        }

              
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -