Guidance
指路人
g.yi.org
software / rapidq / Examples / Audio & Video / Kamerka 0.2 / KAMERKA SOURCE / frm_set.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' ##########################################################################
' Components
' ##########################################################################
     WITH frmSet
      .CAPTION = "Program settings"
      .clientwidth = 330
      .clientheight = 220
      .center
      .delbordericons 1, 2
      .borderstyle = 1
      .font = fntScreen
      .onShow = frmSet_onShow
     END WITH

     WITH MyPort
      .OnOpen = 		MyPort_OnOpen
      .OnReadString   = MyPort_OnReadString
     END WITH

     WITH TimerPort
      .interval = 10
      .onTimer = TimerPort_OnTimer
      .enabled = 0
     END WITH

     WITH tabSet
      .PARENT = frmSet
      .height = 170
      .align = 1
      .addtabs "Global", "Video", "Image"
      .OnChange = tabSet_OnChange
     END WITH

     WITH btnSetOK
      .PARENT = frmSet
      .left = 10: .top = 180: .width = 100: .height = 30
      .CAPTION = "&OK"
      .OnClick = btnSetOK_onClick
      .BMPHandle = bmp_ok
     END WITH

     WITH btnSetCancel
      .PARENT = frmSet
      .left = 220: .top = 180: .width = 100: .height = 30
      .Kind = 2
     END WITH

	' --------------------------------------------------------------------------
     WITH pnlSet0
      .PARENT = tabSet
      .align = 5
      .bevelouter = 1
     END WITH

     WITH lblLang
      .PARENT = pnlSet0
      .left = 10: .top = 13
      .CAPTION = "Language"
     END WITH

     WITH cbxLang
      .PARENT = pnlSet0
      .left = 85: .top = 10: .width = 90
      .style = 2
      .additems "English", "Slovensky"
      .itemindex = 0
      .onchange = cbxLang_onchange
      .font.delstyles 0
      .font.COLOR = RGB(&H99, &H00, &H00)
     END WITH

     WITH lblPort
      .PARENT = pnlSet0
      .left = 10: .top = 43
      .CAPTION = "Serial ports"
     END WITH

     WITH cbxPort
      .PARENT = pnlSet0
      .left = 85: .top = 40: .width = 90
      .style = 2
      .onchange = cbxPort_OnChange
      .font.delstyles 0
      .font.COLOR = RGB(&H99, &H00, &H00)
      .tag = 0
     END WITH

	' --------------------------------------------------------------------------
     WITH pnlSet1
      .PARENT = tabSet
      .align = 5
      .bevelouter = 1
      .visible = 0
     END WITH

     WITH lblFormatSize1
      .PARENT = pnlSet1
      .left = 10: .top = 10
      .CAPTION = "Resolution:"
     END WITH

     WITH lblFormatSize2
      .PARENT = pnlSet1
      .left = 85: .top = 10
      .font.COLOR = RGB(&H00, &H00, &H99)
      .font.addstyles 0
     END WITH

	' --------------------------------------------------------------------------
     WITH pnlSet2
      .PARENT = tabSet
      .align = 5
      .bevelouter = 1
      .visible = 0
     END WITH

     WITH lblSetSaveAs
      .PARENT = pnlSet2
      .left = 10: .top = 13
      .CAPTION = "Save file as"
     END WITH

     WITH cbxSetSaveAs
      .PARENT = pnlSet2
      .left = 110: .top = 10: .width = 65
      .style = 2
      .additems "JPG", "BMP"
      .itemindex = 0
      .onchange = cbxSetSaveAs_onchange
      .font.delstyles 0
      .font.COLOR = RGB(&H99, &H00, &H00)
     END WITH

     WITH lblSetQuality
      .PARENT = pnlSet2
      .left = 10: .top = 43
      .CAPTION = "JPG quality (%)"
     END WITH

     WITH cbxSetQuality
      .PARENT = pnlSet2
      .left = 110: .top = 40: .width = 65
      .style = 2
      .additems "100", "95", "90", "85", "80", "75", "70", "65", _
       "60", "55", "50", "45", "40", "35", "30", "25", "20", "15", "10"
      .itemindex = 0
      .font.delstyles 0
      .font.COLOR = RGB(&H99, &H00, &H00)
      .tag = 0
     END WITH

     WITH chbConfirmDelete
      .PARENT = pnlSet2
      .left = 10: .top = 70: .width = 150
      .checked = 1
      .CAPTION = "Confirm file deleting"
     END WITH

     WITH lblSetPath
      .PARENT = pnlSet2
      .left = 10: .top = 90
      .CAPTION = "Path to images:"
     END WITH

     WITH btnSetPath
      .PARENT = pnlSet2
      .left = 200: .top = 80: .width = 110: .height = 30
      .CAPTION = "&Choose folder"
      .onClick = btnSetPath_onClick
      .font.addstyles 0
      .font.COLOR = RGB(&H99, &H00, &H00)
      .flat = 1
     END WITH

     WITH ediSetPath
      .PARENT = pnlSet2
      .charcase = 1
      .left = 10: .top = 110: .width = frmset.clientwidth - 30
      .enabled = 0
     END WITH

' ##########################################################################
' Subs
' ##########################################################################
' ------------------------------------------------------------------------------
     SUB tabSet_OnChange
      SELECT CASE tabSet.TabIndex
      CASE 0
       pnlSet0.Visible = 1
       pnlSet1.Visible = 0
       pnlSet2.Visible = 0
      CASE 1
       pnlSet0.Visible = 0
       pnlSet1.Visible = 1
       pnlSet2.Visible = 0
      CASE 2
       pnlSet0.Visible = 0
       pnlSet1.Visible = 0
       pnlSet2.Visible = 1
      END SELECT
     END SUB

' ------------------------------------------------------------------------------
     SUB cbxLang_OnChange
      SELECT CASE cbxLang.Item(cbxLang.ItemIndex)
      CASE "English"
       mnuOptions.CAPTION = "&Options"
       mnuOptions.ShortCut = "O"
       mnuHelp.CAPTION = "&Help"
       mnuHelp.ShortCut = "H"
       mnuAbout.CAPTION = "&About"
       mnuAbout.ShortCut = "A"
       mnuExit.CAPTION = "&Exit"
       mnuVideo.CAPTION = "&Video"
       mnuRecord.CAPTION = "&Record"
       mnuRecord.ShortCut = "R"
       mnuFormat.CAPTION = "&Format"
       mnuFormat.ShortCut = "F"
       mnuSource.CAPTION = "&Source"
       mnuSource.ShortCut = "S"
       mnuCompression.CAPTION = "&Compression"
       mnuCompression.ShortCut = "C"
       mnuDisplay.CAPTION = "&Display"
       mnuDisplay.ShortCut = "D"
       mnuImage.CAPTION = "&Image"
       mnuSave.CAPTION = "&Save"
       mnuCopy.CAPTION = "&Copy"
       mnuCompare.CAPTION = "&Compare"
       mnuCompare.ShortCut = "Shift+C"

       lblPort.CAPTION = "Serial ports"
       lblSetSaveAs.CAPTION = "Save file as"
       lblSetQuality.CAPTION = "JPG quality (%)"
       tabSet.Tab(0) = "Global"
       tabSet.Tab(2) = "Image"
       frmSet.CAPTION = "Program settings"
       chbConfirmDelete.CAPTION = "&Confirm file deleting"
       btnSetPath.CAPTION = "&Choose &folder"
       lblSetPath.CAPTION= "Path to images"
       frmCompare.CAPTION = "COMPARE TWO IMAGES"
       gbxCompare1.CAPTION = " Image 1 "
       gbxCompare2.CAPTION = " Image 2 "
       lviCompare1.Column(0).CAPTION = "File"
       lviCompare1.Column(1).CAPTION = "Size"
       lviCompare1.Column(2).CAPTION = "Date"
       lviCompare2.Column(0).CAPTION = "File"
       lviCompare2.Column(1).CAPTION = "Size"
       lviCompare2.Column(2).CAPTION = "Date"
       frmRename.CAPTION = "RENAME FILE"
       lblRename.CAPTION = "File name:"
       popDelete.CAPTION = "Delete"
       popRename.CAPTION = "Rename"

      CASE "Slovensky"
       mnuOptions.CAPTION = "&Možnosti"
       mnuOptions.ShortCut = "M"
       mnuHelp.CAPTION = "&Help"
       mnuHelp.ShortCut = "H"
       mnuAbout.CAPTION = "&O programe"
       mnuAbout.ShortCut = "O"
       mnuExit.CAPTION = "&Koniec"
       mnuVideo.CAPTION = "&Video"
       mnuRecord.CAPTION = "&Nahrávanie"
       mnuRecord.ShortCut = "N"
       mnuFormat.CAPTION = "&Formát"
       mnuFormat.ShortCut = "F"
       mnuSource.CAPTION = "&Zdroj"
       mnuSource.ShortCut = "Z"
       mnuCompression.CAPTION = "&Kompresia"
       mnuCompression.ShortCut = "K"
       mnuDisplay.CAPTION = "&Display"
       mnuDisplay.ShortCut = "D"
       mnuImage.CAPTION = "&Obrázok"
       mnuSave.CAPTION = "&Uloži"
       mnuCopy.CAPTION = "&Kopírova"
       mnuCompare.CAPTION = "&Porovna"
       mnuCompare.ShortCut = "P"

       lblPort.CAPTION = "&Sériový port"
       lblSetSaveAs.CAPTION = "&Uloži súbor ako"
       lblSetQuality.CAPTION = "&JPG kvalita (%)"
       tabSet.Tab(0) = "Všeobecné"
       tabSet.Tab(2) = "Obrázok"
       frmSet.CAPTION = "Nastavenia programu"
       chbConfirmDelete.CAPTION = "&Potvrdi vymazanie súboru"
       btnSetPath.CAPTION = "&Výber adresára"
       lblSetPath.CAPTION= "Cesta k obrázkom"
       frmCompare.CAPTION = "POROVNANIE DVOCH OBRÁZKOV"
       gbxCompare1.CAPTION = " Obrázok 1 "
       gbxCompare2.CAPTION = " Obrázok 2 "
       lviCompare1.Column(0).CAPTION = "Súbor"
       lviCompare1.Column(1).CAPTION = "VeŸkos"
       lviCompare1.Column(2).CAPTION = "Dátum"
       lviCompare2.Column(0).CAPTION = "Súbor"
       lviCompare2.Column(1).CAPTION = "VeŸkos"
       lviCompare2.Column(2).CAPTION = "Dátum"
       frmRename.CAPTION = "PREMENOVANIE SÚBORU"
       lblRename.CAPTION = "Meno súboru:"
       popDelete.CAPTION = "Vymaza"
       popRename.CAPTION = "Premenova"
      END SELECT
     END SUB

' ------------------------------------------------------------------------------
     SUB cbxSetSaveAs_onchange
      IF cbxSetSaveAs.ItemIndex = 0 THEN ' If JPG is choosen
       cbxSetQuality.Enabled = 1
       lblSetQuality.Enabled = 1
       cbxSetQuality.ItemIndex = 0
       ELSE: cbxSetQuality.Enabled = 0
       cbxSetQuality.ItemIndex = -1
       lblSetQuality.Enabled = 0
      END IF
     END SUB

' ------------------------------------------------------------------------------
     SUB cbxPort_OnChange
      MyPort.Port = cbxPort.Item(cbxPort.ItemIndex)
      MyPort.OPEN
      IF MyPort.Connected = 0 THEN
       SELECT CASE cbxLang.Item(cbxLang.ItemIndex)
       CASE "English"
        SHOWMESSAGE "I can not open COM port for image freezing, when camera button was pressed."
       CASE "Slovensky"
        SHOWMESSAGE "Nemôžem otvori COM port pre zastavenie videa, ak bolo stlaèené tlaèítko kamery."
       END SELECT
      END IF
     END SUB

' ------------------------------------------------------------------------------
     SUB MyPort_onOpen
      IF MyPort.Connected = 1 AND cbxPort.Tag = 0 THEN cbxPort.AddItems MyPort.Port
     END SUB

'-------------------------------------------------------------------------------
     SUB TimerPort_OnTimer
      MyPort.WriteString("", 1)
      WHILE MyPort.BytesNotRead > 0
       MyPort.ReadString(MyPort.BytesNotRead, 1)
      WEND
     END SUB

' ------------------------------------------------------------------------------
     SUB MyPort_onReadString
      mnuStop_OnClick
     END SUB

' ------------------------------------------------------------------------------
     SUB btnSetOK_onClick
	' Checking an existing folder for images saving
      IF DIREXISTS (ediSetPath.EditText) = 0 THEN
       SELECT CASE cbxLang.Item(cbxLang.ItemIndex)
       CASE "English": SHOWMESSAGE "Invalid path to images. Please, check it first and than save it again."
       CASE "Slovensky": SHOWMESSAGE "Chybná cesta k obrázkom. Prosím, skontrolujte ju a potom uložte znova."
       END SELECT
       tabSet.TabIndex = 2
       tabSet_OnChange
       SetFocus(ediSetPath.Handle)
       EXIT SUB
      END IF
      DIM StringList AS QSTRINGLIST

	' Save settings to INI file
      StringList.AddItems "Language   = " + cbxLang.Item(cbxLang.ItemIndex)
      StringList.AddItems "ComPort    = " + cbxPort.Item(cbxport.ItemIndex)
      StringList.AddItems "SaveFileAs = " + cbxSetSaveAs.Item(cbxSetSaveAs.ItemIndex)
      StringList.AddItems "SetQuality = " + cbxSetQuality.Item(cbxSetQuality.ItemIndex)
      StringList.AddItems "ConfirmDel = " + STR$(chbConfirmDelete.Checked)
      StringList.AddItems "ImagesPath = " + ediSetPath.EditText

      StringList.SaveToFile (pnlScreen.hint + "\kamerka.ini")
      frmSet.ModalResult = 1
     END SUB

' ------------------------------------------------------------------------------
     SUB frmSet_onShow
      cbxPort.clear
      IF MyPort.Connected = 1 THEN MyPort.CLOSE
      cbxPort.Tag = 0

	' Getting infos about COM devices
      DIM PortNumber AS BYTE
      FOR PortNumber = 1 TO 4
       MyPort.Port = "COM" + STR$(PortNumber)
       MyPort.BaudRate = 9600
       MyPort.Parity   = NOPARITY
       MyPort.DataBits = 8
       MyPort.StopBits = ONESTOPBIT
       MyPort.OPEN 'Open COM Port - see procedure MyPort_onOpen in file "frm_set.bas"
       MyPort.CLOSE
      NEXT

      cbxPort.Tag = 1 ' Prevent from adding new COM ports do combobox
      IF cbxPort.ItemCount > 0 THEN
       TimerPort.Enabled = 1
      END IF

      IF FILEEXISTS (pnlScreen.hint + "\kamerka.ini") THEN
       DIM StringList AS QSTRINGLIST, I AS BYTE, Temp AS STRING

		' Getting settings from INI file
       StringList.LoadFromFile (pnlScreen.hint + "\kamerka.ini")
		' Language
       Temp = RIGHT$(StringList.Item(0), LEN(StringList.Item(0)) - 13)
       SELECT CASE Temp
       CASE "English":  cbxLang.ItemIndex = 0
       CASE "Slovensky": cbxLang.ItemIndex = 1
       END SELECT
       cbxLang_OnChange

		' COM port
       cbxPort.ItemIndex = -1 ' reseting Com port
       Temp = RIGHT$(StringList.Item(1), LEN(StringList.Item(1)) - 13)
       FOR I = 0 TO cbxPort.ItemCount - 1
        IF Temp = cbxPort.Item(I) THEN
         cbxPort.ItemIndex = I
         cbxPort_OnChange
         I = cbxPort.ItemCount
        END IF
       NEXT
       IF cbxPort.ItemIndex = -1 THEN
        SELECT CASE cbxLang.Item(cbxLang.ItemIndex)
        CASE "English": SHOWMESSAGE "Bad COM port setting! See File/Options/COM Port", _
         CASE "Slovensky": SHOWMESSAGE "Zlé nastavenie sériového portu! Pozri Súbor/Možnosti/Sériový port"
        END SELECT
       END IF

		' File extension
       cbxSetSaveAs.ItemIndex = -1 ' reseting File extension
       Temp = RIGHT$(StringList.Item(2), LEN(StringList.Item(2)) - 13)
       FOR I = 0 TO cbxSetSaveAs.ItemCount - 1
        IF Temp = cbxSetSaveAs.Item(I) THEN
         cbxSetSaveAs.ItemIndex = I
         I = cbxSetSaveAs.ItemCount
        END IF
       NEXT

		' File quality
       cbxSetQuality.ItemIndex = -1 ' reseting File extension
       Temp = RIGHT$(StringList.Item(3), LEN(StringList.Item(3)) - 13)
       FOR I = 0 TO cbxSetQuality.ItemCount - 1
        IF Temp = cbxSetQuality.Item(I) THEN
         cbxSetQuality.ItemIndex = I
         I = cbxSetQuality.ItemCount
        END IF
       NEXT

		' Delete confirmation
       Temp = RIGHT$(StringList.Item(4), LEN(StringList.Item(4)) - 13)
       chbConfirmDelete.Checked = VAL(temp)

		' Path to images
       ediSetPath.Text = RIGHT$(StringList.Item(5), LEN(StringList.Item(5)) - 13)
      END IF
     END SUB

' ------------------------------------------------------------------------------
     SUB btnSetPath_OnClick
      IF LEN(ediSetpath.EditText) > 0 THEN dirTree.Directory = ediSetpath.EditText
      IF frmDirectory.SHOWMODAL = 1 THEN
       ediSetPath.Text = dirTree.Directory
      END IF
     END SUB
掌柜推荐
 
 
¥1,390.00 ·
 
 
¥287.00 ·
 
 
¥410.00 ·
 
 
¥1,380.00 ·
 
 
¥1,080.00 ·
 
 
¥271.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2009-07-25 17:30:51