示例#1
0
        /// <summary>
        /// 生成一个代码页
        /// </summary>
        public void AddCodeTabPage(Generator.Codes code)
        {
            TextEditor txt = new TextEditor();

            txt.Dock             = DockStyle.Fill;
            txt.ShowInvalidLines = false;
            txt.SetStyleByExt(code.Ext);
            txt.Text = code.Code;

            TabPage page = new TabPage();

            page.Tag  = code;
            page.Text = string.IsNullOrEmpty(code.Title) ? code.FileName : code.Title;

            page.Controls.Add(txt);
            tcCodes.TabPages.Add(page);
        }
示例#2
0
        private void btnSaveAll_Click(object sender, EventArgs e)
        {
            if (tcCodes.TabPages == null)
            {
                ShowMessage.Alert("请先生成代码!");
                return;
            }

            FolderBrowserDialog dlg = new FolderBrowserDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                foreach (TabPage page in tcCodes.TabPages)
                {
                    Generator.Codes code = page.Tag as Generator.Codes;
                    code.Generate(dlg.SelectedPath);
                }
            }
        }
示例#3
0
        private void btnSaveCurrentTab_Click(object sender, EventArgs e)
        {
            if (tcCodes.SelectedTab == null)
            {
                ShowMessage.Alert("请先生成代码!");
                return;
            }

            Generator.Codes code = tcCodes.SelectedTab.Tag as Generator.Codes;

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.AddExtension = true;
            dlg.FileName     = code.FileName;
            dlg.Filter       = string.Format(".{0}|*.{0}", code.Ext);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Generator.IOHelper.WriteFile(dlg.FileName, code.Code);
            }
        }