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

📄 convertecs2vb.cs

📁 通过数据库结构自动 生成三层结构代码,相当不错的一款软件
💻 CS
字号:
namespace Codematic
{
    using LTP.ConvertCS2VB;
    using LTP.TextEditor;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.IO;
    using System.Resources;
    using System.Text;
    using System.Windows.Forms;
    using WiB.Pinkie.Controls;

    public class ConverteCS2VB : Form
    {
        private ButtonXP btnConvert;
        private ButtonXP btnLoad;
        private ButtonXP btnSave;
        private ButtonXP buttonXP3;
        private IContainer components;
        private GroupBox groupBox1;
        private GroupBox groupBox2;
        private ImageList imageList1;
        private StatusBar statusBar1;
        private StatusBarPanel statusBarPanel1;
        private StatusBarPanel statusBarPanel2;
        private TabControl tabControl1;
        private TabPage tabPageCS;
        private TabPage tabPageVB;
        private TextEditorControl txtCSharp;
        private TextEditorControl txtVB;

        public ConverteCS2VB()
        {
            this.InitializeComponent();
        }

        private void btnConvert_Click(object sender, EventArgs e)
        {
            this.statusBarPanel1.Text = "正在转换,请稍候...";
            this.txtVB.Text = new CSharpToVBConverter().Execute(this.txtCSharp.Text);
            string startupPath = Application.StartupPath;
            this.tabControl1.SelectedIndex = 1;
            this.statusBarPanel1.Text = "转换完成。";
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            string cFileName = "";
            cFileName = this.GetFile();
            if (cFileName.Length > 0)
            {
                this.txtCSharp.Text = this.FileToStr(cFileName);
            }
            string startupPath = Application.StartupPath;
            this.tabControl1.SelectedIndex = 0;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Title = "保存当前查询";
            string text = "";
            if (this.tabControl1.SelectedIndex == 0)
            {
                dialog.Filter = "C# Files (*.cs)|*.cs|All files (*.*)|*.*";
                text = this.txtCSharp.Text;
            }
            else
            {
                dialog.Filter = "VB.NET Files (*.vb)|*.vb|All files (*.*)|*.*";
                text = this.txtVB.Text;
            }
            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                StreamWriter writer = new StreamWriter(dialog.FileName, false, Encoding.Default);
                writer.Write(text);
                writer.Flush();
                writer.Close();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        public string FileToStr(string cFileName)
        {
            StreamReader reader = new StreamReader(cFileName, Encoding.Default);
            string str = reader.ReadToEnd();
            reader.Close();
            return str;
        }

        private string GetFile()
        {
            string fileName = "";
            string str2 = "C# Files (*.cs)|*.cs|All files (*.*)|*.*";
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = str2;
            dialog.RestoreDirectory = true;
            dialog.InitialDirectory = Directory.GetCurrentDirectory();
            if (dialog.ShowDialog() != DialogResult.Cancel)
            {
                fileName = dialog.FileName;
            }
            return fileName;
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ResourceManager manager = new ResourceManager(typeof(ConverteCS2VB));
            this.groupBox1 = new GroupBox();
            this.groupBox2 = new GroupBox();
            this.tabControl1 = new TabControl();
            this.tabPageCS = new TabPage();
            this.txtCSharp = new TextEditorControl();
            this.tabPageVB = new TabPage();
            this.txtVB = new TextEditorControl();
            this.imageList1 = new ImageList(this.components);
            this.statusBar1 = new StatusBar();
            this.statusBarPanel1 = new StatusBarPanel();
            this.statusBarPanel2 = new StatusBarPanel();
            this.btnLoad = new ButtonXP();
            this.btnConvert = new ButtonXP();
            this.btnSave = new ButtonXP();
            this.buttonXP3 = new ButtonXP();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.tabControl1.SuspendLayout();
            this.tabPageCS.SuspendLayout();
            this.tabPageVB.SuspendLayout();
            this.statusBarPanel1.BeginInit();
            this.statusBarPanel2.BeginInit();
            base.SuspendLayout();
            this.groupBox1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.groupBox1.Controls.Add(this.btnLoad);
            this.groupBox1.Controls.Add(this.btnConvert);
            this.groupBox1.Controls.Add(this.btnSave);
            this.groupBox1.Controls.Add(this.buttonXP3);
            this.groupBox1.Location = new Point(8, 8);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x2b0, 0x38);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "操作";
            this.groupBox2.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.groupBox2.Controls.Add(this.tabControl1);
            this.groupBox2.Location = new Point(8, 0x48);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new Size(0x2b0, 360);
            this.groupBox2.TabIndex = 1;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "代码";
            this.tabControl1.Alignment = TabAlignment.Bottom;
            this.tabControl1.Controls.Add(this.tabPageCS);
            this.tabControl1.Controls.Add(this.tabPageVB);
            this.tabControl1.Dock = DockStyle.Fill;
            this.tabControl1.ImageList = this.imageList1;
            this.tabControl1.Location = new Point(3, 0x11);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new Size(0x2aa, 340);
            this.tabControl1.TabIndex = 0;
            this.tabPageCS.Controls.Add(this.txtCSharp);
            this.tabPageCS.ImageIndex = 0;
            this.tabPageCS.Location = new Point(4, 4);
            this.tabPageCS.Name = "tabPageCS";
            this.tabPageCS.Size = new Size(0x2a2, 0x137);
            this.tabPageCS.TabIndex = 0;
            this.tabPageCS.Text = "C#代码";
            this.txtCSharp.Dock = DockStyle.Fill;
            this.txtCSharp.Location = new Point(0, 0);
            this.txtCSharp.Name = "txtCSharp";
            this.txtCSharp.Size = new Size(0x2a2, 0x137);
            this.txtCSharp.TabIndex = 0;
            this.txtCSharp.Text = "";
            this.txtCSharp.IsIconBarVisible = false;
            this.txtCSharp.ShowInvalidLines = false;
            this.txtCSharp.ShowSpaces = false;
            this.txtCSharp.ShowTabs = false;
            this.txtCSharp.ShowEOLMarkers = false;
            this.txtCSharp.ShowVRuler = false;
            this.txtCSharp.Language = TextEditorControlBase.Languages.CSHARP;
            this.txtCSharp.Encoding = Encoding.Default;
            this.txtCSharp.Font = new Font("新宋体", 9f);
            this.tabPageVB.Controls.Add(this.txtVB);
            this.tabPageVB.ImageIndex = 1;
            this.tabPageVB.Location = new Point(4, 4);
            this.tabPageVB.Name = "tabPageVB";
            this.tabPageVB.Size = new Size(0x2a2, 0x137);
            this.tabPageVB.TabIndex = 1;
            this.tabPageVB.Text = "VB.NET代码";
            this.txtVB.Dock = DockStyle.Fill;
            this.txtVB.Location = new Point(0, 0);
            this.txtVB.Name = "txtVB";
            this.txtVB.Size = new Size(0x2a2, 0x137);
            this.txtVB.TabIndex = 0;
            this.txtVB.Text = "";
            this.txtVB.IsIconBarVisible = false;
            this.txtVB.ShowInvalidLines = false;
            this.txtVB.ShowSpaces = false;
            this.txtVB.ShowTabs = false;
            this.txtVB.ShowEOLMarkers = false;
            this.txtVB.ShowVRuler = false;
            this.txtVB.Language = TextEditorControlBase.Languages.VBNET;
            this.txtVB.Encoding = Encoding.Default;
            this.txtVB.Font = new Font("新宋体", 9f);
            this.imageList1.ImageSize = new Size(0x12, 0x12);
            this.imageList1.ImageStream = (ImageListStreamer) manager.GetObject("imageList1.ImageStream");
            this.imageList1.TransparentColor = Color.Transparent;
            this.statusBar1.Location = new Point(0, 0x1b0);
            this.statusBar1.Name = "statusBar1";
            this.statusBar1.Panels.AddRange(new StatusBarPanel[] { this.statusBarPanel1, this.statusBarPanel2 });
            this.statusBar1.ShowPanels = true;
            this.statusBar1.Size = new Size(0x2c0, 0x16);
            this.statusBar1.TabIndex = 2;
            this.statusBarPanel1.Text = "就绪";
            this.statusBarPanel1.Width = 200;
            this.statusBarPanel2.AutoSize = StatusBarPanelAutoSize.Spring;
            this.statusBarPanel2.Width = 0x1e8;
            this.btnLoad._Image = null;
            this.btnLoad.BackColor = Color.FromArgb(0, 0xec, 0xe9, 0xd8);
            this.btnLoad.DefaultScheme = false;
            this.btnLoad.DialogResult = DialogResult.None;
            this.btnLoad.Image = null;
            this.btnLoad.Location = new Point(120, 0x10);
            this.btnLoad.Name = "btnLoad";
            this.btnLoad.Scheme = ButtonXP.Schemes.Blue;
            this.btnLoad.Size = new Size(0x4b, 0x1a);
            this.btnLoad.TabIndex = 0x2a;
            this.btnLoad.Text = "加载文件";
            this.btnLoad.Click += new EventHandler(this.btnLoad_Click);
            this.btnConvert._Image = null;
            this.btnConvert.BackColor = Color.FromArgb(0, 0xec, 0xe9, 0xd8);
            this.btnConvert.DefaultScheme = false;
            this.btnConvert.DialogResult = DialogResult.None;
            this.btnConvert.Image = null;
            this.btnConvert.Location = new Point(0xe0, 0x10);
            this.btnConvert.Name = "btnConvert";
            this.btnConvert.Scheme = ButtonXP.Schemes.Blue;
            this.btnConvert.Size = new Size(0x4b, 0x1a);
            this.btnConvert.TabIndex = 0x2a;
            this.btnConvert.Text = "立即转换";
            this.btnConvert.Click += new EventHandler(this.btnConvert_Click);
            this.btnSave._Image = null;
            this.btnSave.BackColor = Color.FromArgb(0, 0xec, 0xe9, 0xd8);
            this.btnSave.DefaultScheme = false;
            this.btnSave.DialogResult = DialogResult.None;
            this.btnSave.Image = null;
            this.btnSave.Location = new Point(0x148, 0x10);
            this.btnSave.Name = "btnSave";
            this.btnSave.Scheme = ButtonXP.Schemes.Blue;
            this.btnSave.Size = new Size(0x4b, 0x1a);
            this.btnSave.TabIndex = 0x2a;
            this.btnSave.Text = "保存为...";
            this.btnSave.Click += new EventHandler(this.btnSave_Click);
            this.buttonXP3._Image = null;
            this.buttonXP3.BackColor = Color.FromArgb(0, 0xec, 0xe9, 0xd8);
            this.buttonXP3.DefaultScheme = false;
            this.buttonXP3.DialogResult = DialogResult.None;
            this.buttonXP3.Image = null;
            this.buttonXP3.Location = new Point(0x1b0, 0x10);
            this.buttonXP3.Name = "buttonXP3";
            this.buttonXP3.Scheme = ButtonXP.Schemes.Blue;
            this.buttonXP3.Size = new Size(0x4b, 0x1a);
            this.buttonXP3.TabIndex = 0x2a;
            this.buttonXP3.Text = "退  出";
            this.buttonXP3.Click += new EventHandler(this.btnExit_Click);
            this.AutoScaleBaseSize = new Size(6, 14);
            base.ClientSize = new Size(0x2c0, 0x1c6);
            base.Controls.Add(this.statusBar1);
            base.Controls.Add(this.groupBox2);
            base.Controls.Add(this.groupBox1);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "ConverteCS2VB";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "转换C#代码到VB.NET";
            this.groupBox1.ResumeLayout(false);
            this.groupBox2.ResumeLayout(false);
            this.tabControl1.ResumeLayout(false);
            this.tabPageCS.ResumeLayout(false);
            this.tabPageVB.ResumeLayout(false);
            this.statusBarPanel1.EndInit();
            this.statusBarPanel2.EndInit();
            base.ResumeLayout(false);
        }

        private void ThreadWork()
        {
            this.statusBarPanel1.Text = "正在转换,请稍候...";
            this.txtVB.Text = new CSharpToVBConverter().Execute(this.txtCSharp.Text);
            string startupPath = Application.StartupPath;
            this.tabControl1.SelectedIndex = 1;
            this.statusBarPanel1.Text = "转换完成。";
        }
    }
}

⌨️ 快捷键说明

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