格式化输出客户端js脚本的转换器

可以encode和decode双向转换,支持复制,粘贴

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btnFromClient As System.Windows.Forms.Button
    Friend WithEvents btnToClient As System.Windows.Forms.Button
    Friend WithEvents btnSelectAll As System.Windows.Forms.Button
    Friend WithEvents btnCopy As System.Windows.Forms.Button
    Friend WithEvents btnPaste As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Panel1 = New System.Windows.Forms.Panel()
        Me.btnFromClient = New System.Windows.Forms.Button()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.btnToClient = New System.Windows.Forms.Button()
        Me.btnSelectAll = New System.Windows.Forms.Button()
        Me.btnCopy = New System.Windows.Forms.Button()
        Me.Panel2 = New System.Windows.Forms.Panel()
        Me.RichTextBox1 = New System.Windows.Forms.RichTextBox()
        Me.btnPaste = New System.Windows.Forms.Button()
        Me.Panel1.SuspendLayout()
        Me.Panel2.SuspendLayout()
        Me.SuspendLayout()
        '
        'Panel1
        '
        Me.Panel1.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnFromClient, Me.Label1, Me.btnToClient, Me.btnSelectAll, Me.btnCopy, Me.btnPaste})
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(768, 56)
        Me.Panel1.TabIndex = 1
        '
        'btnFromClient
        '
        Me.btnFromClient.Location = New System.Drawing.Point(96, 8)
        Me.btnFromClient.Name = "btnFromClient"
        Me.btnFromClient.Size = New System.Drawing.Size(80, 40)
        Me.btnFromClient.TabIndex = 1
        Me.btnFromClient.Text = "Encode"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(496, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(224, 32)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "使用说明:将客户端javascript脚本转换为vb.net中的预输出,双击左键转换"
        '
        'btnToClient
        '
        Me.btnToClient.Location = New System.Drawing.Point(376, 8)
        Me.btnToClient.Name = "btnToClient"
        Me.btnToClient.Size = New System.Drawing.Size(88, 40)
        Me.btnToClient.TabIndex = 1
        Me.btnToClient.Text = "Decode"
        '
        'btnSelectAll
        '
        Me.btnSelectAll.Location = New System.Drawing.Point(192, 16)
        Me.btnSelectAll.Name = "btnSelectAll"
        Me.btnSelectAll.Size = New System.Drawing.Size(72, 24)
        Me.btnSelectAll.TabIndex = 1
        Me.btnSelectAll.Text = "SelectAll"
        '
        'btnCopy
        '
        Me.btnCopy.Location = New System.Drawing.Point(280, 16)
        Me.btnCopy.Name = "btnCopy"
        Me.btnCopy.Size = New System.Drawing.Size(72, 24)
        Me.btnCopy.TabIndex = 1
        Me.btnCopy.Text = "Copy"
        '
        'Panel2
        '
        Me.Panel2.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBox1})
        Me.Panel2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel2.Location = New System.Drawing.Point(0, 56)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(768, 406)
        Me.Panel2.TabIndex = 2
        '
        'RichTextBox1
        '
        Me.RichTextBox1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.RichTextBox1.Name = "RichTextBox1"
        Me.RichTextBox1.Size = New System.Drawing.Size(768, 406)
        Me.RichTextBox1.TabIndex = 1
        Me.RichTextBox1.Text = "使用说明:将客户端javascript脚本转换为vb.net中的预输出,双击左键转换"
        '
        'btnPaste
        '
        Me.btnPaste.Location = New System.Drawing.Point(16, 16)
        Me.btnPaste.Name = "btnPaste"
        Me.btnPaste.Size = New System.Drawing.Size(64, 24)
        Me.btnPaste.TabIndex = 1
        Me.btnPaste.Text = "Paste"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(768, 462)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Panel2, Me.Panel1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.Panel1.ResumeLayout(False)
        Me.Panel2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

 

    Private Sub RichTextBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If e.Clicks = 2 And e.Button = MouseButtons.Left Then
            Dim s() As String = Me.RichTextBox1.Lines
            Dim src As String
            Dim dst As String = "Dim s as String="""" & vbCrLf & _ " & vbCrLf
            Dim i As Integer
            For i = 0 To s.Length - 2
                src = s(i)
                dst &= (vbTab & vbTab & vbTab & Chr(34) & src.Replace(Chr(34).ToString, (Chr(34) & Chr(34)).ToString) & Chr(34) & " & vbCrLf & _ ") & vbCrLf
            Next
            src = s(i)
            dst &= (vbTab & vbTab & vbTab & Chr(34) & src.Replace(Chr(34).ToString, (Chr(34) & Chr(34)).ToString) & Chr(34) & " & vbCrLf  ") & vbCrLf

            Me.RichTextBox1.Text = dst

        ElseIf e.Clicks = 2 And e.Button = MouseButtons.Right Then
            Me.RichTextBox1.Clear()
            Me.RichTextBox1.AppendText("使用说明:将客户端javascript脚本转换为vb.net中的预输出,双击左键转换")
        End If


    End Sub

    Private Sub btnFromClient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFromClient.Click
        Dim s() As String = Me.RichTextBox1.Lines
        Dim src As String
        Dim dst As String = "Dim s as String="""" & vbCrLf & _ " & vbCrLf
        Dim i As Integer
        For i = 0 To s.Length - 1
            src = s(i)
            dst &= (vbTab & vbTab & vbTab & Chr(34) & src.Replace(Chr(34).ToString, (Chr(34) & Chr(34)).ToString) & Chr(34) & " & vbCrLf & _ ") & vbCrLf
        Next
        If dst.Length > 5 Then
            dst = dst.Remove(dst.Length - 6, 6)
        End If
        Me.RichTextBox1.Text = dst

    End Sub

    Private Sub btnToClient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToClient.Click
        Dim s() As String = Me.RichTextBox1.Lines
        Dim src As String
        Dim dst As String = ""
        Dim i As Integer
        For i = 1 To s.Length - 1
            src = s(i)
            If src <> "" Then
                src = src.Remove(0, src.IndexOf("""") + 1)
                src = src.Remove(src.LastIndexOf(""" & vbCrLf"), src.Length - src.LastIndexOf(""" & vbCrLf"))
                src = src.Replace((Chr(34) & Chr(34)).ToString, Chr(34).ToString)
                dst &= (src & vbCrLf)
            End If
        Next
        If dst.Length > 5 Then
            dst = dst.Remove(dst.Length - 2, 2)
        End If
        Me.RichTextBox1.Text = dst


    End Sub

    Private Sub btnSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectAll.Click
        Me.RichTextBox1.SelectAll()
    End Sub


    Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click
        Me.RichTextBox1.Copy()
    End Sub

    Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaste.Click
        Me.RichTextBox1.Clear()
        Me.RichTextBox1.Paste()
    End Sub
End Class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值