|
9721
|
Programación / .NET (C#, VB.NET, ASP) / Re: ¿Es posible hacer este efecto visual en un WindowsForm?
|
en: 9 Febrero 2013, 04:25 am
|
Me pregunto porque aquí no banean a los trolls, piérdete un rato crio, sólo busco sugerencias de como se haría.
gracias Katze
EDITO: lo de los eventos del mouse ya lo sabía, pero seguro que con OnPaint se puede hacer eso? no afectará tambien a las letras? (Desaparecerían las letras digo?), de todas formas busco acerca de eso en Google y solo encuentro basura sobre como hacer un FadeIN/FadeOut del form, juas.
Como no encuentro info ni tampoco sé hacerlo, a mi se me ocurre una chapuza, dáme tu opinión please: Sería poner un picturebox invisible que ocupe el tamaño del control(botón), con un backcolor = white, y al pasar el mouse sobre el control, hacer un fadeIN/FadeOut del picturebox.
Sé que sería muy incorrecto... ¿pero serviría, no?
Saludos
|
|
|
9724
|
Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets !! (Posteen aquí sus snippets)
|
en: 9 Febrero 2013, 02:10 am
|
Unos snippets para monitorizar unidades... Recopilar información de las unidades conectadas en ese momento: #Region " Get Drives Info Function " ' [ Get Drives Info Function ] ' ' // By Elektro H@cker ' ' Examples : ' ' Dim CDROMS = Get_Drives_Info(DriveType.CDRom, True) ' For Each Drive_Info In Get_Drives_Info(DriveType.ALL, True, True, True, True, True, True) : MsgBox(Drive_Info) : Next Private Enum DriveType ALL CDRom = IO.DriveType.CDRom Fixed = IO.DriveType.Fixed Network = IO.DriveType.Network Ram = IO.DriveType.Ram Removable = IO.DriveType.Removable Unknown = IO.DriveType.Unknown End Enum Private Function Get_Drives_Info( _ ByVal DriveType As DriveType, _ ByVal Name As Boolean, _ Optional ByVal Label As Boolean = False, _ Optional ByVal Type As Boolean = False, _ Optional ByVal Format As Boolean = False, _ Optional ByVal Size As Boolean = False, _ Optional ByVal FreeSpace As Boolean = False) As List(Of String) Dim Drive_Info_List As New List(Of String) Dim Drive_Info As String = Nothing For Each Drive In Microsoft. VisualBasic. FileIO. FileSystem. Drives If (DriveType = DriveType. ALL Or Drive. DriveType = DriveType ) And (Drive. IsReady) Then If Drive. IsReady = True Then If Name Then Drive_Info += Drive. Name & ";" If Label Then Drive_Info += Drive. VolumeLabel & ";" If Type Then Drive_Info += Drive. DriveType. ToString & ";" If Format Then Drive_Info += Drive. DriveFormat & ";" If Size Then Drive_Info += Drive. TotalSize. ToString & ";" If FreeSpace Then Drive_Info += Drive. TotalFreeSpace & ";" End If End If If Drive_Info IsNot Nothing Then Drive_Info_List.Add(Drive_Info) : Drive_Info = Nothing Next Return Drive_Info_List End Function #End Region
Monitorizar la inserción/extracción de dispositivos (y obtener información adicional) by Keyen Night#Region " Monitorize Drives " ' Diccionario para guardar información (letra, información) Public CurrentDrives As New Dictionary(Of Char, DriveInfoGhost ) Public Event DriveConnected(ByVal e As IO.DriveInfo) Public Event DriveDisconnected(ByVal e As DriveInfoGhost) ' Estructura que replica el contenido de DriveInfo Public Structure DriveInfoGhost Public Name As String Public AvailableFreeSpace As Long Public DriveFormat As String Public DriveType As IO.DriveType Public RootDirectory As String Public TotalFreeSpace As Long Public TotalSize As Long Public VolumeLabel As String Public Sub New(ByVal e As IO.DriveInfo) Name = e.Name AvailableFreeSpace = e.AvailableFreeSpace DriveFormat = e.DriveFormat DriveType = e.DriveType RootDirectory = e.RootDirectory.FullName TotalFreeSpace = e.TotalFreeSpace TotalSize = e.TotalSize VolumeLabel = e.VolumeLabel End Sub End Structure ' Estructura nativa de Windows para almacenar información de dispositivos Public Structure WindowsDrive Public Size As Integer Public Type As Integer Public Reserved As Integer Public Mask As Integer End Structure ' Constantes que necesitamos Public Enum ConstWindowsDrivers As Integer Change = &H219 Arrival = &H8000 QueryRemove = &H8001 QueryRemoveFailed = &H8002 RemovePending = &H8003 RemoveComplete = &H8004 TypeVolume = &H2 End Enum Protected Overrides Sub WndProc(ByRef [Message] As Message) Select Case [Message].Msg ' Filtramos los mensajes Case ConstWindowsDrivers.Change ' Si el Hardware cambió ' Transformamos el puntero del primer parametro en una estructura de datos Dim CurrentWDrive As WindowsDrive = CType(System.Runtime.InteropServices.Marshal.PtrToStructure([Message].LParam, GetType(WindowsDrive)), WindowsDrive) ' Transformamos la estructura en información de la unidad Dim CurrentDrive As IO.DriveInfo = New IO.DriveInfo(GetDriveLetter(CurrentWDrive.Mask)) ' El segundo parametros nos indica si se esta desconectando o conectando Select Case [Message].WParam.ToInt32 ' Se esta conectando... Case ConstWindowsDrivers.Arrival ' Si es un dispositivo de almacenamiento If System.Runtime.InteropServices.Marshal.ReadInt32([Message].LParam, 4) = ConstWindowsDrivers.TypeVolume Then ' Llamamos un evento que controla la conexión RaiseEvent DriveConnected(CurrentDrive) ' Guardamos la información del dispositivo en un diccionario fantasma (letra, información), ' ya que cuando se desconecte habremos perdido toda la información, ' sólamente nos quedara la letra de la unidad, con ella podremos volver a obtener la información a traves del diccionario' CurrentDrives.Add(GetDriveLetter(CurrentWDrive.Mask), New DriveInfoGhost(CurrentDrive)) End If ' Si es desconectado... Case ConstWindowsDrivers.RemoveComplete ' Llamamos al evento de desconexión con la información en el diccionario fantasma, ' ya que no tenemos acceso a la información, porque el hardware ha sido desconectado RaiseEvent DriveDisconnected(CurrentDrives(GetDriveLetter(CurrentWDrive.Mask))) ' Removemos el hardware del diccionario CurrentDrives.Remove(GetDriveLetter(CurrentWDrive.Mask)) End Select End Select MyBase.WndProc([Message]) End Sub ' Nos traduce el código de los parametros a letras Private Function GetDriveLetter(ByVal Mask As Integer) As Char Dim Names() As Char = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"} Dim Devices As New BitArray(System.BitConverter.GetBytes(Mask)) For x As Integer = 0 To Devices.Length If Devices(x) Then Return Names(x) End If Next End Function ' Eventos Private Sub Main_DriveConnected(ByVal e As System.IO.DriveInfo) Handles Me.DriveConnected MessageBox.Show(String.Format("Se ha conectado la unidad {0}", e.Name)) End Sub Private Sub Main_DriveDisconnected(ByVal e As DriveInfoGhost) Handles Me.DriveDisconnected MessageBox.Show(String.Format("Se ha desconectado la unidad {0}", e.Name)) End Sub #End Region
Monitorizar la inserción/extracción de dispositivos (y obtener información adicional) by Kub0xPD: Añadir un listbox al Form para ver/entender como actua el code. Imports System.IO Imports System.Threading Public Class Inicio Private Delegate Sub ListenToUSB() Private Delegate Sub UpdateListBoxText(ByVal Text As String) Private Delegate Sub MonitorizeUSB (ByVal Drive As DriveInfo ) Private Sub ListenToRemovableDrives() 'Mejor crear 1 sola variable que ochocientas mil e ir actualizándola periodicamente Dim connectedDrives As DriveInfo() = Nothing While True connectedDrives = DriveInfo.GetDrives() For Each drive As DriveInfo In connectedDrives Next 'Aquí indica el tiempo que quieres que espere el proceso de escucha para después volver a comenzar Thread.Sleep(2500) End While End Sub Private Sub IsRemovableDrive (ByVal Drive As DriveInfo ) If Drive. IsReady And Drive. DriveType = DriveType. Removable Then IsDriveMonitorized (Drive) End If End Sub Private Function GetDrivePosInArray (ByVal Drive As DriveInfo ) As Int32 Dim isInList As Boolean = False Dim i As Int32 = 0 Do If Not IsNothing (CType(Drives(i ), Object)) Then isInList = True End If End If i += 1 Loop Until isInList Or i > = Drives. Length - 1 Return i - 1 End Function Private Function IsDriveInList (ByVal Drive As DriveInfo ) As Boolean Dim isInList As Boolean = False Dim i As Int32 = 0 Do If Not IsNothing (CType(Drives(i ), Object)) Then isInList = True End If End If i += 1 Loop Until isInList Or i > = Drives. Length - 1 Return isInList End Function Private Sub IsDriveMonitorized (ByVal Drive As DriveInfo ) If Not IsDriveInList (Drive) Then 'Como la unidad USB no está siendo monitorizada por otro subproceso 'Añadimos sus características al ListBox ListBox1.BeginInvoke(New UpdateListBoxText(AddressOf UpdateLstBoxText), _ New Object() {"Se ha conectado una nueva Memoria USB en " & Drive. Name}) 'Monitorizamos la unidad USB Dim delegado As New MonitorizeUSB(AddressOf MonitorizeDrive) delegado. BeginInvoke(Drive, Nothing, Nothing) End If End Sub Private Sub MonitorizeDrive (ByVal Drive As DriveInfo ) Dim Removed As Boolean = False While Not Removed If Not Drive. IsReady Then Removed = True Dim pos As Int32 = GetDrivePosInArray (Drive) ReOrganizeArray(pos) ListBox1.BeginInvoke(New UpdateListBoxText(AddressOf UpdateLstBoxText), _ New Object() {"La unidad USB " & Drive. Name & " fue extraída."}) End If End While End Sub Private Sub ReOrganizeArray(ByVal pos As Int32) 'Eliminamos el elemento rotando el Array hacia la izquierda End Sub Private Sub UpdateLstBoxText(ByVal Text As String) ListBox1.Items.Add(Text) End Sub Private Sub Inicio_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim delegado As New ListenToUSB(AddressOf ListenToRemovableDrives) delegado.BeginInvoke(Nothing, Nothing) End Sub End Class
|
|
|
9727
|
Programación / Scripting / Re: ¿Cual es el lenguaje scripting mas rapido?
|
en: 8 Febrero 2013, 04:01 am
|
Los lenguajes de scripting no son compilados, son interpretados, y a Pascal podías ir quitándolo de la lista  ¿No es scripting?  No, no lo es. Si te interesa el tema, aquí tienes una buena lista de lenguajes de scripting: http://en.wikipedia.org/wiki/Category:Scripting_languages¿Phyton se desempaqueta mas lento o igual que ruby? Eso no se puede saber con exactitud, depende de la relación entre el tipo de compresión que se use en el "compilador" (compresión mínima/media/máxima), de la cantidad de archivos que contenga (si son 1.000 archivos de 1 kb de tamaño cada uno, tardará bastante más en descomprimir que 1 sólo archivo del mismo tamaño), y del tamaño final del exe. y quizás algún dato más que me dejo. saludos
|
|
|
9728
|
Programación / .NET (C#, VB.NET, ASP) / Re: Comi hacer "temblar" el raton
|
en: 8 Febrero 2013, 03:44 am
|
¿es que no tienes nada mejor que hacer que andar metiendote siempre con el moderador, conmigo, y con el usuario de este post?, 3x1, vas progresando en aptitudes. el señor q "mami damelo todo resuelto"... aconseja investigar en google Y por cierto, hay una GRAN diferencia entre pedir información, y pedir las cosas echas, no sé si es que no te lo han enseñado en el colegio o sólo es que te gusta molestar, cuando quieras te repasas mis palabras del post del USB que tanto me criticas, o cualquier otro post. Bueno, a ver si nos dejas en paz de una vez a todos, porque nadie te ha dicho nada y tú ya vienes a trollear, Saludos.
|
|
|
9730
|
Programación / Scripting / Re: [AYUDA][VBS] Duda sobre la copia y renombrado automatico de archivos
|
en: 7 Febrero 2013, 23:15 pm
|
1. ¿Es totálmente necesario que séa en VBS? 2. Como sugerencia, si lo que siempre vas a querer copiar es el directorio raíz del dispositivo USB, entonces yo me ahorraría la parte de abrir un user-prompt para preguntar por el directorio, en lugar de eso, le pondría una etiqueta (label) al dispositivo y usaria el script para que reconociese el dispositivo que quieres copiar automáticamente leyendo el label de dicha unidad, obviamente el label que le deberías dar al USB debería de ser el mismo que va a usar tu script. Pseudocode rápido:(dim) declarar "variable label" = "test" (dim) declarar "variable directorio" = "C:\carpeta\"
(for) por cada "unidad" en "unidades conectadas" (if) si "unidad" es "usb" (and) y el label de "unidad" es igual a "variable label": copiar el directorio raíz de "unidad" a "variable directorio" (else) de lo contrario: (next) siguiente "unidad" Saludos.
|
|
|
|
|
|
|