Mostrando las entradas con la etiqueta Property. Mostrar todas las entradas
Mostrando las entradas con la etiqueta Property. Mostrar todas las entradas

martes, 7 de abril de 2020

BoxInteger (clase)


Esta clase hereda de textbox, todo, valga la redundancia, pero le añadiremos un comportamiento particular en su evento KeyPress(). Este evento se lanza o se produce cuando presionamos una tecla. Por medio de un observador capturaremos este evento, haremos un filtro que si la tecla presionada no es un número del 0 a 9 retornemos previamente parando el evento mediante Stop Event haciendo que no se escriba el carácter elegido por el usuario mediante el teclado. Para escribir un número tendrá que presionar nuevamente otra tecla para lanzar el evento nuevamente y ahí actuará nuestro filtro. Otras teclas que permitiremos para que el usuario pueda editar serán suprimir, retornar, inicio, fin y alguna mas.

' gambas class file

'by postapase 07 abr 2020
Export

Inherits TextBox

Public Const Properties As String = "*"
Public Const _IsControl As Boolean = True
Public Const _DefaultSize As String = "14,4"
Public Const _Group As String = "Form"

Public obs As Observer

Property Read Valor As Integer

Public Sub _new()
'aquí esta el observador con el cual podremos manipular los eventos del textbox mediante la palabra "boxinteger" (aquí podemos poner un nombre a elección"
Obs = New Observer(Me) As "BoxInteger"

End




Public Sub BoxInteger_KeyPress()

Select Case Key.Code
Case Key.Del
Return
Case Key.Return
Return
Case Key.Home
Return
Case Key.End
Return
Case 16777234
Return
Case 16777236
Return
Case 16777219
Return
Case 48 To 57 'estos son los códigos ascii del número 0 al 9
Return
Default
End Select

Stop Event
Return

End

Private Function Valor_Read() As Integer

If Me.Text = "" Then Return 0

Return CInt(Me.Text)

End


Código:
https://gambas.one/gambasfarm/?id=776&action=search

viernes, 7 de julio de 2017

Control personalizado


Aquí les dejo mi experimento en la creación de una clase o control personalizado, a medida para un fin x. El código esta en la granja.


' gambas class file

Export

Inherits UserControl

Public Const _Properties As String = "*,Texto,Seleccion,Hombre=True"
Public Const _DefaultEvent As String = "Eleccion"
Public Const _DefaultSize As String = "36,4"

Event Eleccion

Property Seleccion As Boolean
Property Texto As String
Property Hombre As Boolean

Private $Seleccion As Boolean
Private $Texto As String
Private $Hombre As Boolean

Private $hFondo As DrawingArea
Private $TextLabel As TextLabel
Private $CheckBox As CheckBox
Private $Persona As PictureBox

Public Sub _new()

$hFondo = New DrawingArea(Me) As "Fondo"
$hFondo.Background = &HFFEFBF
$hFondo.Arrangement = Arrange.Horizontal

$CheckBox = New CheckBox($hFondo) As "Check"
$CheckBox.Width = 20
$CheckBox.AutoResize = True
$CheckBox.Background = &HD2DFC3

$TextLabel = New TextLabel($hFondo) As "TexLabel"
$TextLabel.Alignment = Align.Center
$TextLabel.Expand = True
$TextLabel.Background = &HFFEFBF

$Persona = New PictureBox($hFondo) As "Persona"
Hombre_Write(True)
$Persona.Width = 40
$Persona.Stretch = True
$Persona.AutoResize = True

End

Public Sub Fondo_Enter()

$hFondo.Background = &H00FFFF

End

Public Sub Fondo_Leave()

$hFondo.Background = &HFFEFBF

End


Public Sub TexLabel_Enter()

$TextLabel.Tooltip = Me.Name

End

Public Sub TexLabel_MouseUp()

$CheckBox.Value = Not $CheckBox.Value

End

Public Sub Persona_MouseUp()

$CheckBox.Value = Not $CheckBox.Value

End


Public Sub Check_Click()

$Seleccion = $CheckBox.Value
Raise Eleccion

End

Private Function Seleccion_Read() As Boolean

Return $Seleccion

End

Private Sub Seleccion_Write(Value As Boolean)

$Seleccion = Value

End

Private Function Texto_Read() As String

$Texto = $TextLabel.Text
Return $Texto

End

Private Sub Texto_Write(Value As String)

$Texto = Value
$TextLabel.Text = $Texto

End

Private Function Hombre_Read() As Boolean

Return $Hombre

End

Private Sub Hombre_Write(Value As Boolean)

$Hombre = Value

If $Hombre Then
$Persona.Picture = Picture.Load("hombre.png")
Else
$Persona.Picture = Picture.Load("mujer.png")
Endif

End


jueves, 26 de enero de 2017

Control fbcolor by postapase



Interfaz gráfica de la clase (form)



' gambas class file

'by Postapase 26 enero 2017
'http://novatocodegambas.blogspot.com.uy/
'control fbcolor (foreground, background color)

Event CambioTrazo
Event CambioFondo
Event EnterTrazo
Event EnterFondo
Event Reseteo
Event EnterReseteo


Public Sub cbtnTrazo_Change()

Raise CambioTrazo

End

Public Sub cbtnFondo_Change()

Raise CambioFondo

End

Public Sub tbtnReseteo_Click()

Raise Reseteo

End

Public Sub cbtnTrazo_Enter()

Raise EnterTrazo

End

Public Sub cbtnFondo_Enter()

Raise EnterFondo

End

Public Sub tbtnReseteo_Enter()

Raise EnterReseteo

End





Clase fbcolor

' gambas class file

'by Postapase 26 enero 2017
'http://novatocodegambas.blogspot.com.uy/
'control fbcolor (foreground y background color)

Export

Inherits UserControl

Public Const _Properties As String = "*,Trazo{Color},Fondo{Color},TrazoPredeterminado{Color},FondoPredeterminado{Color}"
Public Const _DefaultEvent As String = "Modificacion"
Public Const _DefaultSize As String = "18,4"
Public Const _Group As String = "Chooser"

Event Reseteo
Event Modificacion

Property Trazo As Integer
Property Fondo As Integer
Property TrazoPredeterminado As Integer
Property FondoPredeterminado As Integer

Private $ffbcolor As Ffbcolor
Private $Trazo As Integer
Private $Fondo As Integer
Private $TrazoPredeterminado As Integer
Private $FondoPredeterminado As Integer

Public Sub _new()

$ffbcolor = New Ffbcolor(Me) As "Ev"
Me.Proxy = $ffbcolor
Reinicio()

End

Public Sub Ev_CambioTrazo()

$Trazo = $ffbcolor.cbtnTrazo.Value
Raise Modificacion

End

Public Sub Ev_CambioFondo()

$Fondo = $ffbcolor.cbtnFondo.Value
Raise Modificacion

End

Public Sub Ev_Reseteo()

Reinicio()
Raise Reseteo

End

Public Sub Reinicio()

$Fondo = $FondoPredeterminado
$Trazo = $TrazoPredeterminado
$ffbcolor.cbtnFondo.Value = $Fondo
$ffbcolor.cbtnTrazo.Value = $Trazo

End

Public Sub Ev_EnterTrazo()

$ffbcolor.cbtnTrazo.Tooltip = "Color de Trazo (clic para cambiar)"

End

Public Sub Ev_EnterFondo()

$ffbcolor.cbtnFondo.Tooltip = "Color de Fondo (clic para cambiar)"

End

Public Sub Ev_EnterReseteo()

$ffbcolor.tbtnReseteo.Tooltip = "Poner colores predeterminados"

End

Private Function Trazo_Read() As Integer

Return $Trazo

End

Private Sub Trazo_Write(Value As Integer)

$Trazo = Value
$ffbcolor.cbtnTrazo.Value = $Trazo
Raise Modificacion

End

Private Function Fondo_Read() As Integer

Return $Fondo

End

Private Sub Fondo_Write(Value As Integer)

$Fondo = Value
$ffbcolor.cbtnFondo.Value = $Fondo
Raise Modificacion

End

Private Function TrazoPredeterminado_Read() As Integer

Return $TrazoPredeterminado

End

Private Sub TrazoPredeterminado_Write(Value As Integer)

$TrazoPredeterminado = Value
Raise Modificacion

End

Private Function FondoPredeterminado_Read() As Integer

Return $FondoPredeterminado

End

Private Sub FondoPredeterminado_Write(Value As Integer)

$FondoPredeterminado = Value
Raise Modificacion

End



Dropbox fbcolor-0.1.1.tar.gz

jueves, 19 de enero de 2017

Control FontName by postapase


Control pensado para seleccionar tipo de fuente rapidamente y comodamente, con la opción de poner fuente predeterminada con un solo clic.

parte gráfica del control (ffontname) formulario

' gambas class file

'by postapase 18 de enero 2017
'http://novatocodegambas.blogspot.com.uy/
'control FontName

Event Reset
Event Seleccion
Event Enter

Public Sub Form_Open()

End

Public Sub btnFontDefault_Click()

Raise Reset

End

Public Sub cbxNombreFuentes_Click()

Raise Seleccion

End

Public Sub btnFontDefault_Enter()

Raise Enter

End



clase fontname

' gambas class file

'by postapase 18 de enero 2017
'http://novatocodegambas.blogspot.com.uy/
'control FontName

Export

Inherits UserControl

Public Const _Properties As String = "*,Predeterminada,Seleccionada,Index"
Public Const _DefaultEvent As String = "Seleccion"
Public Const _DefaultSize As String = "32,4"
Public Const _Group As String = "Chooser"

Event Seleccion
Event Reseteo ''Selecciona la fuente predeterminada de la aplicación

Property Predeterminada As String
Property Seleccionada As String
Property Index As Integer

Private $xfontname As Ffontname
Private $Predeterminada As String
Private $Seleccionada As String
Private $Index As Integer
Private $ListaFuentes As New String[]

Public Sub _new()

$xfontname = New Ffontname(Me) As "Ev"
$Predeterminada = Application.Font.Name
$Seleccionada = $Predeterminada
Me.Proxy = $xfontname.cbxNombreFuentes
ActualizarFuentes()

End

Public Sub Ev_Reset()

Reinicio()

Raise Reseteo

End

Public Sub Ev_Seleccion()

$Seleccionada = $xfontname.cbxNombreFuentes.Current.Text
$Index = $xfontname.cbxNombreFuentes.Index

Raise Seleccion

End

Public Sub EV_Enter()

$xfontname.btnFontDefault.Tooltip = "Seleccionar fuente predeterminada [ " & $Predeterminada & " ]"

End

Public Sub ActualizarFuentes()

Dim NombreFuente As String

For Each NombreFuente In Fonts
$ListaFuentes.Add(NombreFuente)
Next

$xfontname.cbxNombreFuentes.List = $ListaFuentes
$xfontname.cbxNombreFuentes.Add($Predeterminada, 0)

End

Private Function Predeterminada_Read() As String

Return $Predeterminada

End

Private Sub Predeterminada_Write(Value As String)

$Predeterminada = Value

End

Private Function Seleccionada_Read() As String

Return $Seleccionada

End

Private Sub Seleccionada_Write(Value As String)

$Seleccionada = Value

End

Private Function Index_Read() As Integer

Return $Index

End

Private Sub Index_Write(Value As Integer)

$Index = Value
$xfontname.cbxNombreFuentes.Index = $Index

End

Public Sub Reinicio()

$xfontname.cbxNombreFuentes.Index = 0
$Index = 0

En


Saludos y espero sus opiniones.

Necesario estar registrado en  https://www.gambas-es.org/
Descargar 

Dropbox:  fontname-0.1.2.tar.gz

miércoles, 28 de diciembre de 2016

Clase txtasc



Buenas,
Resulta que en el programa taller 2015 tengo una pequeña herramienta que me ayuda a verificar los cheksum de las .iso de sistemas operativos que cada tanto hay que bajar.

Se puede usar de forma manual, es decir pegar el cheksum en un cuadro de texto, despues simplemente le damos al programa la ubicacion de la .iso y el programa hace la comprobación cuando termina veremos si esta todo bien o hubo error.

Pues bien tambien le di a esta herramienta la posiblilidad de extraer los cheksum de los archivos... ejemplo de archivo:


En ese archivo no parece complicado extraer la informacion y mostrarla en un tableview.....


pero... en el archivo siguiente el asunto se complica por su formato y por que varia el hash, indicado en una etiqueta 'hash:'

Ejemplo:


Bueno esta clase lo que hace es extraer los nombres de las distribuciones
indicado con la flecha azul de la derecha, y sus correspondientes hashes.

bueno les dejo el codigo para que experimenten.
la clase esta fresquita aun, seguramente tiene muchisimas mejoras, pero ya hace su tarea para lo cual fue creada.

Saludos.





' gambas class file

'Clase txtasc by postapase 28/12/2016

Public Const SHA1 As String = "SHA1"
Public Const SHA256 As String = "SHA256"
Public Const SHA512 As String = "SHA512"


Private Const COMIENZO As String = "-----BEGIN PGP SIGNED MESSAGE-----"
Private Const HASH As String = "Hash:"
Private Const FINAL As String = "-----BEGIN PGP SIGNATURE-----"

Property TipoHash As String
Property HashDistro As Collection

Private $TipoHash As String
Private $HashDistro As New Collection


Public Sub _new(RutaArchivo As String) ''Ingresar ruta de archivo *.txt.asc
Dim archivo As File
Dim parrafo As String
Dim tipo As String
Dim CorteTipoHash As New String[]
Dim CorteHash As New String[]
Dim Contenido As String


If Not Exist(RutaArchivo) Then
Debug Error.Text
Return
Endif

archivo = Open RutaArchivo For Read

While Not Eof(archivo)

Line Input #archivo, parrafo

If InStr(parrafo, FINAL) <> 0 Then Break

If InStr(parrafo, HASH) <> 0 Then

CorteTipoHash = Split(parrafo, " ", Null, True)

QueTipoDeHashEs(Trim(CorteTipoHash[1]))

Endif

If InStr(parrafo, COMIENZO) = 0 And If InStr(parrafo, HASH) = 0 And If Not IsNull(parrafo) Then

CorteHash = Split(parrafo, " ", Null, True)

$HashDistro.Add(Trim(CorteHash[0]), Trim(CorteHash[1]))

Endif

Wend

Close #archivo

HashDistro_Write($HashDistro)

End

Private Function TipoHash_Read() As String
Return $TipoHash
End

Private Sub TipoHash_Write(Value As String)
$TipoHash = Value
End

Private Function HashDistro_Read() As Collection
Return $HashDistro
End

Private Sub HashDistro_Write(Value As Collection)
$HashDistro = Value
End

Private Sub QueTipoDeHashEs(texto As String)

Select Case texto
Case SHA1
$TipoHash = SHA1
Case SHA256
$TipoHash = SHA256
Case SHA512
$TipoHash = SHA512
Case Else
$TipoHash = ""
End Select

TipoHash_Write($TipoHash)

End