En esta ocasión os voy a mostrar el diseño de un nuevo control realizado en Visual Basic .NET. Va a ser un display analógico a modo de indicador con aguja. Este os podrá ser útil para cualquier aplicación donde necesitéis indicar de forma analógica algún rango de valores de forma gráfica.
¿Por que me ha dado por hacer este control? Pues bien llevo tiempo pensando en hacer un laboratorio virtual con controles hecho en Visual Basic y creo que poco a poco los iré haciendo para que finalmente pueda compartir con todos vosotr@s una colección para poder hacer un aplicación gráfica bastante chula. De momento, ya están disponibles, el display de 7 segmentos, el display LCD y ahora estará este otro: el "display analógico" o "display analógico de aguja".
El aspecto de este es el que os muestro a continuación. Ya se que no ha quedado muy bonito que se diga, pero todo es cosa de echarle algo más de tiempo y mejorar un poco el aspecto gráfico. Me he centrado más, quizás en la parte de funcionamiento y programación pero aquí esta como primera versión.
Os adelanto el vídeo del control de aguja en funcionamiento en una aplicación de ejemplo. Esta misma la podréis descargar también de esta página. Pues ya sabéis ..... a disfrutar .....y a seguir evolucionando!
- Como usar el control partiendo de la librería .dll que he compilado.
Aquí os adjunto la librería que contiene el control del display analógico, para el que lo quiera usar sin meterse en nada de su diseño.
Librería .dll del control "Display Analógico de Aguja"
Para empezar a usarla tenéis que seguir los siguientes pasos:
1.Crear un nuevo proyecto.
2.Elegir el típico de Windows Forms
3. Ir a la parte del "Cuadro de Herramientas" en la ficha de general pulsa con el botón derecho del ratón para desplegar el menú emergente.
4. Elegir la opción de "Elegir elementos". Ahí, seleccionar la pestaña de "Componentes del .NET Framework" y pulsar sobre el botón de "Examinar". Os aparecerá una ventana de busqueda de archivo de windows y ahí buscar el control.dll del display que os habeis descargado del enlace anterior.
5. Una vez cargado el archivo .dll correspondiente del control, ya se puede hacer uso de él, pues este aparecerá en nuestra barra de herramientas como podréis comprobar. Exactamente en la sección de "General" que es donde lo hemos cargado. En este caso, el nombre con el que aparece es: "Control_1"
6. Solo basta seleccionarlo y arrastrarlo hasta el Windows Form y aparecerá dibujado como aparece cualquier otro control, así como su ventana de propiedades.
7. Finalmente, sin incluir nada de código, y ajustando un poco la ventana del control así como la ventana del Windows Form, nos queda algo como esto.
Solo faltaría dar a ejecutar y veréis algo como esto. A partir de ahí solo os queda hacer una aplicación para manejar el control. Eso sí .... ya depende de lo que vosotros queráis hacer con el control ....
- Aplicación de ejemplo que hace uso del Display Analógico de Aguja.
Pues bien para facilitaros un poco la tarea finalmente he realizado una pequeña aplicación para demostrar el funcionamiento de este control.
El aspecto de esta es la que os muestro a continuación:
Es sencilla, pero suficiente para comprobar algunas de las características del Display Analógico de Aguja. Espero que os guste!
(Recordar dejar el archivo .dll en la misma ruta donde esté el ejecutable .exe)
Código Fuente del User Control Display Analógico de Aguja
Pulsar en este enlace para descargaros el código fuente del Display Analógico de Aguja. Debajo del mismo también lo podéis encontrar para hacer un simple corta y pega.
'*****************************************************************************************
' LICENSE INFORMATION
'*****************************************************************************************
' Control_Analog_Display Version 1.0.0.0
' User control for Visual Basic .NET
'
' Copyright © 2010
' Rubén García Coronado
' Email: rubengaco13@gmail.com
' Created: Dec 2010
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
'*****************************************************************************************
Imports System.Drawing
Public Class Control_1
Inherits System.Windows.Forms.UserControl
Const Medidas As Integer = 12
Const Pi As Double = 3.1416
Const G_0 As Double = 0
Const G_15 As Double = (-Pi / 12)
Const G_30 As Double = G_15 * 2 '(-Pi / 6)
Const G_45 As Double = G_15 * 3 '(-Pi / 4)
Const G_60 As Double = G_15 * 4 '(-Pi / 3)
Const G_75 As Double = G_15 * 5
Const G_90 As Double = G_15 * 6 '(-Pi / 2)
Const G_105 As Double = G_15 * 7
Const G_120 As Double = G_15 * 8 '(2 * -Pi) / 3
Const G_135 As Double = G_15 * 9
Const G_150 As Double = G_15 * 10 '(5 * -Pi) / 6
Const G_165 As Double = G_15 * 11
Const G_180 As Double = G_15 * 12 '-Pi
Const Unidad As String = "Voltios"
Dim Grafico As Graphics
Dim Color_Aguja As Color = Color.Red 'Color.Orange
Dim Pen_Aguja As Pen
Dim Color_Rayas As Color = Color.Yellow 'Color.Black
Dim Pen_Rayas As Pen
Dim Color_Panel As Color = Color.Black 'Color.LemonChiffon
Dim Color_Digitos As Color = Color_Rayas
Dim F_S As Double
Dim X1, Y1, X2, Y2, Radio, Radio_Rayas As Integer
#Region " Código generado por el Diseñador de Windows Forms "
Public Sub New()
MyBase.New()
'El Diseñador de Windows Forms requiere esta llamada.
InitializeComponent()
'Agregar cualquier inicialización después de la llamada a InitializeComponent()
End Sub
'UserControl reemplaza a Dispose para limpiar la lista de componentes.
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
'Requerido por el Diseñador de Windows Forms
Private components As System.ComponentModel.IContainer
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento
'Puede modificarse utilizando el Diseñador de Windows Forms.
'No lo modifique con el editor de código.
Friend WithEvents PictureBox As System.Windows.Forms.PictureBox
Friend WithEvents Label_D12 As System.Windows.Forms.Label
Friend WithEvents Label_D11 As System.Windows.Forms.Label
Friend WithEvents Label_D10 As System.Windows.Forms.Label
Friend WithEvents Label_D9 As System.Windows.Forms.Label
Friend WithEvents Label_D8 As System.Windows.Forms.Label
Friend WithEvents Label_D7 As System.Windows.Forms.Label
Friend WithEvents Label_D6 As System.Windows.Forms.Label
Friend WithEvents Label_D4 As System.Windows.Forms.Label
Friend WithEvents Label_D5 As System.Windows.Forms.Label
Friend WithEvents Label_D3 As System.Windows.Forms.Label
Friend WithEvents Label_D2 As System.Windows.Forms.Label
Friend WithEvents Label_D1 As System.Windows.Forms.Label
Friend WithEvents Label_D0 As System.Windows.Forms.Label
Friend WithEvents Label_Valor As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.PictureBox = New System.Windows.Forms.PictureBox
Me.Label_D12 = New System.Windows.Forms.Label
Me.Label_D11 = New System.Windows.Forms.Label
Me.Label_D10 = New System.Windows.Forms.Label
Me.Label_D9 = New System.Windows.Forms.Label
Me.Label_D8 = New System.Windows.Forms.Label
Me.Label_D7 = New System.Windows.Forms.Label
Me.Label_D6 = New System.Windows.Forms.Label
Me.Label_D4 = New System.Windows.Forms.Label
Me.Label_D5 = New System.Windows.Forms.Label
Me.Label_D3 = New System.Windows.Forms.Label
Me.Label_D2 = New System.Windows.Forms.Label
Me.Label_D1 = New System.Windows.Forms.Label
Me.Label_D0 = New System.Windows.Forms.Label
Me.Label_Valor = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'PictureBox
'
Me.PictureBox.BackColor = System.Drawing.Color.LemonChiffon
Me.PictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.PictureBox.Location = New System.Drawing.Point(0, 0)
Me.PictureBox.Name = "PictureBox"
Me.PictureBox.Size = New System.Drawing.Size(236, 120)
Me.PictureBox.TabIndex = 2
Me.PictureBox.TabStop = False
'
'Label_D12
'
Me.Label_D12.AutoSize = True
Me.Label_D12.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D12.ForeColor = System.Drawing.Color.Black
Me.Label_D12.Location = New System.Drawing.Point(204, 96)
Me.Label_D12.Name = "Label_D12"
Me.Label_D12.Size = New System.Drawing.Size(17, 16)
Me.Label_D12.TabIndex = 29
Me.Label_D12.Text = "12"
Me.Label_D12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D11
'
Me.Label_D11.AutoSize = True
Me.Label_D11.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D11.ForeColor = System.Drawing.Color.Black
Me.Label_D11.Location = New System.Drawing.Point(200, 72)
Me.Label_D11.Name = "Label_D11"
Me.Label_D11.Size = New System.Drawing.Size(17, 16)
Me.Label_D11.TabIndex = 28
Me.Label_D11.Text = "11"
Me.Label_D11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D10
'
Me.Label_D10.AutoSize = True
Me.Label_D10.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D10.ForeColor = System.Drawing.Color.Black
Me.Label_D10.Location = New System.Drawing.Point(192, 52)
Me.Label_D10.Name = "Label_D10"
Me.Label_D10.Size = New System.Drawing.Size(17, 16)
Me.Label_D10.TabIndex = 27
Me.Label_D10.Text = "10"
Me.Label_D10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D9
'
Me.Label_D9.AutoSize = True
Me.Label_D9.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D9.ForeColor = System.Drawing.Color.Black
Me.Label_D9.Location = New System.Drawing.Point(176, 32)
Me.Label_D9.Name = "Label_D9"
Me.Label_D9.Size = New System.Drawing.Size(11, 16)
Me.Label_D9.TabIndex = 26
Me.Label_D9.Text = "9"
Me.Label_D9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D8
'
Me.Label_D8.AutoSize = True
Me.Label_D8.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D8.ForeColor = System.Drawing.Color.Black
Me.Label_D8.Location = New System.Drawing.Point(156, 16)
Me.Label_D8.Name = "Label_D8"
Me.Label_D8.Size = New System.Drawing.Size(11, 16)
Me.Label_D8.TabIndex = 25
Me.Label_D8.Text = "8"
Me.Label_D8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D7
'
Me.Label_D7.AutoSize = True
Me.Label_D7.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D7.ForeColor = System.Drawing.Color.Black
Me.Label_D7.Location = New System.Drawing.Point(132, 8)
Me.Label_D7.Name = "Label_D7"
Me.Label_D7.Size = New System.Drawing.Size(11, 16)
Me.Label_D7.TabIndex = 24
Me.Label_D7.Text = "7"
Me.Label_D7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D6
'
Me.Label_D6.AutoSize = True
Me.Label_D6.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D6.ForeColor = System.Drawing.Color.Black
Me.Label_D6.Location = New System.Drawing.Point(108, 4)
Me.Label_D6.Name = "Label_D6"
Me.Label_D6.Size = New System.Drawing.Size(11, 16)
Me.Label_D6.TabIndex = 23
Me.Label_D6.Text = "6"
Me.Label_D6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D4
'
Me.Label_D4.AutoSize = True
Me.Label_D4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D4.ForeColor = System.Drawing.Color.Black
Me.Label_D4.Location = New System.Drawing.Point(56, 16)
Me.Label_D4.Name = "Label_D4"
Me.Label_D4.Size = New System.Drawing.Size(11, 16)
Me.Label_D4.TabIndex = 22
Me.Label_D4.Text = "4"
Me.Label_D4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D5
'
Me.Label_D5.AutoSize = True
Me.Label_D5.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D5.ForeColor = System.Drawing.Color.Black
Me.Label_D5.Location = New System.Drawing.Point(80, 8)
Me.Label_D5.Name = "Label_D5"
Me.Label_D5.Size = New System.Drawing.Size(11, 16)
Me.Label_D5.TabIndex = 21
Me.Label_D5.Text = "5"
Me.Label_D5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D3
'
Me.Label_D3.AutoSize = True
Me.Label_D3.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D3.ForeColor = System.Drawing.Color.Black
Me.Label_D3.Location = New System.Drawing.Point(36, 32)
Me.Label_D3.Name = "Label_D3"
Me.Label_D3.Size = New System.Drawing.Size(11, 16)
Me.Label_D3.TabIndex = 20
Me.Label_D3.Text = "3"
Me.Label_D3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D2
'
Me.Label_D2.AutoSize = True
Me.Label_D2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D2.ForeColor = System.Drawing.Color.Black
Me.Label_D2.Location = New System.Drawing.Point(20, 52)
Me.Label_D2.Name = "Label_D2"
Me.Label_D2.Size = New System.Drawing.Size(11, 16)
Me.Label_D2.TabIndex = 19
Me.Label_D2.Text = "2"
Me.Label_D2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D1
'
Me.Label_D1.AutoSize = True
Me.Label_D1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D1.ForeColor = System.Drawing.Color.Black
Me.Label_D1.Location = New System.Drawing.Point(12, 72)
Me.Label_D1.Name = "Label_D1"
Me.Label_D1.Size = New System.Drawing.Size(11, 16)
Me.Label_D1.TabIndex = 18
Me.Label_D1.Text = "1"
Me.Label_D1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_D0
'
Me.Label_D0.AutoSize = True
Me.Label_D0.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_D0.ForeColor = System.Drawing.Color.Black
Me.Label_D0.Location = New System.Drawing.Point(8, 96)
Me.Label_D0.Name = "Label_D0"
Me.Label_D0.Size = New System.Drawing.Size(11, 16)
Me.Label_D0.TabIndex = 17
Me.Label_D0.Text = "0"
Me.Label_D0.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label_Valor
'
Me.Label_Valor.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label_Valor.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_Valor.Location = New System.Drawing.Point(0, 120)
Me.Label_Valor.Name = "Label_Valor"
Me.Label_Valor.Size = New System.Drawing.Size(236, 24)
Me.Label_Valor.TabIndex = 30
Me.Label_Valor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Control_1
'
Me.Controls.Add(Me.Label_Valor)
Me.Controls.Add(Me.Label_D12)
Me.Controls.Add(Me.Label_D11)
Me.Controls.Add(Me.Label_D10)
Me.Controls.Add(Me.Label_D9)
Me.Controls.Add(Me.Label_D8)
Me.Controls.Add(Me.Label_D7)
Me.Controls.Add(Me.Label_D6)
Me.Controls.Add(Me.Label_D4)
Me.Controls.Add(Me.Label_D5)
Me.Controls.Add(Me.Label_D3)
Me.Controls.Add(Me.Label_D2)
Me.Controls.Add(Me.Label_D1)
Me.Controls.Add(Me.Label_D0)
Me.Controls.Add(Me.PictureBox)
Me.Name = "Control_1"
Me.Size = New System.Drawing.Size(368, 240)
Me.ResumeLayout(False)
End Sub
#End Region
Public Property Input() As Double
Get
'Return Me.TextBox1.Text
Return Input
End Get
Set(ByVal Value As Double)
'Origen
X1 = 112 '(PictureBox.Size.Width \ 2)
Y1 = 102 '(PictureBox.Size.Width \ 2) - 10
'Fin
X2 = X1
Y2 = 15
'Radios
Radio = Y1 - Y2 - 5
Radio_Rayas = Radio - 15
Me.PictureBox.BackColor = Color_Panel
Me.Label_Valor.BackColor = Color_Panel
Me.Label_Valor.ForeColor = Color_Digitos
'Actualiza caja de texto numerica
'Me.TextBox1.Text = Value.ToString & " " & Unidad
'Me.Label_Valor.Text = ((F_S / Medidas) * Value).ToString & " " & Unidad
If F_S Mod Medidas = 0 Then
Me.Label_Valor.Text = Format(((F_S / Medidas) * Value), "###0").ToString & " " & Unidad
Else
Me.Label_Valor.Text = Format(((F_S / Medidas) * Value), "###0.0").ToString & " " & Unidad
End If
PictureBox.Refresh()
Grafico = PictureBox.CreateGraphics
Pen_Aguja = New Pen(Color_Aguja, 1) 'Para la aguja ( color rojo con 1 de grosor )
Pen_Rayas = New Pen(Color_Rayas, 1)
'Dibuja las rayas y los números
Panel_Rayas()
'Posiciona el centro de la aguja
Grafico.DrawArc(New Pen(Color_Aguja, 6), X1 - 3, Y1 - 3, 6, 6, 0, 360)
'Grafico.DrawLine(Pen_Aguja, X1, Y1, X2, Y2) 'Ejemplo aguja centrada
'Posiciona aguja
Select Case Value
Case 0
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(Pi))) + X1, CInt(Radio * (Math.Sin(Pi))) + Y1)
Case 1
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_165))) + X1, CInt(Radio * (Math.Sin(G_165))) + Y1)
Case 2
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_150))) + X1, CInt(Radio * (Math.Sin(G_150))) + Y1)
Case 3
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_135))) + X1, CInt(Radio * (Math.Sin(G_135))) + Y1)
Case 4
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_120))) + X1, CInt(Radio * (Math.Sin(G_120))) + Y1)
Case 5
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_105))) + X1, CInt(Radio * (Math.Sin(G_105))) + Y1)
Case 6
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_90))) + X1, CInt(Radio * (Math.Sin(G_90))) + Y1)
Case 7
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_75))) + X1, CInt(Radio * (Math.Sin(G_75))) + Y1)
Case 8
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_60))) + X1, CInt(Radio * (Math.Sin(G_60))) + Y1)
Case 9
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_45))) + X1, CInt(Radio * (Math.Sin(G_45))) + Y1)
Case 10
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_30))) + X1, CInt(Radio * (Math.Sin(G_30))) + Y1)
Case 11
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_15))) + X1, CInt(Radio * (Math.Sin(G_15))) + Y1)
Case 12
Grafico.DrawLine(Pen_Aguja, X1, Y1, CInt(Radio * (Math.Cos(G_0))) + X1, CInt(Radio * (Math.Sin(G_0))) + Y1)
End Select
End Set
End Property
Public Sub Panel_Rayas()
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(Pi))) + X1, CInt(Radio * (Math.Sin(Pi))) + Y1, CInt(Radio_Rayas * (Math.Cos(Pi))) + X1, CInt(Radio_Rayas * (Math.Sin(Pi))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_165))) + X1, CInt(Radio * (Math.Sin(G_165))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_165))) + X1, CInt(Radio_Rayas * (Math.Sin(G_165))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_150))) + X1, CInt(Radio * (Math.Sin(G_150))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_150))) + X1, CInt(Radio_Rayas * (Math.Sin(G_150))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_135))) + X1, CInt(Radio * (Math.Sin(G_135))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_135))) + X1, CInt(Radio_Rayas * (Math.Sin(G_135))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_120))) + X1, CInt(Radio * (Math.Sin(G_120))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_120))) + X1, CInt(Radio_Rayas * (Math.Sin(G_120))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_105))) + X1, CInt(Radio * (Math.Sin(G_105))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_105))) + X1, CInt(Radio_Rayas * (Math.Sin(G_105))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_90))) + X1, CInt(Radio * (Math.Sin(G_90))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_90))) + X1, CInt(Radio_Rayas * (Math.Sin(G_90))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_75))) + X1, CInt(Radio * (Math.Sin(G_75))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_75))) + X1, CInt(Radio_Rayas * (Math.Sin(G_75))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_60))) + X1, CInt(Radio * (Math.Sin(G_60))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_60))) + X1, CInt(Radio_Rayas * (Math.Sin(G_60))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_45))) + X1, CInt(Radio * (Math.Sin(G_45))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_45))) + X1, CInt(Radio_Rayas * (Math.Sin(G_45))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_30))) + X1, CInt(Radio * (Math.Sin(G_30))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_30))) + X1, CInt(Radio_Rayas * (Math.Sin(G_30))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_15))) + X1, CInt(Radio * (Math.Sin(G_15))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_15))) + X1, CInt(Radio_Rayas * (Math.Sin(G_15))) + Y1)
Grafico.DrawLine(Pen_Rayas, CInt(Radio * (Math.Cos(G_0))) + X1, CInt(Radio * (Math.Sin(G_0))) + Y1, CInt(Radio_Rayas * (Math.Cos(G_0))) + X1, CInt(Radio_Rayas * (Math.Sin(G_0))) + Y1)
Label_D0.ForeColor = Color_Digitos
Label_D1.ForeColor = Color_Digitos
Label_D2.ForeColor = Color_Digitos
Label_D3.ForeColor = Color_Digitos
Label_D4.ForeColor = Color_Digitos
Label_D5.ForeColor = Color_Digitos
Label_D6.ForeColor = Color_Digitos
Label_D7.ForeColor = Color_Digitos
Label_D8.ForeColor = Color_Digitos
Label_D9.ForeColor = Color_Digitos
Label_D10.ForeColor = Color_Digitos
Label_D11.ForeColor = Color_Digitos
Label_D12.ForeColor = Color_Digitos
Label_D0.BackColor = Color_Panel
Label_D1.BackColor = Color_Panel
Label_D2.BackColor = Color_Panel
Label_D3.BackColor = Color_Panel
Label_D4.BackColor = Color_Panel
Label_D5.BackColor = Color_Panel
Label_D6.BackColor = Color_Panel
Label_D7.BackColor = Color_Panel
Label_D8.BackColor = Color_Panel
Label_D9.BackColor = Color_Panel
Label_D10.BackColor = Color_Panel
Label_D11.BackColor = Color_Panel
Label_D12.BackColor = Color_Panel
End Sub
Public Property Fondo_Escala() As Double
Get
Return Fondo_Escala
End Get
Set(ByVal Value As Double)
Dim Resto As Integer
Resto = Value Mod Medidas
If Resto = 0 Then
Label_D0.Text = Format(((Value / Medidas) * 0), "##0")
Label_D1.Text = Format(((Value / Medidas) * 1), "##0")
Label_D2.Text = Format(((Value / Medidas) * 2), "##0")
Label_D3.Text = Format(((Value / Medidas) * 3), "##0")
Label_D4.Text = Format(((Value / Medidas) * 4), "##0")
Label_D5.Text = Format(((Value / Medidas) * 5), "##0")
Label_D6.Text = Format(((Value / Medidas) * 6), "##0")
Label_D7.Text = Format(((Value / Medidas) * 7), "##0")
Label_D8.Text = Format(((Value / Medidas) * 8), "##0")
Label_D9.Text = Format(((Value / Medidas) * 9), "##0")
Label_D10.Text = Format(((Value / Medidas) * 10), "##0")
Label_D11.Text = Format(((Value / Medidas) * 11), "##0")
Label_D12.Text = Format(((Value / Medidas) * 12), "##0")
Else
Label_D0.Text = Format(((Value / Medidas) * 0), "###0.0")
Label_D1.Text = Format(((Value / Medidas) * 1), "###0.0")
Label_D2.Text = Format(((Value / Medidas) * 2), "###0.0")
Label_D3.Text = Format(((Value / Medidas) * 3), "###0.0")
Label_D4.Text = Format(((Value / Medidas) * 4), "###0.0")
Label_D5.Text = Format(((Value / Medidas) * 5), "###0.0")
Label_D6.Text = Format(((Value / Medidas) * 6), "###0.0")
Label_D7.Text = Format(((Value / Medidas) * 7), "###0.0")
Label_D8.Text = Format(((Value / Medidas) * 8), "###0.0")
Label_D9.Text = Format(((Value / Medidas) * 9), "###0.0")
Label_D10.Text = Format(((Value / Medidas) * 10), "###0.0")
Label_D11.Text = Format(((Value / Medidas) * 11), "###0.0")
Label_D12.Text = Format(((Value / Medidas) * 12), "###0.0")
End If
F_S = Value
End Set
End Property
Public Property Digitos_Negrita() As Boolean
Get
Return Digitos_Negrita
End Get
Set(ByVal Value As Boolean)
If Value = True Then
Label_D0.Font = New Font(Label_D0.Font, FontStyle.Bold)
Else
Label_D0.Font = New Font(Label_D0.Font, FontStyle.Regular)
End If
End Set
End Property
End Class
Código Fuente de toda la Aplicación
(Incluye también el Control Display Analógico de Aguja)
Espero que os guste y que a partir de este nuevo ejemplo podáis hacer vosotros vuestros controles personalizados para vuestras aplicaciones. ....¡Ánimo!... que ya tenemos tres!!!
Un saludo.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Por favor, si te ha gustado el blog, te ha ayudado o has visto algún proyecto interesante del que te has podido descargar alguna documentación por favor deja algún comentario. Gracias.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
No hay comentarios:
Publicar un comentario
Deja tu comentario