Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
ProCam - MainForm.vb

MainForm.vb

Caricato da: Lollo 97
Scarica il programma completo

  1. Imports System.Drawing.Imaging
  2. Imports System.IO
  3. Public Class ProCam
  4.         Inherits System.Windows.Forms.Form
  5.        
  6.         #Region " Windows Form Designer generated code "
  7.        
  8.         Public Sub New()
  9.                 MyBase.New()
  10.                
  11.                 'This call is required by the Windows Form Designer.
  12.                 InitializeComponent()
  13.                
  14.                 'Add any initialization after the InitializeComponent() call
  15.                
  16.         End Sub
  17.        
  18.         'Form overrides dispose to clean up the component list.
  19.         Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  20.                 If disposing Then
  21.                         If Not (components Is Nothing) Then
  22.                                 components.Dispose()
  23.                         End If
  24.                 End If
  25.                 MyBase.Dispose(disposing)
  26.         End Sub
  27.        
  28.         'Required by the Windows Form Designer
  29.         Private components As System.ComponentModel.IContainer
  30.        
  31.         'NOTE: The following procedure is required by the Windows Form Designer
  32.         'It can be modified using the Windows Form Designer.  
  33.         'Do not modify it using the code editor.
  34.         Friend WithEvents grpFile As System.Windows.Forms.GroupBox
  35.         Friend WithEvents buttonSave As System.Windows.Forms.Button
  36.         Friend WithEvents txtFileName As System.Windows.Forms.TextBox
  37.         Friend WithEvents grpDevice As System.Windows.Forms.GroupBox
  38.         Friend WithEvents lstDevices As System.Windows.Forms.ListBox
  39.         Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
  40.         Friend WithEvents buttonStart As System.Windows.Forms.Button
  41.         Friend WithEvents buttonStop As System.Windows.Forms.Button
  42.         Friend WithEvents objPreview As System.Windows.Forms.PictureBox
  43.         Friend WithEvents sfdImage As System.Windows.Forms.SaveFileDialog
  44.         Friend WithEvents buttonGrab As System.Windows.Forms.Button
  45.         <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  46.                 Me.components = New System.ComponentModel.Container()
  47.                 Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(ProCam))
  48.                 Me.sfdImage = New System.Windows.Forms.SaveFileDialog()
  49.                 Me.statusStrip1 = New System.Windows.Forms.StatusStrip()
  50.                 Me.lblStat = New System.Windows.Forms.ToolStripStatusLabel()
  51.                 Me.contextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components)
  52.                 Me.spegniWebCamToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
  53.                 Me.resettaWebCamToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
  54.                 Me.timer1 = New System.Windows.Forms.Timer(Me.components)
  55.                 Me.ofdConvert = New System.Windows.Forms.OpenFileDialog()
  56.                 Me.pagFrame = New System.Windows.Forms.TabPage()
  57.                 Me.grpInfo = New System.Windows.Forms.GroupBox()
  58.                 Me.lblAuthor = New System.Windows.Forms.Label()
  59.                 Me.buttonContactMe = New System.Windows.Forms.Button()
  60.                 Me.lblInfo = New System.Windows.Forms.Label()
  61.                 Me.lblAppName = New System.Windows.Forms.Label()
  62.                 Me.grpFPS = New System.Windows.Forms.GroupBox()
  63.                 Me.lblNowFPS = New System.Windows.Forms.Label()
  64.                 Me.buttonFPS = New System.Windows.Forms.Button()
  65.                 Me.lblFPS = New System.Windows.Forms.Label()
  66.                 Me.txtFPS = New System.Windows.Forms.TextBox()
  67.                 Me.grpConvert = New System.Windows.Forms.GroupBox()
  68.                 Me.buttonOpenNewFile = New System.Windows.Forms.Button()
  69.                 Me.lstConvert = New System.Windows.Forms.ListBox()
  70.                 Me.buttonConvert = New System.Windows.Forms.Button()
  71.                 Me.buttonOpen = New System.Windows.Forms.Button()
  72.                 Me.txtConvert = New System.Windows.Forms.TextBox()
  73.                 Me.grpFile = New System.Windows.Forms.GroupBox()
  74.                 Me.buttonGrab = New System.Windows.Forms.Button()
  75.                 Me.buttonSave = New System.Windows.Forms.Button()
  76.                 Me.txtFileName = New System.Windows.Forms.TextBox()
  77.                 Me.pagWebCam = New System.Windows.Forms.TabPage()
  78.                 Me.grpVideo = New System.Windows.Forms.GroupBox()
  79.                 Me.buttonFileNameVideo = New System.Windows.Forms.Button()
  80.                 Me.txtVideo = New System.Windows.Forms.TextBox()
  81.                 Me.buttonStopVideo = New System.Windows.Forms.Button()
  82.                 Me.buttonPlay = New System.Windows.Forms.Button()
  83.                 Me.objPreview = New System.Windows.Forms.PictureBox()
  84.                 Me.GroupBox2 = New System.Windows.Forms.GroupBox()
  85.                 Me.buttonRefresh = New System.Windows.Forms.Button()
  86.                 Me.buttonStart = New System.Windows.Forms.Button()
  87.                 Me.buttonStop = New System.Windows.Forms.Button()
  88.                 Me.grpDevice = New System.Windows.Forms.GroupBox()
  89.                 Me.lstDevices = New System.Windows.Forms.ListBox()
  90.                 Me.tabControl1 = New System.Windows.Forms.TabControl()
  91.                 Me.statusStrip1.SuspendLayout
  92.                 Me.contextMenuStrip1.SuspendLayout
  93.                 Me.pagFrame.SuspendLayout
  94.                 Me.grpInfo.SuspendLayout
  95.                 Me.grpFPS.SuspendLayout
  96.                 Me.grpConvert.SuspendLayout
  97.                 Me.grpFile.SuspendLayout
  98.                 Me.pagWebCam.SuspendLayout
  99.                 Me.grpVideo.SuspendLayout
  100.                 CType(Me.objPreview,System.ComponentModel.ISupportInitialize).BeginInit
  101.                 Me.GroupBox2.SuspendLayout
  102.                 Me.grpDevice.SuspendLayout
  103.                 Me.tabControl1.SuspendLayout
  104.                 Me.SuspendLayout
  105.                 '
  106.                 'sfdImage
  107.                 '
  108.                 Me.sfdImage.CheckPathExists = false
  109.                 Me.sfdImage.FileName = "HellImage.bmp"
  110.                 Me.sfdImage.Filter = "Immagine BMP|*.bmp|Video .avi|*.avi"
  111.                 '
  112.                 'statusStrip1
  113.                 '
  114.                 Me.statusStrip1.BackColor = System.Drawing.Color.LightSteelBlue
  115.                 Me.statusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.lblStat})
  116.                 Me.statusStrip1.Location = New System.Drawing.Point(0, 277)
  117.                 Me.statusStrip1.Name = "statusStrip1"
  118.                 Me.statusStrip1.Size = New System.Drawing.Size(574, 22)
  119.                 Me.statusStrip1.TabIndex = 2
  120.                 Me.statusStrip1.Text = "statusStrip1"
  121.                 '
  122.                 'lblStat
  123.                 '
  124.                 Me.lblStat.BackColor = System.Drawing.Color.Transparent
  125.                 Me.lblStat.Name = "lblStat"
  126.                 Me.lblStat.Size = New System.Drawing.Size(0, 17)
  127.                 '
  128.                 'contextMenuStrip1
  129.                 '
  130.                 Me.contextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.spegniWebCamToolStripMenuItem, Me.resettaWebCamToolStripMenuItem})
  131.                 Me.contextMenuStrip1.Name = "contextMenuStrip1"
  132.                 Me.contextMenuStrip1.ShowImageMargin = false
  133.                 Me.contextMenuStrip1.Size = New System.Drawing.Size(145, 48)
  134.                 '
  135.                 'spegniWebCamToolStripMenuItem
  136.                 '
  137.                 Me.spegniWebCamToolStripMenuItem.Name = "spegniWebCamToolStripMenuItem"
  138.                 Me.spegniWebCamToolStripMenuItem.Size = New System.Drawing.Size(144, 22)
  139.                 Me.spegniWebCamToolStripMenuItem.Text = "Spegni WebCam"
  140.                 AddHandler Me.spegniWebCamToolStripMenuItem.Click, AddressOf Me.SpegniWebCamToolStripMenuItemClick
  141.                 '
  142.                 'resettaWebCamToolStripMenuItem
  143.                 '
  144.                 Me.resettaWebCamToolStripMenuItem.Name = "resettaWebCamToolStripMenuItem"
  145.                 Me.resettaWebCamToolStripMenuItem.Size = New System.Drawing.Size(144, 22)
  146.                 Me.resettaWebCamToolStripMenuItem.Text = "Resetta WebCam"
  147.                 AddHandler Me.resettaWebCamToolStripMenuItem.Click, AddressOf Me.ResettaWebCamToolStripMenuItemClick
  148.                 '
  149.                 'timer1
  150.                 '
  151.                 Me.timer1.Enabled = true
  152.                 AddHandler Me.timer1.Tick, AddressOf Me.Timer1Tick
  153.                 '
  154.                 'ofdConvert
  155.                 '
  156.                 Me.ofdConvert.Filter = "Immagine BMP|*.bmp"
  157.                 '
  158.                 'pagFrame
  159.                 '
  160.                 Me.pagFrame.BackColor = System.Drawing.SystemColors.GradientInactiveCaption
  161.                 Me.pagFrame.Controls.Add(Me.grpInfo)
  162.                 Me.pagFrame.Controls.Add(Me.grpFPS)
  163.                 Me.pagFrame.Controls.Add(Me.grpConvert)
  164.                 Me.pagFrame.Controls.Add(Me.grpFile)
  165.                 Me.pagFrame.Location = New System.Drawing.Point(4, 22)
  166.                 Me.pagFrame.Name = "pagFrame"
  167.                 Me.pagFrame.Padding = New System.Windows.Forms.Padding(3)
  168.                 Me.pagFrame.Size = New System.Drawing.Size(566, 248)
  169.                 Me.pagFrame.TabIndex = 1
  170.                 Me.pagFrame.Text = "Frame"
  171.                 '
  172.                 'grpInfo
  173.                 '
  174.                 Me.grpInfo.Controls.Add(Me.lblAuthor)
  175.                 Me.grpInfo.Controls.Add(Me.buttonContactMe)
  176.                 Me.grpInfo.Controls.Add(Me.lblInfo)
  177.                 Me.grpInfo.Controls.Add(Me.lblAppName)
  178.                 Me.grpInfo.Location = New System.Drawing.Point(6, 95)
  179.                 Me.grpInfo.Name = "grpInfo"
  180.                 Me.grpInfo.Size = New System.Drawing.Size(265, 150)
  181.                 Me.grpInfo.TabIndex = 14
  182.                 Me.grpInfo.TabStop = false
  183.                 Me.grpInfo.Text = "Informazioni : "
  184.                 '
  185.                 'lblAuthor
  186.                 '
  187.                 Me.lblAuthor.Font = New System.Drawing.Font("Stencil", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte))
  188.                 Me.lblAuthor.ForeColor = System.Drawing.Color.Navy
  189.                 Me.lblAuthor.Location = New System.Drawing.Point(8, 124)
  190.                 Me.lblAuthor.Name = "lblAuthor"
  191.                 Me.lblAuthor.Size = New System.Drawing.Size(170, 23)
  192.                 Me.lblAuthor.TabIndex = 3
  193.                 Me.lblAuthor.Text = "Realizzato da Lollo 97."
  194.                 '
  195.                 'buttonContactMe
  196.                 '
  197.                 Me.buttonContactMe.BackColor = System.Drawing.Color.White
  198.                 Me.buttonContactMe.Location = New System.Drawing.Point(184, 120)
  199.                 Me.buttonContactMe.Name = "buttonContactMe"
  200.                 Me.buttonContactMe.Size = New System.Drawing.Size(75, 27)
  201.                 Me.buttonContactMe.TabIndex = 2
  202.                 Me.buttonContactMe.Text = "Contattami"
  203.                 Me.buttonContactMe.UseVisualStyleBackColor = false
  204.                 AddHandler Me.buttonContactMe.Click, AddressOf Me.ButtonContactMeClick
  205.                 '
  206.                 'lblInfo
  207.                 '
  208.                 Me.lblInfo.Location = New System.Drawing.Point(8, 33)
  209.                 Me.lblInfo.Name = "lblInfo"
  210.                 Me.lblInfo.Size = New System.Drawing.Size(251, 86)
  211.                 Me.lblInfo.TabIndex = 1
  212.                 Me.lblInfo.Text = resources.GetString("lblInfo.Text")
  213.                 '
  214.                 'lblAppName
  215.                 '
  216.                 Me.lblAppName.Font = New System.Drawing.Font("Lucida Calligraphy", 12!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic),System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0,Byte))
  217.                 Me.lblAppName.ForeColor = System.Drawing.Color.RoyalBlue
  218.                 Me.lblAppName.Location = New System.Drawing.Point(63, 10)
  219.                 Me.lblAppName.Name = "lblAppName"
  220.                 Me.lblAppName.Size = New System.Drawing.Size(100, 23)
  221.                 Me.lblAppName.TabIndex = 0
  222.                 Me.lblAppName.Text = "ProCam"
  223.                 '
  224.                 'grpFPS
  225.                 '
  226.                 Me.grpFPS.Controls.Add(Me.lblNowFPS)
  227.                 Me.grpFPS.Controls.Add(Me.buttonFPS)
  228.                 Me.grpFPS.Controls.Add(Me.lblFPS)
  229.                 Me.grpFPS.Controls.Add(Me.txtFPS)
  230.                 Me.grpFPS.Location = New System.Drawing.Point(277, 152)
  231.                 Me.grpFPS.Name = "grpFPS"
  232.                 Me.grpFPS.Size = New System.Drawing.Size(286, 93)
  233.                 Me.grpFPS.TabIndex = 13
  234.                 Me.grpFPS.TabStop = false
  235.                 Me.grpFPS.Text = "Frame per Second (FPS)"
  236.                 '
  237.                 'lblNowFPS
  238.                 '
  239.                 Me.lblNowFPS.Location = New System.Drawing.Point(6, 67)
  240.                 Me.lblNowFPS.Name = "lblNowFPS"
  241.                 Me.lblNowFPS.Size = New System.Drawing.Size(193, 23)
  242.                 Me.lblNowFPS.TabIndex = 3
  243.                 '
  244.                 'buttonFPS
  245.                 '
  246.                 Me.buttonFPS.BackColor = System.Drawing.Color.White
  247.                 Me.buttonFPS.Location = New System.Drawing.Point(208, 35)
  248.                 Me.buttonFPS.Name = "buttonFPS"
  249.                 Me.buttonFPS.Size = New System.Drawing.Size(75, 27)
  250.                 Me.buttonFPS.TabIndex = 2
  251.                 Me.buttonFPS.Text = "Imposta"
  252.                 Me.buttonFPS.UseVisualStyleBackColor = false
  253.                 AddHandler Me.buttonFPS.Click, AddressOf Me.ButtonFPSClick
  254.                 '
  255.                 'lblFPS
  256.                 '
  257.                 Me.lblFPS.Location = New System.Drawing.Point(6, 13)
  258.                 Me.lblFPS.Name = "lblFPS"
  259.                 Me.lblFPS.Size = New System.Drawing.Size(193, 23)
  260.                 Me.lblFPS.TabIndex = 1
  261.                 Me.lblFPS.Text = "Inserisci i Frame per secondo (FPS) : "
  262.                 '
  263.                 'txtFPS
  264.                 '
  265.                 Me.txtFPS.Location = New System.Drawing.Point(6, 39)
  266.                 Me.txtFPS.Name = "txtFPS"
  267.                 Me.txtFPS.Size = New System.Drawing.Size(193, 20)
  268.                 Me.txtFPS.TabIndex = 0
  269.                 '
  270.                 'grpConvert
  271.                 '
  272.                 Me.grpConvert.Controls.Add(Me.buttonOpenNewFile)
  273.                 Me.grpConvert.Controls.Add(Me.lstConvert)
  274.                 Me.grpConvert.Controls.Add(Me.buttonConvert)
  275.                 Me.grpConvert.Controls.Add(Me.buttonOpen)
  276.                 Me.grpConvert.Controls.Add(Me.txtConvert)
  277.                 Me.grpConvert.Location = New System.Drawing.Point(277, 6)
  278.                 Me.grpConvert.Name = "grpConvert"
  279.                 Me.grpConvert.Size = New System.Drawing.Size(286, 143)
  280.                 Me.grpConvert.TabIndex = 12
  281.                 Me.grpConvert.TabStop = false
  282.                 Me.grpConvert.Text = "Converti"
  283.                 '
  284.                 'buttonOpenNewFile
  285.                 '
  286.                 Me.buttonOpenNewFile.Enabled = false
  287.                 Me.buttonOpenNewFile.Location = New System.Drawing.Point(176, 107)
  288.                 Me.buttonOpenNewFile.Name = "buttonOpenNewFile"
  289.                 Me.buttonOpenNewFile.Size = New System.Drawing.Size(77, 27)
  290.                 Me.buttonOpenNewFile.TabIndex = 15
  291.                 Me.buttonOpenNewFile.Text = "Apri il File"
  292.                 Me.buttonOpenNewFile.UseVisualStyleBackColor = true
  293.                 AddHandler Me.buttonOpenNewFile.Click, AddressOf Me.ButtonOpenNewFileClick
  294.                 '
  295.                 'lstConvert
  296.                 '
  297.                 Me.lstConvert.BackColor = System.Drawing.SystemColors.Window
  298.                 Me.lstConvert.Items.AddRange(New Object() {".jpeg", ".png", ".gif"})
  299.                 Me.lstConvert.Location = New System.Drawing.Point(8, 78)
  300.                 Me.lstConvert.Name = "lstConvert"
  301.                 Me.lstConvert.Size = New System.Drawing.Size(162, 56)
  302.                 Me.lstConvert.TabIndex = 14
  303.                 '
  304.                 'buttonConvert
  305.                 '
  306.                 Me.buttonConvert.BackColor = System.Drawing.Color.White
  307.                 Me.buttonConvert.Enabled = false
  308.                 Me.buttonConvert.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray
  309.                 Me.buttonConvert.Location = New System.Drawing.Point(108, 45)
  310.                 Me.buttonConvert.Name = "buttonConvert"
  311.                 Me.buttonConvert.Size = New System.Drawing.Size(145, 27)
  312.                 Me.buttonConvert.TabIndex = 12
  313.                 Me.buttonConvert.Text = "Converti il File .bmp in..."
  314.                 Me.buttonConvert.UseVisualStyleBackColor = false
  315.                 AddHandler Me.buttonConvert.Click, AddressOf Me.ButtonConvertClick
  316.                 '
  317.                 'buttonOpen
  318.                 '
  319.                 Me.buttonOpen.BackColor = System.Drawing.Color.White
  320.                 Me.buttonOpen.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray
  321.                 Me.buttonOpen.Location = New System.Drawing.Point(8, 45)
  322.                 Me.buttonOpen.Name = "buttonOpen"
  323.                 Me.buttonOpen.Size = New System.Drawing.Size(75, 27)
  324.                 Me.buttonOpen.TabIndex = 11
  325.                 Me.buttonOpen.Text = "Scegli"
  326.                 Me.buttonOpen.UseVisualStyleBackColor = false
  327.                 AddHandler Me.buttonOpen.Click, AddressOf Me.ButtonOpenClick
  328.                 '
  329.                 'txtConvert
  330.                 '
  331.                 Me.txtConvert.Location = New System.Drawing.Point(8, 19)
  332.                 Me.txtConvert.Name = "txtConvert"
  333.                 Me.txtConvert.Size = New System.Drawing.Size(245, 20)
  334.                 Me.txtConvert.TabIndex = 10
  335.                 '
  336.                 'grpFile
  337.                 '
  338.                 Me.grpFile.BackColor = System.Drawing.Color.Transparent
  339.                 Me.grpFile.Controls.Add(Me.buttonGrab)
  340.                 Me.grpFile.Controls.Add(Me.buttonSave)
  341.                 Me.grpFile.Controls.Add(Me.txtFileName)
  342.                 Me.grpFile.Location = New System.Drawing.Point(6, 6)
  343.                 Me.grpFile.Name = "grpFile"
  344.                 Me.grpFile.Size = New System.Drawing.Size(265, 83)
  345.                 Me.grpFile.TabIndex = 10
  346.                 Me.grpFile.TabStop = false
  347.                 Me.grpFile.Text = "File Immagine"
  348.                 '
  349.                 'buttonGrab
  350.                 '
  351.                 Me.buttonGrab.BackColor = System.Drawing.Color.White
  352.                 Me.buttonGrab.Enabled = false
  353.                 Me.buttonGrab.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray
  354.                 Me.buttonGrab.Location = New System.Drawing.Point(106, 48)
  355.                 Me.buttonGrab.Name = "buttonGrab"
  356.                 Me.buttonGrab.Size = New System.Drawing.Size(145, 27)
  357.                 Me.buttonGrab.TabIndex = 9
  358.                 Me.buttonGrab.Text = "Cattura Frame WebCam"
  359.                 Me.buttonGrab.UseVisualStyleBackColor = false
  360.                 AddHandler Me.buttonGrab.Click, AddressOf Me.ButtonGrabClick
  361.                 '
  362.                 'buttonSave
  363.                 '
  364.                 Me.buttonSave.BackColor = System.Drawing.Color.White
  365.                 Me.buttonSave.Enabled = false
  366.                 Me.buttonSave.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray
  367.                 Me.buttonSave.Location = New System.Drawing.Point(8, 48)
  368.                 Me.buttonSave.Name = "buttonSave"
  369.                 Me.buttonSave.Size = New System.Drawing.Size(75, 27)
  370.                 Me.buttonSave.TabIndex = 1
  371.                 Me.buttonSave.Text = "Scegli"
  372.                 Me.buttonSave.UseVisualStyleBackColor = false
  373.                 '
  374.                 'txtFileName
  375.                 '
  376.                 Me.txtFileName.Enabled = false
  377.                 Me.txtFileName.Location = New System.Drawing.Point(6, 19)
  378.                 Me.txtFileName.Name = "txtFileName"
  379.                 Me.txtFileName.Size = New System.Drawing.Size(245, 20)
  380.                 Me.txtFileName.TabIndex = 0
  381.                 '
  382.                 'pagWebCam
  383.                 '
  384.                 Me.pagWebCam.BackColor = System.Drawing.SystemColors.GradientInactiveCaption
  385.                 Me.pagWebCam.Controls.Add(Me.grpVideo)
  386.                 Me.pagWebCam.Controls.Add(Me.objPreview)
  387.                 Me.pagWebCam.Controls.Add(Me.GroupBox2)
  388.                 Me.pagWebCam.Controls.Add(Me.grpDevice)
  389.                 Me.pagWebCam.Location = New System.Drawing.Point(4, 22)
  390.                 Me.pagWebCam.Name = "pagWebCam"
  391.                 Me.pagWebCam.Padding = New System.Windows.Forms.Padding(3)
  392.                 Me.pagWebCam.Size = New System.Drawing.Size(566, 248)
  393.                 Me.pagWebCam.TabIndex = 0
  394.                 Me.pagWebCam.Text = "WebCam"
  395.                 '
  396.                 'grpVideo
  397.                 '
  398.                 Me.grpVideo.Controls.Add(Me.buttonFileNameVideo)
  399.                 Me.grpVideo.Controls.Add(Me.txtVideo)
  400.                 Me.grpVideo.Controls.Add(Me.buttonStopVideo)
  401.                 Me.grpVideo.Controls.Add(Me.buttonPlay)
  402.                 Me.grpVideo.Location = New System.Drawing.Point(314, 114)
  403.                 Me.grpVideo.Name = "grpVideo"
  404.                 Me.grpVideo.Size = New System.Drawing.Size(249, 65)
  405.                 Me.grpVideo.TabIndex = 15
  406.                 Me.grpVideo.TabStop = false
  407.                 Me.grpVideo.Text = "Video"
  408.                 '
  409.                 'buttonFileNameVideo
  410.                 '
  411.                 Me.buttonFileNameVideo.BackColor = System.Drawing.Color.White
  412.                 Me.buttonFileNameVideo.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray
  413.                 Me.buttonFileNameVideo.Location = New System.Drawing.Point(168, 35)
  414.                 Me.buttonFileNameVideo.Name = "buttonFileNameVideo"
  415.                 Me.buttonFileNameVideo.Size = New System.Drawing.Size(75, 27)
  416.                 Me.buttonFileNameVideo.TabIndex = 3
  417.                 Me.buttonFileNameVideo.Text = "Scegli"
  418.                 Me.buttonFileNameVideo.UseVisualStyleBackColor = true
  419.                 AddHandler Me.buttonFileNameVideo.Click, AddressOf Me.ButtonFileNameVideoClick
  420.                 '
  421.                 'txtVideo
  422.                 '
  423.                 Me.txtVideo.Location = New System.Drawing.Point(6, 13)
  424.                 Me.txtVideo.Name = "txtVideo"
  425.                 Me.txtVideo.Size = New System.Drawing.Size(240, 20)
  426.                 Me.txtVideo.TabIndex = 2
  427.                 '
  428.                 'buttonStopVideo
  429.                 '
  430.                 Me.buttonStopVideo.Image = CType(resources.GetObject("buttonStopVideo.Image"),System.Drawing.Image)
  431.                 Me.buttonStopVideo.Location = New System.Drawing.Point(59, 35)
  432.                 Me.buttonStopVideo.Name = "buttonStopVideo"
  433.                 Me.buttonStopVideo.Size = New System.Drawing.Size(47, 27)
  434.                 Me.buttonStopVideo.TabIndex = 1
  435.                 Me.buttonStopVideo.UseVisualStyleBackColor = true
  436.                 AddHandler Me.buttonStopVideo.Click, AddressOf Me.ButtonStopVideoClick
  437.                 '
  438.                 'buttonPlay
  439.                 '
  440.                 Me.buttonPlay.Image = CType(resources.GetObject("buttonPlay.Image"),System.Drawing.Image)
  441.                 Me.buttonPlay.Location = New System.Drawing.Point(6, 35)
  442.                 Me.buttonPlay.Name = "buttonPlay"
  443.                 Me.buttonPlay.Size = New System.Drawing.Size(47, 27)
  444.                 Me.buttonPlay.TabIndex = 0
  445.                 Me.buttonPlay.UseVisualStyleBackColor = true
  446.                 AddHandler Me.buttonPlay.Click, AddressOf Me.ButtonPlayClick
  447.                 '
  448.                 'objPreview
  449.                 '
  450.                 Me.objPreview.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom)  _
  451.                                                 Or System.Windows.Forms.AnchorStyles.Left)  _
  452.                                                 Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles)
  453.                 Me.objPreview.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
  454.                 Me.objPreview.Location = New System.Drawing.Point(0, 0)
  455.                 Me.objPreview.Name = "objPreview"
  456.                 Me.objPreview.Size = New System.Drawing.Size(311, 245)
  457.                 Me.objPreview.TabIndex = 0
  458.                 Me.objPreview.TabStop = false
  459.                 '
  460.                 'GroupBox2
  461.                 '
  462.                 Me.GroupBox2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles)
  463.                 Me.GroupBox2.BackColor = System.Drawing.Color.Transparent
  464.                 Me.GroupBox2.Controls.Add(Me.buttonRefresh)
  465.                 Me.GroupBox2.Controls.Add(Me.buttonStart)
  466.                 Me.GroupBox2.Controls.Add(Me.buttonStop)
  467.                 Me.GroupBox2.Location = New System.Drawing.Point(314, 182)
  468.                 Me.GroupBox2.Name = "GroupBox2"
  469.                 Me.GroupBox2.Size = New System.Drawing.Size(249, 60)
  470.                 Me.GroupBox2.TabIndex = 12
  471.                 Me.GroupBox2.TabStop = false
  472.                 Me.GroupBox2.Text = "Frame WebCam"
  473.                 '
  474.                 'buttonRefresh
  475.                 '
  476.                 Me.buttonRefresh.BackColor = System.Drawing.Color.White
  477.                 Me.buttonRefresh.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray
  478.                 Me.buttonRefresh.Location = New System.Drawing.Point(87, 16)
  479.                 Me.buttonRefresh.Name = "buttonRefresh"
  480.                 Me.buttonRefresh.Size = New System.Drawing.Size(75, 27)
  481.                 Me.buttonRefresh.TabIndex = 8
  482.                 Me.buttonRefresh.Text = "Reset"
  483.                 Me.buttonRefresh.UseVisualStyleBackColor = true
  484.                 AddHandler Me.buttonRefresh.Click, AddressOf Me.ButtonRefreshClick
  485.                 '
  486.                 'buttonStart
  487.                 '
  488.                 Me.buttonStart.BackColor = System.Drawing.Color.White
  489.                 Me.buttonStart.Enabled = false
  490.                 Me.buttonStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray
  491.                 Me.buttonStart.Location = New System.Drawing.Point(3, 16)
  492.                 Me.buttonStart.Name = "buttonStart"
  493.                 Me.buttonStart.Size = New System.Drawing.Size(75, 27)
  494.                 Me.buttonStart.TabIndex = 5
  495.                 Me.buttonStart.Text = "Avvia"
  496.                 Me.buttonStart.UseVisualStyleBackColor = true
  497.                 AddHandler Me.buttonStart.Click, AddressOf Me.ButtonStartClick
  498.                 '
  499.                 'buttonStop
  500.                 '
  501.                 Me.buttonStop.BackColor = System.Drawing.Color.White
  502.                 Me.buttonStop.DialogResult = System.Windows.Forms.DialogResult.Cancel
  503.                 Me.buttonStop.Enabled = false
  504.                 Me.buttonStop.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray
  505.                 Me.buttonStop.Location = New System.Drawing.Point(168, 16)
  506.                 Me.buttonStop.Name = "buttonStop"
  507.                 Me.buttonStop.Size = New System.Drawing.Size(75, 27)
  508.                 Me.buttonStop.TabIndex = 7
  509.                 Me.buttonStop.Text = "Ferma"
  510.                 Me.buttonStop.UseVisualStyleBackColor = true
  511.                 AddHandler Me.buttonStop.Click, AddressOf Me.ButtonStopClick
  512.                 '
  513.                 'grpDevice
  514.                 '
  515.                 Me.grpDevice.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles)
  516.                 Me.grpDevice.BackColor = System.Drawing.Color.Transparent
  517.                 Me.grpDevice.Controls.Add(Me.lstDevices)
  518.                 Me.grpDevice.Location = New System.Drawing.Point(314, 0)
  519.                 Me.grpDevice.Name = "grpDevice"
  520.                 Me.grpDevice.Size = New System.Drawing.Size(249, 108)
  521.                 Me.grpDevice.TabIndex = 10
  522.                 Me.grpDevice.TabStop = false
  523.                 Me.grpDevice.Text = "Devices disponibili"
  524.                 '
  525.                 'lstDevices
  526.                 '
  527.                 Me.lstDevices.BackColor = System.Drawing.SystemColors.Window
  528.                 Me.lstDevices.Dock = System.Windows.Forms.DockStyle.Fill
  529.                 Me.lstDevices.Location = New System.Drawing.Point(3, 16)
  530.                 Me.lstDevices.Name = "lstDevices"
  531.                 Me.lstDevices.Size = New System.Drawing.Size(243, 89)
  532.                 Me.lstDevices.TabIndex = 1
  533.                 AddHandler Me.lstDevices.DoubleClick, AddressOf Me.LstDevicesDoubleClick
  534.                 '
  535.                 'tabControl1
  536.                 '
  537.                 Me.tabControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom)  _
  538.                                                 Or System.Windows.Forms.AnchorStyles.Left)  _
  539.                                                 Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles)
  540.                 Me.tabControl1.Controls.Add(Me.pagWebCam)
  541.                 Me.tabControl1.Controls.Add(Me.pagFrame)
  542.                 Me.tabControl1.Location = New System.Drawing.Point(0, 0)
  543.                 Me.tabControl1.Name = "tabControl1"
  544.                 Me.tabControl1.SelectedIndex = 0
  545.                 Me.tabControl1.Size = New System.Drawing.Size(574, 274)
  546.                 Me.tabControl1.TabIndex = 1
  547.                 '
  548.                 'ProCam
  549.                 '
  550.                 Me.AcceptButton = Me.buttonStart
  551.                 Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  552.                 Me.BackColor = System.Drawing.Color.LightSteelBlue
  553.                 Me.CancelButton = Me.buttonStop
  554.                 Me.ClientSize = New System.Drawing.Size(574, 299)
  555.                 Me.ContextMenuStrip = Me.contextMenuStrip1
  556.                 Me.Controls.Add(Me.statusStrip1)
  557.                 Me.Controls.Add(Me.tabControl1)
  558.                 Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
  559.                 Me.Icon = CType(resources.GetObject("$this.Icon"),System.Drawing.Icon)
  560.                 Me.MaximizeBox = false
  561.                 Me.Name = "ProCam"
  562.                 Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  563.                 Me.Text = "ProCam"
  564.                 Me.TopMost = true
  565.                 AddHandler FormClosing, AddressOf Me.ProCamFormClosing
  566.                 AddHandler FormClosed, AddressOf Me.ProCamFormClosed
  567.                 AddHandler Load, AddressOf Me.ProCamLoad
  568.                 Me.statusStrip1.ResumeLayout(false)
  569.                 Me.statusStrip1.PerformLayout
  570.                 Me.contextMenuStrip1.ResumeLayout(false)
  571.                 Me.pagFrame.ResumeLayout(false)
  572.                 Me.grpInfo.ResumeLayout(false)
  573.                 Me.grpFPS.ResumeLayout(false)
  574.                 Me.grpFPS.PerformLayout
  575.                 Me.grpConvert.ResumeLayout(false)
  576.                 Me.grpConvert.PerformLayout
  577.                 Me.grpFile.ResumeLayout(false)
  578.                 Me.grpFile.PerformLayout
  579.                 Me.pagWebCam.ResumeLayout(false)
  580.                 Me.grpVideo.ResumeLayout(false)
  581.                 Me.grpVideo.PerformLayout
  582.                 CType(Me.objPreview,System.ComponentModel.ISupportInitialize).EndInit
  583.                 Me.GroupBox2.ResumeLayout(false)
  584.                 Me.grpDevice.ResumeLayout(false)
  585.                 Me.tabControl1.ResumeLayout(false)
  586.                 Me.ResumeLayout(false)
  587.                 Me.PerformLayout
  588.         End Sub
  589.         Private lblInfo As System.Windows.Forms.Label
  590.         Private lblAuthor As System.Windows.Forms.Label
  591.         Private grpFPS As System.Windows.Forms.GroupBox
  592.         Private lblAppName As System.Windows.Forms.Label
  593.         Private buttonContactMe As System.Windows.Forms.Button
  594.         Friend lblNowFPS As System.Windows.Forms.Label
  595.         Friend txtFPS As System.Windows.Forms.TextBox
  596.         Friend lblFPS As System.Windows.Forms.Label
  597.         Private txtVideo As System.Windows.Forms.TextBox
  598.         Friend buttonFPS As System.Windows.Forms.Button
  599.         Private grpInfo As System.Windows.Forms.GroupBox
  600.         Friend buttonFileNameVideo As System.Windows.Forms.Button
  601.         Private buttonPlay As System.Windows.Forms.Button
  602.         Private buttonStopVideo As System.Windows.Forms.Button
  603.         Friend grpVideo As System.Windows.Forms.GroupBox
  604.         Private buttonOpenNewFile As System.Windows.Forms.Button
  605.         Friend lstConvert As System.Windows.Forms.ListBox
  606.         Friend txtConvert As System.Windows.Forms.TextBox
  607.         Private ofdConvert As System.Windows.Forms.OpenFileDialog
  608.         Friend buttonOpen As System.Windows.Forms.Button
  609.         Friend buttonConvert As System.Windows.Forms.Button
  610.         Friend grpConvert As System.Windows.Forms.GroupBox
  611.         Private timer1 As System.Windows.Forms.Timer
  612.         Private resettaWebCamToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
  613.         Private spegniWebCamToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
  614.         Private contextMenuStrip1 As System.Windows.Forms.ContextMenuStrip
  615.         Private lblStat As System.Windows.Forms.ToolStripStatusLabel
  616.         Friend statusStrip1 As System.Windows.Forms.StatusStrip
  617.         Friend buttonRefresh As System.Windows.Forms.Button
  618.         Private pagFrame As System.Windows.Forms.TabPage
  619.         Private pagWebCam As System.Windows.Forms.TabPage
  620.         Friend tabControl1 As System.Windows.Forms.TabControl
  621.        
  622.         #End Region
  623.        
  624.         Dim iDevice As String = Nothing
  625.         Dim WebCam As New iCam
  626.         Dim IsSaved As Boolean
  627.        
  628.         Sub ProCamLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  629.                 LoadDeviceList()
  630.                 CheckDeviceList()
  631.         End Sub
  632.        
  633.         Sub LoadDeviceList()
  634.                 Dim strName As String = Space(100)
  635.                 Dim strVer As String = Space(100)
  636.                 Dim bReturn As Boolean
  637.                 Dim x As Integer = 0
  638.                 Do
  639.                         bReturn = WebCam.capGetDriverDescriptionA(CShort(x), strName, 100, strVer, 100)
  640.                         If bReturn Then lstDevices.Items.Add(strName.Trim)
  641.                         x += 1
  642.                 Loop Until bReturn = False
  643.         End Sub
  644.        
  645.         Sub CheckDeviceList()
  646.                 If lstDevices.Items.Count > 0 Then
  647.                         lstDevices.SelectedIndex = 0
  648.                         EnableForm()
  649.                         buttonStop.Enabled = False
  650.                 Else
  651.                         lstDevices.Items.Add("Nessun device trovato")
  652.                 End If
  653.         End Sub
  654.        
  655.         Sub EnableForm()
  656.                 txtFileName.Enabled = True
  657.                 buttonSave.Enabled = True
  658.                 buttonGrab.Enabled = True
  659.                 buttonStop.Enabled = True
  660.                 buttonStart.Enabled = True
  661.                 buttonRefresh.Enabled = True
  662.         End Sub
  663.        
  664.         Sub buttonStartClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonStart.Click
  665.                 iDevice = lstDevices.SelectedItem.ToString()
  666.                 WebCam.initCam(objPreview.Handle.ToInt32,iDevice)
  667.                 EnableForm()
  668.         End Sub
  669.        
  670.         Sub buttonStopClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonStop.Click               
  671.                 WebCam.CloseCam()
  672.                 buttonStop.Enabled = False
  673.                 buttonStart.Enabled = True
  674.                 buttonGrab.Enabled = False
  675.                 buttonRefresh.Enabled = False
  676.         End Sub
  677.        
  678.         Sub buttonSaveClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonSave.Click
  679.                 If sfdImage.ShowDialog() = DialogResult.OK Then
  680.                         txtFileName.Text = sfdImage.FileName
  681.                         IsSaved = True
  682.                 Else
  683.                         IsSaved = False
  684.                 End If
  685.         End Sub
  686.        
  687.         Sub buttonGrabClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonGrab.Click
  688.                 If IsSaved Then
  689.                         WebCam.SaveFrame(txtFileName.Text)
  690.                 ElseIf MessageBox.Show("Non hai salvato in nessuna directory.Vuoi salvare ora?",
  691.                         "ProCam",MessageBoxButtons.YesNo) = DialogResult.Yes Then
  692.                         If sfdImage.ShowDialog() = DialogResult.OK Then
  693.                                 WebCam.SaveFrame(txtFileName.Text)
  694.                         End If
  695.                 End If
  696.         End Sub
  697.        
  698.         Sub LstDevicesDoubleClick(sender As Object, e As EventArgs)
  699.                 iDevice = lstDevices.SelectedItem.ToString()
  700.                 WebCam.initCam(objPreview.Handle.ToInt32,iDevice)
  701.                 EnableForm()
  702.         End Sub
  703.        
  704.         Sub ButtonRefreshClick(sender As Object, e As EventArgs)
  705.                 WebCam.resetCam()
  706.         End Sub
  707.        
  708.         Sub SpegniWebCamToolStripMenuItemClick(sender As Object, e As EventArgs)
  709.                 WebCam.CloseCam()
  710.         End Sub
  711.        
  712.         Sub ResettaWebCamToolStripMenuItemClick(sender As Object, e As EventArgs)
  713.                 WebCam.resetCam()
  714.         End Sub
  715.        
  716.         Sub Timer1Tick(sender As Object, e As EventArgs)
  717.                 lblStat.Text = WebCam.StatusString
  718.                 lblNowFPS.Text = "Attuali FPS : " &WebCam.FPS()
  719.         End Sub
  720.        
  721.         Sub ButtonOpenClick(sender As Object, e As EventArgs)
  722.                 If ofdConvert.ShowDialog() = DialogResult.OK Then
  723.                         txtConvert.Text = ofdConvert.FileName
  724.                         buttonConvert.Enabled = True
  725.                         lstConvert.Items.Clear()
  726.                         lstConvert.Items.Add(IO.Path.GetFileNameWithoutExtension(txtConvert.Text) &".jpeg")
  727.                         lstConvert.Items.Add(IO.Path.GetFileNameWithoutExtension(txtConvert.Text) &".png")
  728.                         lstConvert.Items.Add(IO.Path.GetFileNameWithoutExtension(txtConvert.Text) &".gif")
  729.                 End If
  730.         End Sub
  731.        
  732.         Sub ButtonConvertClick(sender As Object, e As EventArgs)
  733.                 If lstConvert.SelectedIndex = 0 Then
  734.                         WebCam.ConvertBMP(txtConvert.Text,ImageFormat.Jpeg)
  735.                         buttonOpenNewFile.Enabled = True
  736.                 ElseIf lstConvert.SelectedIndex = 1 Then
  737.                         WebCam.ConvertBMP(txtConvert.Text,ImageFormat.Png)
  738.                         buttonOpenNewFile.Enabled = True
  739.                 ElseIf lstConvert.SelectedIndex = 2 Then
  740.                         WebCam.ConvertBMP(txtConvert.Text,ImageFormat.Gif)
  741.                         buttonOpenNewFile.Enabled = True
  742.                 End If
  743.         End Sub
  744.        
  745.         Sub ButtonOpenNewFileClick(sender As Object, e As EventArgs)
  746.                 Process.Start("explorer.exe",WebCam.PathString)
  747.         End Sub
  748.        
  749.         Sub ProCamFormClosing(sender As Object, e As FormClosingEventArgs)
  750.                 WebCam.CloseCam()
  751.         End Sub
  752.        
  753.         Sub ProCamFormClosed(sender As Object, e As FormClosedEventArgs)
  754.                 WebCam.CloseCam()
  755.         End Sub
  756.        
  757.         Sub ButtonPlayClick(sender As Object, e As EventArgs)
  758.                 buttonPlay.Enabled = False
  759.                 buttonStopVideo.Enabled = True
  760.                 WebCam.RecordVideo()
  761.         End Sub
  762.        
  763.         Sub ButtonStopVideoClick(sender As Object, e As EventArgs)
  764.                 buttonStopVideo.Enabled = False
  765.                 buttonPlay.Enabled = True
  766.                 WebCam.StopVideo(txtVideo.Text)
  767.         End Sub
  768.        
  769.         Sub ButtonFileNameVideoClick(sender As Object, e As EventArgs)
  770.                 If sfdImage.ShowDialog() = DialogResult.OK Then
  771.                         txtVideo.Text = sfdImage.FileName
  772.                         sfdImage.FileName = ""
  773.                 End If
  774.         End Sub
  775.        
  776.         Sub ButtonFPSClick(sender As Object, e As EventArgs)
  777.                 Try
  778.                         WebCam.setFrameRate(CInt(txtFPS.Text))
  779.                         iDevice = lstDevices.SelectedItem.ToString()
  780.                         WebCam.initCam(objPreview.Handle.ToInt32,iDevice)
  781.                         EnableForm()
  782.                 Catch
  783.                 End Try
  784.         End Sub
  785.  
  786.         Sub ButtonContactMeClick(sender As Object, e As EventArgs)
  787.                 Try
  788.                         System.Diagnostics.Process.Start("mailto: lollo97_ @live.it")
  789.                 Catch
  790.                         MessageBox.Show("Nessun server di posta trovato su questo computer." & _
  791.                         "Contattami su lollo97_@live.it","Errore Mail")
  792.                 End Try
  793.         End Sub
  794.        
  795. End Class