Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - Eleкtro

#9231
Ya está solucionado...

Cambiar:
RemainingTime = Now().Subtract(EndTime)

Por:
RemainingTime = EndTime.Subtract(Now)

Saludos.
#9232
Lo del tiempo transcurrido lo tengo manejado ya, pero para mostrar el tiempo restante me estoy haciendo un lío...

Código (vbnet) [Seleccionar]
   Dim time_out as integer = 60000 ' 'Milisegundos

   Dim StartTime As DateTime ' Tiempo inicio
   Dim EndTime As DateTime ' Tiempo final

   Dim ElapsedTime As TimeSpan ' Tiempo transcurrido
   Dim RemainingTime As TimeSpan ' Tiempo restante


He conseguido mostrar el tiempo restante pero de una manera extraña, el problema es que, aparte de que los valores se muestran negativos, el valor de la hora y el minutero deberían ser "00"... ya que sólo estoy intentando medir el tiempo restante de una operación de "10000" MS (10 segs)

Output:


Este es el code que uso, ¿Como lo arreglo?
Código (vbnet) [Seleccionar]
#Region " Elapsed Time Function "

   Public Function Print_Elapsed_Time()
       If StartTime.ToString = "01/01/0001 0:00:00" Then
           StartTime = Now
           StartTime = StartTime.AddSeconds(-1)
       End If
       ElapsedTime = Now().Subtract(StartTime)
       Return String.Format("{0:00}:{1:00}:{2:00}", CInt(Math.Floor(ElapsedTime.TotalHours)) Mod 60, CInt(Math.Floor(ElapsedTime.TotalMinutes)) Mod 60, CInt(Math.Floor(ElapsedTime.TotalSeconds)) Mod 60)
   End Function
#End Region

#Region " Remaining Time Function "

   Public Function Print_Remaining_Time()
       If EndTime.ToString = "01/01/0001 0:00:00" Then
           EndTime = Now
           EndTime = EndTime.AddMilliseconds(Time_Out - 1000)
       End If
       RemainingTime = Now().Subtract(EndTime)
       Return String.Format("{0:00}:{1:00}:{2:00}", CInt(Math.Floor(RemainingTime.TotalHours)) Mod 60, CInt(Math.Floor(RemainingTime.TotalMinutes)) Mod 60, CInt(Math.Floor(RemainingTime.TotalSeconds)) Mod 60)
   End Function

#End Region
#9233
Ya lo he arreglado, lo que pasa es que tenia unas carpetas con el mismo nombre de proyecto en el directorio Roaming, pero el VS debería preveer estas cosas...

Saludos!
#9234
Software / Re: Configuracion de Google Chrome
18 Marzo 2013, 14:12 PM
Cita de: OmarHack en 18 Marzo 2013, 13:17 PM
http://lmgtfy.com/?q=exportar+configuraci%C3%B3n+chrome#

xD




"...\AppData\Local\Google\Chrome\User Data"

Si no quieres complicarte, también puedes usar aplicaciones para hacer backups de Chrome, como esta: http://google-chrome-backup.en.softonic.com/

Saludos.
#9235
Tengo un problema con el namespace My.Settings cuando intento modificar un valor y guardar las settings (Me sucede con cualquier propiedad...):

Código (vbnet) [Seleccionar]
   Private Sub Button1_Click(Sender As Object, e As MouseEventArgs) Handles Button1.Click
       My.Settings.Remember_Settings = True
       My.Settings.Save()
   End Sub


Me salta este error:



Esta es la excepción:
System.Configuration.ConfigurationErrorsException was unhandled
 BareMessage=Configuration system failed to initialize
 HResult=-2146232062
 Line=0
 Message=Configuration system failed to initialize
 Source=System.Configuration
 StackTrace:
      at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e)
      at System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(String configPath, BaseConfigurationRecord configRecord)
      at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
      at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
      at System.Configuration.ConfigurationManager.GetSection(String sectionName)
      at System.Configuration.ClientSettingsStore.ReadSettings(String sectionName, Boolean isUserScoped)
      at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties)
      at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)
      at System.Configuration.SettingsBase.SetPropertyValueByName(String propertyName, Object propertyValue)
      at System.Configuration.SettingsBase.set_Item(String propertyName, Object value)
      at System.Configuration.ApplicationSettingsBase.set_Item(String propertyName, Object value)
      at Volium.My.MySettings.set_Remember_Settings(Boolean value) in C:\Projects\Volium\Volium\My Project\Settings.Designer.vb:line 137
      at Volium.Form1.CheckBox_Remember_Settings_CheckedChanged(Object sender, EventArgs e) in C:\Projects\Volium\Volium\Form1.vb:line 96
      at System.Windows.Forms.CheckBox.set_CheckState(CheckState value)
      at System.Windows.Forms.CheckBox.OnClick(EventArgs e)
      at System.Windows.Forms.CheckBox.OnMouseUp(MouseEventArgs mevent)
      at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
      at System.Windows.Forms.Control.WndProc(Message& m)
      at System.Windows.Forms.ButtonBase.WndProc(Message& m)
      at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
      at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
      at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
      at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
      at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
      at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
      at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
      at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
      at Volium.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
      at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
      at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      at System.Threading.ThreadHelper.ThreadStart()
 InnerException: System.Configuration.ConfigurationErrorsException
      BareMessage=Unrecognized configuration section userSettings/WindowsApplication1.My.MySettings.
      Filename=C:\Users\Administrador\AppData\Local\Microsoft\Volium.vshost.exe_Url_irr03xswjdrhsokru05hku4eejmnb511\1.0.0.0\user.config
      HResult=-2146232062
      Line=4
      Message=Unrecognized configuration section userSettings/WindowsApplication1.My.MySettings. (C:\Users\Administrador\AppData\Local\Microsoft\Volium.vshost.exe_Url_irr03xswjdrhsokru05hku4eejmnb511\1.0.0.0\user.config line 4)
      Source=System.Configuration
      StackTrace:
           at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
           at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
           at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e)
      InnerException:
#9236
· String a hexadecimal:

Código (vbnet) [Seleccionar]
#Region " String To Hex Function "

    ' [ String To Hex Function ]
    '
    ' Examples :
    ' Dim Hex_str As String = String_To_Hex("Elektro H@cker")

    Private Function String_To_Hex(ByVal Source_String As String) As String
        Dim Hex_StringBuilder As New System.Text.StringBuilder()
        For Each c As Char In Source_String : Hex_StringBuilder.Append(Asc(c).ToString("x2")) : Next c
        Return Hex_StringBuilder.ToString()
    End Function

#End Region





· Hexadecimal a string:

Código (vbnet) [Seleccionar]
#Region " Hex To String Function "

    ' [ Hex To String Function ]
    '
    ' Examples :
    ' Dim str As String = Hex_To_String("456c656b74726f204840636b6572"))

    Private Function Hex_To_String(ByVal Source_String As String) As String
        Dim Hex_StringBuilder As New System.Text.StringBuilder()
        For x As Integer = 0 To Source_String.Length - 1 Step 2 : Hex_StringBuilder.Append(Chr(Val("&H" & Source_String.Substring(x, 2)))) : Next x
        Return Hex_StringBuilder.ToString()
    End Function

#End Region





· Effecto Matrix (Aplicación de consola)

Código (vbnet) [Seleccionar]
    Module Module1
        Sub Main()
            Console.Title = "Matrix Effect"
            Console.ForegroundColor = ConsoleColor.DarkGreen
            Console.WindowLeft = InlineAssignHelper(0, 0)
            Console.WindowHeight = InlineAssignHelper(Console.BufferHeight, Console.LargestWindowHeight)
            Console.WindowWidth = InlineAssignHelper(Console.BufferWidth, Console.LargestWindowWidth)
     
            Console.CursorVisible = False
            Dim width As Integer, height As Integer
            Dim y As Integer()
            Dim l As Integer()
            Initialize(width, height, y, l)
            Dim ms As Integer
            While True
                Dim t1 As DateTime = DateTime.Now
                MatrixStep(width, height, y, l)
                ms = 10 - CInt(Math.Truncate(CType(DateTime.Now - t1, TimeSpan).TotalMilliseconds))
                If ms > 0 Then
                    System.Threading.Thread.Sleep(ms)
                End If
                If Console.KeyAvailable Then
                    If Console.ReadKey().Key = ConsoleKey.F5 Then
                        Initialize(width, height, y, l)
                    End If
                End If
            End While
        End Sub
     
        Dim thistime As Boolean = False
     
        Private Sub MatrixStep(ByVal width As Integer, ByVal height As Integer, ByVal y As Integer(), ByVal l As Integer())
            Dim x As Integer
            thistime = Not thistime
            For x = 0 To width - 1
                If x Mod 11 = 10 Then
                    If Not thistime Then
                        Continue For
                    End If
                    Console.ForegroundColor = ConsoleColor.White
                Else
                    Console.ForegroundColor = ConsoleColor.DarkGreen
                    Console.SetCursorPosition(x, inBoxY(y(x) - 2 - ((l(x) \ 40) * 2), height))
                    Console.Write(R)
                    Console.ForegroundColor = ConsoleColor.Green
                End If
                Console.SetCursorPosition(x, y(x))
                Console.Write(R)
                y(x) = inBoxY(y(x) + 1, height)
                Console.SetCursorPosition(x, inBoxY(y(x) - l(x), height))
                Console.Write(" "c)
            Next
        End Sub
     
        Private Sub Initialize(ByRef width As Integer, ByRef height As Integer, ByRef y As Integer(), ByRef l As Integer())
            Dim h1 As Integer
            Dim h2 As Integer = (InlineAssignHelper(h1, (InlineAssignHelper(height, Console.WindowHeight)) \ 2)) \ 2
            width = Console.WindowWidth - 1
            y = New Integer(width - 1) {}
            l = New Integer(width - 1) {}
            Dim x As Integer
            Console.Clear()
            For x = 0 To width - 1
                y(x) = m_r.[Next](height)
                l(x) = m_r.[Next](h2 * (If((x Mod 11 <> 10), 2, 1)), h1 * (If((x Mod 11 <> 10), 2, 1)))
            Next
        End Sub
     
        Dim m_r As New Random()
        Private ReadOnly Property R() As Char
            Get
                Dim t As Integer = m_r.[Next](10)
                If t <= 2 Then
                    Return ChrW(CInt(AscW("0"c)) + m_r.[Next](10))
                ElseIf t <= 4 Then
                    Return ChrW(CInt(AscW("a"c)) + m_r.[Next](27))
                ElseIf t <= 6 Then
                    Return ChrW(CInt(AscW("A"c) + m_r.[Next](27)))
                Else
                    Return ChrW(m_r.[Next](32, 255))
                End If
            End Get
        End Property
     
        Public Function inBoxY(ByVal n As Integer, ByVal height As Integer) As Integer
            n = n Mod height
            If n < 0 Then
                Return n + height
            Else
                Return n
            End If
        End Function
        Private Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
            target = value
            Return value
        End Function
     
    End Module
#9238
· Periodo Trial

Instrucciones:

1. Crear una Setting de "User" con el nombre "UsageDates" y de tipo "System.collection.specialized.stringcollection"

2. Añadir estas dos funcines al form:

Código (vbnet) [Seleccionar]
Private Function CheckDate(ByVal dateToCheck As Date) As Boolean
       'In reality, CheckDate would get the date (current date) itself and not have it passed in
       Dim retValue As Boolean = False 'Fail safe, default to false
       Dim usageDatesLeft As Int16 = 3 ' set it to 4 just for testing
       'Dim usageDatesLeft As Int16 = 30 ' set this to the number of days of application access

       'Hash the date
       Dim hashedDate As String = HashDate(dateToCheck)
       'Check to see if the hash value exists in the UsageDates

       'Initialize the container if necessary
       If My.Settings.UsageDates Is Nothing Then
           My.Settings.UsageDates = New System.Collections.Specialized.StringCollection
       End If

       If My.Settings.UsageDates.Contains(hashedDate) Then
           'then we are ok...  it's already been checked
           retValue = True
           usageDatesLeft = CShort(usageDatesLeft - My.Settings.UsageDates.Count)

           'sanity check... if the system date is backed up to a previous date in the list, but not the last date
           If usageDatesLeft <= 0 AndAlso My.Settings.UsageDates.IndexOf(hashedDate) <> My.Settings.UsageDates.Count - 1 Then
               retValue = False
           End If
       Else
           If My.Settings.UsageDates.Count < usageDatesLeft Then
               My.Settings.UsageDates.Add(hashedDate)
           End If
           usageDatesLeft = CShort(usageDatesLeft - My.Settings.UsageDates.Count)


           'If not, and the remining count has "slots" open, add it
           If usageDatesLeft > 0 Then
               retValue = True
           Else
               'If not and tree are no more slots, tell user, exit app
               retValue = False
           End If

       End If
       'Display to the user how many days are remianing:
       MessageBox.Show(String.Format("You have {0} day(s) remaining.", usageDatesLeft))

       Return retValue
   End Function

   Private Function HashDate(ByVal dateToHash As Date) As String
       'Get a hash object
       Dim hasher As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create()
       'Take date, make it a Long date and hash it
       Dim data As Byte() = hasher.ComputeHash(System.Text.Encoding.Default.GetBytes(dateToHash.ToLongDateString()))
       ' Create a new Stringbuilder to collect the bytes
       ' and create a string.
       Dim sBuilder As New System.Text.StringBuilder()

       ' Loop through each byte of the hashed data
       ' and format each one as a hexadecimal string.
       Dim idx As Integer
       For idx = 0 To data.Length - 1
           sBuilder.Append(data(idx).ToString("x2"))
       Next idx

       Return sBuilder.ToString

   End Function


3. Usar la función por ejemplo en el Form_Load:

Código (vbnet) [Seleccionar]
   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       Dim aCount As Integer = 0
       Dim loopIt As Boolean = True
       'My.Settings.Reset() 'This is here for design time support... otherwise you won't get your app to run agin

       Do While loopIt
           MessageBox.Show(String.Format("Checking Date: {0}.", Date.Now.AddDays(aCount)))
           loopIt = CheckDate(Date.Now.AddDays(aCount))
           If Not loopIt Then
               MessageBox.Show("Trial Period Ended! Application closing!")
               Me.Close()
           Else
               MessageBox.Show("You can keep using the app")
           End If
           aCount += 1
       Loop
   End Sub






· Trial period (Modificado un poco por mí)

Código (vbnet) [Seleccionar]
#Region " Trial Period Function "

   ' [ Trial Period Function ]
   '
   ' Examples :
   ' Trial_Get(Trial_value.As_Boolean)
   ' MsgBox(String.Format("You have {0} day(s) remaining.", Trial_Get(Trial_value.As_LeftDays)))

   Public Enum Trial_value
       As_Boolean
       As_LeftDays
       As_CountDays
   End Enum

   ' Trial Period [Get]
   Public Function Trial_Get(ByVal Trial_value As Trial_value)
       'My.Settings.Reset() 'If you want to reset the trial period
       Dim TrialCount As Integer = 0
       TrialCount += 1
       Return Trial_CheckDate(Date.Now.AddDays(TrialCount), Trial_value)
   End Function

   ' Trial Period [CheckDate]
   Public Function Trial_CheckDate(ByVal Trial_DateToCheck As Date, ByVal Trial_value As Trial_value)

       Dim Trial_retValue As Boolean = False ' Fail safe, default to false
       Dim Trial_usageDatesLeft As Int16 = 7 ' Set here the number of days of Trial period
       Dim Trial_hashedDate As String = Trial_HashDate(Trial_DateToCheck)

       If My.Settings.Trial_Period Is Nothing Then My.Settings.Trial_Period = New System.Collections.Specialized.StringCollection

       If My.Settings.Trial_Period.Contains(Trial_hashedDate) Then
           Trial_retValue = True
           Trial_usageDatesLeft = CShort(Trial_usageDatesLeft - My.Settings.Trial_Period.Count)
           If Trial_usageDatesLeft <= 0 AndAlso My.Settings.Trial_Period.IndexOf(Trial_hashedDate) <> My.Settings.Trial_Period.Count - 1 Then Trial_retValue = False
       Else
           If My.Settings.Trial_Period.Count < Trial_usageDatesLeft Then My.Settings.Trial_Period.Add(Trial_hashedDate)
           Trial_usageDatesLeft = CShort(Trial_usageDatesLeft - My.Settings.Trial_Period.Count)
           If Trial_usageDatesLeft > 0 Then Trial_retValue = True Else Trial_retValue = False
       End If

       Select Case Trial_value
           Case Trial_value.As_Boolean : Return Trial_retValue ' If False then Trial Period is expired
           Case Trial_value.As_LeftDays : Return Trial_usageDatesLeft ' Days left
           Case Trial_value.As_CountDays : Return My.Settings.Trial_Period.Count ' Count days
           Case Else : Return Nothing
       End Select

   End Function

   ' Trial Period [HashDate]
   Public Function Trial_HashDate(ByVal Trial_DateToHash As Date) As String
       Dim Trial_Hasher As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create()
       Dim Trial_Data As Byte() = Trial_Hasher.ComputeHash(System.Text.Encoding.Default.GetBytes(Trial_DateToHash.ToLongDateString()))
       Dim Trial_StringBuilder As New System.Text.StringBuilder()
       Dim Trial_IDX As Integer
       For Trial_IDX = 0 To Trial_Data.Length - 1 : Trial_StringBuilder.Append(Trial_Data(Trial_IDX).ToString("x2")) : Next Trial_IDX
       Return Trial_StringBuilder.ToString
   End Function

#End Region
#9239
El problema de los scripts que le están aconsejando es que se corre el riesgo de que se pueda apagar el equipo mientras el renderizado todavía no haya finalizado... es lo que digo desde un principio, esa opción debe ir (casi al 90% seguro) en la aplicación que se usa para renderizar, no es necesario más.

Pero de hacer un script, como ya te dije te recomendaría que hagas mediciones del consumo de RAM de la aplicación, es decir, cuando no renderizas, cuando el proceso está en IDLE consume la memória normal (yo no puedo saber cuanto es porque no tengo la aplicación), pero cuando renderizas, el proceso consume MUCHA más memória, así que te hago un pequeño script:



Código (dos) [Seleccionar]
@Echo OFF

REM Si el proceso está consumiendo menos de 104857600 Bytes (100 MB), el PC se apagará...
REM de lo contrario, seguirá monitorizando el consumo de memória del proceso.

Set "APP_Name=explorer.exe"
Set /A "Max_Memory=104857600"
Set /A "Interval=5"

:Loop
For /F "Tokens=*" %%# in ('wmic.exe process where "caption="%APP_Name%"" get WorkingSetSize ^| FINDSTR "^[0-9].*[0-9]"') Do (Set /A "Process_Memory=%%#")

If %Process_Memory% LSS %Max_Memory% (
    Echo [%TIME:~0,-3%] Process "%APP_Name%" is consuming less than %Max_Memory% Bytes of memory...
    Echo [%TIME:~0,-3%] Turning off the computer...
    Shutdown.exe /S /F
) ELSE (
    Echo [%TIME:~0,-3%] Process "%APP_Name%" memory consumition: %Process_Memory% Bytes...
    Ping -n %Interval% LocalHost >NUL
    Goto :Loop
)


Saludos!
#9240
· Función para modificar el color del borde de un control.



Nota:
Afecta a todos los controles handleados, es decir, si cambiamos el color de "button1", y luego el color de "button2", el color de "button1" pasará a ser el color que usa "button2", no he conseguido mejorarlo más, pero bueno, lo suyo es colorear todos los bordes dle mismo color, ¿no?, así que creo que no tiene mucha importancia...


#Region " Set Control Border Color Function "

   ' [ Set Control Border Color Function ]
   '
   ' // By Elektro H@cker
   '
   ' Examples :
   ' Set_Control_Border_Color(Button1, Pens.Crimson, Pens.Red, Pens.DarkRed)
   ' Set_Control_Border_Color(Checkbox1, Pens.Transparent, Pens.Transparent, Pens.Transparent)

   Dim Border_Color_Light As Pen
   Dim Border_Color_Middle As Pen
   Dim Border_Color_Dark As Pen

   Private Function Set_Control_Border_Color(ByVal Control As Control, Color_Light As Pen, ByVal Color_Middle As Pen, ByVal Color_Dark As Pen) As Boolean
       Try
           Border_Color_Light = Color_Light
           Border_Color_Middle = Color_Middle
           Border_Color_Dark = Color_Dark
           Handled_Controls.Add(Control)
           AddHandler Control.Paint, AddressOf Control_Paint
           Return True
       Catch ex As Exception : Throw New Exception(ex.Message)
       End Try
   End Function

   Private Sub Control_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
       Dim offset As Integer = 0
       e.Graphics.DrawRectangle(Border_Color_Light, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1))))
       offset += 1
       e.Graphics.DrawRectangle(Border_Color_Middle, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1))))
       offset += 1
       e.Graphics.DrawRectangle(Border_Color_Dark, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1))))
   End Sub

#End Region


Mejorado:

Código (vbnet) [Seleccionar]
#Region " Set Control Border Color Function "

   ' [ Set Control Border Color Function ]
   '
   ' // By Elektro H@cker
   '
   ' Examples :
   ' Set_Control_Border_Color(Button1, Pens.Crimson, Pens.Red, Pens.DarkRed)
   ' Set_Control_Border_Color(Checkbox1, Pens.Transparent, Pens.Transparent, Pens.Transparent)

   Dim Border_Color_Light As Pen
   Dim Border_Color_Middle As Pen
   Dim Border_Color_Dark As Pen
   Dim Last_Handled_control As Control

   Private Function Set_Control_Border_Color(ByVal Control As Control, Color_Light As Pen, ByVal Color_Middle As Pen, ByVal Color_Dark As Pen) As Boolean
       Try
           Border_Color_Light = Color_Light
           Border_Color_Middle = Color_Middle
           Border_Color_Dark = Color_Dark
           AddHandler Control.Paint, AddressOf Control_Paint
           Last_Handled_control = Control
           Return True
       Catch ex As Exception : Throw New Exception(ex.Message)
       End Try
   End Function

   Private Sub Control_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
       If sender.name = Last_Handled_control.Name Then
           Dim offset As Integer = 0
           e.Graphics.DrawRectangle(Border_Color_Light, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1))))
           offset += 1
           e.Graphics.DrawRectangle(Border_Color_Middle, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1))))
           offset += 1
           e.Graphics.DrawRectangle(Border_Color_Dark, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1))))
       End If
   End Sub

#End Region