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

📄 waverender.vb

📁 这是一个用vb.net编写的扫描条形码程序
💻 VB
📖 第 1 页 / 共 3 页
字号:
Imports System
Imports System.Drawing.Graphics
Imports System.ComponentModel
Imports System.Runtime.InteropServices

Public Class vbnetWaveRender
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        UserControl_Initialize()

    End Sub

    'UserControl1 overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            UserControl_Terminate()
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents mainpanel As System.Windows.Forms.Panel
    Friend WithEvents hozScroll As System.Windows.Forms.HScrollBar
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.mainpanel = New System.Windows.Forms.Panel
        Me.hozScroll = New System.Windows.Forms.HScrollBar
        Me.mainpanel.SuspendLayout()
        Me.SuspendLayout()
        '
        'mainpanel
        '
        Me.mainpanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.mainpanel.Controls.Add(Me.hozScroll)
        Me.mainpanel.Dock = System.Windows.Forms.DockStyle.Fill
        Me.mainpanel.Location = New System.Drawing.Point(0, 0)
        Me.mainpanel.Name = "mainpanel"
        Me.mainpanel.Size = New System.Drawing.Size(400, 400)
        Me.mainpanel.TabIndex = 0
        '
        'hozScroll
        '
        Me.hozScroll.Dock = System.Windows.Forms.DockStyle.Bottom
        Me.hozScroll.Location = New System.Drawing.Point(0, 379)
        Me.hozScroll.Name = "hozScroll"
        Me.hozScroll.Size = New System.Drawing.Size(396, 17)
        Me.hozScroll.TabIndex = 0
        '
        'vbnetWaveRender
        '
        Me.Controls.Add(Me.mainpanel)
        Me.Name = "vbnetWaveRender"
        Me.Size = New System.Drawing.Size(400, 400)
        Me.mainpanel.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
    Public Structure WaveData
        Dim m_AudioPathL As Drawing2D.GraphicsPath
        Dim m_AudioPathR As Drawing2D.GraphicsPath
    End Structure

    'Stucture for Render Information
    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
    Private Structure PaintInfo
        Dim m_oCSD_SX As Integer
        Dim m_oCSD_SY As Integer
        Dim m_oCSD_LX As Integer
        Dim m_oCSD_LY As Integer
        Dim m_oCSD_PEN As Pen

        Dim m_oCHADT_SX As Integer
        Dim m_oCHADT_SY As Integer
        Dim m_oCHADT_LX As Integer
        Dim m_oCHADT_LY As Integer
        Dim m_oCHADT_PEN As Pen

        Dim m_oCHADB_SX As Integer
        Dim m_oCHADB_SY As Integer
        Dim m_oCHADB_LX As Integer
        Dim m_oCHADB_LY As Integer
        Dim m_oCHADB_PEN As Pen

        Dim m_oCMDTT_SX As Integer
        Dim m_oCMDTT_SY As Integer
        Dim m_oCMDTT_LX As Integer
        Dim m_oCMDTT_LY As Integer
        Dim m_oCMDTT_pen As Pen

        Dim m_oCMDTB_SX As Integer
        Dim m_oCMDTB_SY As Integer
        Dim m_oCMDTB_LX As Integer
        Dim m_oCMDTB_LY As Integer
        Dim m_oCMDTB_pen As Pen

        Dim m_oCMDBT_SX As Integer
        Dim m_oCMDBT_SY As Integer
        Dim m_oCMDBT_LX As Integer
        Dim m_oCMDBT_LY As Integer
        Dim m_oCMDBT_pen As Pen

        Dim m_oCMDBB_SX As Integer
        Dim m_oCMDBB_SY As Integer
        Dim m_oCMDBB_LX As Integer
        Dim m_oCMDBB_LY As Integer
        Dim m_oCMDBB_pen As Pen

        Dim m_WAVENDCoverRec As Drawing.Rectangle
        Dim m_WAVENDCoverBrh As Drawing.Brush

        Dim m_AudioPathL As Drawing2D.GraphicsPath
        Dim m_AudioPathR As Drawing2D.GraphicsPath
        Dim m_AudioPen As Pen

        Public Sub init()
            m_AudioPathL = New Drawing2D.GraphicsPath
            m_AudioPathR = New Drawing2D.GraphicsPath
        End Sub
    End Structure

    'Set Enums
    Public Enum EWaveViewerZoom
        e24to1 = -24
        e16to1 = -16
        e8to1 = -8
        e6to1 = -6
        e4to1 = -4
        e3to1 = -3
        e2to1 = -2
        e1to1 = 1
        e1to2 = 2
        e1to4 = 4
        e1to8 = 8
        e1to16 = 16
        e1to32 = 32
        e1to64 = 64
        e1to128 = 128
        e1to256 = 256
        e1to512 = 512
        e1to1024 = 1024
        e1to2048 = 2048
        e1to4196 = 4196
        e1to8192 = 8192
        e1to16384 = 16384
    End Enum

    'State Events
    Public Event HalfAmplitudeDividerColorChange()
    Public Event HalfAmplitudeDividerWidthChange()
    Public Event HalfAmplitudeDividerStyleChange()
    Public Event WaveForeColorChange()
    Public Event StereoDividerColorChange()
    Public Event StereoDividerWidthChange()
    Public Event StereoDividerStyleChange()
    Public Event MidDividerColorChange()
    Public Event MidDividerWidthchange()
    Public Event MidDividerStylechange()
    Public Event NoWaveBackColorChange()
    Public Event BorderStyleChange()
    Public Event RenderFinished()
    Public Event RenderStarted()

    Private m_cWAVRead As WaveFile
    Private m_FileOpen As Boolean
    'Private WithEvents m_cScroll As cScrollBars
    Private m_lSampleStep As Integer
    Private m_lPixelStep As Integer
    Private m_lSamplePerPixelStep As Integer
    Private m_bSetting As Boolean
    Private m_GraphicInfoReady As Boolean
    Private PaintData As PaintInfo

    'State Property Variables
    Private m_lZoom As EWaveViewerZoom
    Private m_oWaveBackColor As System.Drawing.Color
    Private m_oNoWaveBackColor As System.Drawing.Color
    Private m_oWaveForeColor As System.Drawing.Color
    Private m_oColorStereoDivider As System.Drawing.Color
    Private m_oColorMidDivider As System.Drawing.Color
    Private m_oColorHalfAmplitudeDivider As System.Drawing.Color
    Private m_oStereoDividerLineThickNess As Short
    Private m_oStereoDividerLineStyle As Drawing2D.DashStyle
    Private m_oMidDividerLineThickNess As Short
    Private m_oMidDividerLineStyle As Drawing2D.DashStyle
    Private m_oHalfAmplitudeDividerLineThickNess As Short
    Private m_oHalfAmplitudeDividerLineStyle As Drawing2D.DashStyle
    Private m_bUseThread As Boolean
    Private m_ThreadDone As Boolean
    Private m_ThreadResultOk As Boolean

    'Thread Headers for WaveInfo Function
    Delegate Function WaveInfoHandler(ByVal lLastx As Integer, ByVal lLastLeftY As Integer, ByVal lLastRightY As Integer, _
    ByVal lx As Integer, ByVal ly As Integer, ByVal lEnd As Integer, ByVal lAbsSizeY As Integer, _
    ByVal bRectangles As Boolean, ByVal lMidy As Integer) As WaveData
    Delegate Sub UpdateUIHandler(ByVal Statusmsg As String, ByVal result As WaveData)
    Private WaveInfo_handler As WaveInfoHandler = AddressOf WaveInfo
    Private WaveInfo_callback As AsyncCallback = AddressOf GetWaveInfo_callback

    'Set the file name, used to start render operation
    <Category("Control Options"), Description("Sets the file name")> _
        Public Property WaveFile() As String
        Get
            If m_FileOpen Then
                WaveFile = m_cWAVRead.Filename
            Else
                WaveFile = ""
            End If
        End Get
        Set(ByVal Value As String)
            If Len(Value) = 0 Then
                m_cWAVRead = New WaveFile
            End If
            m_cWAVRead.Filename = Value

            If m_cWAVRead.FileOpen Then
                m_FileOpen = True
            End If

            SetScroll()
            renderWave()
        End Set
    End Property

    'File open information - read only
    '-------------------------------------------------------------
    ' Must be called before calling any of the following read only
    ' properties
    <Category("Control Data"), Description("Is a file open")> _
    Public ReadOnly Property WaveOpen() As Boolean
        Get
            WaveOpen = m_FileOpen
        End Get
    End Property
    'Number of chanels in data - read only
    '-------------------------------------------------------------
    ' The host application should only call this after detemining
    ' that a file is open (see above)
    ' Will return the number of chanels in the wave form
    <Category("Control Data"), Description("Number of Channels")> _
    Public ReadOnly Property WaveChannels() As Int16
        Get
            WaveChannels = m_cWAVRead.Channels
        End Get
    End Property
    'Sampling Frequency of data - read only
    '-------------------------------------------------------------
    ' The host application should only call this after detemining
    ' that a file is open (see above)
    ' Will return the sampling frequency of the wave form
    <Category("Control Data"), Description("Sampling Frequency")> _
    Public ReadOnly Property WaveSamplingFreq() As Integer
        Get
            WaveSamplingFreq = m_cWAVRead.SamplingFrequency
        End Get
    End Property
    'Number of bits per sample in data - read only
    '-------------------------------------------------------------
    ' The host application should only call this after detemining
    ' that a file is open (see above)
    ' Will return the number of bits per sample in the wave form
    <Category("Control Data"), Description("Bits per sample")> _
    Public ReadOnly Property WaveBitsPerSample() As Integer
        Get
            WaveBitsPerSample = m_cWAVRead.BitsPerSample
        End Get
    End Property

    'Processing Options
    <Category("Processing"), Description("Alowes control to use process render information in a new thread")> _
    Public Property ThreadUse() As Boolean
        Get
            ThreadUse = m_bUseThread
        End Get
        Set(ByVal Value As Boolean)
            m_bUseThread = Value
        End Set
    End Property
    Public Sub ResetThreadUse()
        m_bUseThread = True
    End Sub

    'Property Stuctures
    <Category("Appearance"), Description("Sets boarderstyle of the control")> _
    Public Property BoarderStyle() As BorderStyle
        Get
            BoarderStyle = mainpanel.BorderStyle
        End Get
        Set(ByVal Value As BorderStyle)
            mainpanel.BorderStyle = Value

⌨️ 快捷键说明

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