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

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


  Mostrar Temas
Páginas: 1 ... 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 [80] 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 ... 105
791  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] Una ayuda sobre las variables dinámicas en: 6 Enero 2013, 00:46 am
¿Como puedo resolver esto en VB.NET?

EDITO:
Ups, pregunté demasiado rápido...

La solución:
Código
  1. My.Resources.ResourceManager.GetObject(variable)


Código
  1.    Public Sub LlamadaButton(ByVal sender As Object, ByVal e As System.EventArgs)
  2.        Dim ButtonN As Button = CType(sender, Button)
  3.        Dim ResourceName = ButtonN.Text
  4.        ReadDelimitedText(My.Resources._(ResourceName), ";")     ' El problema: My.Resources._(ResourceName)
  5.    End Sub

Error: Identifier expected
792  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] Evento "IsClicked" o algo parecido para los botones? en: 6 Enero 2013, 00:29 am
Me gustaría manejar el mismo evento para una serie de botones, algo así:

Código
  1.    Private Sub Buttons_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
  2.        If Button1.IsClicked = True Then MsgBox("Se ha clickado el botón 1")
  3.        If Button2.IsClicked = True Then MsgBox("Se ha clickado el botón 2")
  4.        If Button3.IsClicked = True Then MsgBox("Se ha clickado el botón 3")
  5.    End Sub

¿Es posible hacer eso?

Si no es posible...¿Que alternativas tengo para simplificarlo de alguna manera parecida, sin tener que hacer un sub por cada evento ".Click" de cada Botón?

Gracias.
793  Programación / .NET (C#, VB.NET, ASP) / Property Viewer en: 5 Enero 2013, 16:33 pm
¿Donde puedo descargar un buen property viewer?

Algo parecido a esto:



En especial ví uno muy bueno con una interfaz sencilla y un dialogo para cargar cualquier DLL dentro del programa y testear sus propiedades en tiempo real,
por ejemplo abres un control DLL que contiene un botón, en el property viewer, y puedes cambiar las propiedades del color en tiempo real...

Por desgracia perdí la aplicación :(.


794  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] Mi app tarda demasiado en iniciar en: 4 Enero 2013, 11:53 am
Hola, necesito ayuda con mi programa que tarda unos 10 seg. en visualizarse el form principal, y se carga antes el notifyicon que el form con unos segundos de diferencia xD  ¿Eso es normal?

Antes tardaba incluso más en cargar, pero he mejorado el tiempo de carga ejecutando el sub importante un nuevo thread.

En el form load solo hago 4 estúpidas compbocaciones y lo importante corre en un thread separado, por eso pienso que no debería tardar tanto en mostrarse el form...

¿Que puede ser?, ¿Ven algo extraño en el form load?

Bueno, voy a intentar dar datos útiles:



Proyecto: Windows form
Form: double buffered
Framework: 4.0
Controles de terceros: un GroupPanel con degradado, un dialogo de carpetas, y una barra de progreso. (La barra de progreso está visible por defecto.)
Recursos que tiene que cargar el exe: 3 dll's que pesan en total 5 MB. están separados, aunque también comparé la velocidad unificandolo con .NET shrink y el resultado es el mismo.
Prefetch de windows: Desactivado (No pienso activarlo para solucionar el problema)


El proyecto entero:
http://www.mediafire.com/?zije2zggdmv669t

Como podeis ver, es una app sencilla, pero aparte de que tarda en iniciarse, me consumía muchos muchos recursos, si no le libero memória como hago en el form antes consumía 40 mb después de iniciarse SIN TOCAR NADA, ni con dispose lo arreglaba, ahora solo consume 4-5 mb, pero digo que eso es extraño...

El form principal:
Código
  1. Public Class Form1
  2.  
  3. #Region "Declarations"
  4.  
  5.    Dim filesystem As Object
  6.    Dim ThisDir As Object
  7.    Dim mcheck(0) As CheckBox
  8.    Dim labelnum = 0
  9.    Public Shared playerargs As String
  10.    Public Shared Temp_file As String = System.IO.Path.GetTempPath & "\PlayDir_tmp.m3u"
  11.  
  12.    ' Checkboxes Thread
  13.    Public checkboxes_thread As System.Threading.Thread = New Threading.Thread(AddressOf updatecheckboxes)
  14.  
  15.    ' Select all Thread
  16.    Public select_all_thread As System.Threading.Thread = New Threading.Thread(AddressOf Select_or_unselect_all)
  17.  
  18.    ' Randomize thread
  19.    Public Thread_is_completed As Boolean = False
  20.    Public Want_to_abort_thread As Boolean = False
  21.    Public Want_to_cancel_thread As Boolean = False
  22.  
  23.    ' Flush memory
  24.    Declare Function SetProcessWorkingSetSize Lib "kernel32.dll" (ByVal process As IntPtr, ByVal minimumWorkingSetSize As Integer, ByVal maximumWorkingSetSize As Integer) As Integer
  25.  
  26. #End Region
  27.  
  28. #Region "Properties"
  29.  
  30.    'userSelectedPlayerFilePath
  31.    Public Property userSelectedPlayerFilePath() As String
  32.        Get
  33.            Return Textbox_Player.Text
  34.        End Get
  35.        Set(value As String)
  36.            Textbox_Player.Text = value
  37.        End Set
  38.    End Property
  39.  
  40.    ' userSelectedFolderPath
  41.    Public Property userSelectedFolderPath() As String
  42.        Get
  43.            Return Textbox_Folder.Text
  44.        End Get
  45.        Set(value As String)
  46.            Textbox_Folder.Text = value
  47.        End Set
  48.    End Property
  49.  
  50. #End Region
  51.  
  52. #Region "Load / Close"
  53.  
  54.    ' Form load
  55.    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  56.  
  57.        If Not My.Computer.FileSystem.DirectoryExists(My.Settings.folderpath) Then
  58.            My.Settings.folderpath = Nothing
  59.            ProgressBar.Visible = False
  60.            Me.Size = New System.Drawing.Size(Me.Width, 240)
  61.            Panel_Folders.Size = New System.Drawing.Size(0, 0)
  62.            Checkbox_SelectAll.Enabled = False
  63.        Else
  64.            Checkbox_SelectAll.Enabled = True
  65.            Textbox_Folder.Text = My.Settings.folderpath
  66.            ProgressBar.Visible = True
  67.        End If
  68.  
  69.        If Not My.Computer.FileSystem.FileExists(My.Settings.playerpath) Then
  70.            My.Settings.playerpath = Nothing
  71.        Else
  72.            Textbox_Player.Text = My.Settings.playerpath
  73.        End If
  74.  
  75.        If My.Settings.randomize = True Then Checkbox_Randomize.Checked = True
  76.        If My.Settings.autoclose = True Then Checkbox_AutoClose.Checked = True
  77.  
  78.        Updatecheckboxes_Start()
  79.  
  80.        My.Settings.Save()
  81.  
  82.    End Sub
  83.  
  84.    ' Form close
  85.    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  86.        Want_to_abort_thread = True
  87.  
  88.        SyncLock thread_1 'ensures all other threads running stop
  89.            thread_1.Abort()
  90.        End SyncLock
  91.  
  92.        If Not My.Settings.folderpath = Nothing Then
  93.            GenerarPropiedades()
  94.        End If
  95.  
  96.        My.Settings.Save()
  97.  
  98.        NotifyIcon1.Visible = False
  99.        NotifyIcon1.Dispose()
  100.  
  101.    End Sub
  102.  
  103. #End Region
  104.  
  105. #Region "Save / Get settings"
  106.  
  107.    ' Generate properties
  108.    Public Sub GenerarPropiedades()
  109.  
  110.        Dim mCheckados(0) As Int32
  111.        Dim Cuantos As Int32 = 0
  112.        Dim empty = Nothing
  113.  
  114.        Try
  115.            For Each c As CheckBox In Panel_Folders.Controls
  116.                empty = False
  117.            Next
  118.  
  119.            If Not empty = False Then
  120.                My.Settings.Valores = Nothing
  121.            Else
  122.                For i As Int32 = 0 To mcheck.Length - 1
  123.                    If mcheck(i).Checked = True Then
  124.                        Cuantos += 1
  125.                        Array.Resize(mCheckados, Cuantos)
  126.                        mCheckados(Cuantos - 1) = i + 1
  127.                    End If
  128.                Next
  129.                My.Settings.Valores = mCheckados
  130.            End If
  131.        Catch
  132.        End Try
  133.  
  134.    End Sub
  135.  
  136.    ' Load properties
  137.    Public Sub CargarPropiedades()
  138.        If My.Settings.Valores IsNot Nothing Then
  139.            For Each indiceCheckado As Int32 In My.Settings.Valores()
  140.                If Not indiceCheckado = 0 Then
  141.                    InvokeControl(mcheck(indiceCheckado - 1), Sub(x) x.Checked = True)
  142.                End If
  143.            Next
  144.        End If
  145.    End Sub
  146.  
  147. #End Region
  148.  
  149. #Region "Checkboxes"
  150.  
  151.    ' Checkbox thread start
  152.    Private Sub Updatecheckboxes_Start()
  153.        checkboxes_thread.Abort()
  154.        checkboxes_thread = New Threading.Thread(AddressOf updatecheckboxes)
  155.        checkboxes_thread.IsBackground = False
  156.        checkboxes_thread.Start()
  157.    End Sub
  158.  
  159.    ' Checkbox thread
  160.    Public Sub updatecheckboxes()
  161.  
  162.        If Not My.Settings.folderpath Is Nothing Then
  163.  
  164.            InvokeControl(Checkbox_SelectAll, Sub(x) x.Enabled = False)
  165.            InvokeControl(Checkbox_SelectAll, Sub(x) x.Checked = False)
  166.            InvokeControl(Button_PLAY, Sub(x) x.Enabled = False)
  167.            InvokeControl(Button_PLAY, Sub(x) x.BackColor = Color.FromArgb(50, 50, 50))
  168.            InvokeControl(Panel_Folders, Sub(x) x.Enabled = False)
  169.            InvokeControl(ProgressBar, Sub(x) x.TextFormat = "Sorting folders, please wait...")
  170.            InvokeControl(ProgressBar, Sub(x) x.TextShow = ProgBar.ProgBarPlus.eTextShow.FormatString)
  171.  
  172.            ' delete the old checkboxes
  173.            InvokeControl(Panel_Folders, Sub(x) x.Controls.Clear())
  174.  
  175.            ' create the new checkboxes
  176.            Dim filesystem = CreateObject("Scripting.FileSystemObject")
  177.            Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath)
  178.            Dim i As Int32 = 0
  179.            Dim pos As Int32 = 5
  180.            For Each folder In ThisDir.Subfolders
  181.                Array.Resize(mcheck, i + 1)
  182.                mcheck(i) = New CheckBox
  183.                With mcheck(i)
  184.                    .BackColor = Color.Transparent
  185.                    .ForeColor = Color.White
  186.                    .AutoSize = False
  187.                    .Size = New Point(338, 20)
  188.                    .Location = New Point(1, pos)
  189.                    .Name = "CheckBox" & i + 1
  190.                    .Text = folder.Name
  191.                    .Cursor = Cursors.Hand
  192.                End With
  193.                InvokeControl(Panel_Folders, Sub(x) x.Controls.Add(mcheck(i)))
  194.                AddHandler mcheck(i).CheckedChanged, AddressOf LlamadaCheckBox
  195.                i += 1
  196.                pos += 20
  197.            Next
  198.  
  199.            ' Load checked checkboxes
  200.            CargarPropiedades()
  201.  
  202.            ' Reset saved checked checkboxes
  203.            My.Settings.Valores = Nothing
  204.  
  205.            InvokeControl(ProgressBar, Sub(x) x.TextShow = ProgBar.ProgBarPlus.eTextShow.None)
  206.            InvokeControl(ProgressBar, Sub(x) x.TextFormat = "Sorting files... {1}% Done")
  207.            InvokeControl(Panel_Folders, Sub(x) x.Enabled = True)
  208.            InvokeControl(Button_PLAY, Sub(x) x.Enabled = True)
  209.            InvokeControl(Button_PLAY, Sub(x) x.BackColor = Color.SteelBlue)
  210.            InvokeControl(Checkbox_SelectAll, Sub(x) x.Enabled = True)
  211.            InvokeControl(Panel_Folders, Sub(x) x.Focus())
  212.  
  213.        End If
  214.  
  215.        FlushMemory("PlayDir")
  216.    End Sub
  217.  
  218.    ' Checkbox events
  219.    Public Sub LlamadaCheckBox(ByVal sender As Object, ByVal e As System.EventArgs)
  220.        Dim filesystem = CreateObject("Scripting.FileSystemObject")
  221.        Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath)
  222.        Dim CheckboxN As CheckBox = CType(sender, CheckBox)
  223.  
  224.        If CheckboxN.Checked = True Then
  225.            labelnum += 1
  226.            playerargs = playerargs & " " & ControlChars.Quote & System.IO.Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote
  227.        Else
  228.            labelnum -= 1
  229.            playerargs = Replace(playerargs, " " & ControlChars.Quote & System.IO.Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote, "")
  230.        End If
  231.  
  232.        If labelnum < 0 Then
  233.            labelnum = 0
  234.            InvokeControl(Label_SelectedFolders, Sub(x) x.Text = "0 folders selected")
  235.        Else
  236.            InvokeControl(Label_SelectedFolders, Sub(x) x.Text = labelnum & " folders selected")
  237.        End If
  238.  
  239.    End Sub
  240.  
  241. #End Region
  242.  
  243. #Region "Buttons"
  244.  
  245.    ' Folder button
  246.    Public Sub Button_SearchFolder_Click(sender As Object, e As EventArgs) Handles Button_SearchFolder.Click
  247.        Dim folderselect As New Ookii.Dialogs.VistaFolderBrowserDialog
  248.        folderselect.ShowNewFolderButton = True
  249.        If folderselect.ShowDialog.ToString() = "OK" Then
  250.            My.Settings.Valores = Nothing
  251.            labelnum = 0
  252.            Label_SelectedFolders.Text = labelnum & " folders selected"
  253.            userSelectedFolderPath = folderselect.SelectedPath
  254.            My.Settings.folderpath = folderselect.SelectedPath
  255.            My.Settings.Save()
  256.            playerargs = Nothing
  257.            Me.Size = New System.Drawing.Size(400, 550)
  258.            Panel_Folders.Size = New System.Drawing.Size(360, 250)
  259.            ProgressBar.Visible = True
  260.            Updatecheckboxes_Start()
  261.        End If
  262.    End Sub
  263.  
  264.    ' Player button
  265.    Public Sub Button_SearchPlayer_Click(sender As Object, e As EventArgs) Handles Button_SearchPlayer.Click
  266.        Dim playerselected As New OpenFileDialog()
  267.        playerselected.InitialDirectory = Environ("programfiles")
  268.        playerselected.Title = "Select your favorite music player"
  269.        playerselected.Filter = "Music players|bsplayer.exe;mpc.exe;mpc-hc.exe;mpc-hc64.exe;umplayer.exe;vlc.exe;winamp.exe;wmp.exe"
  270.        PlayerDialog.FilterIndex = 1
  271.        Dim selection As System.Windows.Forms.DialogResult = playerselected.ShowDialog()
  272.        If selection = DialogResult.OK Then
  273.            userSelectedPlayerFilePath = playerselected.FileName
  274.            My.Settings.playerpath = playerselected.FileName
  275.            My.Settings.Save()
  276.        End If
  277.        FlushMemory("PlayDir")
  278.    End Sub
  279.  
  280.    ' Refresh button
  281.    Private Sub Button_Refresh_Click(sender As Object, e As EventArgs) Handles Button_Refresh.Click
  282.        labelnum = 0
  283.        Label_SelectedFolders.Text = "0 folders selected"
  284.        Updatecheckboxes_Start()
  285.    End Sub
  286.  
  287.    ' Play button
  288.    Public Sub Button_PLAY_Click(sender As Object, e As EventArgs) Handles Button_PLAY.Click
  289.        Me.Focus()
  290.  
  291.        If Button_PLAY.Tag = "Cancel" Then
  292.            Want_to_cancel_thread = True
  293.            Want_to_abort_thread = True
  294.            While Not Thread_is_completed = True
  295.                Application.DoEvents()
  296.            End While
  297.            ProgressBar.ResetBar()
  298.            ProgressBar.Max = 100
  299.            ProgressBar.Value = 0
  300.        Else
  301.            If Not System.IO.File.Exists(Textbox_Player.Text) Then
  302.                MessageBox.Show("You need to select a music player...", "PlayDir", MessageBoxButtons.OK, MessageBoxIcon.Error)
  303.            Else
  304.                If Not playerargs = Nothing Then
  305.                    Checkbox_Randomize.Enabled = False
  306.                    Checkbox_SelectAll.Enabled = False
  307.                    Button_PLAY.Image = My.Resources.Cancel_button
  308.                    Button_PLAY.Tag = "Cancel"
  309.                    Button_PLAY.BackColor = Color.Red
  310.                    ProgressBar.Max = 100
  311.                    ProgressBar.TextShow = ProgBar.ProgBarPlus.eTextShow.FormatString
  312.                    If Checkbox_Randomize.Checked = True Then
  313.                        Thread_is_completed = False
  314.                        Dim thread_1 As System.Threading.Thread = New Threading.Thread(AddressOf mithread)
  315.                        thread_1.IsBackground = True
  316.                        thread_1.Start()
  317.                        While Not Thread_is_completed = True
  318.                            Application.DoEvents()
  319.                        End While
  320.                    Else
  321.                        If Not thread_1.ThreadState = Threading.ThreadState.AbortRequested Or Want_to_abort_thread = True Or Want_to_cancel_thread = True Then
  322.                            Process.Start(userSelectedPlayerFilePath, playerargs)
  323.                        End If
  324.                    End If
  325.                    If Checkbox_AutoClose.Checked = True And Not Want_to_cancel_thread = True Then Me.Close()
  326.                Else
  327.                    If Textbox_Player.Text = "Select a music player..." Then MessageBox.Show("You need to select a music player...", "PlayDir", MessageBoxButtons.OK, MessageBoxIcon.Error)
  328.                    If Textbox_Folder.Text = "Select a folder..." Then MessageBox.Show("You need to open a folder with music files...", "PlayDir", MessageBoxButtons.OK, MessageBoxIcon.Error)
  329.                    MessageBox.Show("You need to select at least one folder...", "PlayDir", MessageBoxButtons.OK, MessageBoxIcon.Stop)
  330.                End If
  331.            End If
  332.            Want_to_abort_thread = False
  333.            Want_to_cancel_thread = False
  334.            Button_PLAY.Image = My.Resources.Play
  335.            Button_PLAY.Tag = "Play"
  336.            Button_PLAY.BackColor = Color.SteelBlue
  337.            ProgressBar.TextShow = ProgBar.ProgBarPlus.eTextShow.None
  338.            Panel_Folders.Focus()
  339.            Checkbox_Randomize.Enabled = True
  340.            Checkbox_SelectAll.Enabled = True
  341.            FlushMemory("PlayDir")
  342.        End If
  343.    End Sub
  344.  
  345.    ' Auto-close
  346.    Public Sub Checkbox_AutoClose_CheckedChanged(sender As Object, e As EventArgs) Handles Checkbox_AutoClose.CheckedChanged
  347.        If Checkbox_AutoClose.Checked = True Then
  348.            Picturebox_AutoClose.Visible = True
  349.            My.Settings.autoclose = True
  350.        Else
  351.            Picturebox_AutoClose.Visible = False
  352.            My.Settings.autoclose = False
  353.        End If
  354.        Panel_Folders.Focus()
  355.        My.Settings.Save()
  356.    End Sub
  357.  
  358.    ' Randomize
  359.    Public Sub Checkbox_Randomize_CheckedChanged(sender As Object, e As EventArgs) Handles Checkbox_Randomize.CheckedChanged
  360.        If Checkbox_Randomize.Checked = True Then
  361.            Picturebox_Randomize.Visible = True
  362.            My.Settings.randomize = True
  363.        Else
  364.            Picturebox_Randomize.Visible = False
  365.            My.Settings.randomize = False
  366.        End If
  367.        Panel_Folders.Focus()
  368.        My.Settings.Save()
  369.    End Sub
  370.  
  371.    ' Select  ALL checkboxes
  372.    Public Sub Checkbox_SelectAll_CheckedChanged(sender As Object, e As EventArgs) Handles Checkbox_SelectAll.CheckedChanged
  373.        select_all_thread.Abort()
  374.        select_all_thread = New Threading.Thread(AddressOf Select_or_unselect_all)
  375.        select_all_thread.IsBackground = True
  376.        select_all_thread.Start()
  377.        Panel_Folders.Focus()
  378.    End Sub
  379.  
  380.    Private Sub Select_or_unselect_all()
  381.        CheckForIllegalCrossThreadCalls = False
  382.        If Checkbox_SelectAll.Checked = False Then
  383.  
  384.            InvokeControl(Picturebox_SelectAll, Sub(x) x.Visible = False)
  385.            InvokeControl(Checkbox_SelectAll, Sub(x) x.Text = "Select all")
  386.  
  387.            For Each ControlName In Panel_Folders.Controls
  388.                ControlName.Checked = False
  389.            Next
  390.  
  391.        Else
  392.  
  393.            InvokeControl(Picturebox_SelectAll, Sub(x) x.Visible = True)
  394.            InvokeControl(Checkbox_SelectAll, Sub(x) x.Text = "Select none")
  395.  
  396.            For Each ControlName In Panel_Folders.Controls
  397.                ControlName.Checked = True
  398.            Next
  399.  
  400.        End If
  401.        CheckForIllegalCrossThreadCalls = True
  402.        FlushMemory("PlayDir")
  403.    End Sub
  404.  
  405. #End Region
  406.  
  407. #Region "Drag & Drop"
  408.  
  409.    Private Sub Textboxes_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Textbox_Folder.DragDrop, Panel_Folders.DragDrop
  410.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  411.            Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)
  412.            Dim attributes = Objetos(0)
  413.            If System.IO.Directory.Exists(attributes) Then
  414.                Textbox_Folder.Text = Objetos(0)
  415.                userSelectedFolderPath = Objetos(0)
  416.                My.Settings.folderpath = Objetos(0)
  417.                My.Settings.Save()
  418.                playerargs = Nothing
  419.                Me.Size = New System.Drawing.Size(400, 540)
  420.                Panel_Folders.Size = New System.Drawing.Size(360, 250)
  421.                labelnum = 0
  422.                Label_SelectedFolders.Text = "0 folders selected"
  423.                Updatecheckboxes_Start()
  424.            Else
  425.                MessageBox.Show("Invalid directory!", "PlayDir", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  426.            End If
  427.        End If
  428.    End Sub
  429.  
  430.    Private Sub Textboxes_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Textbox_Folder.DragEnter, Panel_Folders.DragEnter
  431.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  432.            e.Effect = DragDropEffects.All
  433.        End If
  434.    End Sub
  435.  
  436. #End Region
  437.  
  438. #Region " Notify icon "
  439.  
  440.    ' Form resize
  441.    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
  442.        If Me.WindowState = FormWindowState.Minimized Then
  443.            Me.WindowState = FormWindowState.Normal
  444.            Me.Hide()
  445.        End If
  446.        FlushMemory("PlayDir")
  447.    End Sub
  448.  
  449.    ' Double click
  450.    Private Sub NotifyIcon1_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
  451.        If Me.Visible = True Then
  452.            Me.Hide()
  453.        Else
  454.            Me.Show()
  455.        End If
  456.        FlushMemory("PlayDir")
  457.    End Sub
  458.  
  459.    ' right click
  460.    Private Sub NotifyIcon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
  461.        If e.Button = MouseButtons.Right Then NotifyIcon1.ContextMenuStrip.Show()
  462.        FlushMemory("PlayDir")
  463.    End Sub
  464.  
  465.    ' Mostrar
  466.    Private Sub MostrarToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ContextMenuStrip1.Click
  467.        Me.Show()
  468.        FlushMemory("PlayDir")
  469.    End Sub
  470.  
  471.    ' Ocultar
  472.    Private Sub OcultarToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles Ocultar.Click
  473.        Me.Hide()
  474.        FlushMemory("PlayDir")
  475.    End Sub
  476.  
  477.    ' Salir
  478.    Private Sub SalirToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles Salir.Click
  479.        Me.Close()
  480.    End Sub
  481.  
  482. #End Region
  483.  
  484. #Region " Tooltip events "
  485.  
  486.    Private Sub SuperTooltip_TooltipClosed(sender As Object, e As EventArgs) Handles SuperTooltip1.TooltipClosed
  487.        FlushMemory("PlayDir")
  488.    End Sub
  489.  
  490. #End Region
  491.  
  492. #Region " Randomize Thread "
  493.  
  494.    Public thread_1 As System.Threading.Thread = New Threading.Thread(AddressOf mithread)
  495.  
  496.    Public Sub mithread()
  497.  
  498.        Dim Str As String
  499.        Dim Pattern As String = ControlChars.Quote
  500.        Dim ArgsArray() As String
  501.        Str = Replace(playerargs, " " & ControlChars.Quote, "")
  502.        ArgsArray = Split(Str, Pattern)
  503.        Using objWriter As New System.IO.StreamWriter(Temp_file, False, System.Text.Encoding.UTF8)
  504.            Dim n As Integer = 0
  505.            Dim count As Integer = 0
  506.            Dim foldercount As Integer = -1
  507.  
  508.            For Each folder In ArgsArray
  509.                foldercount += 1
  510.                If foldercount > 1 Then
  511.                    InvokeControl(ProgressBar, Sub(x) x.Max = foldercount)
  512.                End If
  513.            Next
  514.  
  515.            If foldercount = 1 Then
  516.                For Each folder In ArgsArray
  517.                    If Not folder = Nothing Then
  518.                        Dim di As New IO.DirectoryInfo(folder)
  519.                        Dim files As IO.FileInfo() = di.GetFiles("*")
  520.                        Dim file As IO.FileInfo
  521.                        InvokeControl(ProgressBar, Sub(x) x.Max = files.Count)
  522.                        For Each file In files
  523.                            If Want_to_abort_thread = False And Want_to_cancel_thread = False Then
  524.                                n += 1
  525.                                CheckPrimeNumber(n)
  526.                                count += 1
  527.                                If file.Extension.ToLower = ".lnk" Then
  528.                                    Dim ShotcutTarget As String = Shortcut.ResolveShortcut((file.FullName).ToString())
  529.                                    objWriter.Write(ShotcutTarget & vbCrLf)
  530.                                Else
  531.                                    objWriter.Write(file.FullName & vbCrLf)
  532.                                End If
  533.                            Else
  534.                                Exit For
  535.                            End If
  536.                        Next
  537.                    End If
  538.                Next
  539.  
  540.            ElseIf foldercount > 1 Then
  541.                For Each folder In ArgsArray
  542.                    If Not folder = Nothing Then
  543.                        Dim di As New IO.DirectoryInfo(folder)
  544.                        Dim files As IO.FileInfo() = di.GetFiles("*")
  545.                        Dim file As IO.FileInfo
  546.                        For Each file In files
  547.                            If Want_to_abort_thread = False And Want_to_cancel_thread = False Then
  548.                                If file.Extension.ToLower = ".lnk" Then
  549.                                    Dim ShotcutTarget As String = Shortcut.ResolveShortcut((file.FullName).ToString())
  550.                                    objWriter.Write(ShotcutTarget & vbCrLf)
  551.                                Else
  552.                                    objWriter.Write(file.FullName & vbCrLf)
  553.                                End If
  554.                            Else
  555.                                Exit For
  556.                            End If
  557.                        Next
  558.                    End If
  559.                    InvokeControl(ProgressBar, Sub(x) x.Value += 1)
  560.                Next
  561.            End If
  562.        End Using
  563.  
  564.        If Not thread_1.ThreadState = Threading.ThreadState.AbortRequested And Not Want_to_abort_thread = True And Not Want_to_cancel_thread = True Then
  565.            Randomize_a_file.RandomizeFile(Temp_file)
  566.            InvokeControl(ProgressBar, Sub(x) x.Value = 0)
  567.            Try
  568.                Process.Start(userSelectedPlayerFilePath, ControlChars.Quote & Temp_file.ToString() & ControlChars.Quote)
  569.            Catch
  570.            End Try
  571.        End If
  572.        Thread_is_completed = True
  573.    End Sub
  574.  
  575. #End Region
  576.  
  577. #Region " Check prime number function "
  578.    Private Sub CheckPrimeNumber(ByVal number As Integer)
  579.        Dim IsPrime As Boolean = True
  580.        For i = 2 To number / 2
  581.            If (number Mod i = 0) Then
  582.                IsPrime = False
  583.                Exit For
  584.            End If
  585.        Next i
  586.        If IsPrime = True Then
  587.            InvokeControl(ProgressBar, Sub(x) x.Value = number)
  588.        End If
  589.    End Sub
  590. #End Region
  591.  
  592. #Region " InvokeControl "
  593.  
  594.    Public Sub InvokeControl(Of T As Control)(ByVal Control As T, ByVal Action As Action(Of T))
  595.        If Not Want_to_abort_thread = True Then
  596.            Try
  597.                If Control.InvokeRequired Then
  598.                    Control.Invoke(New Action(Of T, Action(Of T))(AddressOf InvokeControl), New Object() {Control, Action})
  599.                Else
  600.                    Action(Control)
  601.                End If
  602.            Catch
  603.            End Try
  604.        End If
  605.    End Sub
  606. #End Region
  607.  
  608. #Region "Flush memory"
  609.  
  610.    Public Sub FlushMemory(process_to_flush)
  611.        Try
  612.            GC.Collect()
  613.            GC.WaitForPendingFinalizers()
  614.            If (Environment.OSVersion.Platform = PlatformID.Win32NT) Then
  615.                SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1)
  616.                Dim myProcesses As Process() = Process.GetProcessesByName(process_to_flush)
  617.                Dim myProcess As Process
  618.                For Each myProcess In myProcesses
  619.                    SetProcessWorkingSetSize(myProcess.Handle, -1, -1)
  620.                Next myProcess
  621.            End If
  622.        Catch
  623.        End Try
  624.    End Sub
  625.  
  626. #End Region
  627.  
  628. End Class
  629.  
  630.  
  631.  
795  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] ¿Como se hace un "NumberPicker"? en: 2 Enero 2013, 11:48 am
Quiero hacer esos "selectores" de números, con sus botones de subir/bajar a la derecha igual que en esta imagen:



¿Que control necesito usar?

Una vez lo intenté hacer con un ComboBox y haciendo uso del system.windows.time, pero me salió como el culo :laugh:, toda la info que encontré es para hacer un "TimePicker", pero no es lo mismo :-/

¿Hay algún control nativo o extendido que esté pensado para eso?

Un saludo!
796  Programación / .NET (C#, VB.NET, ASP) / ¿Como compilo esto en una DLL? en: 2 Enero 2013, 00:08 am
Quiero compilar este control para que el archivo resultante séa una dll, así de sencillo  :-\.

Lo intento creando un nuevo proyecto de tipo "class library" como me dijo Seba123Neo, el problema es que no me encuentra el "Listview" en el inherits...

He intentado importar algo sin tener conocimiento de si debo importar algo primero,
He buscado como hacerlo en Google,
He descargado listviews extendidas para ver que le falta a este código (Ni idea),
... Lo he intentado, ¿Vale? xD

Código
  1. Public Class Listview_Unflickered
  2.  
  3.       Inherits ListView
  4.  
  5.       Public Sub New()
  6.           MyBase.New()
  7.           ' This bypass the flashing effect when adding items into the Listview
  8.           Me.DoubleBuffered = True
  9.       End Sub
  10.  
  11.   End Class
797  Programación / .NET (C#, VB.NET, ASP) / Observaciones sobre el diseño de mi app en: 31 Diciembre 2012, 18:28 pm
¿Le ven alguna mejora al diseño de la aplicación?





Los botones quizás sond emasiado grandes, pero lo que más me preocupa es el panel de opciones, que cada vez se hace más grande (más opciones nuevas que añadir...) y ya no se donde meterlo ni como ajustarlo de tamaño y posición, a mi no me convence mucho como está ahora mismo. ¿Le ven alguna solución a eso?

PD: No quiero usar pestañas, por eso... xD.
798  Programación / .NET (C#, VB.NET, ASP) / Listview, ¿ordenar el contenido al clickar sobre una columna? en: 31 Diciembre 2012, 13:40 pm
¿Me pueden decir alguna manera sencilla para ordenar alfabéticamente la columna de "problem" al pulsar click sobre el nombre de la columna?

O al menos, ¿Como se llama el evento que debo manejar? :S

Gracias.

799  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] ¿Como evitar el efecto Flashing de un listview? en: 31 Diciembre 2012, 12:45 pm
Cuando añado un item al listrview, hace un flash, un efecto muy desagradable.

Lo he intentado TODO, AddRange, Suspendlayout, Me.Doublebuffered, y por último BeginUpdate... Nada lo ha resuelto.

Código
  1. for each file....
  2.  
  3.                Problems += 1
  4.                str(0) = Problems
  5.                str(1) = str(1).Substring(2)
  6.                str(2) = File.FullName
  7.                itm = New ListViewItem(str)
  8.                InvokeControl(ListView, Sub(x) x.BeginUpdate())
  9.                InvokeControl(ListView, Sub(x) x.Items.Add(itm))
  10.                InvokeControl(ListView, Sub(x) x.EnsureVisible(ListView.Items.Count - 1))
  11.                InvokeControl(ListView, Sub(x) x.EndUpdate())
  12. end for...
  13.  

Esto es otra variante del código, aquí noto cierta mejora (Flashes más cortos):
Código
  1.   Private Sub AddItemToListView()
  2.        str(0) = Problems
  3.        str(1) = str(1).Substring(2)
  4.        str(2) = File.FullName
  5.        itm = New ListViewItem(str)
  6.        ListView.SuspendLayout()
  7.        InvokeControl(ListView, Sub(x) x.BeginUpdate())
  8.        InvokeControl(ListView, Sub(x) x.Items.Add(itm))
  9.        InvokeControl(ListView, Sub(x) x.EnsureVisible(ListView.Items.Count - 1))
  10.        InvokeControl(ListView, Sub(x) x.EndUpdate())
  11.        ListView.ResumeLayout()
  12.        If NumberIsOdd(Problems) Then
  13.            itm.BackColor = Color.FromArgb(15, 15, 15)
  14.        Else
  15.            itm.BackColor = Color.FromArgb(30, 30, 30)
  16.        End If
  17.    End Sub



Sé que el AddRange y BeginUpdate están pensados para añadir varios items, pero como podeis comprobar en el ejemplo es que yo necesito añadirlos uno por uno.

¿Que puedo hacer?
800  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] ¿Como eliminar un NotifyIcon al cerrar la APP? en: 28 Diciembre 2012, 12:01 pm
Necesito terminar la ejecución de mi APP con un "End",
Todos sabemos que si matamos una aplicación, el icono del SystemTray se queda en memoria, es decir, seguirá visible...
Pero por otro lado imagino que se debe poder eliminar el icono del systray en tiempo de ejecución, antes de matar indebídamente la APP, para que eso no suceda.

¿Como puedo eliminar el NotifyIcon?

Código
  1.    ' Close
  2.    Private Sub Form_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  3.        Worker.Dispose() ' Liberar los recursos del BackgroundWorker
  4.  
  5.        ' Eliminar la visibilidad del SysTrayMenu antes de matar la APP, para que no se quede visible en el SystemTray...
  6.        SystrayMenu.Visible = False
  7.        SystrayMenu.Dispose()
  8.  
  9.        End ' Matar todo lo relacionado con la APP
  10.    End Sub

EDITO: Ups, con las prisas no me dí cuenta, había confundido el nombre del menú con otro menú que tengo en la APP,
Tema solucionado XD
Páginas: 1 ... 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 [80] 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 ... 105
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines