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


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


  Mostrar Mensajes
Páginas: 1 ... 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 [876] 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 ... 1253
8751  Programación / Scripting / Re: QPF to Chapter file en: 12 Julio 2013, 18:07 pm
¿Algo está mal? ¿Acaso no se puede operar con numeros decimales?

Exacto, ese es el problema, Batch no soporta operaciones con decimales.

Aunque se pueden llegar a hacer, pero es un jaleo de código y porsupuesto no es algo "nativo" que digamos, diréctamente te recomiendo cualquier otro lenguaje.

Si no quieres depender de tener un intérprete instalado en el PC entonces te iría bien usar VBScript, javascript, O Powershell.

Saludos!
8752  Programación / Scripting / Re: QPF to Chapter file en: 12 Julio 2013, 09:43 am
me gustaria saber pq no me lista los numeros.

No estás usando comillas en el comando agrupado, no le estás indicando al FOR que se trata de un archivo, en lugar de eso estás usando comillas dobles así que estás leyendo interpretando un String "...\10. QPFILE_NAME.txt", no el contenido del archivo.

Hay dos formas de hacerlo, una es usando el parámetro "usebackq" del FOR y usar sólo comillas, y la otra es usando la sintaxis correcta del For agrupando un comando con comillas: ...In ('Type "archivo"') Do..., bueno, aquí tienes la sintaxis:

Citar
Código:
 FOR /F ["options"] %%parameter IN ('command_to_process') DO command

Citar
Código:
      usebackq     Use the alternate quoting style:                        
                   - Use double quotes for long file names in "filenameset".
                   - Use single quotes for 'Text string to process'
                   - Use back quotes for `command_to_process`


Código
  1. @echo off
  2. SetLocal EnableDelayEdexpansion
  3.  
  4. FOR /F "usebackq delims=" %%A IN (
  5. "C:\Users\Isra\Desktop\Nueva carpeta\10. QPFILE_NAME.txt"
  6. ) DO (
  7. SET "Reg=%%A"
  8. ECHO !Reg!
  9. )
  10.  
  11. Pause&Exit

Saludos
8753  Programación / .NET (C#, VB.NET, ASP) / Re: [Duda] Capturar evento global y simular click en: 12 Julio 2013, 09:26 am
Captura global del MiddleButton: http://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1855844#msg1855844
8754  Programación / .NET (C#, VB.NET, ASP) / Re: [SOURCECODE] -> WTF! (WinampToFolder) en: 11 Julio 2013, 15:49 pm
seria excelente (para mi) si utilizaras el framework 2.0, sólo por compatibilidad

Imposible, uso Linq y métodos del FW 4.0, demasiada tarea como para poder pasarlo al 2.0.





v1.5

Cambios:

 - Añadido soporte para arrastrar y soltar archivos de música a la lista del monitor.

 - La lista del monitor ahora se puede reorganizar clickando en las columnas.

 - El menú contextual de la lista del monitor ya no está disponible cuando se están enviando canciones a los directorios.

 - Opción añadida en el menú contextual para modificar la carpeta de destino de una canción préviamente agregada.

 - Opción añadida en el menú contextual para eliminar todas las canciones de la lista.

 - Opción añadida en el menú contextual para copiar una cancion de la lista.

 - Algunos elementos importantes del monitor se activan al pasar el ratón por encima de ellos, consiguiendo una rapidez de uso extra. (La barra de volumen, la barra de posición, el combobox y el listview).

 - Tiple click para seleccionar todo el texto en los textboxes.

- Añadido preguntas de confirmación para eliminar un archivo de la lista y/o para limpiar la lista.

8755  Informática / Software / Re: Modificar ISO. en: 10 Julio 2013, 21:55 pm
1. El sistema operativo da igual, es para aplicarlo a cualquier güindous.

¿Y si hubiese sido para Linux y te doy una contestación de 10 páginas sobre una solución para Windows encontes que?. hay que especificar estos detalles hombre...

llevo 10 minutos intentando descargar dicho archivo, el server está bastante colapsado o bastante jodido, no puedo descargarlo ni con JDownloader, ya veremos mañana.

3. ¿Como se llama el software que está grabado en la ISO?

Citar
Éste software es de Gigabyte y se llama Xpress Recovery2,

Comprueba si en la misma carpeta del executable hay algún archivo de configuración (cfg, ini, txt, etc...) que contenga parámetros personalizables configurables, por ejemplo algo como esto "Output=C:\", y encontes lo cambias. De lo contrario... no creo que haya nada que hacer.

No he probado la aplicación pero como afirmas que es un proceso automático entonces lo más lógico es que la aplicación trabaje sobre el mismo disco duro donde se efectua la operación (porque la lógica de la aplicación sabe que ese disco duro existe), aunque no he programado yo la aplicación y pueden haber usado otra lógica, pero a mi me parecería algo muy ilógico por parte de los desarrolladores el hecho de permitirte modificar el HDD de destino, más que nada por si por un error humano o cualquier otra cosa la unidad de destino no existiese, entonces al ser un proceso automático habría un gran FAIL por parte del programa y adiós al backup.

PD: No ayudo por privado, usemos el foro.

Saludos
8756  Programación / .NET (C#, VB.NET, ASP) / Re: Self-extractor de Ionic Zip no esperado en: 10 Julio 2013, 21:27 pm
...DotNetZip es un wrapper de WinZip, lo sabrías si lo hubiera leido, es obvio que no es lo mismo que WinRar...

Winrar no es opensource, y no hay ningún wrapper de winrar.

O usas .NetZip o usas 7zipsharp (Hay más, pero ni valen la pena xD).

1. Creas el archivo comprimido (SFX o sin ser SFX)
2. Creas la Gui y la hardcodeas para que se asemeje a la Gui de WinRar, y añades el archivo comprimido como recurso a tu proyecto, y también la librería para descomprimirlo.
3. Al darle al botón "Instalar" de tu Gui, pues descomprimes de forma automática y oculta el archivo que préviamente has comprimido en el paso 1 y añadido a tu Gui en el paso 2...

EDITO: Un sfx de 7zip lo puedes customizar muchísimo de aspecto y de tamaño (Puedes hacerlo con los metodos de sevenzipsharp agregando tu custom sfx modificado), las dos librerías son buenas pero en mi opinión dotnetzip no le llega a sevenzipsharp ni a la punta de... ejem, por el soporte de formatos y por la customización.

Saludos.
8757  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 10 Julio 2013, 20:30 pm
Integración para deshacer/rehacer (Undo/Redo) para estos controles:

Código:
    TextBox
    ComboBox
    DateTimePicker
    NumericUpDown
    MaskedTextBox
    ListBox (single and multi-select)
    CheckBox
    RadioButton
    MonthCalendar


INSTRUCCIONES:
1. copiar las siguientes classes en el proyecto:


Código
  1. '******************************************************************************************************************
  2. ' Undo/Redo framework (c) Copyright 2009 Etienne Nijboer
  3. '******************************************************************************************************************
  4.  
  5. Public Enum UndoRedoCommandType
  6.    ctNone
  7.    ctUndo
  8.    ctRedo
  9. End Enum
  10.  
  11. Public Class UndoRedoManager
  12.  
  13. #Region "UndoRedoMonitor auto register types"
  14.  
  15.    Private Shared RegisteredUndoRedoMonitorTypes As List(Of Type) = Nothing
  16.  
  17.    ' ScanAssembly
  18.    ' The first created UndoRedoMonitor will scan the assembly for BaseUndoRedoMonitors and
  19.    ' store these types in the monitor type list.
  20.    '
  21.    Private Shared Sub ScanAssembly()
  22.        If RegisteredUndoRedoMonitorTypes Is Nothing Then
  23.            RegisteredUndoRedoMonitorTypes = New List(Of Type)
  24.            Dim AssemblyTypes() As Type = Reflection.Assembly.GetExecutingAssembly().GetTypes()
  25.            Dim BaseUndoRedoMonitorType As Type = GetType(BaseUndoRedoMonitor)
  26.            For Each typeItem As Type In AssemblyTypes
  27.                If typeItem.BaseType Is BaseUndoRedoMonitorType Then
  28.                    RegisteredUndoRedoMonitorTypes.Add(typeItem)
  29.                End If
  30.            Next
  31.        End If
  32.    End Sub
  33.  
  34. #End Region
  35.  
  36.    Private Control As Control = Nothing
  37.    Private UndoRedoMonitors As List(Of BaseUndoRedoMonitor)
  38.    Private ExcludeControls As List(Of Control)
  39.  
  40.    ' InitializeUndoRedoMonitors
  41.    ' When a new UndoRedoManager instance is created, a new instance of each registered monitor
  42.    ' is created and used only within the scope of this UndoRedoManager, preventing temporary data
  43.    ' moved to another UndoRedoManager. This is because Each form, or group control like a panel
  44.    ' to make seperate undo/redo groups on a single form, can have it's own UndoRedoManager. It is
  45.    ' of course also possible to use one global UndoRedoManager for multiple forms. This lets you
  46.    ' control how data is seperated or combined, depending on the relation between te undo/redo commands.
  47.    Private Sub InitializeUndoRedoMonitors()
  48.        ScanAssembly()
  49.        UndoRedoMonitors = New List(Of BaseUndoRedoMonitor)
  50.        For Each typeItem In RegisteredUndoRedoMonitorTypes
  51.            UndoRedoMonitors.Add(Activator.CreateInstance(typeItem, Me))
  52.        Next
  53.    End Sub
  54.  
  55.    Public Sub New()
  56.        InitializeUndoRedoMonitors()
  57.    End Sub
  58.  
  59.    Public Sub New(ByVal AControl As Control)
  60.        Me.New(AControl, New List(Of Control))
  61.    End Sub
  62.  
  63.    Public Sub New(ByVal AControl As Control, ByVal AExcludeControls As List(Of Control))
  64.        Me.New()
  65.        ExcludeControls = AExcludeControls
  66.        MonitorControl(AControl)
  67.    End Sub
  68.  
  69.    Public Sub New(ByVal AControl As Control, ByVal ParamArray AExcludeControls() As Control)
  70.        Me.New(AControl, AExcludeControls.ToList)
  71.    End Sub
  72.  
  73.    ' MonitorControl
  74.    ' If a given control is not in the list of controls to exclude from undo/redo actions,
  75.    ' an attempt is made to attach it to a matching UndoRedoMonitor. If no direct match is
  76.    ' found, a same attempt is made for each control contained within the control recursively.
  77.    Private Sub MonitorControl(ByVal AControl As Control)
  78.        If Not ExcludeControls.Contains(AControl) Then
  79.            If Not BindMonitor(AControl) Then
  80.                For Each ctl As Control In AControl.Controls
  81.                    MonitorControl(ctl)
  82.                Next
  83.            End If
  84.        End If
  85.    End Sub
  86.  
  87.    ' BindMonitor
  88.    ' An attempt is made to bind the control to a each registered monitor. When a match is  
  89.    ' found the search ends and the function will return true, false otherwise meaning there
  90.    ' is no specific UndoRedoMonitor for this control.
  91.    Private Function BindMonitor(ByVal AControl As Control) As Boolean
  92.        Dim index As Integer = UndoRedoMonitors.Count - 1, result As Boolean = False
  93.        While index >= 0 And Not result
  94.            result = UndoRedoMonitors(index).Monitor(AControl)
  95.            index -= 1
  96.        End While
  97.        Return result
  98.    End Function
  99.  
  100.    Public Sub Monitor(ByVal AControl As Control)
  101.        MonitorControl(AControl)
  102.    End Sub
  103.  
  104.    Private undoStack As Stack(Of BaseUndoRedoCommand) = New Stack(Of BaseUndoRedoCommand)
  105.    Private redoStack As Stack(Of BaseUndoRedoCommand) = New Stack(Of BaseUndoRedoCommand)
  106.    Private _undoRedoCommand As UndoRedoCommandType = UndoRedoCommandType.ctNone
  107.    Private _canUndo As Boolean = False
  108.    Private _canRedo As Boolean = False
  109.  
  110.    Public Event CanUndoChanged(ByVal Sender As Object, ByVal CanUndo As Boolean)
  111.    Public Event CanRedoChanged(ByVal Sender As Object, ByVal CanRedo As Boolean)
  112.    Public Event UndoRedoStacksChanged(ByVal Sender As Object)
  113.  
  114.    Private Sub UpdateCanUndoRedo()
  115.        Dim isCanUndoChanged As Boolean = Not (undoStack.Count > 0) = _canUndo, _
  116.            isCanRedoChanged As Boolean = Not (redoStack.Count > 0) = _canRedo
  117.        _canUndo = undoStack.Count > 0
  118.        _canRedo = redoStack.Count > 0
  119.        If isCanUndoChanged Then
  120.            RaiseEvent CanUndoChanged(Me, _canUndo)
  121.        End If
  122.        If isCanRedoChanged Then
  123.            RaiseEvent CanRedoChanged(Me, _canRedo)
  124.        End If
  125.        RaiseEvent UndoRedoStacksChanged(Me)
  126.    End Sub
  127.  
  128.    Public ReadOnly Property isUndoing() As Boolean
  129.        Get
  130.            Return _undoRedoCommand = UndoRedoCommandType.ctUndo
  131.        End Get
  132.    End Property
  133.    Public ReadOnly Property isRedoing() As Boolean
  134.        Get
  135.            Return _undoRedoCommand = UndoRedoCommandType.ctRedo
  136.        End Get
  137.    End Property
  138.    Public ReadOnly Property isPerformingUndoRedo() As Boolean
  139.        Get
  140.            Return _undoRedoCommand <> UndoRedoCommandType.ctNone
  141.        End Get
  142.    End Property
  143.  
  144.    Public ReadOnly Property CanUndo() As Boolean
  145.        Get
  146.            Return _canUndo
  147.        End Get
  148.    End Property
  149.  
  150.    Public ReadOnly Property CanRedo() As Boolean
  151.        Get
  152.            Return _canRedo
  153.        End Get
  154.    End Property
  155.  
  156.    Public Sub AddUndoCommand(ByVal UndoRedoCommand As BaseUndoRedoCommand)
  157.        If Not isUndoing Then
  158.            undoStack.Push(UndoRedoCommand)
  159.            If Not isRedoing Then
  160.                redoStack.Clear()
  161.                UpdateCanUndoRedo()
  162.            End If
  163.        End If
  164.    End Sub
  165.  
  166.    Public Sub AddRedoCommand(ByVal UndoRedoCommand As BaseUndoRedoCommand)
  167.        If Not isRedoing Then
  168.            redoStack.Push(UndoRedoCommand)
  169.            If Not isUndoing Then
  170.                UpdateCanUndoRedo()
  171.            End If
  172.        End If
  173.    End Sub
  174.  
  175.    Public Sub AddCommand(ByVal UndoRedoCommandType As UndoRedoCommandType, ByVal UndoRedoCommand As BaseUndoRedoCommand)
  176.        Select Case UndoRedoCommandType
  177.            Case UndoRedoCommandType.ctUndo
  178.                AddUndoCommand(UndoRedoCommand)
  179.            Case UndoRedoCommandType.ctRedo
  180.                AddRedoCommand(UndoRedoCommand)
  181.            Case Else
  182.                Throw New Exception("An undo or redo command could not be accepted.")
  183.        End Select
  184.    End Sub
  185.  
  186.    Public Sub Undo()
  187.        If CanUndo Then
  188.            'Try                
  189.            _undoRedoCommand = UndoRedoCommandType.ctUndo
  190.            undoStack.Pop.Undo()
  191.            'Catch e As Exception
  192.            'Finally
  193.            UpdateCanUndoRedo()
  194.            _undoRedoCommand = UndoRedoCommandType.ctNone
  195.            'End Try
  196.        End If
  197.    End Sub
  198.  
  199.    Public Sub Redo()
  200.        If CanRedo Then
  201.            _undoRedoCommand = UndoRedoCommandType.ctRedo
  202.            redoStack.Pop.Redo()
  203.            UpdateCanUndoRedo()
  204.            _undoRedoCommand = UndoRedoCommandType.ctNone
  205.        End If
  206.    End Sub
  207.  
  208.    Protected Overrides Sub Finalize()
  209.        MyBase.Finalize()
  210.    End Sub
  211.  
  212.  
  213. #Region "debug info"
  214.  
  215.    Public Shared Function ArrayToString(ByVal ObjectArray() As Object) As String
  216.        Dim sb As New System.Text.StringBuilder
  217.        For Each item As Object In ObjectArray
  218.            sb.AppendLine(item.ToString)
  219.        Next
  220.        Return sb.ToString
  221.    End Function
  222.  
  223.  
  224.    Public Function GetUndoStack() As String
  225.        Return ArrayToString(undoStack.ToArray)
  226.    End Function
  227.  
  228.    Public Function GetRedoStack() As String
  229.        Return ArrayToString(redoStack.ToArray)
  230.    End Function
  231.  
  232.    Public Function GetRegisteredUndoRedoMonitorTypes() As String
  233.        Return ArrayToString(RegisteredUndoRedoMonitorTypes.ToArray)
  234.    End Function
  235.  
  236. #End Region
  237.  
  238. End Class
  239.  

Código
  1. '******************************************************************************************************************
  2. ' Undo/Redo framework (c) Copyright 2009 Etienne Nijboer
  3. '******************************************************************************************************************
  4.  
  5. Public MustInherit Class BaseUndoRedoMonitor
  6.  
  7.    Public Sub New(ByVal AUndoRedoManager As UndoRedoManager)
  8.        _UndoRedoManager = AUndoRedoManager
  9.    End Sub
  10.  
  11.    Private _UndoRedoManager As UndoRedoManager
  12.    Public Property UndoRedoManager() As UndoRedoManager
  13.        Get
  14.            Return _UndoRedoManager
  15.        End Get
  16.        Set(ByVal value As UndoRedoManager)
  17.            _UndoRedoManager = value
  18.        End Set
  19.    End Property
  20.  
  21.    Public ReadOnly Property isUndoing() As Boolean
  22.        Get
  23.            Return UndoRedoManager.isUndoing
  24.        End Get
  25.    End Property
  26.    Public ReadOnly Property isRedoing() As Boolean
  27.        Get
  28.            Return UndoRedoManager.isRedoing
  29.        End Get
  30.    End Property
  31.  
  32.    Public ReadOnly Property isPerformingUndoRedo() As Boolean
  33.        Get
  34.            Return UndoRedoManager.isPerformingUndoRedo
  35.        End Get
  36.    End Property
  37.  
  38.    Public Sub AddCommand(ByVal UndoRedoCommandType As UndoRedoCommandType, ByVal UndoRedoCommand As BaseUndoRedoCommand)
  39.        UndoRedoManager.AddCommand(UndoRedoCommandType, UndoRedoCommand)
  40.    End Sub
  41.  
  42.    Public MustOverride Function Monitor(ByVal AControl As Control) As Boolean
  43.  
  44. End Class
  45.  
  46. '****************************************************************************************************************
  47. ' SimpleControl
  48. ' Controls: TextBox, ComboBox, DateTimePicker, NumericUpDown, MaskedTextBox
  49. '****************************************************************************************************************
  50. Public Class SimpleControlMonitor : Inherits BaseUndoRedoMonitor
  51.  
  52.    Private Data As String
  53.  
  54.    Public Sub New(ByVal AUndoRedoManager As UndoRedoManager)
  55.        MyBase.New(AUndoRedoManager)
  56.    End Sub
  57.  
  58.    Public Overrides Function Monitor(ByVal AControl As System.Windows.Forms.Control) As Boolean
  59.        If TypeOf AControl Is TextBox Or _
  60.           TypeOf AControl Is ComboBox Or _
  61.           TypeOf AControl Is DateTimePicker Or _
  62.           TypeOf AControl Is NumericUpDown Or _
  63.           TypeOf AControl Is ListView Or _
  64.           TypeOf AControl Is MaskedTextBox Then
  65.            AddHandler AControl.Enter, AddressOf Control_Enter
  66.            AddHandler AControl.Leave, AddressOf Control_Leave
  67.            Return True
  68.        End If
  69.        Return False
  70.    End Function
  71.  
  72.    Private Sub Control_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs)
  73.        Data = CType(sender, Control).Text
  74.    End Sub
  75.  
  76.    Private Sub Control_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
  77.        Dim CurrentData As String = CType(sender, Control).Text
  78.        If Not String.Equals(CurrentData, Data) Then
  79.            AddCommand(UndoRedoCommandType.ctUndo, New SimpleControlUndoRedoCommand(Me, sender, Data))
  80.        End If
  81.    End Sub
  82. End Class
  83.  
  84. '****************************************************************************************************************
  85. ' ListBox
  86. '****************************************************************************************************************
  87. Public Class ListBoxMonitor : Inherits BaseUndoRedoMonitor
  88.  
  89.    Private Data As Object
  90.  
  91.    Public Sub New(ByVal AUndoRedoManager As UndoRedoManager)
  92.        MyBase.New(AUndoRedoManager)
  93.    End Sub
  94.  
  95.    Public Overrides Function Monitor(ByVal AControl As System.Windows.Forms.Control) As Boolean
  96.        If TypeOf AControl Is ListBox Then
  97.            AddHandler AControl.Enter, AddressOf Control_Enter
  98.            AddHandler CType(AControl, ListBox).SelectedIndexChanged, AddressOf Control_Changed
  99.            Return True
  100.        End If
  101.        Return False
  102.    End Function
  103.  
  104.    Public Function GetSelected(ByVal AListBox As Object) As String
  105.        Dim Indices As List(Of String) = New List(Of String)
  106.        For Each itemIndex As Integer In CType(AListBox, ListBox).SelectedIndices
  107.            Indices.Add(CStr(itemIndex + 1))
  108.        Next
  109.        Return String.Join(",", Indices.ToArray)
  110.    End Function
  111.  
  112.    Public Sub RestoreSelected(ByVal AListBox As Object, ByVal ASelection As String)
  113.        If Not String.IsNullOrEmpty(ASelection) Then
  114.            Dim Indices As List(Of Integer) = New List(Of Integer)(Array.ConvertAll(ASelection.Split(","), New Converter(Of String, Integer)(AddressOf Integer.Parse)))
  115.            Dim Control As ListBox = CType(AListBox, ListBox)
  116.            Select Case Control.SelectionMode
  117.                Case SelectionMode.None
  118.                Case SelectionMode.One
  119.                    Control.SetSelected(Indices(0) - 1, True)
  120.                Case SelectionMode.MultiSimple, SelectionMode.MultiExtended
  121.                    For index As Integer = 0 To Control.Items.Count - 1
  122.                        Control.SetSelected(index, Indices.IndexOf(index + 1) >= 0)
  123.                    Next
  124.            End Select
  125.        Else
  126.            CType(AListBox, ListBox).ClearSelected()
  127.        End If
  128.    End Sub
  129.  
  130.    Private Sub Control_Changed(ByVal sender As System.Object, ByVal e As System.EventArgs)
  131.        ' Events that are also fired when the undo/redo value is changed by code, like change events,
  132.        ' it is important to make sure that no undo/redo command is added when performing a undo/redo action.
  133.        If Not isPerformingUndoRedo Then
  134.            Dim CurrentData As String = GetSelected(sender)
  135.            If Not String.Equals(Data, CurrentData) Then
  136.                AddCommand(UndoRedoCommandType.ctUndo, New ListBoxUndoRedoCommand(Me, sender, Data))
  137.                Data = CurrentData
  138.            End If
  139.        End If
  140.    End Sub
  141.  
  142.    Private Sub Control_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs)
  143.        Data = GetSelected(sender)
  144.    End Sub
  145.  
  146. End Class
  147.  
  148.  
  149. '****************************************************************************************************************
  150. ' CheckBox
  151. '****************************************************************************************************************
  152. Public Class CheckBoxMonitor : Inherits BaseUndoRedoMonitor
  153.    Private Data As CheckState
  154.  
  155.    Public Sub New(ByVal AUndoRedoManager As UndoRedoManager)
  156.        MyBase.New(AUndoRedoManager)
  157.    End Sub
  158.  
  159.    Public Overrides Function Monitor(ByVal AControl As System.Windows.Forms.Control) As Boolean
  160.        If TypeOf AControl Is CheckBox Then
  161.            AddHandler AControl.Enter, AddressOf Control_Enter
  162.            AddHandler AControl.Leave, AddressOf Control_Leave
  163.            Return True
  164.        End If
  165.        Return False
  166.    End Function
  167.  
  168.    Private Sub Control_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs)
  169.        Data = CType(sender, CheckBox).CheckState
  170.    End Sub
  171.  
  172.    Private Sub Control_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs)
  173.        Dim CurrentData As CheckState = CType(sender, CheckBox).CheckState
  174.        If Data <> CurrentData Then
  175.            AddCommand(UndoRedoCommandType.ctUndo, New CheckBoxUndoRedoCommand(Me, sender, Data))
  176.        End If
  177.    End Sub
  178. End Class
  179.  
  180. '****************************************************************************************************************
  181. ' RadioButton
  182. '****************************************************************************************************************
  183. Public Class RadioButtonMonitor : Inherits BaseUndoRedoMonitor
  184.    Private Data As RadioButton
  185.  
  186.    Public Sub New(ByVal AUndoRedoManager As UndoRedoManager)
  187.        MyBase.New(AUndoRedoManager)
  188.    End Sub
  189.  
  190.    Public Overrides Function Monitor(ByVal AControl As System.Windows.Forms.Control) As Boolean
  191.        If TypeOf AControl Is RadioButton Then
  192.            AddHandler CType(AControl, RadioButton).CheckedChanged, AddressOf Control_CheckedChanged
  193.            Return True
  194.        End If
  195.        Return False
  196.    End Function
  197.  
  198.    Private Sub Control_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
  199.        ' Events that are also fired when the undo/redo value is changed by code, like change events,
  200.        ' it is important to make sure that no undo/redo command is added when performing a undo/redo action.  
  201.        If Not isPerformingUndoRedo Then
  202.            If CType(sender, RadioButton).Checked Then
  203.                AddCommand(UndoRedoCommandType.ctUndo, New RadioButtonUndoRedoCommand(Me, sender, Data))
  204.            Else
  205.                Data = sender
  206.            End If
  207.        End If
  208.    End Sub
  209. End Class
  210.  
  211. '****************************************************************************************************************
  212. ' MonthCalendar
  213. '****************************************************************************************************************
  214. Public Class MonthCalendarMonitor : Inherits BaseUndoRedoMonitor
  215.    Private Data As SelectionRange
  216.  
  217.    Public Sub New(ByVal AUndoRedoManager As UndoRedoManager)
  218.        MyBase.New(AUndoRedoManager)
  219.    End Sub
  220.  
  221.    Public Overrides Function Monitor(ByVal AControl As System.Windows.Forms.Control) As Boolean
  222.        If TypeOf AControl Is MonthCalendar Then
  223.            AddHandler AControl.Enter, AddressOf Control_Enter
  224.            AddHandler CType(AControl, MonthCalendar).DateSelected, AddressOf Control_DateSelected
  225.            Return True
  226.        End If
  227.        Return False
  228.    End Function
  229.  
  230.    Private Sub Control_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs)
  231.        Data = CType(sender, MonthCalendar).SelectionRange
  232.    End Sub
  233.  
  234.    Private Sub Control_DateSelected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs)
  235.        ' Events that are also fired when the undo/redo value is changed by code, like selected events,
  236.        ' it is important to make sure that no undo/redo command is added when performing a undo/redo action.
  237.        If Not isPerformingUndoRedo Then
  238.            Dim CurrentData As SelectionRange = CType(sender, MonthCalendar).SelectionRange
  239.            If Not SelectionRange.Equals(Data, CurrentData) Then
  240.                AddCommand(UndoRedoCommandType.ctUndo, New MonthCalendarUndoRedoCommand(Me, sender, Data))
  241.                Data = CurrentData
  242.            End If
  243.        End If
  244.    End Sub
  245.  
  246. End Class

Código
  1. '******************************************************************************************************************
  2. ' Undo/Redo framework (c) Copyright 2009 Etienne Nijboer
  3. '******************************************************************************************************************
  4.  
  5. Public MustInherit Class BaseUndoRedoCommand
  6.  
  7.    Private _UndoRedoMonitor As BaseUndoRedoMonitor
  8.    Private _UndoRedoControl As Control
  9.    Private _UndoRedoData As Object
  10.  
  11.    Public ReadOnly Property UndoRedoMonitor() As BaseUndoRedoMonitor
  12.        Get
  13.            Return _UndoRedoMonitor
  14.        End Get
  15.    End Property
  16.  
  17.    Public ReadOnly Property UndoRedoControl() As Control
  18.        Get
  19.            Return _UndoRedoControl
  20.        End Get
  21.    End Property
  22.  
  23.    Protected Property UndoRedoData() As Object
  24.        Get
  25.            Return _UndoRedoData
  26.        End Get
  27.        Set(ByVal value As Object)
  28.            _UndoRedoData = value
  29.        End Set
  30.    End Property
  31.  
  32.    Protected Sub New()
  33.        Throw New Exception("Cannot create instance with the default constructor.")
  34.    End Sub
  35.  
  36.    Public Sub New(ByVal AUndoRedoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control)
  37.        Me.New(AUndoRedoMonitor, AMonitorControl, Nothing)
  38.    End Sub
  39.  
  40.    Public Sub New(ByVal AUndoRedoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control, ByVal AUndoRedoData As Object)
  41.        _UndoRedoMonitor = AUndoRedoMonitor
  42.        _UndoRedoControl = AMonitorControl
  43.        _UndoRedoData = AUndoRedoData
  44.    End Sub
  45.  
  46.    Protected Sub AddCommand(ByVal UndoRedoCommandType As UndoRedoCommandType, ByVal UndoRedoCommand As BaseUndoRedoCommand)
  47.        UndoRedoMonitor.AddCommand(UndoRedoCommandType, UndoRedoCommand)
  48.    End Sub
  49.  
  50.    Public Overridable Sub Undo()
  51.        AddCommand(UndoRedoCommandType.ctRedo, Activator.CreateInstance(Me.GetType, UndoRedoMonitor, UndoRedoControl))
  52.    End Sub
  53.  
  54.    Public Overridable Sub Redo()
  55.        AddCommand(UndoRedoCommandType.ctUndo, Activator.CreateInstance(Me.GetType, UndoRedoMonitor, UndoRedoControl))
  56.    End Sub
  57.  
  58.    Public Overridable Sub Undo(ByVal RedoData As Object)
  59.        AddCommand(UndoRedoCommandType.ctRedo, Activator.CreateInstance(Me.GetType, UndoRedoMonitor, UndoRedoControl, RedoData))
  60.    End Sub
  61.  
  62.    Public Overridable Sub Redo(ByVal UndoData As Object)
  63.        AddCommand(UndoRedoCommandType.ctUndo, Activator.CreateInstance(Me.GetType, UndoRedoMonitor, UndoRedoControl, UndoData))
  64.    End Sub
  65.  
  66.    Public MustOverride Function CommandAsText() As String
  67.  
  68.    Public Overrides Function ToString() As String
  69.        Return CommandAsText()
  70.    End Function
  71.  
  72. End Class
  73.  
  74. '****************************************************************************************************************
  75. ' SimpleControl
  76. ' Controls: TextBox, ComboBox, DateTimePicker, NumericUpDown, MaskedTextBox
  77. '****************************************************************************************************************
  78. Public Class SimpleControlUndoRedoCommand : Inherits BaseUndoRedoCommand
  79.  
  80.    Protected ReadOnly Property UndoRedoText() As String
  81.        Get
  82.            Return CStr(UndoRedoData)
  83.        End Get
  84.    End Property
  85.  
  86.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control)
  87.        MyBase.New(AUndoMonitor, AMonitorControl)
  88.        UndoRedoData = UndoRedoControl.Text
  89.    End Sub
  90.  
  91.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control, ByVal AUndoRedoData As String)
  92.        MyBase.New(AUndoMonitor, AMonitorControl, AUndoRedoData)
  93.    End Sub
  94.  
  95.    Public Overrides Sub Undo()
  96.        MyBase.Undo()
  97.        UndoRedoControl.Text = UndoRedoText
  98.    End Sub
  99.  
  100.    Public Overrides Sub Redo()
  101.        MyBase.Redo()
  102.        UndoRedoControl.Text = UndoRedoText
  103.    End Sub
  104.  
  105.    Public Overrides Function CommandAsText() As String
  106.        Return String.Format("Change to '{0}'", UndoRedoText)
  107.    End Function
  108.  
  109. End Class
  110.  
  111. '****************************************************************************************************************
  112. ' ListBox
  113. '****************************************************************************************************************
  114. Public Class ListBoxUndoRedoCommand : Inherits BaseUndoRedoCommand
  115.  
  116.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control)
  117.        MyBase.New(AUndoMonitor, AMonitorControl)
  118.        UndoRedoData = GetSelection()
  119.    End Sub
  120.  
  121.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control, ByVal AUndoRedoData As Object)
  122.        MyBase.New(AUndoMonitor, AMonitorControl, AUndoRedoData)
  123.    End Sub
  124.  
  125.    Public ReadOnly Property Control() As ListBox
  126.        Get
  127.            Return CType(UndoRedoControl, ListBox)
  128.        End Get
  129.    End Property
  130.  
  131.    Private Sub RestoreSelection()
  132.        CType(UndoRedoMonitor, ListBoxMonitor).RestoreSelected(UndoRedoControl, CStr(UndoRedoData))
  133.    End Sub
  134.  
  135.    Private Function GetSelection() As Object
  136.        Return CType(UndoRedoMonitor, ListBoxMonitor).GetSelected(UndoRedoControl)
  137.    End Function
  138.  
  139.    Public Overrides Sub Undo()
  140.        MyBase.Undo()
  141.        RestoreSelection()
  142.    End Sub
  143.  
  144.    Public Overrides Sub Redo()
  145.        MyBase.Redo()
  146.        RestoreSelection()
  147.    End Sub
  148.  
  149.    Public Overrides Function CommandAsText() As String
  150.        Return String.Format("Select {0}", CStr(UndoRedoData))
  151.    End Function
  152. End Class
  153.  
  154.  
  155. '****************************************************************************************************************
  156. ' CheckBox
  157. '****************************************************************************************************************
  158. Public Class CheckBoxUndoRedoCommand : Inherits BaseUndoRedoCommand
  159.  
  160.    Protected ReadOnly Property UndoRedoCheckState() As CheckState
  161.        Get
  162.            Return CType(UndoRedoData, CheckState)
  163.        End Get
  164.    End Property
  165.  
  166.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control)
  167.        MyBase.New(AUndoMonitor, AMonitorControl)
  168.        UndoRedoData = Control.CheckState
  169.    End Sub
  170.  
  171.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control, ByVal AUndoRedoData As String)
  172.        MyBase.New(AUndoMonitor, AMonitorControl, AUndoRedoData)
  173.    End Sub
  174.  
  175.    Public ReadOnly Property Control() As CheckBox
  176.        Get
  177.            Return CType(UndoRedoControl, CheckBox)
  178.        End Get
  179.    End Property
  180.  
  181.    Public Overrides Sub Undo()
  182.        MyBase.Undo()
  183.        Control.CheckState = UndoRedoCheckState
  184.    End Sub
  185.  
  186.    Public Overrides Sub Redo()
  187.        MyBase.Redo()
  188.        Control.CheckState = UndoRedoCheckState
  189.    End Sub
  190.  
  191.    Public Overrides Function CommandAsText() As String
  192.        Return String.Format("Change to '{0}'", UndoRedoCheckState.ToString)
  193.    End Function
  194.  
  195. End Class
  196.  
  197. '****************************************************************************************************************
  198. ' RadioButton
  199. '****************************************************************************************************************
  200. Public Class RadioButtonUndoRedoCommand : Inherits BaseUndoRedoCommand
  201.  
  202.    Protected ReadOnly Property UndoRedoRadioButton() As RadioButton
  203.        Get
  204.            Return CType(UndoRedoData, RadioButton)
  205.        End Get
  206.    End Property
  207.  
  208.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control)
  209.        MyBase.New(AUndoMonitor, AMonitorControl)
  210.        UndoRedoData = Control.Checked
  211.    End Sub
  212.  
  213.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control, ByVal AUndoRedoData As Control)
  214.        MyBase.New(AUndoMonitor, AMonitorControl, AUndoRedoData)
  215.    End Sub
  216.  
  217.    Public ReadOnly Property Control() As RadioButton
  218.        Get
  219.            Return CType(UndoRedoControl, RadioButton)
  220.        End Get
  221.    End Property
  222.  
  223.    Public Overrides Sub Undo()
  224.        MyBase.Undo(UndoRedoRadioButton)
  225.        Control.Checked = False
  226.        If UndoRedoRadioButton IsNot Nothing Then
  227.            UndoRedoRadioButton.Checked = True
  228.        End If
  229.    End Sub
  230.  
  231.    Public Overrides Sub Redo()
  232.        MyBase.Redo(UndoRedoRadioButton)
  233.        If UndoRedoRadioButton IsNot Nothing Then
  234.            UndoRedoRadioButton.Checked = False
  235.        End If
  236.        Control.Checked = True
  237.    End Sub
  238.  
  239.    Public Overrides Function CommandAsText() As String
  240.        If UndoRedoRadioButton IsNot Nothing Then
  241.            Return String.Format("Invert '{0}'/'{1}'", Control.Text, UndoRedoRadioButton.Text)
  242.        Else
  243.            Return String.Format("Change '{0}'", Control.Text)
  244.        End If
  245.    End Function
  246.  
  247. End Class
  248.  
  249.  
  250. '****************************************************************************************************************
  251. ' MonthCalendar
  252. '****************************************************************************************************************
  253. Public Class MonthCalendarUndoRedoCommand : Inherits BaseUndoRedoCommand
  254.  
  255.    Protected ReadOnly Property UndoRedoSelectionRange() As SelectionRange
  256.        Get
  257.            Return CType(UndoRedoData, SelectionRange)
  258.        End Get
  259.    End Property
  260.  
  261.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control)
  262.        MyBase.New(AUndoMonitor, AMonitorControl)
  263.        UndoRedoData = Control.SelectionRange
  264.    End Sub
  265.  
  266.    Public Sub New(ByVal AUndoMonitor As BaseUndoRedoMonitor, ByVal AMonitorControl As Control, ByVal AUndoRedoData As SelectionRange)
  267.        MyBase.New(AUndoMonitor, AMonitorControl, AUndoRedoData)
  268.    End Sub
  269.  
  270.    Public ReadOnly Property Control() As MonthCalendar
  271.        Get
  272.            Return CType(UndoRedoControl, MonthCalendar)
  273.        End Get
  274.    End Property
  275.  
  276.    Public Overrides Sub Undo()
  277.        MyBase.Undo()
  278.        Control.SelectionRange = UndoRedoSelectionRange
  279.    End Sub
  280.  
  281.    Public Overrides Sub Redo()
  282.        MyBase.Redo()
  283.        Control.SelectionRange = UndoRedoSelectionRange
  284.    End Sub
  285.  
  286.    Public Overrides Function CommandAsText() As String
  287.        If Date.Equals(UndoRedoSelectionRange.Start, UndoRedoSelectionRange.End) Then
  288.            Return String.Format("Select date {0}", FormatDateTime(UndoRedoSelectionRange.Start, DateFormat.ShortDate))
  289.        Else
  290.        End If
  291.        Return String.Format("Change to '{0}'", String.Format("{0} until {1}", FormatDateTime(UndoRedoSelectionRange.Start, DateFormat.ShortDate), _
  292.                                                                               FormatDateTime(UndoRedoSelectionRange.End, DateFormat.ShortDate)))
  293.    End Function
  294.  
  295. End Class

2. Usarlo de esta manera:

Código
  1. Public Class Form1
  2.  
  3.    Private WithEvents frmUndoRedoManager As UndoRedoManager
  4.  
  5.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  6.        frmUndoRedoManager = New UndoRedoManager(Me)
  7.    End Sub
  8.  
  9.    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  10.        frmUndoRedoManager.Undo()
  11.    End Sub
  12.  
  13.    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  14.        frmUndoRedoManager.Redo()
  15.    End Sub
  16.  
  17. End Class

Saludos.
8758  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda con procedimiento en: 10 Julio 2013, 20:26 pm
-> http://msdn.microsoft.com/en-us/library/7taxzxka%28v=vs.110%29.aspx

Citar
AddHandler event, AddressOf eventhandler


Código
  1. ...
  2. addhandler picturebox2.click, addressof save
  3. end sub
  4.  
  5. private sub save(sender as object,  e as EventArgs)
  6. ...
  7. end sub

Saludos
8759  Informática / Software / Re: Modificar ISO. en: 10 Julio 2013, 20:11 pm
Pocos datos.

1. ¿Que sistema operativo es?
2. ¿Es una ISO bootable?
3. ¿Como se llama el software que está grabado en la ISO?

Quisiera saber si se puede modificar o no ésta ISO para que me pueda permitir elegir el lugar de destino,

Una ISO no tiene lógica... quiero decir que la ISO no es quien te guarda ese backup de tu sistema, sinó el software que haya dentro de dicha ISO, y nisiquiera sabemos el nombre del software... mucho menos podemos saber si dispone de opciones para modificar los parámetros de forma desatendida...

De todas formas con cualquier programa para manejar ISO's puedes modificar/extraer el contenido de una ISO... pero no sé exáctamente lo que pretendes hacer la verdad...

Saludos.
8760  Programación / Scripting / MOVIDO: Modificar ISO. en: 10 Julio 2013, 20:06 pm
El tema ha sido movido a Software.

http://foro.elhacker.net/index.php?topic=394500.0
Páginas: 1 ... 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 [876] 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 ... 1253
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines