elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 ... 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [24] 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 ... 58 Ir Abajo Respuesta Imprimir
Autor Tema: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)  (Leído 480,165 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #230 en: 1 Julio 2013, 04:34 am »

Un AppActivate más sencillo de usar que el default, se puede usar especificando el nombre del proceso.

PD: Sirve para activar (darle Focus) a un proceso externo.

Código
  1.    #Region " App Activate "
  2.  
  3.    ' [ App Activate ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    '
  9.    ' App_Activate("cmd")
  10.    ' App_Activate("cmd.exe")
  11.    ' If App_Activate("cmd") Then...
  12.  
  13.    Private Function App_Activate(ByVal ProcessName As String) As Boolean
  14.        If ProcessName.ToLower.EndsWith(".exe") Then ProcessName = ProcessName.Substring(0, ProcessName.Length - 4)
  15.        Dim ProcessArray = Process.GetProcessesByName(ProcessName)
  16.        If ProcessArray.Length = 0 Then
  17.            Return False
  18.        Else
  19.            AppActivate(ProcessArray(0).Id)
  20.            Return True
  21.            End If
  22.    End Function
  23.  
  24.    #End Region


En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #231 en: 1 Julio 2013, 09:01 am »

Una Class para controlar WinAmp: http://pastebin.com/4yC91AnD
También está disponible compilada en un dll: http://sourceforge.net/projects/wacc/

PD: Funciona en las versiones 5.X

Ejemplos de uso (Aparte de los oficiales):

Código
  1. #Region " Examples "
  2.  
  3. ' // By Elektro H@cker
  4. '
  5. ' INSTRUCTIONS:
  6. '
  7. ' 1. Add a reference for "WACC.DLL"
  8.  
  9. Public Class Form1
  10.  
  11.    Dim Winamp As WACC.clsWACC = New WACC.clsWACC
  12.  
  13.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  14.  
  15.        ' // Bind the WinAmp process to the variable object
  16.        Winamp.Bind()
  17.  
  18.        ' // Get WinAmp process PID
  19.        ' Winamp.ProcessID()
  20.  
  21.        ' // Close WinAmp
  22.        ' Winamp.CloseWinamp()
  23.  
  24.        ' // Restart WinAmp
  25.        ' Winamp.RestartWinamp()
  26.  
  27.        ' // Open new instance of WinAmp
  28.        ' Winamp.OpenNewInstance()
  29.  
  30.        ' // Play playback
  31.        ' Winamp.Playback.Play()
  32.  
  33.        ' // Pause playback
  34.        ' Winamp.Playback.PauseUnpause()
  35.  
  36.        ' // Stop playback
  37.        ' Winamp.Playback.Stop()
  38.  
  39.        ' // Junp to previous track
  40.        ' Winamp.Playlist.JumpToPreviousTrack()
  41.  
  42.        ' // Junp to next track
  43.        ' Winamp.Playlist.JumpToNextTrack()
  44.  
  45.        ' // Rewind 5 seconds of the current song
  46.        ' Winamp.Playback.Rewind5s()
  47.  
  48.        ' // Forward 5 seconds of the current song
  49.        ' Winamp.Playback.Forward5s()
  50.  
  51.        ' // Get Track Length
  52.        ' Winamp.Playback.GetTrackLength * 1000 '(ms)
  53.  
  54.        ' // Set Track Position
  55.        ' Winamp.Playback.TrackPosition = 60000 ' (ms)
  56.  
  57.        ' // Get WinAmp state
  58.        ' MsgBox(Winamp.Playback.PlaybackState().ToString)
  59.        ' If Winamp.Playback.PlaybackState = clsWACC.cPlayback.Playback_State.Playing Then : End If
  60.  
  61.        ' // Set volume
  62.        ' Winamp.AudioControls.Volume = Math.Round(50 / (100 / 255))
  63.  
  64.        ' // Volume up
  65.        ' Winamp.AudioControls.VolumeUp()
  66.  
  67.        ' // Volume down
  68.        ' Winamp.AudioControls.VolumeDown()
  69.  
  70.        ' // Get current track BitRate
  71.        ' MsgBox(Winamp.Playback.Bitrate.ToString & " kbps")
  72.  
  73.        ' // Get current track SampleRate
  74.        ' MsgBox(Winamp.Playback.SampleRate.ToString & " kHz")
  75.  
  76.        ' // Get current track channels
  77.        ' MsgBox(Winamp.Playback.Channels.ToString & " channels")
  78.  
  79.        ' // Clear playlist
  80.        ' Winamp.Playlist.Clear()
  81.  
  82.        ' // Remove missing files in playlist
  83.        ' Winamp.Playlist.RemoveMissingFiles()
  84.  
  85.        ' // Enable/Disable Shuffle
  86.        ' Winamp.Playback.ShuffleEnabled = True
  87.  
  88.        ' // Enable/Disable Repeat
  89.        ' Winamp.Playback.RepeatEnabled = True
  90.  
  91.        ' // Set WinAmp OnTop
  92.        ' Winamp.Options.AlwaysOnTop = True
  93.  
  94.    End Sub
  95.  
  96. End Class
  97.  
  98. #End Region


« Última modificación: 1 Julio 2013, 09:06 am por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #232 en: 2 Julio 2013, 07:27 am »

He extendido y mejorado la función para buscar texto en la colección de Items de un listview:

PD: la versión antigua la pueden encontrar aquí: http://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1865639#msg1865639

#Region " [ListView] Find ListView Text "

    ' [ListView] Find ListView Text Function
    '
    ' // By Elektro H@cker
    '
    ' Examples :
    ' MsgBox(Find_ListView_Text(ListView1, "Test"))
    ' MsgBox(Find_ListView_Text(ListView1, "Test", 2, True, True))
    ' If Find_ListView_Text(ListView1, "Test") Then...

    Private Function Find_ListView_Text(ByVal ListView As ListView, _
                                        ByVal SearchString As String, _
                                        Optional ByVal ColumnIndex As Int32 = Nothing, _
                                        Optional ByVal MatchFullText As Boolean = True, _
                                        Optional ByVal IgnoreCase As Boolean = True) As Boolean

        Dim ListViewColumnIndex As Int32 = ListView.Columns.Count - 1

        Select Case ColumnIndex

            Case Is < 0, Is > ListViewColumnIndex ' ColumnIndex is out of range

                Throw New Exception("ColumnIndex is out of range. " & vbNewLine & _
                                    "ColumnIndex Argument: " & ColumnIndex & vbNewLine & _
                                    "ColumnIndex ListView: " & ListViewColumnIndex)

            Case Nothing ' ColumnIndex is nothing

                If MatchFullText AndAlso IgnoreCase Then ' Match full text, All columns, IgnoreCase
                    For Each Item As ListViewItem In ListView.Items
                        For X As Int32 = 0 To ListViewColumnIndex
                            If Item.SubItems(X).Text.ToLower = SearchString.ToLower Then Return True
                        Next
                    Next
                ElseIf MatchFullText AndAlso Not IgnoreCase Then ' Match full text, All columns, CaseSensitive
                    For Each Item As ListViewItem In ListView.Items
                        For X As Int32 = 0 To ListViewColumnIndex
                            If Item.SubItems(X).Text = SearchString Then Return True
                        Next
                    Next
                ElseIf Not MatchFullText AndAlso IgnoreCase Then ' Match part of text, All columns, IgnoreCase
                    If ListView1.FindItemWithText(SearchString) IsNot Nothing Then _
                         Return True _
                    Else Return False
                ElseIf Not MatchFullText AndAlso Not IgnoreCase Then ' Match part of text, All columns, CaseSensitive
                    For Each Item As ListViewItem In ListView.Items
                        For X As Int32 = 0 To ListViewColumnIndex
                            If Item.SubItems(X).Text.Contains(SearchString) Then Return True
                        Next
                    Next
                End If

            Case Else ' ColumnIndex is other else

                If MatchFullText AndAlso IgnoreCase Then ' Match full text, ColumnIndex, IgnoreCase
                    For Each Item As ListViewItem In ListView.Items
                        If Item.SubItems(ColumnIndex).Text.ToLower = SearchString.ToLower Then Return True
                    Next
                ElseIf MatchFullText AndAlso Not IgnoreCase Then  ' Match full text, ColumnIndex, CaseSensitive
                    For Each Item As ListViewItem In ListView.Items
                        If Item.SubItems(ColumnIndex).Text = SearchString Then Return True
                    Next
                ElseIf Not MatchFullText AndAlso IgnoreCase Then ' Match part of text, ColumnIndex, IgnoreCase
                    For Each Item As ListViewItem In ListView.Items
                        If Item.SubItems(ColumnIndex).Text.ToLower.Contains(SearchString.ToLower) Then Return True
                    Next
                ElseIf Not MatchFullText AndAlso Not IgnoreCase Then ' Match part of text, ColumnIndex, CaseSensitive
                    For Each Item As ListViewItem In ListView.Items
                        If Item.SubItems(ColumnIndex).Text.Contains(SearchString) Then Return True
                    Next
                End If

        End Select

        Return False

    End Function

#End Region



EDITO:

Vuelto a mejorar:

(El anterior no medía la cantidad de subitems de cada item, por ejemplo en un listview con 3 columnas, un item con dos subitems y otro item con 3 subitems entonces daba error porque el primer item no tenia un tercer subitem)

Código
  1. #Region " [ListView] Find ListView Text "
  2.  
  3.    ' [ListView] Find ListView Text Function
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Find_ListView_Text(ListView1, "Test"))
  9.    ' MsgBox(Find_ListView_Text(ListView1, "Test", 2, True, True))
  10.    ' If Find_ListView_Text(ListView1, "Test") Then...
  11.  
  12.    Private Function Find_ListView_Text(ByVal ListView As ListView, _
  13.                                        ByVal SearchString As String, _
  14.                                        Optional ByVal ColumnIndex As Int32 = Nothing, _
  15.                                        Optional ByVal MatchFullText As Boolean = True, _
  16.                                        Optional ByVal IgnoreCase As Boolean = True) As Boolean
  17.  
  18.        Select Case ColumnIndex
  19.  
  20.            Case Is < 0, Is > ListView.Columns.Count - 1 ' ColumnIndex is out of range
  21.  
  22.                Throw New Exception("ColumnIndex is out of range. " & vbNewLine & _
  23.                                    "ColumnIndex Argument: " & ColumnIndex & vbNewLine & _
  24.                                    "ColumnIndex ListView: " & ListView.Columns.Count - 1)
  25.  
  26.            Case Nothing ' ColumnIndex is nothing
  27.  
  28.                If MatchFullText Then ' Match full text in all columns
  29.  
  30.                    For Each Item As ListViewItem In ListView.Items
  31.                        For X As Int32 = 0 To Item.SubItems.Count - 1
  32.                            If String.Compare(Item.SubItems(X).Text, SearchString, IgnoreCase) = 0 Then
  33.                                Return True
  34.                            End If
  35.                        Next
  36.                    Next
  37.  
  38.                ElseIf Not MatchFullText Then ' Match part of text in all columns
  39.  
  40.                    Select Case IgnoreCase
  41.                        Case True ' IgnoreCase
  42.                            If ListView1.FindItemWithText(SearchString) IsNot Nothing Then
  43.                                Return True
  44.                            End If
  45.                        Case False ' CaseSensitive
  46.                            For Each Item As ListViewItem In ListView.Items
  47.                                For X As Int32 = 0 To Item.SubItems.Count - 1
  48.                                    If Item.SubItems(X).Text.Contains(SearchString) Then Return True
  49.                                Next
  50.                            Next
  51.                    End Select
  52.  
  53.                End If
  54.  
  55.            Case Else ' ColumnIndex is other else
  56.  
  57.                If MatchFullText Then ' Match full text in ColumnIndex
  58.  
  59.                    For Each Item As ListViewItem In ListView.Items
  60.                        If String.Compare(Item.SubItems(ColumnIndex).Text, SearchString, IgnoreCase) = 0 Then
  61.                            Return True
  62.                        End If
  63.                    Next
  64.  
  65.                ElseIf Not MatchFullText Then ' Match part of text in ColumnIndex
  66.  
  67.                    For Each Item As ListViewItem In ListView.Items
  68.                        Select Case IgnoreCase
  69.                            Case True ' IgnoreCase
  70.                                If Item.SubItems(ColumnIndex).Text.ToLower.Contains(SearchString.ToLower) Then
  71.                                    Return True
  72.                                End If
  73.                            Case False ' CaseSensitive
  74.                                If Item.SubItems(ColumnIndex).Text.Contains(SearchString) Then
  75.                                    Return True
  76.                                End If
  77.                        End Select
  78.                    Next
  79.  
  80.                End If
  81.  
  82.        End Select
  83.  
  84.        Return False ' Any matches
  85.  
  86.    End Function
  87.  
  88. #End Region
« Última modificación: 2 Julio 2013, 08:40 am por EleKtro H@cker » En línea

z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #233 en: 3 Julio 2013, 10:42 am »

Ya he actualizado el Updater :)

http://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1864041#msg1864041

Ahora si va. ;D
En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #234 en: 3 Julio 2013, 14:31 pm »

Ahora si va. ;D

No quiero desvirtuar mucho el tema, pero por curiosidad cual era el fallo?
En línea

z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #235 en: 3 Julio 2013, 14:51 pm »

No quiero desvirtuar mucho el tema, pero por curiosidad cual era el fallo?

Que el archivo no se descargaba, no lo hablamos ayer? xD
En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #236 en: 3 Julio 2013, 15:54 pm »

Que el archivo no se descargaba, no lo hablamos ayer? xD

claro, quiero decir que ¿Como lo arreglaste? que correcciones habia que hacerle? xD
En línea

z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #237 en: 3 Julio 2013, 17:19 pm »

Pues llevababas tu razón con los Ifs... A parte:

Código
  1. If File.Exists(patha) Then
  2.            File.Delete(patha)
  3.        End If

Esto si lo pongo al final, lo va a borrar y no va a leer nada. Si lo ponemos al principio, lo borra y lo vuelve a descargar. :P
En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #238 en: 3 Julio 2013, 17:38 pm »

Format Time

Formatea un número de milisegundos.

Código
  1. #Region " Format Time "
  2.  
  3.    ' [ Format Time Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Format_Time(61500, TimeFormat.M_S_MS)) ' Result: "01:01:500"
  9.    ' MsgBox(Format_Time(65000, TimeFormat.M_S))    ' Result: "01:05"
  10.  
  11.    ' TimeFormat [ENUM]
  12.    Public Enum TimeFormat
  13.        D_H_M_S_MS
  14.        D_H_M_S
  15.        D_H_M
  16.        D_H
  17.        D
  18.  
  19.        H_M_S_MS
  20.        H_M_S
  21.        H_M
  22.        H
  23.  
  24.        M_S_MS
  25.        M_S
  26.        M
  27.  
  28.        S_MS
  29.        S
  30.    End Enum
  31.  
  32.    ' Format Time [FUNC]
  33.    Private Function Format_Time(ByVal MilliSeconds As Int64, ByVal TimeFormat As TimeFormat) As String
  34.  
  35.        Dim Time As New TimeSpan(TimeSpan.TicksPerMillisecond * MilliSeconds)
  36.  
  37.        Select Case TimeFormat
  38.  
  39.            Case TimeFormat.D_H_M_S_MS
  40.                Return Time.ToString("dd\:hh\:mm\:ss\:fff")
  41.            Case TimeFormat.D_H_M_S
  42.                Return Time.ToString("dd\:hh\:mm\:ss")
  43.            Case TimeFormat.D_H_M
  44.                Return Time.ToString("dd\:hh\:mm")
  45.            Case TimeFormat.D_H
  46.                Return Time.ToString("dd\:hh")
  47.            Case TimeFormat.D
  48.                Return Time.ToString("dd")
  49.            Case TimeFormat.H_M_S_MS
  50.                Return Time.ToString("hh\:mm\:ss\:fff")
  51.            Case TimeFormat.H_M_S
  52.                Return Time.ToString("hh\:mm\:ss")
  53.            Case TimeFormat.H_M
  54.                Return Time.ToString("hh\:mm")
  55.            Case TimeFormat.H
  56.                Return Time.ToString("hh")
  57.            Case TimeFormat.M_S_MS
  58.                Return Time.ToString("mm\:ss\:fff")
  59.            Case TimeFormat.M_S
  60.                Return Time.ToString("mm\:ss")
  61.            Case TimeFormat.M
  62.                Return Time.ToString("mm")
  63.            Case TimeFormat.S_MS
  64.                Return Time.ToString("ss\:fff")
  65.            Case TimeFormat.S
  66.                Return Time.ToString("ss")
  67.            Case Else
  68.                Return Nothing
  69.        End Select
  70.  
  71.    End Function
  72.  
  73. #End Region





Cuando creo un listview suelo añadir un índice numérico en la primera columna, para mantener un orden, bueno pues este snippet sirve para reindexar esa columna por ejemplo cuando eliminamos un item del listview.



Código
  1. #Region " ReIndex ListView "
  2.  
  3.    ' [ ReIndex ListView ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' ReIndex_ListView(ListView1)
  9.  
  10.    ' ReIndex ListView [SUB]
  11.    Private Sub ReIndex_ListView(ByVal ListView As ListView, Optional ByVal Column As Int32 = 0)
  12.        Dim Index As Int32 = 0
  13.        For Each Item As ListViewItem In ListView.Items
  14.            Index += 1
  15.            Item.SubItems(Column).Text = Index
  16.        Next
  17.    End Sub
  18.  
  19. #End Region
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #239 en: 3 Julio 2013, 17:56 pm »

Actualizada la colección de snippets con un total de 400 Snippets...
...Casi nada!!

-> http://elektrostudios.tk/Snippets.zip

En la primera página de este hilo tienen un índice de todos los snippets que contiene el pack.

Saludos!
En línea

Páginas: 1 ... 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [24] 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 ... 58 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines