예제 #1
0
        private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(SystemConfig.SystemConfigTag.OpenSaveDefaultPath))
            {
                //从配置读取初始路径,避免每次打开或保存文件都要选择路径
                openFileDialog1.InitialDirectory = SystemConfig.SystemConfigTag.OpenSaveDefaultPath;
            }

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ResourceHelper resourceHelper = new ResourceHelper(openFileDialog1.FileName);

                m_HTable = resourceHelper.GetObject(HConst.HTableKey) as HTable;

                if (m_HTable == null) m_HTable = new HTable();

                txtENName.Text = m_HTable.ENName;
                txtCHName.Text = m_HTable.CHName;
                txtClassName.Text = m_HTable.ClassName;

                m_Datas = resourceHelper.GetObject(HConst.FieldListKey) as List<HField>;

                RefreshList();

                this.Text = Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
            }
        }
예제 #2
0
        private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(SystemConfig.SystemConfigTag.OpenSaveDefaultPath))
            {
                //从配置读取初始路径,避免每次打开或保存文件都要选择路径
                saveFileDialog1.InitialDirectory = SystemConfig.SystemConfigTag.OpenSaveDefaultPath;
            }

            if (string.IsNullOrEmpty(saveFileDialog1.FileName))
            {
                saveFileDialog1.FileName = txtClassName.Text + "(" + txtCHName.Text + ")";
            }

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ResourceHelper resourceHelper = new ResourceHelper(saveFileDialog1.FileName);

                resourceHelper.SetObject(HConst.FieldListKey, m_Datas);

                GetHTableFromUI();

                resourceHelper.SetObject(HConst.HTableKey, m_HTable);

                resourceHelper.Save();

                this.Text = Path.GetFileNameWithoutExtension(saveFileDialog1.FileName);
            }
        }