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

📄 codetemplate.cs

📁 通过数据库结构自动 生成三层结构代码,相当不错的一款软件
💻 CS
📖 第 1 页 / 共 2 页
字号:
            this.groupBox2 = new GroupBox();
            this.list_KeyField = new ListBox();
            this.btn_SetKey = new Button();
            this.btn_SelClear = new Button();
            this.btn_SelI = new Button();
            this.btn_SelAll = new Button();
            this.splitter1 = new Splitter();
            this.listView1 = new ListView();
            this.tabPage2 = new TabPage();
            this.txtCode = new TextEditorControl();
            this.imglistView = new ImageList(this.components);
            this.btn_Run = new Button();
            this.statusStrip1.SuspendLayout();
            this.tabControl1.SuspendLayout();
            this.tabPage1.SuspendLayout();
            this.panel1.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.tabPage2.SuspendLayout();
            base.SuspendLayout();
            this.statusStrip1.Items.AddRange(new ToolStripItem[] { this.StatusLabel1 });
            this.statusStrip1.Location = new Point(0, 0x1b7);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new Size(0x254, 0x16);
            this.statusStrip1.TabIndex = 0;
            this.statusStrip1.Text = "statusStrip1";
            this.StatusLabel1.Name = "StatusLabel1";
            this.StatusLabel1.Size = new Size(0, 0x11);
            this.tabControl1.Alignment = TabAlignment.Bottom;
            this.tabControl1.Controls.Add(this.tabPage1);
            this.tabControl1.Controls.Add(this.tabPage2);
            this.tabControl1.Cursor = Cursors.Hand;
            this.tabControl1.Dock = DockStyle.Fill;
            this.tabControl1.HotTrack = true;
            this.tabControl1.ImageList = this.imglistView;
            this.tabControl1.ItemSize = new Size(0x3a, 0x13);
            this.tabControl1.Location = new Point(0, 0);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new Size(0x254, 0x1b7);
            this.tabControl1.TabIndex = 1;
            this.tabPage1.Controls.Add(this.panel1);
            this.tabPage1.Controls.Add(this.splitter1);
            this.tabPage1.Controls.Add(this.listView1);
            this.tabPage1.ImageIndex = 1;
            this.tabPage1.Location = new Point(4, 4);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Padding = new Padding(3);
            this.tabPage1.RightToLeft = RightToLeft.No;
            this.tabPage1.Size = new Size(0x24c, 0x19c);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = "模版";
            this.tabPage1.UseVisualStyleBackColor = true;
            this.panel1.Controls.Add(this.groupBox1);
            this.panel1.Controls.Add(this.groupBox2);
            this.panel1.Dock = DockStyle.Fill;
            this.panel1.Location = new Point(3, 0x97);
            this.panel1.Name = "panel1";
            this.panel1.Size = new Size(0x246, 0x102);
            this.panel1.TabIndex = 11;
            this.groupBox1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.groupBox1.Controls.Add(this.txtTemplate);
            this.groupBox1.Location = new Point(3, 0x38);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x23c, 0xca);
            this.groupBox1.TabIndex = 9;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "模版";
            this.txtTemplate.Dock = DockStyle.Fill;
            this.txtTemplate.Location = new Point(3, 0x11);
            this.txtTemplate.Name = "txtTemplate";
            this.txtTemplate.Size = new Size(0x236, 0xb6);
            this.txtTemplate.TabIndex = 8;
            this.txtTemplate.Text = "";
            this.txtTemplate.MouseUp += new MouseEventHandler(this.txtTemplate_MouseUp);
            this.txtTemplate.IsIconBarVisible = false;
            this.txtTemplate.ShowInvalidLines = false;
            this.txtTemplate.ShowSpaces = false;
            this.txtTemplate.ShowTabs = false;
            this.txtTemplate.ShowEOLMarkers = false;
            this.txtTemplate.ShowVRuler = false;
            this.txtTemplate.Language = TextEditorControlBase.Languages.XML;
            this.txtTemplate.Encoding = Encoding.Default;
            this.txtTemplate.Font = new Font("新宋体", 9f);
            this.groupBox2.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.groupBox2.Controls.Add(this.list_KeyField);
            this.groupBox2.Controls.Add(this.btn_SetKey);
            this.groupBox2.Controls.Add(this.btn_SelClear);
            this.groupBox2.Controls.Add(this.btn_SelI);
            this.groupBox2.Controls.Add(this.btn_SelAll);
            this.groupBox2.Location = new Point(3, 1);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new Size(0x23c, 0x34);
            this.groupBox2.TabIndex = 6;
            this.groupBox2.TabStop = false;
            this.list_KeyField.FormattingEnabled = true;
            this.list_KeyField.ItemHeight = 12;
            this.list_KeyField.Location = new Point(0x1b3, 14);
            this.list_KeyField.Name = "list_KeyField";
            this.list_KeyField.Size = new Size(0x81, 0x1c);
            this.list_KeyField.TabIndex = 1;
            this.btn_SetKey.Location = new Point(0x141, 0x11);
            this.btn_SetKey.Name = "btn_SetKey";
            this.btn_SetKey.Size = new Size(0x6c, 0x17);
            this.btn_SetKey.TabIndex = 0;
            this.btn_SetKey.Text = "主键(条件)字段";
            this.btn_SetKey.UseVisualStyleBackColor = true;
            this.btn_SetKey.Click += new EventHandler(this.btn_SetKey_Click);
            this.btn_SelClear.Location = new Point(0xb2, 0x11);
            this.btn_SelClear.Name = "btn_SelClear";
            this.btn_SelClear.Size = new Size(0x4b, 0x17);
            this.btn_SelClear.TabIndex = 0;
            this.btn_SelClear.Text = "清空";
            this.btn_SelClear.UseVisualStyleBackColor = true;
            this.btn_SelClear.Click += new EventHandler(this.btn_SelClear_Click);
            this.btn_SelI.Location = new Point(0x61, 0x11);
            this.btn_SelI.Name = "btn_SelI";
            this.btn_SelI.Size = new Size(0x4b, 0x17);
            this.btn_SelI.TabIndex = 0;
            this.btn_SelI.Text = "反选";
            this.btn_SelI.UseVisualStyleBackColor = true;
            this.btn_SelI.Click += new EventHandler(this.btn_SelI_Click);
            this.btn_SelAll.Location = new Point(0x10, 0x11);
            this.btn_SelAll.Name = "btn_SelAll";
            this.btn_SelAll.Size = new Size(0x4b, 0x17);
            this.btn_SelAll.TabIndex = 0;
            this.btn_SelAll.Text = "全选";
            this.btn_SelAll.UseVisualStyleBackColor = true;
            this.btn_SelAll.Click += new EventHandler(this.btn_SelAll_Click);
            this.splitter1.Dock = DockStyle.Top;
            this.splitter1.Location = new Point(3, 0x94);
            this.splitter1.Name = "splitter1";
            this.splitter1.Size = new Size(0x246, 3);
            this.splitter1.TabIndex = 10;
            this.splitter1.TabStop = false;
            this.listView1.Dock = DockStyle.Top;
            this.listView1.Location = new Point(3, 3);
            this.listView1.Name = "listView1";
            this.listView1.Size = new Size(0x246, 0x91);
            this.listView1.TabIndex = 9;
            this.listView1.UseCompatibleStateImageBehavior = false;
            this.tabPage2.Controls.Add(this.txtCode);
            this.tabPage2.ImageIndex = 2;
            this.tabPage2.Location = new Point(4, 4);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Padding = new Padding(3);
            this.tabPage2.Size = new Size(0x24c, 0x19c);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Text = "代码";
            this.tabPage2.UseVisualStyleBackColor = true;
            this.txtCode.Dock = DockStyle.Fill;
            this.txtCode.Location = new Point(3, 3);
            this.txtCode.Name = "txtCode";
            this.txtCode.Size = new Size(0x246, 0x196);
            this.txtCode.TabIndex = 0;
            this.txtCode.Text = "";
            this.txtCode.IsIconBarVisible = false;
            this.txtCode.ShowInvalidLines = false;
            this.txtCode.ShowSpaces = false;
            this.txtCode.ShowTabs = false;
            this.txtCode.ShowEOLMarkers = false;
            this.txtCode.ShowVRuler = false;
            this.txtCode.Language = TextEditorControlBase.Languages.CSHARP;
            this.txtCode.Encoding = Encoding.Default;
            this.txtCode.Font = new Font("新宋体", 9f);
            this.imglistView.ImageStream = (ImageListStreamer) manager.GetObject("imglistView.ImageStream");
            this.imglistView.TransparentColor = Color.Transparent;
            this.imglistView.Images.SetKeyName(0, "fild2.gif");
            this.imglistView.Images.SetKeyName(1, "xml.ico");
            this.imglistView.Images.SetKeyName(2, "file.ico");
            this.btn_Run.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btn_Run.Location = new Point(0x179, 0x1b7);
            this.btn_Run.Name = "btn_Run";
            this.btn_Run.Size = new Size(0x4b, 0x17);
            this.btn_Run.TabIndex = 13;
            this.btn_Run.Text = "生成";
            this.btn_Run.UseVisualStyleBackColor = true;
            this.btn_Run.Visible = false;
            this.btn_Run.Click += new EventHandler(this.btn_Run_Click);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x254, 0x1cd);
            base.Controls.Add(this.btn_Run);
            base.Controls.Add(this.tabControl1);
            base.Controls.Add(this.statusStrip1);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "CodeTemplate";
            this.Text = "模版代码生成";
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            this.tabControl1.ResumeLayout(false);
            this.tabPage1.ResumeLayout(false);
            this.panel1.ResumeLayout(false);
            this.groupBox1.ResumeLayout(false);
            this.groupBox2.ResumeLayout(false);
            this.tabPage2.ResumeLayout(false);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public void Run()
        {
            this.StatusLabel1.Text = "正在生成...";
            string filename = @"Template\temp.xslt";
            try
            {
                string text = this.txtTemplate.Text;
                if (text.Trim() == "")
                {
                    MessageBox.Show("模版内容为空,请先在模版管理器里选择模版!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.StatusLabel1.Text = "就绪";
                    return;
                }
                XmlDocument document = new XmlDocument();
                document.LoadXml(text);
                document.Save(filename);
            }
            catch (Exception exception)
            {
                this.StatusLabel1.Text = "模版格式有误:" + exception.Message;
                return;
            }
            string code = "";
            try
            {
                code = new BuilderTemp(this.dbobj, this.dbname, this.tablename, this.GetFieldlist(), this.GetKeyFields(), filename).GetCode();
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                string path = @"Template\temp.xml";
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
            catch (Exception exception2)
            {
                this.StatusLabel1.Text = "代码转换失败!" + exception2.Message;
                return;
            }
            this.txtCode.Text = code;
            this.tabControl1.SelectedIndex = 1;
            this.StatusLabel1.Text = "生成成功。";
        }

        public void SetListView(DbView dbviewfrm)
        {
            TreeNode selectedNode = dbviewfrm.treeView1.SelectedNode;
            if (selectedNode != null)
            {
                string str = selectedNode.Tag.ToString();
                if (str == null)
                {
                    goto Label_011F;
                }
                if (!(str == "table") && !(str == "view"))
                {
                    if (str == "column")
                    {
                        this.servername = selectedNode.Parent.Parent.Parent.Parent.Text;
                        this.dbname = selectedNode.Parent.Parent.Parent.Text;
                        this.tablename = selectedNode.Parent.Text;
                        this.dbobj = ObjHelper.CreatDbObj(this.servername);
                        this.BindlistViewCol(this.dbname, this.tablename);
                        return;
                    }
                    goto Label_011F;
                }
                this.servername = selectedNode.Parent.Parent.Parent.Text;
                this.dbname = selectedNode.Parent.Parent.Text;
                this.tablename = selectedNode.Text;
                this.dbobj = ObjHelper.CreatDbObj(this.servername);
                this.BindlistViewCol(this.dbname, this.tablename);
            }
            return;
        Label_011F:
            this.listView1.Items.Clear();
        }

        public void SettxtTemplate(string Filename)
        {
            StreamReader reader = new StreamReader(Filename, Encoding.Default);
            string str = reader.ReadToEnd();
            reader.Close();
            this.txtTemplate.Text = str;
        }

        private void Showlistview()
        {
            DbView dbviewfrm = (DbView) Application.OpenForms["DbView"];
            if (dbviewfrm.treeView1.InvokeRequired)
            {
                SetListCallback method = new SetListCallback(this.Showlistview);
                dbviewfrm.Invoke(method, null);
            }
            else
            {
                this.SetListView(dbviewfrm);
            }
        }

        private void txtTemplate_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                sender.ToString();
            }
        }

        private delegate void SetListCallback();
    }
}

⌨️ 快捷键说明

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