|
9752
|
Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets !! (Posteen aquí sus snippets)
|
en: 15 Enero 2013, 20:48 pm
|
Oscurecer una imagen a escala de grises ( Disable image) PD: He retocado la función original para añadirle opción de elegir distintos tonos de gris, me ha quedado bastante bien. #Region " GrayScale Image Function " ' [ GrayScale Image Function ] ' ' Examples: ' ' PictureBox1.Image = GrayScale_Image(PictureBox1.Image, GrayScale.Light_Gray) ' PictureBox1.Image = GrayScale_Image(PictureBox1.Image, GrayScale.Mid_Gray) ' PictureBox1.Image = GrayScale_Image(PictureBox1.Image, GrayScale.Dark_Gray) Enum GrayScale Light_Gray Mid_Gray Dark_Gray End Enum Private Function GrayScale_Image(ByVal Image As Image, ByVal Gray_Tone As GrayScale) As Bitmap Dim Image_Bitmap As Bitmap = New Bitmap(Image.Width, Image.Height) Dim Image_Graphic As Graphics = Graphics.FromImage(Image_Bitmap) Dim Color_Matrix As System.Drawing.Imaging.ColorMatrix = Nothing Select Case Gray_Tone Case GrayScale.Light_Gray : Color_Matrix = New System.Drawing.Imaging.ColorMatrix(New Single()() {New Single() {0.2, 0.2, 0.2, 0, 0}, New Single() {0.2, 0.2, 0.2, 0, 0}, New Single() {0.5, 0.5, 0.5, 0, 0}, New Single() {0, 0, 0, 1, 0}, New Single() {0, 0, 0, 0, 1}}) Case GrayScale.Mid_Gray : Color_Matrix = New System.Drawing.Imaging.ColorMatrix(New Single()() {New Single() {0, 0, 0, 0, 0}, New Single() {0, 0, 0, 0, 0}, New Single() {0.5, 0.5, 0.5, 0, 0}, New Single() {0, 0, 0, 1, 0}, New Single() {0, 0, 0, 0, 1}}) Case GrayScale.Dark_Gray : Color_Matrix = New System.Drawing.Imaging.ColorMatrix(New Single()() {New Single() {0, 0, 0, 0, 0}, New Single() {0, 0, 0, 0, 0}, New Single() {0.2, 0.2, 0.2, 0, 0}, New Single() {0, 0, 0, 1, 0}, New Single() {0, 0, 0, 0, 1}}) End Select Dim Image_Attributes As System.Drawing.Imaging.ImageAttributes = New System.Drawing.Imaging.ImageAttributes() Image_Attributes.SetColorMatrix(Color_Matrix) Image_Graphic.DrawImage(Image, New Rectangle(0, 0, Image.Width, Image.Height), 0, 0, Image.Width, Image.Height, GraphicsUnit.Pixel, Image_Attributes) Image_Graphic.Dispose() Return Image_Bitmap End Function #End Region
|
|
|
9756
|
Programación / .NET (C#, VB.NET, ASP) / [APORTE] Splitty v1.6 [Source code]
|
en: 15 Enero 2013, 19:21 pm
|
SplittyBy Elektro H@ckerEsta utilidad se encarga de organizar un directorio separando el directorio en varias carpetas de un tamaño específico (tamaño de la capacidad de disco) para grabarlo posteriormente. Para que lo entiendan mejor, pongámonos en situación, imaginemos que tenemos una carpeta con subcarpetas, llenas de archivos, y la carpeta pesa 100 GB, si por necesidad queremos grabar la carpeta a DVD's tenemos que organizarlo todo (Cortar y medir) manualmente, lo cual es una tarea muy agobiante xD... Pues para eso hice este programa. versión 1.6: El código fuente: > http://www.mediafire.com/download/pn69i21t9nja5xm/Splitty.rar* Está desarrollado en VB.NET (VS2012), Es un WinForm y requiere Framework 4.0.
|
|
|
9759
|
Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] Permitir solo una coma en un textbox
|
en: 15 Enero 2013, 15:38 pm
|
Estoy intentando que el textbox sólamente acepte números, y una coma (sólamente una coma), No se que estoy haciendo mal (Acepta más de una coma). Private Sub TextBox_Custom_Size_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox_Custom_Size.KeyPress e.Handled = NumericOnly(e.KeyChar) End Sub Public Function NumericOnly(ByVal eChar As Char) As Boolean Dim chkStr As String = "0123456789," If chkStr.IndexOf(eChar) > -1 OrElse eChar = vbBack Then If eChar = Keys.Oemcomma & TextBox_Custom_Size.Text.Contains(",") Then Return True Return False Else Return True End If End Function
Saludos!
|
|
|
9760
|
Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets !! (Posteen aquí sus snippets)
|
en: 15 Enero 2013, 07:33 am
|
He añadido, ordenado, y mejorado bastantes snippets del pack de snippets, el nuevo enlace está en el comentario principal. Función para eliminar atributos de un archivo, preservando el resto de atributos. #Region " File Remove Attribute Function " ' [ File Remove Attribute Function ] ' ' Examples : ' ' MsgBox(File_Remove_Attribute("C:\Test.txt", FileAttribute.ReadOnly)) ' MsgBox(File_Remove_Attribute("C:\Test.txt", FileAttribute.ReadOnly + FileAttribute.Hidden)) Public Function File_Remove_Attribute (ByVal File As String, ByVal Remove_Attribute As FileAttribute ) As Boolean Try Dim FileAttributes As FileAttribute = IO. File. GetAttributes(File) IO. File. SetAttributes(File, FileAttributes And Not Remove_Attribute ) Return True Catch ex As Exception Return False End Try End Function #End Region
Función para añadir atributos a un archivo, preservando el resto de atributos. #Region " File Add Attribute Function " ' [ File Add Attribute Function ] ' ' Examples : ' ' MsgBox(File_Add_Attribute("C:\Test.txt", FileAttribute.ReadOnly)) ' MsgBox(File_Add_Attribute("C:\Test.txt", FileAttribute.ReadOnly + FileAttribute.Hidden)) Public Function File_Add_Attribute (ByVal File As String, ByVal Add_Attribute As FileAttribute ) As Boolean Try Dim FileAttributes As FileAttribute = IO. File. GetAttributes(File) IO. File. SetAttributes(File, FileAttributes Or Add_Attribute ) Return True Catch ex As Exception Return False End Try End Function #End Region
Función que comprueba si un archivo tiene un atributo #Region " File Have Attribute Function " ' [ File Have Attribute Function ] ' ' Examples : ' ' MsgBox(File_Have_Attribute("C:\Test.txt", FileAttribute.ReadOnly)) ' MsgBox(File_Have_Attribute("C:\Test.txt", FileAttribute.ReadOnly + FileAttribute.Hidden)) Public Function File_Have_Attribute (ByVal File As String, ByVal CheckAttribute As FileAttribute ) As Boolean Try Dim FileAttributes As FileAttribute = IO. File. GetAttributes(File) If (FileAttributes And CheckAttribute) = CheckAttribute Then Return True Else Return False Catch ex As Exception Return Nothing End Try End Function #End Region
|
|
|
|
|
|
|