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

 

 


Tema destacado: Estamos en la red social de Mastodon


  Mostrar Mensajes
Páginas: 1 ... 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 [987] 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 ... 1236
9861  Programación / .NET (C#, VB.NET, ASP) / Re: Mi app tarda demasiado en iniciar en: 4 Enero 2013, 12:31 pm
Gracias por comentar

para ser 1 simple aplicacion veo un uso excesivo de threads,y codigo .... no me imagino en 1 proyecto de mas de 30mil lineas :S

Entonces quizás no séa tán simple,

Uso un hilo para dibujar los checkboxes en el panel
Otro hilo para la casilla de "select all" (Para marcar/desmarcar todos los checkboxes)
Y otro hilo para el botón azúl de "play", para randomizar los archivos cuando la opción está activada.

Necesito usar los 3 threads símplemente para que no se cuelgue el form mientras se procesa esas cosas, creo que he hecho lo más correcto, lo erróneo habría sido dejar que el form se cuelgue mientras trabaja, vaya... si hay otra forma de hacerlo sin threads no sé hacerlo pero podrías decirme.





Citar
prueba en la linea 79 poner me.refresh, estoy seguro q no muestra el form, debido a las tareas del thread, posiblemente ya que el hilo esta siendo ejecutado en el preload del form...
(no he revisado el codigo fue simplemente viendolo por encima)
Eso antes no era un thread, la aplicación tardaba en iniciarse más como he comentado, lo puse en un thread y ahora tarda 1-2 segundos menos.

He probado con el me.refresh justo debajo de llamar a ese thread como me has dicho, no lo ha solucionado  :-\.




Citar
PORFAVOR
  ' Flush memory
   Declare Function SetProcessWorkingSetSize Lib "kernel32.dll" (ByVal process As IntPtr, ByVal minimumWorkingSetSize As Integer, ByVal maximumWorkingSetSize As Integer) As Integer
 
no uses API sin saber su verdadero USO.

No puedo decir que séa mentira lo que dices porque efectívamente no tengo idea de lo que hace la función de esa API, ví el snippet, leí muy buenos comentarios acerca del snippet, y lo usé,

pero lo que si puedo afirmar es que he monitorizado la aplicación, la app no crea ni "dumpea" memória por así decirlo en ningún archivo del disco duro cuando uso la función de esa API[/b][/i],

además el rendimiento no disminuye nada (Al menos en esta app) mejora complétamente, y se nota consideráblemente, el proceso de randomizado aumenta de velocidad en más de un 50%, y es por hacer uso de esa API, hice muchos tests estos días comparando velocidad y estoy seguro de esto que digo.





Citar
haces invoke en 1 therad hijo ? god...
Perdona que vuelva a discrepar, pero no sé cual es el error que dices que he cometido en ese thread,
si no uso los delegados en ese thread, manda el típico error de "cross-thread operation", por eso invoco los controles.


PD: Como puedes ver no hago las cosas a lo loco.


Un saludo!
9862  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.  
9863  Programación / Scripting / Re: Simulador de SO [Batch] en: 4 Enero 2013, 10:24 am
Casi sería más fácil hacer un simulador de aviones en Batch xD

tmb90, dejando a un lado el nivel que tengas tanto de Batch como de C/C++/C# (el cual no voy a comentar), Binary_Death tiene razón en los dos cosas,
La primera es que aún no hemos visto ni siquiera una imagen del simulador, y la segunda es que simplemente con que tengas indicios de C ya es una locura que vayas a hacerlo en Batch.

Pero bueno, no es una tarea imposible, alguien ya hizo esto en otro foro:


No tengo más imagenes y cuando me lo descargué no era compatible con mi Windows 7 (Creo que porque necesitaba mucho uso del Debug.exe) así que no sé como es "por dentro" ni si se le puede considerar un verdadero simulador de SO,
Pero si no recuerdo mal está todo hecho en Batch, menos las "extensiones" (llamemosle comandos externos) en C y Ruby (Alguna app mía xD), y algunos scripts en Batch.

Un saludo!
9864  Programación / Scripting / Re: Link para descargar colous.exe en: 4 Enero 2013, 10:13 am
Aquí tienes:

Cita de: Elektro H@cker en otro foro
Para instalar en modo silencioso sin interacción del usuario:

Código:

Código:
Colous.exe /S
 

http://exoshare.com/download.php?uid=1OD7ODMM

Extras del instalador: Unas imagenes de ejemplos de uso sacadas del tutorial de Bolivianito.


Saludos!
9865  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!
9866  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
9867  Programación / .NET (C#, VB.NET, ASP) / Re: (SOLUCIONADO) Crear un FileLink en un richtextbox, y un evento... en: 2 Enero 2013, 00:04 am
Export image > PNG

Nota: Perdón si te estoy desviando el tema, si no quieres que escriba mas sobre esto dímelo, lo entiendo

Eso díselo al mod  :silbar:,
El tema de este post ya está solucionado así que por mi no hay problema en que se cierre el post, o en seguir hablando sobre mi certero diseño xD.

Saludos!
9868  Programación / .NET (C#, VB.NET, ASP) / Re: (SOLUCIONADO) Crear un FileLink en un richtextbox, y un evento... en: 1 Enero 2013, 17:35 pm
Recomiendo el Sothink y el Aurora 3D logo maker, el primero es más en flash y formas/figuras modernas, el segundo es más para logotipos en 3D,
Ese logo no me llevó más de 3 minutos porque usé una plantilla que viene en el programa, pero para hacer algo realmente único obviamente hay que usar photoshop.

* Logo = Las letras con el reflejo y la figura de detrás de la "F"

El brillo (el foco de luz) es del wallpaper xD.

Saludos.
9869  Programación / Scripting / Re: Recopilatorio de manuales Python en: 1 Enero 2013, 11:48 am
entonces borro el post?
Sólamente los mods/adms podemos eliminar posts :P,
dejo el tema abierto, por si alquien quiere aportar algo nuevo de todas formas.

Saludos!
9870  Programación / Scripting / Re: Recopilatorio de manuales Python en: 1 Enero 2013, 08:25 am
@The_Mushr00m

Fíjate en los posts con chincheta.

Recopilatorio de temas interesantes - Scripting -

Citar
Python:

Foro:

Aprendiendo Python
http://foro.elhacker.net/index.php/topic,104880.0.html

Tutorial Python (ver links respuestas)
http://foro.elhacker.net/index.php/topic,79568.0.html

Python? (ver lnks respuestas)
http://foro.elhacker.net/index.php/topic,113874.0.html

Un buen manual para el PYTHON (ver links respuestas)
http://foro.elhacker.net/index.php/topic,120534.0.html

PODEROSO SOLO QUE A LEER Y PENSAR PYTHON
http://foro.elhacker.net/index.php/topic,126352.0.html

Manual Iniciación Python
http://foro.elhacker.net/index.php/topic,72226.0.html

Enviar Correo con Python
http://foro.elhacker.net/index.php/topic,132706.0.html

[PAPER] Compilación de scripts en Python a .exe
http://foro.elhacker.net/index.php/topic,332575.0.html

Pack de 15 cursos y tutoriales de Python en pdf
http://foro.elhacker.net/index.php/topic,369548.0.html

Saludos
Páginas: 1 ... 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 [987] 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines